Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lorenzo Bianconi" <lorenzo.bianconi@oss.qualcomm.com>
Cc: conor+dt@kernel.org, linux-pci@vger.kernel.org, robh@kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v3 3/5] PCI/pwrctrl: tc9563: Add GPIO auxiliary device support
Date: Fri, 04 Sep 2026 17:34:03 +0000	[thread overview]
Message-ID: <20260904173403.B6A511F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260904-pci-tc9563-aux-v3-3-5b1449d62ba2@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

New issues:
- [High] The GPIO auxiliary device is unconditionally registered without runtime PM synchronization with the parent device, exposing unpowered hardware to I2C accesses.
- [High] Hardcoded auxiliary device ID causes a sysfs naming collision, breaking support for multiple TC9563 controllers.

Pre-existing issues:
- [High] Inversion of teardown order between the I2C adapter reference and devm-managed resources.
--

commit 4ceb9152c94ce43b58577ae6c0490e74f1fcf9de
Author: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>

PCI/pwrctrl: tc9563: Add GPIO auxiliary device support

The TC9563 embeds a GPIO controller used for per-port reset signals.
Create an auxiliary device for it so the gpio-tc9563 driver can
register the GPIO chip and enable DT-based GPIO lookups.

> diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
> index 59ad219c26c02..2230765950b88 100644
> --- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
> +++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c
[ ... ]
> @@ -393,6 +395,69 @@ static int tc9563_pwrctrl_parse_device_dt(struct device_node *node,
[ ... ]
> +static int tc9563_pwrctrl_add_gpio_adev(struct tc9563_pwrctrl *tc9563)
> +{
> +	struct device *dev = tc9563->pwrctrl.dev;
> +
> +	if (!of_property_read_bool(dev->of_node, "gpio-controller") ||
> +	    !of_property_present(dev->of_node, "#gpio-cells"))
> +		return 0;
> +
> +	return tc9563_pwrctrl_adev_add(dev, TC9563_GPIO_DEV_NAME, 0,
> +				       dev->of_node, tc9563->regmap);
                                                                  ^
[Severity: High]
Does this hardcoded auxiliary device ID of 0 in
tc9563_pwrctrl_add_gpio_adev() (in drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c)
cause a sysfs naming collision?

If there is more than one TC9563 controller in the system, the first
will probe and register successfully. When the second probes, won't it
attempt to register the same name and fail with -EEXIST?

[Severity: High]
Will unconditionally registering the GPIO auxiliary device here expose
it to accesses while the parent device is suspended?

The PCI subsystem manages the hardware's power state via the pwrctrl
callbacks, powering it off when the PCI endpoint suspends. However, the
GPIO auxiliary device remains registered and active without runtime PM
synchronization.

When userspace or another subsystem accesses a GPIO via sysfs or libgpiod
while the PCI link is suspended, wouldn't the resulting I2C operations
target an unpowered chip?

> +}
> +
[ ... ]
> @@ -596,6 +661,10 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev)
>  	tc9563->pwrctrl.power_on = tc9563_pwrctrl_power_on;
>  	tc9563->pwrctrl.power_off = tc9563_pwrctrl_power_off;
>  
> +	ret = tc9563_pwrctrl_add_gpio_adev(tc9563);
> +	if (ret)
> +		goto remove_i2c;
> +

[Severity: High]
This is a pre-existing issue, but could dropping the I2C adapter
reference manually here and in tc9563_pwrctrl_remove() create a
use-after-free risk during devm teardown?

The driver acquires the I2C adapter via of_get_i2c_adapter_by_node() in
tc9563_pwrctrl_probe() (in drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c).
In the probe error path (and similarly in tc9563_pwrctrl_remove() during
unbind), i2c_put_adapter() is called manually before the devm teardown
runs.

With this patch adding the auxiliary device via devm, devm will
unregister the GPIO auxiliary device after the adapter reference is
dropped. If the GPIO driver performs any I2C transfers during its
teardown, it will access the I2C adapter after its reference has been
released.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-pci-tc9563-aux-v3-0-5b1449d62ba2@oss.qualcomm.com?part=3

  reply	other threads:[~2026-09-04 17:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 17:15 [PATCH v3 0/5] PCI/pwrctrl: tc9563: introduce support for embedded GPIO controller Lorenzo Bianconi
2026-09-04 17:15 ` [PATCH v3 1/5] dt-bindings: PCI: toshiba,tc9563: Document " Lorenzo Bianconi
2026-09-04 17:21   ` sashiko-bot
2026-09-04 18:32     ` Lorenzo Bianconi
2026-09-04 17:15 ` [PATCH v3 2/5] gpio: tc9563: Add support for the " Lorenzo Bianconi
2026-09-04 17:23   ` sashiko-bot
2026-09-04 17:15 ` [PATCH v3 3/5] PCI/pwrctrl: tc9563: Add GPIO auxiliary device support Lorenzo Bianconi
2026-09-04 17:34   ` sashiko-bot [this message]
2026-09-04 19:25     ` Lorenzo Bianconi
2026-09-04 17:15 ` [PATCH v3 4/5] PCI/pwrctrl: tc9563: Switch per-port reset to GPIO descriptor API Lorenzo Bianconi
2026-09-04 17:32   ` sashiko-bot
2026-09-04 17:15 ` [PATCH v3 5/5] arm64: dts: qcom: qcs6490-rb3gen2: Enable TC9563 embedded GPIO controller Lorenzo Bianconi
2026-09-04 17:23   ` sashiko-bot

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=20260904173403.B6A511F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.bianconi@oss.qualcomm.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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