From: Magnus Lindholm <linmag7@gmail.com>
To: davem@davemloft.net, andreas@gaisler.com
Cc: sam@ravnborg.org, sparclinux@vger.kernel.org,
linux-kernel@vger.kernel.org, linmag7@gmail.com
Subject: [PATCH v5 1/6] sparc32: use memblock when mapping the kernel
Date: Wed, 7 Oct 2026 19:41:10 +0200 [thread overview]
Message-ID: <20261007174128.959307-2-linmag7@gmail.com> (raw)
In-Reply-To: <20261007174128.959307-1-linmag7@gmail.com>
memblock already contains the available memory ranges when map_kernel()
runs. Iterate those ranges directly and remove the sp_banks-specific
mapping helper. memblock range ends are exclusive, so use end - start as
the range size.
Suggested-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Magnus Lindholm <linmag7@gmail.com>
---
arch/sparc/mm/srmmu.c | 47 +++++++++++++++++++------------------------
1 file changed, 21 insertions(+), 26 deletions(-)
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index 9a74902ad181..110e2f248c60 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -817,39 +817,34 @@ static void __init do_large_mapping(unsigned long vaddr, unsigned long phys_base
*__nocache_fix(pgdp) = __pgd(big_pte);
}
-/* Map sp_bank entry SP_ENTRY, starting at virtual address VBASE. */
-static unsigned long __init map_spbank(unsigned long vbase, int sp_entry)
-{
- unsigned long pstart = (sp_banks[sp_entry].base_addr & PGDIR_MASK);
- unsigned long vstart = (vbase & PGDIR_MASK);
- unsigned long vend = PGDIR_ALIGN(vbase + sp_banks[sp_entry].num_bytes);
- /* Map "low" memory only */
- const unsigned long min_vaddr = PAGE_OFFSET;
- const unsigned long max_vaddr = PAGE_OFFSET + SRMMU_MAXMEM;
-
- if (vstart < min_vaddr || vstart >= max_vaddr)
- return vstart;
-
- if (vend > max_vaddr || vend < min_vaddr)
- vend = max_vaddr;
-
- while (vstart < vend) {
- do_large_mapping(vstart, pstart);
- vstart += PGDIR_SIZE; pstart += PGDIR_SIZE;
- }
- return vstart;
-}
-
static void __init map_kernel(void)
{
- int i;
+ phys_addr_t start, end;
+ u64 i;
if (phys_base > 0) {
do_large_mapping(PAGE_OFFSET, phys_base);
}
- for (i = 0; sp_banks[i].num_bytes != 0; i++) {
- map_spbank((unsigned long)__va(sp_banks[i].base_addr), i);
+ for_each_mem_range(i, &start, &end) {
+ unsigned long vbase = (unsigned long)__va(start);
+ unsigned long pstart = start & PGDIR_MASK;
+ unsigned long vstart = vbase & PGDIR_MASK;
+ unsigned long vend = PGDIR_ALIGN(vbase + end - start);
+ const unsigned long min_vaddr = PAGE_OFFSET;
+ const unsigned long max_vaddr = PAGE_OFFSET + SRMMU_MAXMEM;
+
+ /* Map low memory only. */
+ if (vstart < min_vaddr || vstart >= max_vaddr)
+ continue;
+ if (vend > max_vaddr || vend < min_vaddr)
+ vend = max_vaddr;
+
+ while (vstart < vend) {
+ do_large_mapping(vstart, pstart);
+ vstart += PGDIR_SIZE;
+ pstart += PGDIR_SIZE;
+ }
}
}
--
2.43.0
next prev parent reply other threads:[~2026-10-07 17:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 17:41 [PATCH v5 0/6] sparc32: replace sp_banks with memblock Magnus Lindholm
2026-10-07 17:41 ` Magnus Lindholm [this message]
2026-10-07 17:41 ` [PATCH v5 2/6] sparc32: use memblock to find available system memory Magnus Lindholm
2026-10-07 17:41 ` [PATCH v5 3/6] sparc32: populate memblock from the PROM memory map Magnus Lindholm
2026-10-07 17:41 ` [PATCH v5 4/6] sparc32: drop unused valid address bitmap Magnus Lindholm
2026-10-07 17:41 ` [PATCH v5 5/6] sparc32: move early memory setup to setup_arch Magnus Lindholm
2026-10-07 17:41 ` [PATCH v5 6/6] sparc32: drop sp_banks Magnus Lindholm
2026-10-08 8:46 ` [PATCH v5 0/6] sparc32: replace sp_banks with memblock Andreas Larsson
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=20261007174128.959307-2-linmag7@gmail.com \
--to=linmag7@gmail.com \
--cc=andreas@gaisler.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=sam@ravnborg.org \
--cc=sparclinux@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.