Re: [PATCH 4/5] sparc32: move early memory setup to setup_arch
From: Magnus Lindholm
Date: Sat Aug 29 2026 - 04:21:47 EST
Hi Sam,
On Sat, Aug 29, 2026 at 8:26 AM Sam Ravnborg <sam@xxxxxxxxxxxx> wrote:
>
> Hi Magnus
>
> On Thu, Aug 27, 2026 at 08:24:16PM +0200, Magnus Lindholm wrote:
> > Move the early memory configuration out of SRMMU paging setup and next to
> > the rest of setup_arch(). Derive the PFN limits from memblock, reserve the
> > kernel and initrd there, and retain mem= support with
> > memblock_enforce_memory_limit().
> >
> > When PAGE_OFFSET maps a relocated kernel, remove memory below phys_base
> > from memblock because it cannot be reached through the linear map. This
> > replaces the equivalent trimming of sp_banks.
> >
> Rebasing the relocate kernel patch on top of this would prevent the same
> code to be patched twice. But the end result would ofc be the same.
>
Doable, but as you say the end result would be the same. The relocate patch
is part of the phys_base series that's already posted and is a boot
prerequisite on my hardware, so pulling one patch out of it to re-land on
top of this while both are in flight felt like more churn than the tidier
history is worth.
> > - for (i = 0; sp_banks[i].num_bytes != 0; i++) {
> > - unsigned long start = sp_banks[i].base_addr;
> > - unsigned long end = start + sp_banks[i].num_bytes;
> > + for_each_mem_range(i, &start, &end) {
> > + unsigned long start_pfn = PFN_DOWN(start);
>
> Here for_each_mem_pfn_range() could be used.
>
Yes, that make sense
> > + min_low_pfn = PFN_DOWN(memblock_start_of_DRAM());
> > + pfn_base = phys_base >> PAGE_SHIFT;
> > + max_pfn = PFN_DOWN(memblock_end_of_DRAM());
> > + last_valid_pfn = max_pfn;
> last_valid_pfn can be replaced with max_low_pfn in all places.
> > + max_low_pfn = max_pfn;
> Likewise, replace all uses of max_pfn with max_low_pfn.
>
> Code becomes easier to understand when the memblock defined variables
> are used.
>
I agree, I will fix this.
> > + for_each_mem_range(i, &start, &end) {
> > while (start < end) {
> > set_bit(start >> 20, sparc_valid_addr_bitmap);
> > start += PAGE_SIZE;
> There are no users of sparc_valid_addr_bitmap, it would be better
> to drop the whole function in a preparation patch.
>
Well spotted, will do.
I'll get started on a v2 of this series and post it asap.
Regards
Magnus