linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	npiggin@gmail.com
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH v1 05/10] powerpc/mm: Do early ioremaps from top to bottom on PPC64 too.
Date: Tue, 13 Aug 2019 20:11:38 +0000 (UTC)	[thread overview]
Message-ID: <019c5d90f7027ccff00e38a3bcd633d290f6af59.1565726867.git.christophe.leroy@c-s.fr> (raw)
In-Reply-To: <6bc35eca507359075528bc0e55938bc1ce8ee485.1565726867.git.christophe.leroy@c-s.fr>

Until vmalloc system is up and running, ioremap basically
allocates addresses at the border of the IOREMAP area.

On PPC32, addresses are allocated down from the top of the area
while on PPC64, addresses are allocated up from the base of the
area.

On PPC32, the base of vmalloc area is not known yet when ioremap()
starts to be used, while the end of it is fixed. On PPC64, both the
start and the end are already fixed when ioremap() starts to being
used.

Changing PPC64 behaviour is the lighest change, so change PPC64
ioremap() to allocate addresses from the top as PPC32 does.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/mm/book3s64/hash_utils.c    |  2 +-
 arch/powerpc/mm/book3s64/radix_pgtable.c |  2 +-
 arch/powerpc/mm/pgtable_64.c             | 18 +++++++++---------
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c
index e6d471058597..0f954dc40346 100644
--- a/arch/powerpc/mm/book3s64/hash_utils.c
+++ b/arch/powerpc/mm/book3s64/hash_utils.c
@@ -1030,7 +1030,7 @@ void __init hash__early_init_mmu(void)
 	__kernel_io_start = H_KERN_IO_START;
 	__kernel_io_end = H_KERN_IO_END;
 	vmemmap = (struct page *)H_VMEMMAP_START;
-	ioremap_bot = IOREMAP_BASE;
+	ioremap_bot = IOREMAP_END;
 
 #ifdef CONFIG_PCI
 	pci_io_base = ISA_IO_BASE;
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
index b4ca9e95e678..11303e2fffb1 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -611,7 +611,7 @@ void __init radix__early_init_mmu(void)
 	__kernel_io_start = RADIX_KERN_IO_START;
 	__kernel_io_end = RADIX_KERN_IO_END;
 	vmemmap = (struct page *)RADIX_VMEMMAP_START;
-	ioremap_bot = IOREMAP_BASE;
+	ioremap_bot = IOREMAP_END;
 
 #ifdef CONFIG_PCI
 	pci_io_base = ISA_IO_BASE;
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index 6fa2e969bf0e..0f0b1e1ea5ab 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -101,7 +101,7 @@ unsigned long __pte_frag_size_shift;
 EXPORT_SYMBOL(__pte_frag_size_shift);
 unsigned long ioremap_bot;
 #else /* !CONFIG_PPC_BOOK3S_64 */
-unsigned long ioremap_bot = IOREMAP_BASE;
+unsigned long ioremap_bot = IOREMAP_END;
 #endif
 
 int __weak ioremap_range(unsigned long ea, phys_addr_t pa, unsigned long size, pgprot_t prot, int nid)
@@ -169,11 +169,11 @@ void __iomem * __ioremap_caller(phys_addr_t addr, unsigned long size,
 
 	/*
 	 * Choose an address to map it to.
-	 * Once the imalloc system is running, we use it.
+	 * Once the vmalloc system is running, we use it.
 	 * Before that, we map using addresses going
-	 * up from ioremap_bot.  imalloc will use
-	 * the addresses from ioremap_bot through
-	 * IMALLOC_END
+	 * down from ioremap_bot.  vmalloc will use
+	 * the addresses from IOREMAP_BASE through
+	 * ioremap_bot
 	 * 
 	 */
 	paligned = addr & PAGE_MASK;
@@ -186,7 +186,7 @@ void __iomem * __ioremap_caller(phys_addr_t addr, unsigned long size,
 		struct vm_struct *area;
 
 		area = __get_vm_area_caller(size, VM_IOREMAP,
-					    ioremap_bot, IOREMAP_END,
+					    IOREMAP_BASE, ioremap_bot,
 					    caller);
 		if (area == NULL)
 			return NULL;
@@ -194,9 +194,9 @@ void __iomem * __ioremap_caller(phys_addr_t addr, unsigned long size,
 		area->phys_addr = paligned;
 		ret = __ioremap_at(paligned, area->addr, size, prot);
 	} else {
-		ret = __ioremap_at(paligned, (void *)ioremap_bot, size, prot);
+		ret = __ioremap_at(paligned, (void *)ioremap_bot - size, size, prot);
 		if (ret)
-			ioremap_bot += size;
+			ioremap_bot -= size;
 	}
 
 	if (ret)
@@ -217,7 +217,7 @@ void __iounmap(volatile void __iomem *token)
 	
 	addr = (void *) ((unsigned long __force)
 			 PCI_FIX_ADDR(token) & PAGE_MASK);
-	if ((unsigned long)addr < ioremap_bot) {
+	if ((unsigned long)addr >= ioremap_bot) {
 		printk(KERN_WARNING "Attempt to iounmap early bolted mapping"
 		       " at 0x%p\n", addr);
 		return;
-- 
2.13.3


  parent reply	other threads:[~2019-08-13 20:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-13 20:11 [PATCH v1 01/10] powerpc/mm: drop ppc_md.iounmap() Christophe Leroy
2019-08-13 20:11 ` [PATCH v1 02/10] powerpc/mm: rework io-workaround invocation Christophe Leroy
2019-08-14  5:38   ` Christoph Hellwig
2019-08-13 20:11 ` [PATCH v1 03/10] powerpc/mm: move common 32/64 bits ioremap functions into ioremap.c Christophe Leroy
2019-08-13 20:11 ` [PATCH v1 04/10] powerpc/mm: move ioremap_prot() " Christophe Leroy
2019-08-13 20:11 ` Christophe Leroy [this message]
2019-08-14  5:55   ` [PATCH v1 05/10] powerpc/mm: Do early ioremaps from top to bottom on PPC64 too Christoph Hellwig
2019-08-14  6:10     ` Christophe Leroy
2019-08-14  6:14       ` Christoph Hellwig
2019-08-19 13:42   ` Nicholas Piggin
2019-08-20  0:20     ` Michael Ellerman
2019-08-20  5:10       ` Christophe Leroy
2019-08-13 20:11 ` [PATCH v1 06/10] powerpc/mm: make ioremap_bot common to all Christophe Leroy
2019-08-13 20:11 ` [PATCH v1 07/10] powerpc/mm: move iounmap() into ioremap.c and drop __iounmap() Christophe Leroy
2019-08-19 12:55   ` Michael Ellerman
2019-08-13 20:11 ` [PATCH v1 08/10] powerpc/mm: move __ioremap_at() and __iounmap_at() into ioremap.c Christophe Leroy
2019-08-14  5:23   ` Christoph Hellwig
2019-08-20  0:18   ` Michael Ellerman
2019-08-13 20:11 ` [PATCH v1 09/10] powerpc/mm: make __ioremap_caller() common to PPC32 and PPC64 Christophe Leroy
2019-08-13 20:11 ` [PATCH v1 10/10] powerpc/mm: refactor ioremap_range() and use ioremap_page_range() Christophe Leroy
2019-08-14  5:49   ` Christoph Hellwig
2019-08-14  6:23     ` Christophe Leroy
2019-08-14  6:30       ` Christoph Hellwig
2019-08-14  5:19 ` [PATCH v1 01/10] powerpc/mm: drop ppc_md.iounmap() Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=019c5d90f7027ccff00e38a3bcd633d290f6af59.1565726867.git.christophe.leroy@c-s.fr \
    --to=christophe.leroy@c-s.fr \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).