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
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).
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:
16 SW1(IP1) - IPI resched,
20 HW3(IP5) - ICU 96-127,
21 HW4(IP6) - ICU 128-159,
24 This patch enables all interrupt lines on the second VPE.
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.
31 Tested on Lantiq xRX200.
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>
37 arch/mips/lantiq/prom.c | 26 ++++++++++++++++++++++++--
38 1 file changed, 24 insertions(+), 2 deletions(-)
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;
47 + * These structs are used to override vsmp_init_secondary()
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;
54 const char *get_system_type(void)
56 return soc_info.sys_type;
57 @@ -100,6 +108,17 @@ void __init device_tree_init(void)
58 unflatten_and_copy_device_tree();
61 +#if defined(CONFIG_MIPS_MT_SMP)
62 +static void lantiq_init_secondary(void)
65 + * MIPS CPU startup function vsmp_init_secondary() will only
66 + * enable some of the interrupts for the second CPU/VPE.
68 + set_c0_status(ST0_IM);
72 void __init prom_init(void)
74 /* call the soc specific detetcion code and get it to fill soc_info */
75 @@ -111,7 +130,10 @@ void __init prom_init(void)
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);