Re: [PATCH 2/2] irqchip: Add Microchip PIC64-HPSC/HX NVM interrupt controller

From: Charles Perry

Date: Fri Dec 04 2026 - 10:55:42 EST


On Fri, Dec 04, 2026 at 11:57:00AM +0100, Thomas Gleixner wrote:
> On Thu, Dec 03 2026 at 13:14, Charles Perry wrote:
>
> > On Thu, Dec 03, 2026 at 11:35:20AM +0100, Thomas Gleixner wrote:
> >> On Wed, Dec 02 2026 at 17:20, Charles Perry wrote:
> >> > On Tue, Dec 01, 2026 at 08:31:19PM +0100, Thomas Gleixner wrote:
> >> >> > + * Clear it, then dispatch only the sources whose line is still high.
> >> >> > + */
> >> >> > + writel(pending, intc->base + P64H_NVM_INTC_STATUS);
> >> >>
> >> >> What happens in the case that there is only BIT(N) pending in STATUS and
> >> >> that bit is not set in ENABLED?
> >> >
> >> > That happens only with PREEMPT_RT.
> >>
> >> I don't think that's a PREEMPT_RT issue. That's an issue related to
> >> threaded interrupts. Just add 'threadirqs' on the kernel command line
> >> with a !RT kernel and you should observe the same.
> >
> > I've tested 'threadirqs' with !RT and I observe the same thing as with RT.
>
> Not a surprise.
>
> Let's look how level interrupt controllers work in general:
>
> Hardware CPU
>
> Line is raised
> interrupt is raised
> interrupt()
> handle_level_irq()
> mask_ack()
> device_handler()
> Line is cleared ...
> unmask()
>
> The mask_ack() does two things:
>
> 1) It masks the interrupt so the it can't be raised again until the
> device handler completed. That's required because with level type
> the interrupt line stays raised until the device handler cleared
> it in the device.
>
> 2) It acks the interrupt, which resets the logic in the interrupt
> chip to raise the interrupt in the CPU again.
>
> So if ACK happens without masking the interrupt stays asserted or the
> ACK might cause a 1-0-1 transition in some chips.
>
> Threaded mode does not really change this:
>
> interrupt is raised
> interrupt()
> handle_level_irq()
> mask_ack()
> wake_thread()
> return // interrupt stays masked
>
> thread()
> device_handler()
> unmask()
>
> All what changes is the timing.
>
> So this sequence:
>
> pending = read(STATUS) & read(ENABLE);
>
> write(pending, STATUS);
>
> pending &= read(STATUS);

This read() was on VALUE, see my diagram below.

>
> does not make sense for a sanely designed level type controller which
> usually does:
>
> STATUS = LINESTATE & ENABLED
>
> and if it has multiple input lines then the output is simply:
>
> OUTLINE = STATUS(0) | STATUS(1) .... | STATUS(N)
>
> From your code and comments it seems STATUS is latched which does not
> make sense.

We have 3 registers, VALUE, STATUS and ENABLE. VALUE is the live output of
the device, STATUS reflects a latched value of each input and ENABLE
controls which output gets muxed:

+----------------------------------------+
| nvm-intc |
| |
| |
+--------+ VALUE[0] +------+ STATUS[0] +---+ +---+ |
| Device |----|------>| Edge |---------->| | | | |
| | | | | | | | | |
+--------+ | +------+ |AND| | | |
| | |-->| | | +--------+
| | | | | | | APLIC |
| ENABLE[0]--->| | | | | | |
| +---+ | | | | |
| | |----->| |
+--------+ VALUE[1] +------+ STATUS[1] +---+ |OR | | | |
| Device |----------->| Edge |---------->| | | | | | |
| | | | | | | | | | | |
+--------+ | +------+ |AND|-->| | | +--------+
| | | | | |
| | | | | |
| ENABLE[1]--->| | | | |
| +---+ | | |
| | | |
| ... | | |
+----------------------------------+---+-+

Is it a problem that ENABLE doesn't prevent VALUE from latching STATUS?

>
> But even then it does not explain how the status bit stays raised with
> the mask_ack() sequence of the level handler.

Because ENABLE acts on the output, it doesn't prevent VALUE from latching
STATUS. So if another interrupt happens while calling the device handler
STATUS will be high, even though ENABLE is 0.

>
> That makes me very confident that these SoCs are redefining the future
> for space and mission critical applications :)

I'm sure it will with your help!

--
Thanks,
Charles