From patchwork Fri Feb 26 17:34:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 63088 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp838930lbc; Fri, 26 Feb 2016 09:35:29 -0800 (PST) X-Received: by 10.98.86.91 with SMTP id k88mr3549667pfb.78.1456508129743; Fri, 26 Feb 2016 09:35:29 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id e82si21142399pfb.126.2016.02.26.09.35.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Feb 2016 09:35:29 -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 1aZMIV-0000cF-1e; Fri, 26 Feb 2016 17:35:23 +0000 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aZMHq-0007YX-M0 for linux-mtd@lists.infradead.org; Fri, 26 Feb 2016 17:34:46 +0000 Received: by mail-wm0-x22e.google.com with SMTP id g62so79596717wme.0 for ; Fri, 26 Feb 2016 09:34:22 -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=Jpr1XJX+rHgeQX817EFPO5otjYDI1C4Zee11Le91OuySr0HqF4BMLCS/tCTRqSyKuS Usw/Xf7c9tmp9umpiJUfNS3c+dYCgVgHo56PspVqmRWczq56vW0UBtaiPyR17eQmipb3 NyTwuYjkOU9a3CrpG25Eiyh9W4ebUcW2iQLm4= 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=CF62jdh+fzwUBu1MzWAmdMzJiYKIInK6voYUFVFvgMDJq3MR2RcCCiMM6xyi7juIxQ vfLyFTPR+oek9vkhUY6X3Tfu5xa+fqHmFRICxSPOXt3Htu8rBIMyKEg6MHaRqOMERx9g IfYaQwFMTjM1TeJh2CqmuNzsovSPOS53n8UzEkWNE2ngy/rurG2Q86lKkUrvxeNVlt8o ojwJEgYBlVHdB554NfWNuzO+TsMbp0f0gZAcJyAaoeRVa+ngjTefgQC9i4rkQCQXYzg5 8KRd6KoP944c+g2c2rBwiZzZx4JZ3dQJk82GGSW31ZgK2Vjs0LK+yEU9GVWLT+ouvNam +40w== X-Gm-Message-State: AD7BkJIb+Q1zy0iWMB1AiMm3Qb2cP1NrChTu012OoOVzzC+hMviXihneCXITRumWSC053dhd X-Received: by 10.194.84.2 with SMTP id u2mr2850560wjy.61.1456508060930; Fri, 26 Feb 2016 09:34:20 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id ei9sm13337802wjd.40.2016.02.26.09.34.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Feb 2016 09:34:20 -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 2/3] memremap: add arch specific hook for MEMREMAP_WB mappings Date: Fri, 26 Feb 2016 18:34:12 +0100 Message-Id: <1456508053-15015-3-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_093442_998142_7337AE46 X-CRM114-Status: GOOD ( 13.45 ) 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: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-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, 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); } /*