mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Radu Rendec <radu@rendec.net>
To: "Farber, Eliav" <farbere@amazon.com>,
	Thomas Gleixner <tglx@kernel.org>,
	"Shenhar, Talel"	 <talel@amazon.com>
Cc: Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	 "linux-kernel@vger.kernel.org"	 <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 8/8] irqchip/al-fic: add irq_set_affinity callback
Date: Sat, 10 Oct 2026 16:19:03 -0400	[thread overview]
Message-ID: <150803f555ade32668f31d507e151558a505cfe1.camel@rendec.net> (raw)
In-Reply-To: <BY3PR18MB4722F4AFC8E300C4D01BE217C6962@BY3PR18MB4722.namprd18.prod.outlook.com>

On Mon, 2026-10-05 at 11:20 +0000, Farber, Eliav wrote:
> On Sun, 2026-10-05 at 01:25 +0000, Radu Rendec wrote:
> > This is a common problem to all multiplexing irq drivers; not because
> > the parent interrupt is shared but because changing the affinity of one
> > child interrupt (by changing the parent interrupt's affinity under the
> > hood) would have the side effect of changing the affinity of all its
> > siblings.
> > 
> > I think the correct behavior is to fail with -EINVAL in this case.
> 
> -EINVAL is not usable here because it restores the failure this patch
> fixes. The consumer is arm-cmn. We have a SoC where its interrupt is
> routed through a FIC group instead of a direct GIC SPI, and
> drivers/perf/arm-cmn.c does
> 
>         err = irq_set_affinity(irq, cpumask_of(cmn->cpu));
>         if (err)
>                 return err;
> 
> at probe, so with no .irq_set_affinity callback the PMU does not probe at
> all.

All right, now I see what the problem is. I will be fully honest and
transparent and admit I don't know much about PMU drivers in general or
arm-cmn in particular. But I believe that irq_set_affinity() (with a
hard fail) is there for a reason. Of course, because we are in 2026, I
did ask a LLM what that reason could be, but I will refrain from taking
the answer as correct/definitive or speculating; I will just say it
probably needs careful consideration.

The requested affinity mask includes a single CPU; by contrast, unless
explicitly configured, the FIC parent IRQ will probably be affine to
all available CPUs, so the cpumask_equal() in your patch will likely be
always false. The concern is not the warning itself (you're using
pr_warn_once); it's that the arm-cmn IRQ handler will run on a
different CPU than it expects/has requested.

> > If you insist on having the ability to change the child interrupts'
> > affinity, you may want to look at this patch and do something similar:
> > https://lore.kernel.org/all/20251128212055.1409093-4-rrendec@redhat.com/
> 
> I implemented that for al-fic and tested it on hardware. It seems to
> work: with the parent SPI pinned to one CPU and the child's affinity set
> to another, the child dispatch is accounted on the target CPU, one
> dispatch per parent interrupt, no re-fire storm.
> 
> What stops me from just sending it is that it changes the interrupt path
> for every child of every FIC instance, not only for a child that asks for
> affinity. .irq_pre_redirect is called before the affinity check, so it
> runs on every dispatch. The ack therefore has to leave the flow handler
> and be done in the parent context always, and .irq_ack has to become a
> noop so it is not done twice. A level configured group has to be masked
> in .irq_pre_redirect as well, because the FIC re-asserts the cause bit
> while the source is still asserted, so for those groups the mask moves
> into the parent context too. Today all of this happens inside
> handle_level_irq() and handle_edge_irq(), under desc->lock.

The dw_pci driver is not the best example because it uses a stacked
layout with the multiplexing irqchip at the bottom and a hierarchy
irqchip on top (which is why the .irq_pre_redirect was necessary).
Unfortunately it's the only example I am aware of (and also what
prompted the redirect framework implementation). I apologize for the
confusion it may have created.

I think in the case of al-fic, it's sufficient to set
irq_chip_redirect_set_affinity as the .irq_set_affinity handler and
replace generic_handle_domain_irq with generic_handle_demux_domain_irq.
That will not change the ack/mask path.

> Do you still consider that justified for this driver, given that the only
> caller needing anything here is one that just needs the call not to fail?

As I explained above, I really doubt that arm-cmn just needs the call
not to fail. I am inclined to think that it actually *needs* the IRQ to
run on the CPU it wants, hence the hard fail.

-- 
Regards,
Radu

  reply	other threads:[~2026-10-10 20:19 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-27  8:06 [PATCH v2 0/8] irqchip/al-fic: shared parent IRQ, error/fatal outputs and affinity Eliav Farber
2026-09-27  8:06 ` [PATCH v2 1/8] irqchip/al-fic: fix argument alignment and a repeated word Eliav Farber
2026-10-04 16:15   ` Radu Rendec
2026-09-27  8:06 ` [PATCH v2 2/8] irqchip/al-fic: use %pOF and raise init log level Eliav Farber
2026-10-04 16:25   ` Radu Rendec
2026-09-27  8:06 ` [PATCH v2 3/8] irqchip/al-fic: keep the device_node instead of a cached name string Eliav Farber
2026-10-04 17:40   ` Radu Rendec
2026-10-05 11:17     ` Farber, Eliav
2026-10-08  1:14       ` Radu Rendec
2026-09-27  8:06 ` [PATCH v2 4/8] irqchip/al-fic: switch to shared parent interrupt Eliav Farber
2026-10-04 19:30   ` Radu Rendec
2026-10-05 11:18     ` Farber, Eliav
2026-09-27  8:06 ` [PATCH v2 5/8] dt-bindings: interrupt-controller: amazon,al-fic: add mask selection Eliav Farber
2026-09-28 16:50   ` Conor Dooley
2026-10-04 21:06   ` Radu Rendec
2026-09-27  8:06 ` [PATCH v2 6/8] irqchip/al-fic: support error and fatal outputs and FIC v2 Eliav Farber
2026-10-05  1:01   ` Radu Rendec
2026-10-05 11:19     ` Farber, Eliav
2026-10-08  1:19       ` Radu Rendec
2026-10-08  8:20         ` Farber, Eliav
2026-09-27  8:06 ` [PATCH v2 7/8] irqchip/al-fic: add support for FIC v3 Eliav Farber
2026-10-05  1:04   ` Radu Rendec
2026-09-27  8:06 ` [PATCH v2 8/8] irqchip/al-fic: add irq_set_affinity callback Eliav Farber
2026-10-05  1:25   ` Radu Rendec
2026-10-05 11:20     ` Farber, Eliav
2026-10-10 20:19       ` Radu Rendec [this message]
2026-10-11  3:09         ` Radu Rendec
2026-10-11  4:56           ` Farber, Eliav

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=150803f555ade32668f31d507e151558a505cfe1.camel@rendec.net \
    --to=radu@rendec.net \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=farbere@amazon.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=talel@amazon.com \
    --cc=tglx@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

all inboxes | Powered by JetHome®