From: Antonio Borneo <antonio.borneo@foss.st.com>
To: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>,
Linus Walleij <linusw@kernel.org>,
Krzysztof Kozlowski <krzk@kernel.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
<linux-gpio@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] pinctrl: stm32: Fix reset control leak in stm32_pctl_probe() error paths
Date: Thu, 19 Nov 2026 12:27:13 +0100 [thread overview]
Message-ID: <2a6ea91480a6c002a7354ce1223c1d904891371f.camel@foss.st.com> (raw)
In-Reply-To: <20261119060924.675-1-laixiangwu@cmss.chinamobile.com>
On Thu, 2026-11-19 at 14:09 +0800, Xiangwu Lai wrote:
> Hi Linus,
>
> thanks for taking a look. For the record, this is about "[PATCH v2]
> pinctrl: stm32: Fix reset control leak in stm32_pctl_probe() error
> paths":
>
> https://lore.kernel.org/all/20261110083253.1525-1-laixiangwu@cmss.chinamobile.com/
>
> On Wed, Nov 18, 2026 at 10:09:40PM +0100, Linus Walleij wrote:
> > Fix your email address in .gitconfig please so you don't use
> > your login name as name.
>
> Sorry about that. The email address is unchanged, what was wrong is
> that git picked my login handle up as the user name; the .gitconfig
> name is set to "Xiangwu Lai" now, and the patch was already resent
> with the corrected author and sign-off before your reply arrived - it
> is identical to v2 otherwise:
>
> [PATCH v3] pinctrl: stm32: Fix reset control leak in stm32_pctl_probe() error paths
> https://lore.kernel.org/all/20261116031043.502-1-laixiangwu@cmss.chinamobile.com/
>
> On Wed, Nov 18, 2026 at 10:08:09PM +0100, Linus Walleij wrote:
> > Looks like a bulky fix, what about just stop using
> > of_reset_control_get_exclusive()
> > and use devm_reset_control_get_exclusive(&pdev->dev, ..) hmm?
>
> The managed getter is unfortunately not a drop-in replacement here:
> the reset phandles live in the per-bank child nodes, while
> devm_reset_control_get_exclusive() resolves the "resets" property
> from dev_fwnode(&pdev->dev), that is the pinctrl node itself. The
> driver fetches one reset line per GPIO bank from each child:
>
> bank->rstc = of_reset_control_get_exclusive(np, NULL);
>
> with np = to_of_node(child). The reset core only provides devm
> variants that take a struct device *; there is no devm getter
> parameterized by a device_node/fwnode, which is what the per-bank
> lookup would need.
>
> If you prefer the managed form, the equivalent that keeps the
> child-node lookup would be to register the put as a devm action after
> each successful get:
>
> static void stm32_pctl_put_reset_control(void *data)
> {
> reset_control_put(data);
> }
>
> bank->rstc = of_reset_control_get_exclusive(np, NULL);
> if (PTR_ERR(bank->rstc) == -EPROBE_DEFER) {
> ...
> return -EPROBE_DEFER;
> }
>
> ret = devm_add_action_or_reset(dev, stm32_pctl_put_reset_control,
> bank->rstc);
>
> which turns all the error paths back into plain returns - devres
> releases the rstcs acquired so far - and removes the goto
> err_put_rstcs wiring from v3. On success the semantics stay as they
> are: the rstcs are held for the lifetime of the device (the driver
> has no .remove) and are still in use, stm32_gpiolib_register_bank()
> deasserts them. phy-qcom-qmp-pcie-msm8996.c uses the same
> combination for the same reason, a reset phandle living in a
> sub-node.
>
> Philipp, does this look sane from the reset core point of view, or
> would a devm getter that takes a fwnode be something acceptable in
> the core?
>
> I can respin a v4 with the devm action conversion on top of v3, or
> keep the explicit unwind of v3 - let me know which form you prefer.
The driver's "resets" property is not currently used by any upstream DT.
Using it is also problematic, as asserting the reset affects all GPIOs in
the bank, including those already configured by the bootloader or secure
world. The current driver uses this only to deassert the reset during
probe.
As part of the cleanup following the planned removal of armv7m support,
I was considering removing this unused property from both the binding and
the driver. Although the ST reference manual documents a per-bank reset,
I lean toward removing its support given the maintenance burden of unused
code.
I've added Krzysztof in copy to get his early feedback on whether removing
the "resets" property from the binding would be acceptable and appropriate.
This patch has the "Fixes:" tag. Whatever the evolution of this thread,
I think this patch should be taken for backport in stable then,
eventually, followed by the "resets" removal.
Regards,
Antonio
prev parent reply other threads:[~2026-11-19 11:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 8:32 Xiangwu Lai
2026-11-18 21:08 ` Linus Walleij
2026-11-18 21:09 ` Linus Walleij
2026-11-19 6:09 ` Xiangwu Lai
2026-11-19 11:27 ` Antonio Borneo [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=2a6ea91480a6c002a7354ce1223c1d904891371f.camel@foss.st.com \
--to=antonio.borneo@foss.st.com \
--cc=alexandre.torgue@foss.st.com \
--cc=krzk@kernel.org \
--cc=laixiangwu@cmss.chinamobile.com \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=p.zabel@pengutronix.de \
/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®