ibex icon indicating copy to clipboard operation
ibex copied to clipboard

An higher prio interrupt routine is interrupted by lower prio IRQ

Open vit82 opened this issue 7 years ago • 6 comments

When executing a higher priority interrupt routine, it can be interrupted by a lower prio interrupt if MIE is set high and high prio IRQ source cleared. Is it an intended implementation?

Below is a screenshot where fast_irq_i[0] and fast_irq_i[1] occur simultaneously. First, fast_irq_i[1] is being served. But after I clear fast_irq_i[1] source & set MIE high, the routing is preempted by fast_irq_i[0] . Once fast_irq_i[0] routine is complete, the rest of fast_irq_i[1] is completed. image

vit82 avatar Nov 19 '19 13:11 vit82

firmware_rv32imc.lss.txt Attached is FW listing file.

vit82 avatar Nov 19 '19 13:11 vit82

Hi @vit82 , yes, that is intended behavior. As far as I know, the priority only matters if multiple interrupt lines are high and the core needs to decide which one to start handling first.

vogelpi avatar Nov 19 '19 14:11 vogelpi

Alright, I see it's possible to implement the above mentioned function by adding extra logic outside CPU. But it would require replication of arbitration logic etc. So isn't it more optimal to put everything inside CPU core? Or may there's a use case when higher prio routine needs to be preempted by a lower prio routine?

vit82 avatar Nov 19 '19 14:11 vit82

This behavior can be implemented in software: Before re-enabling interrupts by setting mstatus.MIE to 1'b1, the content of mie has to be modified. This CSR holds the interrupt enable of the individual interrupts.

For example when handling fast interrupt no. 1 (mfip[1], interrupt ID 17), all mie[17:0] has to be set to 0. The interrupt routine is then only interrupted by fast interrupt no. 2 - 14 (ID 18 - 30).

vogelpi avatar Nov 19 '19 15:11 vogelpi

Ok, your suggested approach works. Though it increases interrupt service overhead.

vit82 avatar Nov 21 '19 16:11 vit82

Please look into an external interrupt controller, like PLIC or CLIC, if you are interested in more hardware processing for your interrupts.

imphil avatar Nov 21 '19 18:11 imphil