From patchwork Fri Mar 4 09:48:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 63559 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp365330lbc; Fri, 4 Mar 2016 01:50:50 -0800 (PST) X-Received: by 10.66.186.14 with SMTP id fg14mr10664527pac.102.1457085048514; Fri, 04 Mar 2016 01:50:48 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 72si4813331pfi.35.2016.03.04.01.50.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Mar 2016 01:50:48 -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 1abmNd-0003S5-Kt; Fri, 04 Mar 2016 09:50:41 +0000 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1abmMK-0001Zt-PA for linux-mtd@lists.infradead.org; Fri, 04 Mar 2016 09:49:23 +0000 Received: by mail-wm0-x233.google.com with SMTP id l68so22442043wml.1 for ; Fri, 04 Mar 2016 01:49:03 -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=cLNbnngI0Fyt1Jn6nTRQ0VFQuVFkT6IIDlkUhIY9++w=; b=SqlC3fJJ+MA8rqZFr1PTpTU50atj24lWO3CPs2jYhjl24ags4MtmBZFwN7+xRjMWrh 06YrGYONsRrKWpVdmos0bUlGZDeZnmYnaD197jhDA4BkZnyEIB8kO1LQAkX2FgPMWmaw QMIOIF0Y90itnse0oidYZQP+NXF+vMzWSK4EE= 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=cLNbnngI0Fyt1Jn6nTRQ0VFQuVFkT6IIDlkUhIY9++w=; b=SLXSTjgt11a4RNcQtxIOZd60uul/zmpi7C5Uq7eKCJlPLeT5L0XKyDQBSugs+f60Sy KpFywrLSZiYgWeYkLr6mEJeKJ9y235VNADf+O7zrY1khCwIDGbDMHEmZgj7juJ5xUI0U dkZ4Yvq9MxQGk/7e1AXaKrGvE0RqHklnPziqJft2okvwarxUSP4eFpML2E1yEiw4YSVg gW0/MJInpHGZ+Uaxb+5EuNZhen3owB5MANi2PcdGyU9D4wHXF2UBp1zZ03JT+aboh05u mGkoNsexJaqrQs122sag2C3qEI3IJ3+gbcLDWNH/NjKgYH9KJgpK0j6OMugrdrIroELl hZpA== X-Gm-Message-State: AD7BkJLI2UbYzWC9PayuytjjxHIbFPGKFvOt+L4sNGiH7heeJC3PvDD7qiclyJ4/8T0N/Pu5 X-Received: by 10.194.115.35 with SMTP id jl3mr7861857wjb.76.1457084941970; Fri, 04 Mar 2016 01:49:01 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id s206sm2426533wmf.23.2016.03.04.01.48.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Mar 2016 01:49:01 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-mtd@lists.infradead.org, linux@arm.linux.org.uk, dan.j.williams@intel.com Subject: [PATCH v3 3/4] memremap: add arch specific hook for MEMREMAP_WB mappings Date: Fri, 4 Mar 2016 10:48:47 +0100 Message-Id: <1457084928-21179-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457084928-21179-1-git-send-email-ard.biesheuvel@linaro.org> References: <1457084928-21179-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160304_014921_158394_06E36384 X-CRM114-Status: GOOD ( 13.44 ) 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:233 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-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: robert.jarzmik@free.fr, computersforpeace@gmail.com, dwmw2@infradead.org, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-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, 8 insertions(+), 3 deletions(-) -- 2.5.0 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/kernel/memremap.c b/kernel/memremap.c index 7a1b5c3ef14e..77c41648ba16 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) { struct page *page = pfn_to_page(offset >> PAGE_SHIFT); @@ -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 (!PageHighMem(page)) return __va(offset); - return NULL; /* fallback to ioremap_cache */ + return arch_memremap_wb(offset, size); } /** @@ -80,8 +87,6 @@ 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); } /*