[PATCH v3 19/29] sparc: introduce arch_zone_limits_init()

Mike Rapoport
2026-01-11T08:26:11Z

Move calculations of zone limits to a dedicated arch_zone_limits_init()
function.

Later MM core will use this function as an architecture specific callback
during nodes and zones initialization and thus there won't be a need to
call free_area_init() from every architecture.

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
arch/sparc/mm/init_64.c | 6 ++++++
arch/sparc/mm/srmmu.c | 12 ++++++++----
2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index df9f7c444c39..fbaad449dfc9 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -2279,6 +2279,11 @@ static void __init reduce_memory(phys_addr_t limit_ram)
memblock_enforce_memory_limit(limit_ram);
}

+void __init arch_zone_limits_init(unsigned long *max_zone_pfns)
+{
+ max_zone_pfns[ZONE_NORMAL] = last_valid_pfn;
+}
+
void __init paging_init(void)
{
unsigned long end_pfn, shift, phys_base;
@@ -2461,6 +2466,7 @@ void __init paging_init(void)

max_zone_pfns[ZONE_NORMAL] = end_pfn;

+ arch_zone_limits_init(max_zone_pfns);
free_area_init(max_zone_pfns);
}

diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index f8fb4911d360..81e90151db90 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -884,6 +884,13 @@ static void __init map_kernel(void)

void (*poke_srmmu)(void) = NULL;

+void __init arch_zone_limits_init(unsigned long *max_zone_pfns)
+{
+ max_zone_pfns[ZONE_DMA] = max_low_pfn;
+ max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
+ max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
+}
+
void __init srmmu_paging_init(void)
{
int i;
@@ -967,10 +974,7 @@ void __init srmmu_paging_init(void)
{
unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 };

- max_zone_pfn[ZONE_DMA] = max_low_pfn;
- max_zone_pfn[ZONE_NORMAL] = max_low_pfn;
- max_zone_pfn[ZONE_HIGHMEM] = highend_pfn;
-
+ arch_zone_limits_init(max_zone_pfn);
free_area_init(max_zone_pfn);
}
}
--
2.51.0