aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/patches-4.14/100-mt7621-core-detect-hack.patch
blob: 991e19b6dfbb92ee1fccd3ccb80268befc53d3da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
There is a variant of MT7621 which contains only one CPU core instead of 2.
This is not reflected in the config register, so the kernel detects more
physical cores, which leads to a hang on SMP bringup.
Add a hack to detect missing cores.

Signed-off-by: Felix Fietkau <nbd@nbd.name>

--- a/arch/mips/kernel/smp-cps.c
+++ b/arch/mips/kernel/smp-cps.c
@@ -47,6 +47,11 @@ static unsigned core_vpe_count(unsigned
 	return mips_cps_numvps(cluster, core);
 }
 
+bool __weak plat_cpu_core_present(int core)
+{
+	return true;
+}
+
 static void __init cps_smp_setup(void)
 {
 	unsigned int nclusters, ncores, nvpes, core_vpes;
@@ -64,6 +69,8 @@ static void __init cps_smp_setup(void)
 
 		ncores = mips_cps_numcores(cl);
 		for (c = 0; c < ncores; c++) {
+			if (!plat_cpu_core_present(c))
+				continue;
 			core_vpes = core_vpe_count(cl, c);
 
 			if (c > 0)
--- a/arch/mips/ralink/mt7621.c
+++ b/arch/mips/ralink/mt7621.c
@@ -15,6 +15,7 @@
 #include <asm/mips-cps.h>
 #include <asm/mach-ralink/ralink_regs.h>
 #include <asm/mach-ralink/mt7621.h>
+#include <asm/mips-boards/launch.h>
 
 #include <pinmux.h>
 
@@ -162,6 +163,20 @@ void __init ralink_of_remap(void)
 		panic("Failed to remap core resources");
 }
 
+bool plat_cpu_core_present(int core)
+{
+	struct cpulaunch *launch = (struct cpulaunch *)CKSEG0ADDR(CPULAUNCH);
+
+	if (!core)
+		return true;
+	launch += core * 2; /* 2 VPEs per core */
+	if (!(launch->flags & LAUNCH_FREADY))
+		return false;
+	if (launch->flags & (LAUNCH_FGO | LAUNCH_FGONE))
+		return false;
+	return true;
+}
+
 void prom_soc_init(struct ralink_soc_info *soc_info)
 {
 	void __iomem *sysc = (void __iomem *) KSEG1ADDR(MT7621_SYSC_BASE);