[PATCH 3/6] pmdomain: zte: Add a zx297520v3 power domain driver
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Fri Nov 20 11:51:31 PST 2026
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 at 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
More information about the linux-phy
mailing list