[openwrt/openwrt] bmips: fix SMP CPU mapping

LEDE Commits lede-commits at lists.infradead.org
Tue Feb 23 09:27:03 EST 2021


noltari pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/4dd5845f4981c1dbecaf76ed695e28d6137cc7cd

commit 4dd5845f4981c1dbecaf76ed695e28d6137cc7cd
Author: Álvaro Fernández Rojas <noltari at gmail.com>
AuthorDate: Tue Feb 23 15:25:13 2021 +0100

    bmips: fix SMP CPU mapping
    
    SMP isn't supported on BCM6358 since it has a shared TLB. Some boards boot
    with CPU #1 instead of CPU #0, and this is currently not supported do to a
    smp-bmips bug.
    
    Signed-off-by: Álvaro Fernández Rojas <noltari at gmail.com>
---
 .../200-mips-smp-bmips-fix-CPU-mappings.patch      | 58 ++++++++++++++++++++++
 .../202-irqchip-bcm6345-l1-intc-fix-smp.patch      | 11 ----
 2 files changed, 58 insertions(+), 11 deletions(-)

diff --git a/target/linux/bmips/patches-5.10/200-mips-smp-bmips-fix-CPU-mappings.patch b/target/linux/bmips/patches-5.10/200-mips-smp-bmips-fix-CPU-mappings.patch
new file mode 100644
index 0000000000..16232f8b04
--- /dev/null
+++ b/target/linux/bmips/patches-5.10/200-mips-smp-bmips-fix-CPU-mappings.patch
@@ -0,0 +1,58 @@
+From 56e3adab09cbadb30045893c10ec2ff0d629bc6f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari at gmail.com>
+Date: Tue, 23 Feb 2021 13:41:12 +0100
+Subject: [PATCH] mips: smp-bmips: fix CPU mappings
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+When booting bmips with SMP enabled on a BCM6358 running on CPU #1 instead of
+CPU #0, the current CPU mapping code produces the following:
+- smp_processor_id(): 0
+- cpu_logical_map(): 1
+- cpu_number_map(): 1
+
+This is because SMP isn't supported on BCM6358 since it has a shared TLB, so
+it is disabled and max_cpus is decreased from 2 to 1.
+
+Signed-off-by: Álvaro Fernández Rojas <noltari at gmail.com>
+---
+ arch/mips/kernel/smp-bmips.c | 27 +++++++++++++++++----------
+ 1 file changed, 17 insertions(+), 10 deletions(-)
+
+--- a/arch/mips/kernel/smp-bmips.c
++++ b/arch/mips/kernel/smp-bmips.c
+@@ -134,17 +134,24 @@ static void __init bmips_smp_setup(void)
+ 	if (!board_ebase_setup)
+ 		board_ebase_setup = &bmips_ebase_setup;
+ 
+-	__cpu_number_map[boot_cpu] = 0;
+-	__cpu_logical_map[0] = boot_cpu;
++	if (max_cpus > 1) {
++		__cpu_number_map[boot_cpu] = 0;
++		__cpu_logical_map[0] = boot_cpu;
+ 
+-	for (i = 0; i < max_cpus; i++) {
+-		if (i != boot_cpu) {
+-			__cpu_number_map[i] = cpu;
+-			__cpu_logical_map[cpu] = i;
+-			cpu++;
++		for (i = 0; i < max_cpus; i++) {
++			if (i != boot_cpu) {
++				__cpu_number_map[i] = cpu;
++				__cpu_logical_map[cpu] = i;
++				cpu++;
++			}
++			set_cpu_possible(i, 1);
++			set_cpu_present(i, 1);
+ 		}
+-		set_cpu_possible(i, 1);
+-		set_cpu_present(i, 1);
++	} else {
++		__cpu_number_map[0] = boot_cpu;
++		__cpu_logical_map[0] = 0;
++		set_cpu_possible(0, 1);
++		set_cpu_possible(0, 1);
+ 	}
+ }
+ 
diff --git a/target/linux/bmips/patches-5.10/202-irqchip-bcm6345-l1-intc-fix-smp.patch b/target/linux/bmips/patches-5.10/202-irqchip-bcm6345-l1-intc-fix-smp.patch
deleted file mode 100644
index f9001e685e..0000000000
--- a/target/linux/bmips/patches-5.10/202-irqchip-bcm6345-l1-intc-fix-smp.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/drivers/irqchip/irq-bcm6345-l1.c
-+++ b/drivers/irqchip/irq-bcm6345-l1.c
-@@ -121,7 +121,7 @@ static void bcm6345_l1_irq_handle(struct
- 	unsigned int idx;
- 
- #ifdef CONFIG_SMP
--	cpu = intc->cpus[cpu_logical_map(smp_processor_id())];
-+	cpu = intc->cpus[smp_processor_id()];
- #else
- 	cpu = intc->cpus[0];
- #endif



More information about the lede-commits mailing list