[PATCH v2 10/28] mips: introduce arch_zone_limits_init()

Mike Rapoport
2026-01-02T07:02:54Z

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/mips/loongson64/numa.c | 9 +++++++--
arch/mips/mm/init.c | 14 +++++++++-----
arch/mips/sgi-ip27/ip27-memory.c | 7 ++++++-
3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c
index 95d5f553ce19..f72a58f87878 100644
--- a/arch/mips/loongson64/numa.c
+++ b/arch/mips/loongson64/numa.c
@@ -154,13 +154,18 @@ static __init void prom_meminit(void)
}
}

+void __init arch_zone_limits_init(unsigned long *max_zone_pfns)
+{
+ max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
+ max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
+}
+
void __init paging_init(void)
{
unsigned long zones_size[MAX_NR_ZONES] = {0, };

pagetable_init();
- zones_size[ZONE_DMA32] = MAX_DMA32_PFN;
- zones_size[ZONE_NORMAL] = max_low_pfn;
+ arch_zone_limits_init(zones_size);
free_area_init(zones_size);
}

diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index a673d3d68254..ab08249cfede 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -394,12 +394,8 @@ void maar_init(void)
}

#ifndef CONFIG_NUMA
-void __init paging_init(void)
+void __init arch_zone_limits_init(unsigned long *max_zone_pfns)
{
- unsigned long max_zone_pfns[MAX_NR_ZONES];
-
- pagetable_init();
-
#ifdef CONFIG_ZONE_DMA
max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
#endif
@@ -417,7 +413,15 @@ void __init paging_init(void)
max_zone_pfns[ZONE_HIGHMEM] = max_low_pfn;
}
#endif
+}
+
+void __init paging_init(void)
+{
+ unsigned long max_zone_pfns[MAX_NR_ZONES];
+
+ pagetable_init();

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

diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c
index 2b3e46e2e607..babeb0e07687 100644
--- a/arch/mips/sgi-ip27/ip27-memory.c
+++ b/arch/mips/sgi-ip27/ip27-memory.c
@@ -406,11 +406,16 @@ void __init prom_meminit(void)
}
}

+void __init arch_zone_limits_init(unsigned long *max_zone_pfns)
+{
+ max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
+}
+
void __init paging_init(void)
{
unsigned long zones_size[MAX_NR_ZONES] = {0, };

pagetable_init();
- zones_size[ZONE_NORMAL] = max_low_pfn;
+ arch_zone_limits_init(zones_size);
free_area_init(zones_size);