The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@kernel.org>
To: Alex Elder <elder@riscstar.com>,
	radu@rendec.net, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org
Cc: Daniel Thompson <daniel@riscstar.com>,
	p.zabel@pengutronix.de, mohd.anwar@oss.qualcomm.com,
	lorenzo.bianconi@oss.qualcomm.com, danielt@kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] irqchip: introduce TC9564 SoC MSIGEN support
Date: Sat, 05 Dec 2026 20:25:50 +0100	[thread overview]
Message-ID: <87tskrlebl.ffs@fw13> (raw)
In-Reply-To: <e6d494d7-e557-484e-8b0c-848539e28239@riscstar.com>

On Fri, Dec 04 2026 at 17:46, Alex Elder wrote:
> On 11/9/26 4:37 PM, Alex Elder wrote:
>>> You want to use generic_handle_demux_domain_irq(), which allows you to
>>> actually implement affinity settings for individual interrupts.
>> 
>> That sounds better, thanks for pointing it out.
>
> Implementing affinity for individual interrupts would be great.
> We have a bunch TX and RX queues with independent DMA channels
> so it might be beneficial.
>
> However I don't think it will work, and if what I'm saying
> is correct, maybe you can guide me toward a way we can still
> use something like this.
>
> I'm going to reproduce the core of the function, with
> line numbers, so it's less split up and easier to refer to.
>
>   1  chained_irq_enter(chip, desc);

Missed to point out that you should use

       guard_chained_irq(chip, desc);

instead.

>   3  status = irq_reg_readl(gc, INT_STS_OFFSET);
>   4  for_each_set_bit(hwirq, &status, HWIRQ_COUNT)
>   5      generic_handle_domain_irq(irq_domain, hwirq);
>   6
>   7  /*
>   8   * Clear the MSI flag. Most interrupts within TC9564 are
>   9   * leveh-high type. If any interrupts are still asserted

Most? Better all of them are or you are in trouble with handling those
which are edge type via handle_level_irq() independent of redirect.

> 10   * then clearing this flag will cause the (edge-triggered)
> 11   * MSI to be regenerated.
> 12   */
> 13  irq_reg_writel(gc, MSI_MASK_VALUE, MSI_MASK_CLR_OFFSET);
> 14
> 15  chained_irq_exit(chip, desc);
>
> The key parts are the loop on lines 4 and 5, and the write
> on line 13.
>
> Your suggestion is to replace generic_handle_domain_irq()
> on line 5 with generic_handle_demux_domain_irq().
>
> The two functions differ in that the "demux" one calls
> demux_redirect_remote(), which is able to ship handling
> of sn IRQ over to another CPU, via a call to
> irq_work_queue_on().  If that happens, the redirected
> handler completes asynchronously (right?).

Correct.

> The bits in the INT_STS_OFFSET register represent 17
> possible interrupt conditions--8 RX + 8 TX DMA interrupts
> plus a general MAC interrupt.  I suspect it won't be
> unusual to have more than one condition pending when
> a single MSI interrupt fires.
>
> The problem I see is that the final irq_reg_writel()
> call is telling the MSIGEN hardware that we have
> finished handling *this* MSI interrupt, which implies
> we have handled some number of underlying conditions.
>
> But if demux_redirect_remote() queued an interrupt
> condition to be handled on a different CPU, its
> handler might not have completed yet.  And in that
> case, we should not issue that irq_reg_writel().

As your input interrupts to the MSIGEN IP are level type according to
the generic chip initializer in your patch, the obvious solution here is
to implement the irq_chip::irq_pre_redirect() callback, which is invoked
_before_ the redirect.

static void tc_irq_pre_redirect(struct irq_data *data)
{
        struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data);

	irq_gc_mask_set_bit(data);
}

That's unfortunately a redundant operation as handle_level_irq() masks
anyway, but that's harmless. This can be optimized and probably replaced
by a generic implementation. We'll do that once we have a couple of
users and can see their requirements. So far they are straight forward
and very much the same. Let's see.

So if the interrupt is not yet handled, the input line is still active,
but the masking excludes it from the re-trigger condition of the MSI
output block.

After handle_level_irq() completes (either local or remote) the
interrupt is unmasked again (if appropriate) and everything works as
before. If the interrupt input line is still or again active, then the
retrigger logic will send another MSI message.

That's not different from how temporarily disabled level or threaded
level type interrupts are handled.

Hint: You could have looked at the two in tree users of this mechanism :)

Thanks,

        tglx

      reply	other threads:[~2026-12-05 19:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 19:02 [PATCH 0/2] irqchip: add TC9564 support Alex Elder
2026-10-12 19:02 ` [PATCH 1/2] dt-bindings: interrupt-controller: introduce toshiba,tc9564-msigen.yaml Alex Elder
2026-10-13 17:54   ` Conor Dooley
2026-10-14 10:15     ` Krzysztof Kozlowski
2026-10-14 10:22       ` Krzysztof Kozlowski
2026-10-14 14:55         ` Alex Elder
2026-10-14 16:41           ` Conor Dooley
2026-10-14 16:57             ` Alex Elder
2026-10-19 19:49               ` Conor Dooley
2026-10-20  9:04                 ` Daniel Thompson
2026-10-12 19:02 ` [PATCH 2/2] irqchip: introduce TC9564 SoC MSIGEN support Alex Elder
2026-11-08 21:17   ` Thomas Gleixner
2026-11-09 22:37     ` Alex Elder
2026-12-04 23:46       ` Alex Elder
2026-12-05 19:25         ` Thomas Gleixner [this message]

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=87tskrlebl.ffs@fw13 \
    --to=tglx@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=daniel@riscstar.com \
    --cc=danielt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=elder@riscstar.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.bianconi@oss.qualcomm.com \
    --cc=mohd.anwar@oss.qualcomm.com \
    --cc=p.zabel@pengutronix.de \
    --cc=radu@rendec.net \
    --cc=robh@kernel.org \
    /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