From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3zmHvP2bCKzF1CB for ; Wed, 21 Feb 2018 11:10:56 +1100 (AEDT) From: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= To: linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, Michael Ellerman , linux-mm@kvack.org, Joel Stanley , =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= , Benjamin Herrenschmidt , Paul Mackerras , Christophe Leroy , Balbir Singh , Guenter Roeck Subject: [PATCH 1/6] powerpc/mm/32: Use pfn_valid to check if pointer is in RAM Date: Tue, 20 Feb 2018 17:14:19 +0100 Message-Id: <20180220161424.5421-2-j.neuschaefer@gmx.net> In-Reply-To: <20180220161424.5421-1-j.neuschaefer@gmx.net> References: <20180220161424.5421-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , The Nintendo Wii has a memory layout that places two chunks of RAM at non-adjacent addresses, and MMIO between them. Currently, the allocation of these MMIO areas is made possible by declaring the MMIO hole as reserved memory and allowing reserved memory to be allocated (cf. wii_memory_fixups). This patch is the first step towards proper support for discontiguous memory on PPC32 by using pfn_valid to check if a pointer points into RAM, rather than open-coding the check. It should result in no functional difference. Signed-off-by: Jonathan Neuschäfer --- arch/powerpc/mm/pgtable_32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c index d35d9ad3c1cd..b5c009893a44 100644 --- a/arch/powerpc/mm/pgtable_32.c +++ b/arch/powerpc/mm/pgtable_32.c @@ -147,7 +147,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, unsigned long flags, * Don't allow anybody to remap normal RAM that we're using. * mem_init() sets high_memory so only do the check after that. */ - if (slab_is_available() && (p < virt_to_phys(high_memory)) && + if (slab_is_available() && pfn_valid(__phys_to_pfn(p)) && !(__allow_ioremap_reserved && memblock_is_region_reserved(p, size))) { printk("__ioremap(): phys addr 0x%llx is RAM lr %ps\n", (unsigned long long)p, __builtin_return_address(0)); -- 2.16.1