From patchwork Mon Feb 22 14:02:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 8376751 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6169AC0553 for ; Mon, 22 Feb 2016 14:04:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7453C20501 for ; Mon, 22 Feb 2016 14:04:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 84D4020453 for ; Mon, 22 Feb 2016 14:04:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aXr54-0008Ll-VO; Mon, 22 Feb 2016 14:03:18 +0000 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aXr4S-0007xv-J2 for linux-arm-kernel@lists.infradead.org; Mon, 22 Feb 2016 14:02:42 +0000 Received: by mail-wm0-x22c.google.com with SMTP id c200so172726854wme.0 for ; Mon, 22 Feb 2016 06:02:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iW18jnbHiv1XzgQeELwWF3Wupt4Cin/435YkrYB4y5Q=; b=L1eFd3AQ5RfMfNn7jOW7N5MZC+h57SXmLgfBT0H6295ufKehCXj4kY6dxZ8yfMZFXB hdFwzqirsPzA7xa+EBfQBy6lEc7iLG4c6PJtEpULiFr7lQZHJwM/rPjCxbanpPakJrGl gsr2MSc3xPigigbJFLZhZzbHGl/NiFzmygeTI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iW18jnbHiv1XzgQeELwWF3Wupt4Cin/435YkrYB4y5Q=; b=d/qhPbOCtwnynTP2VHzjTomq3GlnS9KQdx0x0Xtf192WYEFbFuaVFX14UyOhyBk3hl VVTuHLcNQbrxhAo/RBn2P09ScQtqPhVJRw4tRRzRlcnOhvINGPdwoScGWIllOjPbIqvK XS7VdVXw1gPNRc0TQ3N/K+uGTyPipXOOBhbQthD5LJdzcp+ERJIDVA72exzXqd2w+Cck MzLQxf71SeVLDpe8zuS/BfKUX6BVJrm//M3Pth3kdbLch+fz86TksxloXd8Um9ubIqcW uLxk7AUlzR2v4mYN3Z6IY8qoYPsinpct9EUg261N5z9UyRATUDyYawaP+CBGkDHMHynR kdDA== X-Gm-Message-State: AG10YOSz7nCqmAvcNVAgJNpapYdOKVV6q9Rz6nGdRgvQ0xu1ezG/aJ7TqD6ofo+76INCZtBI X-Received: by 10.194.92.107 with SMTP id cl11mr32762061wjb.21.1456149737979; Mon, 22 Feb 2016 06:02:17 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id b5sm21269068wmh.15.2016.02.22.06.02.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Feb 2016 06:02:17 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux@arm.linux.org.uk, dan.j.williams@intel.com Subject: [RFC PATCH 2/2] ARM: memremap: implement arch_memremap_wb() Date: Mon, 22 Feb 2016 15:02:08 +0100 Message-Id: <1456149728-16706-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456149728-16706-1-git-send-email-ard.biesheuvel@linaro.org> References: <1456149728-16706-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160222_060240_940675_859F7F5A X-CRM114-Status: GOOD ( 14.02 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Russell King , Ard Biesheuvel , arnd@arndb.de, nico@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The generic memremap() falls back to using ioremap_cache() to create MEMREMAP_WB mappings if the requested region is not already covered by the linear mapping, unless the architecture provides an implementation of arch_memremap_wb(). Since ioremap_cache() is not appropriate on ARM to map memory with the same attributes used for the linear mapping, implement arch_memremap_wb() which does exactly that. Also, relax the WARN() check to allow MT_MEMORY_RW mappings of pfn_valid() pages. Cc: Russell King Signed-off-by: Ard Biesheuvel --- arch/arm/include/asm/io.h | 3 +++ arch/arm/mm/ioremap.c | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h index 485982084fe9..7456638e6b3a 100644 --- a/arch/arm/include/asm/io.h +++ b/arch/arm/include/asm/io.h @@ -402,6 +402,9 @@ void __iomem *ioremap_wc(resource_size_t res_cookie, size_t size); void iounmap(volatile void __iomem *iomem_cookie); #define iounmap iounmap +void *arch_memremap_wb(phys_addr_t phys_addr, size_t size); +#define arch_memremap_wb arch_memremap_wb + /* * io{read,write}{16,32}be() macros */ diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c index 66a978d05958..d3a2b028c614 100644 --- a/arch/arm/mm/ioremap.c +++ b/arch/arm/mm/ioremap.c @@ -297,9 +297,10 @@ static void __iomem * __arm_ioremap_pfn_caller(unsigned long pfn, } /* - * Don't allow RAM to be mapped - this causes problems with ARMv6+ + * Don't allow RAM to be mapped with mismatched attributes - this + * causes problems with ARMv6+ */ - if (WARN_ON(pfn_valid(pfn))) + if (WARN_ON(pfn_valid(pfn) && mtype != MT_MEMORY_RW)) return NULL; area = get_vm_area_caller(size, VM_IOREMAP, caller); @@ -414,6 +415,12 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached) __builtin_return_address(0)); } +void *arch_memremap_wb(phys_addr_t phys_addr, size_t size) +{ + return __arm_ioremap_caller(phys_addr, size, MT_MEMORY_RW, + __builtin_return_address(0)); +} + void __iounmap(volatile void __iomem *io_addr) { void *addr = (void *)(PAGE_MASK & (unsigned long)io_addr);