Skip to content

Commit 796b795

Browse files
ycsinfabiobaltieri
authored andcommitted
drivers: intc: plic: fix for SMP=n when MP_MAX_NUM_CPUS > 1
The functions to obtain the address are hardcoded to return the address of the first core when `CONFIG_SMP != y`, this causes an issue with enabling an IRQ when there are more than one core in the system (`CONFIG_MP_MAX_NUM_CPUS > 1`), as the driver would first enable the IRQ on the first core, and when it tries to obtain the address for the following cores and disable the IRQ on them, the functions continue to return the address of the first core, causing the IRQ to be disabled on the first core. Fix this by determine if `CONFIG_MP_MAX_NUM_CPUS > 1` instead of `CONFIG_SMP=y` when returning the address. Signed-off-by: Yong Cong Sin <[email protected]> Signed-off-by: Yong Cong Sin <[email protected]>
1 parent 0376a41 commit 796b795

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/interrupt_controller/intc_plic.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static inline mem_addr_t get_context_en_addr(const struct device *dev, uint32_t
164164
/*
165165
* We want to return the irq_en address for the context of given hart.
166166
*/
167-
#if CONFIG_SMP
167+
#if CONFIG_MP_MAX_NUM_CPUS > 1
168168
hartid = _kernel.cpus[cpu_num].arch.hartid;
169169
#else
170170
hartid = arch_proc_id();
@@ -188,7 +188,7 @@ static inline mem_addr_t get_threshold_priority_addr(const struct device *dev, u
188188
const struct plic_config *config = dev->config;
189189
uint32_t hartid;
190190

191-
#if CONFIG_SMP
191+
#if CONFIG_MP_MAX_NUM_CPUS > 1
192192
hartid = _kernel.cpus[cpu_num].arch.hartid;
193193
#else
194194
hartid = arch_proc_id();
@@ -493,7 +493,7 @@ static void plic_irq_handler(const struct device *dev)
493493
*
494494
* (by RISC-V Privileged Architecture v1.10)
495495
*/
496-
if (IS_ENABLED(CONFIG_SMP) && (local_irq == 0U)) {
496+
if ((CONFIG_MP_MAX_NUM_CPUS > 1) && (local_irq == 0U)) {
497497
return;
498498
}
499499

0 commit comments

Comments
 (0)