From: Magnus Lindholm <linmag7@gmail.com>
To: sparclinux@vger.kernel.org
Cc: davem@davemloft.net, andreas@gaisler.com,
linux-kernel@vger.kernel.org, sam@ravnborg.org,
Magnus Lindholm <linmag7@gmail.com>
Subject: [PATCH 1/5] sparc32: use memblock when mapping the kernel
Date: Thu, 27 Aug 2026 20:24:13 +0200 [thread overview]
Message-ID: <20260827182757.6856-2-linmag7@gmail.com> (raw)
In-Reply-To: <20260827182757.6856-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>
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 f0fe09169528..483235458d69 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -846,39 +846,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-08-27 18:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 18:24 [PATCH 0/5] sparc32: replace sp_banks with memblock Magnus Lindholm
2026-08-27 18:24 ` Magnus Lindholm [this message]
2026-08-27 18:24 ` [PATCH 2/5] sparc32: use memblock to find available system memory Magnus Lindholm
2026-08-27 18:24 ` [PATCH 3/5] sparc32: populate memblock from the PROM memory map Magnus Lindholm
2026-08-27 18:24 ` [PATCH 4/5] sparc32: move early memory setup to setup_arch Magnus Lindholm
2026-08-27 18:24 ` [PATCH 5/5] sparc32: drop sp_banks Magnus Lindholm
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=20260827182757.6856-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®