Message ID | 20240119040240.392442-2-huangpei@loongson.cn (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [1/2] MIPS: reserve exception vector space ONLY ONCE | expand |
On 1/19/24 7:02 AM, Huang Pei wrote: > "cpu_probe" is called both by BP and APs, but reserving exception vector > (like 0x0-0x1000) called by "cpu_probe" need once and calling on BPs is > too late since memblock is unavailable at that time. > > So, reserve exception vector ONLY by BP. > > Signed-off-by: Huang Pei <huangpei@loongson.cn> > --- > arch/mips/kernel/cpu-probe.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c > index b406d8bfb15a..6939d0de2a03 100644 > --- a/arch/mips/kernel/cpu-probe.c > +++ b/arch/mips/kernel/cpu-probe.c > @@ -1581,7 +1581,9 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu) > __cpu_name[cpu] = "Broadcom BMIPS4380"; > set_elf_platform(cpu, "bmips4380"); > c->options |= MIPS_CPU_RIXI; > - reserve_exception_space(0x400, VECTORSPACING * 64); > + if (cpu == 0) { No need for {} around single statement. > + reserve_exception_space(0x400, VECTORSPACING * 64); > + } > } else { > c->cputype = CPU_BMIPS4350; > __cpu_name[cpu] = "Broadcom BMIPS4350"; > @@ -1598,7 +1600,9 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu) > __cpu_name[cpu] = "Broadcom BMIPS5000"; > set_elf_platform(cpu, "bmips5000"); > c->options |= MIPS_CPU_ULRI | MIPS_CPU_RIXI; > - reserve_exception_space(0x1000, VECTORSPACING * 64); > + if (cpu == 0) { Ditto. > + reserve_exception_space(0x1000, VECTORSPACING * 64); > + } > break; > } > } [...] MBR, Sergey
On Fri, Jan 19, 2024 at 12:02:39PM +0800, Huang Pei wrote: > "cpu_probe" is called both by BP and APs, but reserving exception vector > (like 0x0-0x1000) called by "cpu_probe" need once and calling on BPs is > too late since memblock is unavailable at that time. > > So, reserve exception vector ONLY by BP. > > Signed-off-by: Huang Pei <huangpei@loongson.cn> > --- > arch/mips/kernel/cpu-probe.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c > index b406d8bfb15a..6939d0de2a03 100644 > --- a/arch/mips/kernel/cpu-probe.c > +++ b/arch/mips/kernel/cpu-probe.c > @@ -1581,7 +1581,9 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu) > __cpu_name[cpu] = "Broadcom BMIPS4380"; > set_elf_platform(cpu, "bmips4380"); > c->options |= MIPS_CPU_RIXI; > - reserve_exception_space(0x400, VECTORSPACING * 64); > + if (cpu == 0) { > + reserve_exception_space(0x400, VECTORSPACING * 64); > + } why not do a if (smp_processor_id() == 0) memblock_reserve(...) in reserve_exception_space() ? Thomas.
On Fri, Jan 19, 2024 at 05:15:02PM +0100, Thomas Bogendoerfer wrote: > On Fri, Jan 19, 2024 at 12:02:39PM +0800, Huang Pei wrote: > > "cpu_probe" is called both by BP and APs, but reserving exception vector > > (like 0x0-0x1000) called by "cpu_probe" need once and calling on BPs is > > too late since memblock is unavailable at that time. > > > > So, reserve exception vector ONLY by BP. > > > > Signed-off-by: Huang Pei <huangpei@loongson.cn> > > --- > > arch/mips/kernel/cpu-probe.c | 13 +++++++++---- > > 1 file changed, 9 insertions(+), 4 deletions(-) > > > > diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c > > index b406d8bfb15a..6939d0de2a03 100644 > > --- a/arch/mips/kernel/cpu-probe.c > > +++ b/arch/mips/kernel/cpu-probe.c > > @@ -1581,7 +1581,9 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu) > > __cpu_name[cpu] = "Broadcom BMIPS4380"; > > set_elf_platform(cpu, "bmips4380"); > > c->options |= MIPS_CPU_RIXI; > > - reserve_exception_space(0x400, VECTORSPACING * 64); > > + if (cpu == 0) { > > + reserve_exception_space(0x400, VECTORSPACING * 64); > > + } > > why not do a > > if (smp_processor_id() == 0) > memblock_reserve(...) > > in reserve_exception_space() ? This is better, I will include this in V6 > > Thomas. > > -- > Crap can work. Given enough thrust pigs will fly, but it's not necessarily a > good idea. [ RFC1925, 2.3 ]
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index b406d8bfb15a..6939d0de2a03 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c @@ -1581,7 +1581,9 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu) __cpu_name[cpu] = "Broadcom BMIPS4380"; set_elf_platform(cpu, "bmips4380"); c->options |= MIPS_CPU_RIXI; - reserve_exception_space(0x400, VECTORSPACING * 64); + if (cpu == 0) { + reserve_exception_space(0x400, VECTORSPACING * 64); + } } else { c->cputype = CPU_BMIPS4350; __cpu_name[cpu] = "Broadcom BMIPS4350"; @@ -1598,7 +1600,9 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu) __cpu_name[cpu] = "Broadcom BMIPS5000"; set_elf_platform(cpu, "bmips5000"); c->options |= MIPS_CPU_ULRI | MIPS_CPU_RIXI; - reserve_exception_space(0x1000, VECTORSPACING * 64); + if (cpu == 0) { + reserve_exception_space(0x1000, VECTORSPACING * 64); + } break; } } @@ -1992,12 +1996,13 @@ void cpu_probe(void) */ loongson3_cpucfg_synthesize_data(c); + if (cpu == 0) { #ifdef CONFIG_64BIT - if (cpu == 0) __ua_limit = ~((1ull << cpu_vmbits) - 1); #endif + reserve_exception_space(0, 0x1000); + } - reserve_exception_space(0, 0x1000); } void cpu_report(void)
"cpu_probe" is called both by BP and APs, but reserving exception vector (like 0x0-0x1000) called by "cpu_probe" need once and calling on BPs is too late since memblock is unavailable at that time. So, reserve exception vector ONLY by BP. Signed-off-by: Huang Pei <huangpei@loongson.cn> --- arch/mips/kernel/cpu-probe.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)