b7b95d6bfc8951c50d23cd32d7475787d9e1cf04
[openwrt/openwrt.git] /
1 From 730320fd770d4114a2ecb6fb223dcc8c3cecdc5b Mon Sep 17 00:00:00 2001
2 From: Aleksander Jan Bajkowski <olek2@wp.pl>
3 Date: Wed, 21 Sep 2022 22:59:44 +0200
4 Subject: [PATCH] MIPS: lantiq: enable all hardware interrupts on second VPE
5
6 This patch is needed to handle interrupts by the second VPE on the Lantiq
7 ARX100, xRX200, xRX300 and xRX330 SoCs. Switching some ICU interrupts to
8 the second VPE results in a hang. Currently, the vsmp_init_secondary()
9 function is responsible for enabling these interrupts. It only enables
10 Malta-specific interrupts (SW0, SW1, HW4 and HW5).
11
12 The MIPS core has 8 interrupts defined. On Lantiq SoCs, hardware
13 interrupts are wired to an ICU instance. Each VPE has an independent
14 instance of the ICU. The mapping of the ICU interrupts is shown below:
15 SW0(IP0) - IPI call,
16 SW1(IP1) - IPI resched,
17 HW0(IP2) - ICU 0-31,
18 HW1(IP3) - ICU 32-63,
19 HW2(IP4) - ICU 64-95,
20 HW3(IP5) - ICU 96-127,
21 HW4(IP6) - ICU 128-159,
22 HW5(IP7) - timer.
23
24 This patch enables all interrupt lines on the second VPE.
25
26 This problem affects multithreaded SoCs with a custom interrupt controller.
27 SOCs with 1004Kc core and newer use the MIPS GIC. At this point, I am aware
28 that the Realtek RTL839x and RTL930x SoCs may need a similar fix. In the
29 future, this may be replaced with some generic solution.
30
31 Tested on Lantiq xRX200.
32
33 Suggested-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
34 Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl>
35 Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
36 ---
37 arch/mips/lantiq/prom.c | 26 ++++++++++++++++++++++++--
38 1 file changed, 24 insertions(+), 2 deletions(-)
39
40 --- a/arch/mips/lantiq/prom.c
41 +++ b/arch/mips/lantiq/prom.c
42 @@ -37,6 +37,14 @@ static struct ltq_soc_info soc_info;
43 /* for Multithreading (APRP), vpe.c will use it */
44 unsigned long cp0_memsize;
45
46 +/*
47 + * These structs are used to override vsmp_init_secondary()
48 + */
49 +#if defined(CONFIG_MIPS_MT_SMP)
50 +extern const struct plat_smp_ops vsmp_smp_ops;
51 +static struct plat_smp_ops lantiq_smp_ops;
52 +#endif
53 +
54 const char *get_system_type(void)
55 {
56 return soc_info.sys_type;
57 @@ -100,6 +108,17 @@ void __init device_tree_init(void)
58 unflatten_and_copy_device_tree();
59 }
60
61 +#if defined(CONFIG_MIPS_MT_SMP)
62 +static void lantiq_init_secondary(void)
63 +{
64 + /*
65 + * MIPS CPU startup function vsmp_init_secondary() will only
66 + * enable some of the interrupts for the second CPU/VPE.
67 + */
68 + set_c0_status(ST0_IM);
69 +}
70 +#endif
71 +
72 void __init prom_init(void)
73 {
74 /* call the soc specific detetcion code and get it to fill soc_info */
75 @@ -111,7 +130,10 @@ void __init prom_init(void)
76 prom_init_cmdline();
77
78 #if defined(CONFIG_MIPS_MT_SMP)
79 - if (register_vsmp_smp_ops())
80 - panic("failed to register_vsmp_smp_ops()");
81 + if (cpu_has_mipsmt) {
82 + lantiq_smp_ops = vsmp_smp_ops;
83 + lantiq_smp_ops.init_secondary = lantiq_init_secondary;
84 + register_smp_ops(&lantiq_smp_ops);
85 + }
86 #endif
87 }