Skip to content

Commit 1d60d74

Browse files
committed
drivers: intc: plic: implement irq_set_affinity()
- Implement `irq_set_affinity()` in RISCV PLIC. - Added new affinity shell command to get/set the irq(s) affinity in runtime, when `0` is sent as the `local_irq`, it means set/get all IRQs affinity. - Some minor optimizations Updated the build_all test to build this new configuration. Signed-off-by: Yong Cong Sin <[email protected]> Signed-off-by: Yong Cong Sin <[email protected]>
1 parent 897cb0e commit 1d60d74

File tree

7 files changed

+437
-69
lines changed

7 files changed

+437
-69
lines changed

arch/riscv/core/smp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ void arch_secondary_cpu_init(int hartid)
7474
#endif
7575
#ifdef CONFIG_SMP
7676
irq_enable(RISCV_IRQ_MSOFT);
77-
#endif
77+
#ifdef CONFIG_PLIC_IRQ_AFFINITY
78+
/* Enable on secondary cores so that they can respond to PLIC */
79+
irq_enable(RISCV_IRQ_MEXT);
80+
#endif /* CONFIG_PLIC_IRQ_AFFINITY */
81+
#endif /* CONFIG_SMP */
7882
riscv_cpu_init[cpu_num].fn(riscv_cpu_init[cpu_num].arg);
7983
}
8084

drivers/interrupt_controller/Kconfig.plic

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,50 @@ config PLIC
77
depends on DT_HAS_SIFIVE_PLIC_1_0_0_ENABLED
88
select MULTI_LEVEL_INTERRUPTS
99
select 2ND_LEVEL_INTERRUPTS
10+
select IRQ_HAS_AFFINITY
1011
help
1112
Platform Level Interrupt Controller provides support
1213
for external interrupt lines defined by the RISC-V SoC.
1314

1415
if PLIC
1516

17+
config PLIC_IRQ_AFFINITY
18+
bool
19+
default y if IRQ_AFFINITY
20+
depends on SMP
21+
depends on MP_MAX_NUM_CPUS > 1
22+
help
23+
Internal helper to indicate that IRQ affinity is enabled.
24+
25+
config IRQ_AFFINITY_MASK
26+
depends on PLIC_IRQ_AFFINITY
27+
default 0x1
28+
help
29+
Default mask for the driver when IRQ affinity is enabled.
30+
1631
config PLIC_SHELL
1732
bool "PLIC shell commands"
1833
depends on SHELL
1934
help
2035
Enable additional shell commands useful for debugging.
2136
Caution: This can use quite a bit of RAM (PLICs * IRQs * sizeof(uint16_t)).
2237

38+
if PLIC_SHELL
39+
40+
config PLIC_SHELL_IRQ_COUNT
41+
bool "IRQ count shell commands"
42+
default y
43+
help
44+
Records the number of hits per interrupt line and provide shell commands to access them.
45+
Caution: This can use quite a bit of RAM (PLICs * IRQs * sizeof(PLIC_IRQ_COUNT_TYPE)).
46+
47+
config PLIC_SHELL_IRQ_AFFINITY
48+
bool "Shell commands to configure IRQ affinity"
49+
default y
50+
depends on PLIC_IRQ_AFFINITY
51+
help
52+
Provide shell commands to configure IRQ affinity in runtime.
53+
54+
endif # PLIC_SHELL
55+
2356
endif # PLIC

0 commit comments

Comments
 (0)