riscv: plic: IRQs may not be enabled in non-zero HART #78138
Labels
area: Interrupt Controller
area: RISCV
RISCV Architecture (32-bit & 64-bit)
bug
The issue is a bug, or the PR is fixing a bug
Enhancement
Changes/Updates/Additions to existing features
priority: low
Low impact/importance bug
Is your enhancement proposal related to a problem? Please describe.
All enabled HARTs should be able to handle the IRQ. #65922 is supposed to enable the IRQ on all HARTs, however the patch assumed that the first HART of a SoC has 1 context, whereas the other HARTs have 2 contexts each, i.e.:
zephyr/drivers/interrupt_controller/intc_plic.c
Lines 112 to 134 in 5b15751
This means that for SoC that doesn't fit into that assumption, the implementation will not work, i.e. QEMU RISC-V SoCs, which has 2 contexts per HART:
zephyr/dts/riscv/qemu/virt-riscv.dtsi
Lines 164 to 182 in 5b15751
The current PLIC driver will enable the interrupt on context 0, 1, 3, .., (hartid * 2 - 1) of the QEMU SoC, which corresponds to:
as a result, machine external interrupts, like UART, only works on
hartid=0
This can be tested by building the
hello_world
withSHELL
enabled (to test the UART interrupt), but boot it onhartid=1
instead of0
:Since UART IRQ isn't enabled on the context M of HART 1, there will be no prompt on the terminal, and typing in the terminal will have no response from the device:
The workaround for QEMU RISC-V SoCs is simple:
Run the same build command again, the terminal will be responsive this time around:
However, this workaround only works on SoC where each hart has 2 contexts.
Describe the solution you'd like
Update the implementation so that the interrupt will work regardless of the mapping of the contexts.
Describe alternatives you've considered
Not fixing it.
The text was updated successfully, but these errors were encountered: