[PLIC] Interrupt does not occur when disabling in the ISR before complete

59 views
Skip to first unread message

Padmarao Begari

unread,
Mar 7, 2023, 10:39:41 AM3/7/23
to RISC-V SW Dev
Hi,

Point 1 - The Interrupt is not working
Point 2 - The Interrupt is working 

1). The Interrupt does not occur when disabling the interrupt before interrupt complete, Is this expected behaviour with the PLIC?
With below Pseudo code, Claim the interrupt number and a call to the handler, the interrupt is disabled in the handler and  there is no
impact on the Interrupt Complete register when writing with the interrupt number, so the next interrupt(same) doesn't occur even
though the interrupt is enabled.

***********************PLIC External Interrupt ISR Pseudo Code*********************************
void handle_m_ext_interrupt(void)
{
    int_num = PLIC_ClaimIRQ();      /* get interrupt number by reading interrupt claim register */
    ext_irq_handler(int_num);       /* service the interrupt handler */
    PLIC_CompleteIRQ
(int_num); /* Clear interrupt claim/complete register */
    PLIC_EnableIRQ(int_num);  /* enable interrupt  here or later */
}
void  ext_irq_handler(int_num)
{
    PLIC_DisableIRQ(int_num);  /* disable interrupt */
}
***************************************************************************************************

2). The Interrupt occurs when the interrupt complete is cleared before disable the interrupt and getting the next interrupt.

***********************PLIC External Interrupt ISR Pseudo Code*********************************
void handle_m_ext_interrupt(void)
{
    int_num = PLIC_ClaimIRQ();      /* get interrupt number by reading interrupt claim register */
    ext_irq_handler(int_num);       /* service the interrupt service handler */

    PLIC_EnableIRQ(int_num); /* enable interrupt  here or later */
}
void  ext_irq_handler(int_num)
{
    PLIC_CompleteIRQ(int_num); /* Clear interrupt claim/complete register */
    PLIC_DisableIRQ(int_num);  /* disable interrupt */
}
************************************************************************************
Regards
Padmarao

Richard Herveille

unread,
Mar 7, 2023, 11:10:22 AM3/7/23
to Padmarao Begari, RISC-V SW Dev, Richard Herveille

Is this comment for the PLIC in general or a particular implementation?

 

Cheers,

Richard

--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAP95y-jeO0GPiKFD7xXkMtUeA2%2BsYgKBRwWDJTw1SE2EEXmQEA%40mail.gmail.com.

Padmarao Begari

unread,
Mar 7, 2023, 11:21:14 AM3/7/23
to Richard Herveille, RISC-V SW Dev
It’s SiFive PLIC

On 07-Mar-2023, at 9:40 PM, Richard Herveille <richard....@roalogic.com> wrote:



Richard Herveille

unread,
Mar 8, 2023, 12:10:41 AM3/8/23
to Padmarao Begari, RISC-V SW Dev
I can’t help you with that one. 
We have our own implementation: https://github.com/roalogic/plic
The user guide/datasheet describes how we think the ISR should work. 

Richard 

On Mar 7, 2023, at 08:21, Padmarao Begari <padma...@gmail.com> wrote:

 It’s SiFive PLIC

Jun Xie

unread,
Mar 9, 2023, 4:35:57 AM3/9/23
to RISC-V SW Dev, RISC-V SW Dev, padma...@gmail.com

Sebastian Huber

unread,
Mar 9, 2023, 5:17:49 AM3/9/23
to RISC-V SW Dev, RISC-V SW Dev
Where is it specified in


that the interrupt completion depends on the enabled/disabled state of the interrupt?

For example, the described behaviour is not implemented in the Qemu PLIC emulation:

https://github.com/qemu/qemu/blob/master/hw/intc/sifive_plic.c#L242

In fact, the described behaviour is quite unusual for an interrupt controller. The Arm GIC, NXP MPIC, and Gaisler IRQ(A)MP for example work differently.

How can you safely implement a two step interrupt processing (interrupt context followed by task context) which the PLIC?

Jun Xie

unread,
Mar 9, 2023, 6:56:09 AM3/9/23
to RISC-V SW Dev, RISC-V SW Dev
The last sentence of the first paragraph of Chapter 8 says “If the completion ID does not match an interrupt source that is currently enabled for the target, the completion is silently ignored.

I think it means that the interrupt can only be completed when the interrupt is enabled.

In addition, I thought the intention of the PLIC is to mask/unmask requests from external interrupt sources through claim/complete, so there is no need to enable/disable interrupts in runtime. What's the purpose of disabling interrupt here?
Reply all
Reply to author
Forward
0 new messages