Devicetree
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@kernel.org>
To: Charles Perry <charles.perry@microchip.com>
Cc: Charles Perry <charles.perry@microchip.com>,
	Radu Rendec <radu@rendec.net>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Romain Caritey <romain.caritey@microchip.com>,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 2/2] irqchip: Add Microchip PIC64-HPSC/HX NVM interrupt controller
Date: Fri, 04 Dec 2026 21:40:14 +0100	[thread overview]
Message-ID: <87a4mkn5jl.ffs@fw13> (raw)
In-Reply-To: <axLiKJ8b-MTFYqd3@MON-LT-C78453.mchp-main.com>

On Fri, Dec 04 2026 at 10:54, Charles Perry wrote:
> On Fri, Dec 04, 2026 at 11:57:00AM +0100, Thomas Gleixner wrote:
>> 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?

Not if you mask it out with the enabled bits. But ...

>> 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.

.. you say the input is latched into status on a raising edge, right?

Which means the input logic is edge type. The output is level type.

But you claim the input is level type too. That doesn't make any sense.

A strict level type interrupt source in a device is not required to have
a 1-0-1 transition. The interrupt line can stay asserted even when the
first interrupt is handled by the device driver. A typical scenario is
that in the device there is a interrupt status register. So the
following can happen:

Device		dev-irq
   IS == 0	0
   IS == 1      1	 
   				interrupt
  		              	   mask_ack()
   				     handler()
                                      // Reads 1
                                      pending = read(IS);
   IS == 3
   				      // Clears bit(0)
   IS == 2			      handle(pending)
                                      return;
                                   unmask();

That's legit from a device driver POV if the device interrupt is
strictly level type output because the driver can rely on the interrupt
being re-raised in the CPU after the unmask.

If your input logic latches on a rising edge, then this case is not
re-raising the interrupt because the mask_ack() clears the status bit
and if there is no 1-0-1 transition on the input line, then the
interrupt line becomes stale.

So none of this adds up. 

If the interrupt is latched on a rising edge, then you need to treat it
as edge interrupt type. The underlying APLIC interrupt can still be
level type because that's an independent interrupt.

Thanks,

        tglx

  reply	other threads:[~2026-12-04 20:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 16:06 [PATCH 0/2] Add support for Microchip PIC64-HPSC/HX NVM interrupt controller Charles Perry
2026-12-01 16:06 ` [PATCH 1/2] dt-bindings: interrupt-controller: document Microchip PIC64-HPSC/HX NVM intc Charles Perry
2026-12-01 18:13   ` Conor Dooley
2026-12-02 16:44     ` Charles Perry
2026-12-01 16:06 ` [PATCH 2/2] irqchip: Add Microchip PIC64-HPSC/HX NVM interrupt controller Charles Perry
2026-12-01 16:21   ` sashiko-bot
2026-12-01 19:31   ` Thomas Gleixner
2026-12-02 22:20     ` Charles Perry
2026-12-03 10:35       ` Thomas Gleixner
2026-12-03 18:14         ` Charles Perry
2026-12-04 10:57           ` Thomas Gleixner
2026-12-04 15:54             ` Charles Perry
2026-12-04 20:40               ` Thomas Gleixner [this message]
2026-12-04 11:00   ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a4mkn5jl.ffs@fw13 \
    --to=tglx@kernel.org \
    --cc=charles.perry@microchip.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=radu@rendec.net \
    --cc=robh@kernel.org \
    --cc=romain.caritey@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox