From: sashiko-bot@kernel.org
To: "Stefan Dösinger" <stefandoesinger@gmail.com>
Cc: devicetree@vger.kernel.org, mfd@lists.linux.dev,
linux-phy@lists.infradead.org, robh@kernel.org,
conor+dt@kernel.org, vkoul@kernel.org, neil.armstrong@linaro.org,
olteanv@gmail.com, lee@kernel.org
Subject: Re: [PATCH 3/6] pmdomain: zte: Add a zx297520v3 power domain driver
Date: Fri, 20 Nov 2026 19:51:31 +0000 [thread overview]
Message-ID: <sashiko-outbox-225964@kernel.org> (raw)
In-Reply-To: <20261120-zx29usb-v1-3-b0433258e51b@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] pmdomain: zte: child-to-parent device link deadlock in
zx29_pd_probe()
- [High] pmdomain: zte: wrong supplier device in zx29_pd_attach_dev()
device link
--
commit 65d36c75a56ee45de3b21629f8434fb30bf2339b
Author: Stefan Dösinger <stefandoesinger@gmail.com>
pmdomain: zte: Add a zx297520v3 power domain driver
This commit adds a power domain driver for the ZTE zx297520v3 SoC to
control the power, reset, and bus isolation registers for the USB
controller.
> diff --git a/drivers/pmdomain/zte/zx297520v3-pm-domain.c b/drivers/pmdomain/zte/zx297520v3-pm-domain.c
> new file mode 100644
> index 0000000000000..3df4cd5f1b229
> --- /dev/null
> +++ b/drivers/pmdomain/zte/zx297520v3-pm-domain.c
[ ... ]
> +static int zx29_pd_attach_dev(struct generic_pm_domain *domain, struct device *dev)
> +{
> + /* The DT link to the consumer targets the (MFD) parent, which doesn't prevent unbinding the
> + * this driver or removing the module. Either would leave the consumer with a dangling
> + * reference.
> + */
> + if (!device_link_add(dev, &domain->dev, DL_FLAG_AUTOREMOVE_CONSUMER))
> + return -ENOMEM;
> +
> + return 0;
> +}
[Severity: High]
Should the device link supplier here be the zx297520v3-socsys-power
platform device (&pdev->dev) rather than &domain->dev?
&domain->dev is the internal genpd provider device deleted by
of_genpd_del_provider(). Because no consumer link targets &pdev->dev,
unbinding this driver starts devres teardown while consumers are still
bound and only unbinds them inside zx29_pd_release_provider() ->
of_genpd_del_provider() -> device_del(&gpd->dev) under gpd_list_lock and
of_genpd_mutex.
That inverts the normal lock order against a probing consumer that already
holds device_lock(consumer) while calling dev_pm_domain_attach() ->
genpd_dev_pm_attach():
CPU0 CPU1
---- ----
lock(&consumer->mutex)
lock(&gpd_list_lock)
lock(&of_genpd_mutex)
lock(&gpd_list_lock)
lock(&consumer->mutex)
*** DEADLOCK ***
CPU0: really_probe(consumer) -> ... -> genpd_get_from_provider()
CPU1: zx29_pd_release_provider() -> of_genpd_del_provider() ->
device_del(&gpd->dev) -> ... -> device_links_unbind_consumers()
In addition, if a consumer attaches via genpd_dev_pm_attach_by_id() or
genpd_dev_pm_attach_by_name(), dev is a driverless virtual device on
genpd_bus_type, so its link to &domain->dev stays in DL_STATE_AVAILABLE:
device_links_unbind_consumers() never detaches it,
device_links_driver_cleanup() hits WARN_ON(), and pm_genpd_remove() fails
with -EBUSY right before devres frees zx29_pd, leaving a freed
generic_pm_domain on gpd_list.
[ ... ]
> +static int zx29_pd_probe(struct platform_device *pdev)
> +{
[ ... ]
> + res = of_genpd_add_provider_onecell(of_node, zx29_pd_data);
> + if (res)
> + return dev_err_probe(dev, res, "Cannot register power domains\n");
> +
> + device_link_add(dev, dev->parent, DL_FLAG_AUTOREMOVE_CONSUMER);
> +
> + dev_dbg(dev, "zx297520v3 power domain initialized.\n");
> +
> + return devm_add_action_or_reset(dev, zx29_pd_release_provider, of_node);
> +}
[Severity: High]
Can adding a managed device link from dev to dev->parent deadlock when
zx297520v3_crm_probe() registers its MFD children after late_initcall
(for example on module load or driver rebind)?
zx297520v3_crm_probe() calls devm_mfd_add_devices() while really_probe()
holds device_lock(dev->parent). Because of_genpd_add_provider_onecell()
sets genpd_sync_state on dev->parent, finishing dev's probe queues
sync_state on dev->parent and tries to lock dev->parent again on the same
thread:
really_probe(dev->parent)
device_lock(dev->parent)
zx297520v3_crm_probe()
devm_mfd_add_devices()
...
really_probe(dev)
zx29_pd_probe()
of_genpd_add_provider_onecell(dev->parent->of_node, ...)
device_link_add(dev, dev->parent, DL_FLAG_AUTOREMOVE_CONSUMER)
driver_bound(dev)
device_links_driver_bound(dev)
device_links_flush_sync_list(..., dev)
device_lock(dev->parent) <-- self-deadlock
Since dev is a child device registered via devm_mfd_add_devices() on
dev->parent, the driver core already orders suspend/resume and removes dev
when dev->parent unbinds without this link.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120-zx29usb-v1-0-b0433258e51b@gmail.com?part=3
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-11-20 19:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 19:20 [PATCH 0/6] ZTE zx297520v3 USB support Stefan Dösinger
2026-11-20 19:20 ` [PATCH 1/6] dt-bindings: soc: zte: Document zx297520v3 socsys controller Stefan Dösinger
2026-11-20 19:38 ` sashiko-bot
2026-11-20 19:20 ` [PATCH 2/6] mfd: zx297520v3: Add socsys to the mfd host driver Stefan Dösinger
2026-11-20 19:20 ` [PATCH 3/6] pmdomain: zte: Add a zx297520v3 power domain driver Stefan Dösinger
2026-11-20 19:51 ` sashiko-bot [this message]
2026-11-20 19:20 ` [PATCH 4/6] phy: zte: Add a zx29 USB PHY driver Stefan Dösinger
2026-11-20 19:47 ` sashiko-bot
2026-11-20 19:20 ` [PATCH 5/6] ARM: dts: zte: Declare nodes to enable the board's dwc2 controller Stefan Dösinger
2026-11-20 19:20 ` [PATCH 6/6] ARM: dts: zte: Declare the HSIC controller node Stefan Dösinger
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=sashiko-outbox-225964@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lee@kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=mfd@lists.linux.dev \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=stefandoesinger@gmail.com \
--cc=vkoul@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