From patchwork Mon Apr 4 08:31:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 64970 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1058704lbc; Mon, 4 Apr 2016 01:34:32 -0700 (PDT) X-Received: by 10.98.93.155 with SMTP id n27mr18834156pfj.88.1459758872380; Mon, 04 Apr 2016 01:34:32 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id b5si37095050pat.133.2016.04.04.01.34.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Apr 2016 01:34:32 -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 1amzwq-00044S-H6; Mon, 04 Apr 2016 08:33:24 +0000 Received: from mail-lf0-x22e.google.com ([2a00:1450:4010:c07::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1amzvS-0002KM-LW for linux-arm-kernel@lists.infradead.org; Mon, 04 Apr 2016 08:32:07 +0000 Received: by mail-lf0-x22e.google.com with SMTP id c126so39317365lfb.2 for ; Mon, 04 Apr 2016 01:31:38 -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=jaYXoQimDOO6EWG5mPvTJ3QyjfSQstlSF3W/VvyWkCYg8eu3sxhzd7d83178lb/OZ/ gZCDUDGDbTq12PwunNi566f0/RUl3IihXLJLPk+sbpUZdtHfUZrtFra/4Cax4OpsEtjq IhYniqO4BDEVbnXJrRfcKQ8oEc9PhIYA6foXA= 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=UBI8uW/8NhxagCEeon+mCL18ziQWGfd4OszcRc1hOEIpYxhHK3V2lqZpcoGbMCJFTO RfNN7XnzwQBpzRLJD+KBfbVCWdCeTCHaP3n2sNdTek7gNQ+3ZQ7ywXPL7EYOih9aj/fR 74cCYBhkcQd5Ws8t5iu+t9MRUiy5QlUQw3CZ0HprFC1A7AVxFMfc/JZcUxUPxcOiMrF+ ct74r5sKEJhy9n/NJKcridy6wV5u16V4OO/ccyOT3Dtl0hTj5nkV0++xji0yapEEM6HU QNwIW9ETmgoXQRwbBztBtrsTsI+/guRSGlLGEeK9ZyrIPvU0vFNWc/WyNVo2HqR6rYdP C22g== X-Gm-Message-State: AD7BkJKjGaAqTuFX4gzx+pmHT8CuPxQ7kOlpLZpuqOvVZPuwfHEQnansRAwbHdoPiIADRj0W X-Received: by 10.194.62.110 with SMTP id x14mr10281965wjr.68.1459758696709; Mon, 04 Apr 2016 01:31:36 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id cb2sm27838278wjc.16.2016.04.04.01.31.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Apr 2016 01:31:35 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk Subject: [PATCH v5 3/4] memremap: add arch specific hook for MEMREMAP_WB mappings Date: Mon, 4 Apr 2016 10:31:23 +0200 Message-Id: <1459758684-16191-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459758684-16191-1-git-send-email-ard.biesheuvel@linaro.org> References: <1459758684-16191-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160404_013159_419036_4B5D83FE X-CRM114-Status: GOOD ( 15.47 ) 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:4010:c07:0:0:0:22e 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, 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); } /*