From patchwork Thu Mar 31 09:18:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 64753 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp51814lbc; Thu, 31 Mar 2016 02:46:47 -0700 (PDT) X-Received: by 10.98.10.29 with SMTP id s29mr20871390pfi.166.1459417607243; Thu, 31 Mar 2016 02:46:47 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ku9si12754067pab.99.2016.03.31.02.46.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Mar 2016 02:46:47 -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; dmarc=fail (p=NONE dis=NONE) header.from=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 1alZAc-0007Q4-Kf; Thu, 31 Mar 2016 09:45:42 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1alZAM-0006Im-8S for linux-arm-kernel@bombadil.infradead.org; Thu, 31 Mar 2016 09:45:26 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by casper.infradead.org with esmtps (Exim 4.85 #2 (Red Hat Linux)) id 1alYlH-000249-W0 for linux-arm-kernel@lists.infradead.org; Thu, 31 Mar 2016 09:19:32 +0000 Received: by mail-wm0-x22d.google.com with SMTP id p65so105907457wmp.0 for ; Thu, 31 Mar 2016 02:19:11 -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=x4TBbrUlXFsmqNByedUbXQWYOEWCC5wsq0FdUF4AB/s=; b=XQ4zwwWUb953GGQqyUUaiF//5TS6759bxnnJEaxB1wMV6bQj0wq9cmm2IFgP0HHyec iHR3/HZsKmJTkJu6B2M2IVeWJXURSPKYgJRUmne5kmkc8lRyvYuNfbnzzEH1dPkj8aw2 4jvZY7TkJzqhFykFBVUgPgfPb0hGynKpHHTe8= 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=x4TBbrUlXFsmqNByedUbXQWYOEWCC5wsq0FdUF4AB/s=; b=c5TnCuh/jLZsAdckB86XwHq6hww7ip3JObMLISRh0Zsyk6W4K40rd+PaRdYd3bgbRS m3uUzQ0dzWYArXSLvNz9IGhqWtnJVmsDurndedF6bqWqC9vm3BJj1rZSTKyRR4nN/1xw 1hG0OBjJNj62knTlqPjuxyF1F840DbPV5bZdYG/5rcxatvFftvIxrnxoYU04sErT73s5 LTVrOb/YIslvIS1aTlZ0+QgS5cxg2SRsd7ZtduE2TB7idEN/SG0/LM4GjcYE39ySJFTZ q9YBTP7lvceeMiP1ISJt3EkVL8rwEuRmFL/o/TnwMCp2pFEJJc/eW7f5G6NplVYThAeU UCGA== X-Gm-Message-State: AD7BkJLetFl1o9ck2CPlmrBDXR23tnalOSd1DtCXOGVlhSHxet8KzL8LmebVkckEdmfB1ZrO X-Received: by 10.28.109.4 with SMTP id i4mr988879wmc.44.1459415950760; Thu, 31 Mar 2016 02:19:10 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id k125sm23742060wmb.14.2016.03.31.02.19.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 Mar 2016 02:19:10 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk Subject: [PATCH v4 3/4] memremap: add arch specific hook for MEMREMAP_WB mappings Date: Thu, 31 Mar 2016 11:18:51 +0200 Message-Id: <1459415932-17852-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459415932-17852-1-git-send-email-ard.biesheuvel@linaro.org> References: <1459415932-17852-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160331_101932_057176_EFF7E088 X-CRM114-Status: GOOD ( 17.51 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on casper.infradead.org summary: Content analysis details: (-2.7 points, 5.0 required) 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:22d 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_VALID_AU Message has a valid DKIM or DK signature from author's domain 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 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, 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 Currently, the memremap code serves MEMREMAP_WB mappings directly from the kernel direct mapping, unless the region is in high memory, in which case it falls back to using ioremap_cache(). However, the semantics of ioremap_cache() are not unambiguously defined, and on ARM, it will actually result in a mapping type that differs from the attributes used for the linear mapping, and for this reason, the ioremap_cache() call fails if the region is part of the memory managed by the kernel. So instead, implement an optional hook 'arch_memremap_wb' whose default implementation calls ioremap_cache() as before, but which can be overridden by the architecture to do what is appropriate for it. Acked-by: Dan Williams Signed-off-by: Ard Biesheuvel --- kernel/memremap.c | 11 +++++++++-- 1 file changed, 9 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/kernel/memremap.c b/kernel/memremap.c index a6d382312e6f..017532193fb1 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -27,6 +27,13 @@ __weak void __iomem *ioremap_cache(resource_size_t offset, unsigned long size) } #endif +#ifndef arch_memremap_wb +static void *arch_memremap_wb(resource_size_t offset, unsigned long size) +{ + return (__force void *)ioremap_cache(offset, size); +} +#endif + static void *try_ram_remap(resource_size_t offset, size_t size) { unsigned long pfn = PHYS_PFN(offset); @@ -34,7 +41,7 @@ static void *try_ram_remap(resource_size_t offset, size_t size) /* In the simple case just return the existing linear address */ if (pfn_valid(pfn) && !PageHighMem(pfn_to_page(pfn))) return __va(offset); - return NULL; /* fallback to ioremap_cache */ + return NULL; /* fallback to arch_memremap_wb */ } /** @@ -90,7 +97,7 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags) if (is_ram == REGION_INTERSECTS) addr = try_ram_remap(offset, size); if (!addr) - addr = ioremap_cache(offset, size); + addr = arch_memremap_wb(offset, size); } /*