From patchwork Tue Mar 29 07:18:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 64572 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1850141lbc; Tue, 29 Mar 2016 00:20:49 -0700 (PDT) X-Received: by 10.66.141.103 with SMTP id rn7mr1111097pab.70.1459236048944; Tue, 29 Mar 2016 00:20:48 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id f18si21198819pfd.206.2016.03.29.00.20.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Mar 2016 00:20:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org 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 1aknwJ-0001bo-UD; Tue, 29 Mar 2016 07:19:47 +0000 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aknvL-0000om-0n for linux-arm-kernel@lists.infradead.org; Tue, 29 Mar 2016 07:18:49 +0000 Received: by mail-wm0-x232.google.com with SMTP id 191so39241718wmq.0 for ; Tue, 29 Mar 2016 00:18:26 -0700 (PDT) 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=oOWWFImRavTREkaWh5j97y08tCbYroHqMX5g2PvIX2I=; b=RDhQIuJxwJrXpOnI4xrx17WojYnPNZ21s6BEWLvgr8ywSyyIxcrah3Ni4IRDNDse/z pKzyy2Vwe+ZBrsC5hZePeUSKRl9p1cgYEHJkcUfuPyuFrdg9SpQC3C12lMd6b1SVy9Ng XDyt8cQQ9ShEOUFUEsJqDJWM7xySOI1p+ItQE= 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=oOWWFImRavTREkaWh5j97y08tCbYroHqMX5g2PvIX2I=; b=gWgf9QNXr6BjMoPDRLD4wGNOdf2So3oXupUBJPpSqVMxov0EKRygkhh+IMP8BqInF2 90iYx048B1fNJzyviTKbJ+NbjljI1m9WwlkqJtC8wXZ5GW1Da2COSwU1wFW+o5T8v6IE aiIRCOtbfwRZ8SmiQ9Fsm6Lxq7bF3frj5okLP0/yFY0WUE5sTzjkPEbV9eNWVCLGLhBh uI2TWhD/S1K9729Y4fpojpnbHwflT1zPotDkbI9bRT1uyNssAQbM2sN0ubga0oKDb28z Gc7dZ9tNyYUtjAzC8aFm+mzLedxiMYWkq0RqOAnfYoI2YrorV4RfnTFlnF8JaY1iH0ik L4VQ== X-Gm-Message-State: AD7BkJJ60RSx3wtAqF0vbSIqdFPFU1aHwdNCwTeEOQcZjVGKe3fLeieIVZPfprWlGPtHe0xt X-Received: by 10.28.126.65 with SMTP id z62mr8338550wmc.42.1459235905505; Tue, 29 Mar 2016 00:18:25 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id av3sm27921427wjc.44.2016.03.29.00.18.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Mar 2016 00:18:24 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk, linux+pull@arm.linux.org.uk Subject: [PULL 4/4] ARM: memremap: implement arch_memremap_wb() Date: Tue, 29 Mar 2016 09:18:04 +0200 Message-Id: <1459235884-24318-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459235884-24318-1-git-send-email-ard.biesheuvel@linaro.org> References: <1459235884-24318-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160329_001847_396371_BC2F4A66 X-CRM114-Status: GOOD ( 14.75 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:232 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: matt@codeblueprint.co.uk, Russell King , dan.j.williams@intel.com, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org 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 Acked-by: Dan Williams Signed-off-by: Ard Biesheuvel --- arch/arm/include/asm/io.h | 6 ++++++ arch/arm/mm/ioremap.c | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) -- 2.5.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h index fb94de290edd..781ef5fe235d 100644 --- a/arch/arm/include/asm/io.h +++ b/arch/arm/include/asm/io.h @@ -392,6 +392,9 @@ void __iomem *ioremap(resource_size_t res_cookie, size_t size); #define ioremap ioremap #define ioremap_nocache ioremap +/* + * Do not use ioremap_cache for mapping memory. Use memremap instead. + */ void __iomem *ioremap_cache(resource_size_t res_cookie, size_t size); #define ioremap_cache ioremap_cache @@ -408,6 +411,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 d5350f6af089..ff0eed23ddf1 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); @@ -418,6 +419,13 @@ __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 (__force void *)arch_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);