From: Radu Rendec <radu@rendec.net>
To: "Farber, Eliav" <farbere@amazon.com>,
Thomas Gleixner <tglx@kernel.org>,
"Shenhar, Talel" <talel@amazon.com>,
Rob Herring <robh@kernel.org>
Cc: 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 3/8] irqchip/al-fic: keep the device_node instead of a cached name string
Date: Wed, 07 Oct 2026 21:14:06 -0400 [thread overview]
Message-ID: <bc9249ba60ee202b995aeccc5b8db35e9eece0cc.camel@rendec.net> (raw)
In-Reply-To: <BY3PR18MB47221B1A895DF607B6480576C6962@BY3PR18MB4722.namprd18.prod.outlook.com>
On Mon, 2026-10-05 at 11:17 +0000, Farber, Eliav wrote:
> On Sun, 2026-10-04 at 17:40 +0000, Radu Rendec wrote:
> > On Sun, 2026-09-27 at 08:06 +0000, Eliav Farber wrote:
> > > struct al_fic cached a "const char *name" that al_fic_wire_init() received
> > > as a separate argument and set from node->name. That string was never owned
> > > by the driver: it aliased storage inside the device_node and stayed valid
> > > only as long as the node did, yet nothing in the struct held the node to
> > > express that dependency. Keep the device_node in the struct instead: it
> > > holds the owning object rather than a bare pointer into it, lets each site
> > > derive the name on demand, and gives the driver the node it needs in the
> > > next change, which requests the parent interrupt by the node's full_name.
> >
> > That makes sense. But keeping a pointer to the whole structure instead
> > of aliasing a pointer inside the structure makes no additional
> > guarantees w.r.t. the lifetime of that structure, it just makes the
> > intention more obvious.
> >
> > What prevents the "struct device_node" from going away after the init
> > function returns? It cannot go away before it returns because the init
> > function is called as desc->irq_init_cb() from of_irq_init(), while
> > holding a reference to the node. I *think* the assumption that it can
> > never go away (even after the init function returns) is correct because
> > the code in of_irq_init() seems to deliberately "leak" a reference to
> > the node. But this is not documented anywhere. So perhaps it's worth
> > calling it out at least in the commit message.
> >
> > Rob, you're a maintainer for drivers/of/irq.c and it looks like you
> > merged most (or all?) of the recent patches to it. Perhaps you can help
> > us and explain how this is supposed to work?
>
> You read it right. of_irq_init() takes a reference with of_node_get()
> before calling the init callback, and on a successful init that
> reference is never put - the of_intc_desc is freed but desc->dev is left
> pinned. On a failed init it is put. So the node is kept alive for the
> life of the system once probe succeeds, same as you described.
>
> I've added that to the commit message, and made clear this patch is not
> closing a lifetime bug - node->name was never actually at risk of
> dangling, since the storage it points into is pinned the same way. The
> value of keeping the device_node is making that dependency explicit
> rather than fixing something broken.
Thanks! I think it's very clearly explained now.
> I'll leave the question of whether this ought to be documented in
> of_irq_init() itself to Rob.
Of course. After giving it more thought, I'm quite confident it's the
intended behavior. There were some patches to of_irq_init() that fixed
some reference leaks on the error paths. If keeping the reference on
the successful path hadn't been the intended behavior, it would've been
called out when those patches were reviewed.
> > > irq_alloc_domain_generic_chips() keeps the pointer it is given, so it now
> > > uses node->full_name.
> >
> > nit: should this use of_node_full_name() instead? Not that fic->node
> > can be null, but if there is an accessor, why not use it?
>
> Done, here and in patch 4's request_irq() call.
>
> Both changes are in v3, which I will post shortly.
>
> Thanks,
> Eliav
next prev parent reply other threads:[~2026-10-08 1:14 UTC|newest]
Thread overview: 25+ 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 [this message]
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
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=bc9249ba60ee202b995aeccc5b8db35e9eece0cc.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®