From patchwork Tue Mar 29 07:18:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 64571 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1850044lbc; Tue, 29 Mar 2016 00:20:28 -0700 (PDT) X-Received: by 10.98.12.8 with SMTP id u8mr1125170pfi.36.1459236028858; Tue, 29 Mar 2016 00:20:28 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ix8si26053813pac.10.2016.03.29.00.20.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Mar 2016 00:20:28 -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 1aknw4-0001T5-68; Tue, 29 Mar 2016 07:19:32 +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 1aknvJ-0000kv-D8 for linux-arm-kernel@lists.infradead.org; Tue, 29 Mar 2016 07:18:46 +0000 Received: by mail-wm0-x234.google.com with SMTP id 191so39240977wmq.0 for ; Tue, 29 Mar 2016 00:18:25 -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=uOGZURd4Z7NIlMXotDDxAVo/imbnYVnqdhnuu+uEs58=; b=LbCtxrulmNGZkLUM5Jhi1xPHR3Mgt8ILGPt5/WwvIYyR+L4KyQWj+Z0ZrDDqGcoAWj 2Vl1sZeCRtUceVqKYDYnYoOCIlADTvWhAFp5N6GgTKjOE4AwTZ+rRSW7KfqMqs4weKJW sErmqhA2uxb0fgQtPu4yMM0oUm9jcjv4+KRlw= 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=uOGZURd4Z7NIlMXotDDxAVo/imbnYVnqdhnuu+uEs58=; b=Oz+r0TicxFykpb03AAOxU7Tzrm/fUzDvDv/S+UOBko932j07n6ED2pTig8x6da+Fpi NnNe5RLK6WAlWzFm3vZXUcB/s4fjJGSroCAV6mifxXQ0lbahPOPdIt0xHgQuwH54BBl5 nQfRv2BQnpgw+GpEqOXMYRCKjrGGolmc/s53Z8B4LB+TyWMP7132Tsn9rkhxiamXO4ya xQwjihYQLewj1e3C9ST+Pxgh/DIvLvjTxD31VkygIFRpa4ytHgywkebNEvRHXKJclvbd nttonIaomuAx4Xo6bzJkgE/zBRSyupuTg7HzTyHjmz1m66zOABw3QxRI6AaLeamip8f8 HYVQ== X-Gm-Message-State: AD7BkJJOTBW3v6uY75DeA5SqYpN8QaNQ2ubmuTYQ9RBfj3oaWawb64uorWgUGDcXR3V+jN9k X-Received: by 10.194.84.66 with SMTP id w2mr892175wjy.6.1459235903966; Tue, 29 Mar 2016 00:18:23 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id av3sm27921427wjc.44.2016.03.29.00.18.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Mar 2016 00:18:23 -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 3/4] memremap: add arch specific hook for MEMREMAP_WB mappings Date: Tue, 29 Mar 2016 09:18:03 +0200 Message-Id: <1459235884-24318-4-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_001845_685260_E7265CA6 X-CRM114-Status: GOOD ( 15.05 ) 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-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, 8 insertions(+), 3 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..6723c77ccc70 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 arch_memremap_wb(offset, size); } /** @@ -89,8 +96,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); } /*