From patchwork Fri Feb 26 17:34:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 63104 Delivered-To: patch@linaro.org Received: by 10.112.235.234 with SMTP id up10csp1416lbc; Fri, 26 Feb 2016 09:37:25 -0800 (PST) X-Received: by 10.98.8.74 with SMTP id c71mr3758661pfd.155.1456508245082; Fri, 26 Feb 2016 09:37:25 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ud10si4233325pab.54.2016.02.26.09.37.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Feb 2016 09:37:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-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; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro.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 1aZMIp-0001Du-Ut; Fri, 26 Feb 2016 17:35:43 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aZMHs-0007Zn-30 for linux-mtd@lists.infradead.org; Fri, 26 Feb 2016 17:34:47 +0000 Received: by mail-wm0-x234.google.com with SMTP id g62so81529370wme.0 for ; Fri, 26 Feb 2016 09:34:23 -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=igCuySeSg4+o2iDgFORvsFtTKQEmho/NhTFcPfGFxFrl68iyjgJ+RnpT1GXAuqf80B 1JDJlrDA0npm3647CDFPJkyxDSAF13zrHhkylc/TuhuPcMD1mLEIKI7ZBezb1cTe5z0Z efETLF9SVBMBLPWMaaXOl+rV2wIsRAaGwUQ3g= 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=jJ0OxWHgHY9nznWkeIWHChF6o/S3EBy1Pm0dQ2mTE2g/OFXb5G4DdtOmThkOiZV7wf QRWKjgm92+iaEgSdhooDPgGXdlPdEHn0jW4Hu4OPfMelQ1G5kbdNZSQExEmNAMv5kjNJ JraStNDyKQZt34HRIzYcIM0BsS89m2jzkFR4V5gCF+Y2KMng3j2Ebd+eK6DcagsXuzWO ATclWqws0FUeknjQ04hf+SLo27H1ojBYiztVAeJ3jBK0JwMFrm8eOYJCtJzL1+Gwnlte UN0joLtZSYpJTHgNH2krgI9jjErfg7Pb0OF+4OdY0r9a5oa0cOsMaC9WMeX3EHsvUoZ/ D7Qg== X-Gm-Message-State: AD7BkJJlv8wKOX+1ZWGXFQhAgrVnT97MlcM6XukndreNK0l1HFXNc5kiUMjbuCV4qai+xAhD X-Received: by 10.28.107.221 with SMTP id a90mr3798442wmi.76.1456508062506; Fri, 26 Feb 2016 09:34:22 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id ei9sm13337802wjd.40.2016.02.26.09.34.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Feb 2016 09:34:21 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-mtd@lists.infradead.org, dan.j.williams@intel.com, linux@arm.linux.org.uk Subject: [PATCH v2 3/3] ARM: memremap: implement arch_memremap_wb() Date: Fri, 26 Feb 2016 18:34:13 +0100 Message-Id: <1456508053-15015-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456508053-15015-1-git-send-email-ard.biesheuvel@linaro.org> References: <1456508053-15015-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160226_093444_471616_72C5A6A9 X-CRM114-Status: GOOD ( 13.34 ) 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:234 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-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Russell King , robert.jarzmik@free.fr, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-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 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(-) -- 2.5.0 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ 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);