]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
PM: domains: Add flags to specify power on attach/detach
authorClaudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Thu, 3 Jul 2025 11:27:06 +0000 (14:27 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 7 Jul 2025 18:41:20 +0000 (20:41 +0200)
commitd42c7c6fd66a6e2a78ae1da666c5df6c2fde8389
treedfaa445af19b99e13b6fde58c5414f617f54b1fa
parent9047685cfd2911c36ce89a16270aafa71057c507
PM: domains: Add flags to specify power on attach/detach

Calling dev_pm_domain_attach()/dev_pm_domain_detach() in bus driver
probe/remove functions can affect system behavior when the drivers
attached to the bus use devres-managed resources. Since devres actions
may need to access device registers, calling dev_pm_domain_detach() too
early, i.e., before these actions complete, can cause failures on some
systems. One such example is Renesas RZ/G3S SoC-based platforms.

If the device clocks are managed via PM domains, invoking
dev_pm_domain_detach() in the bus driver's remove function removes the
device's clocks from the PM domain, preventing any subsequent
pm_runtime_resume*() calls from enabling those clocks.

The second argument of dev_pm_domain_attach() specifies whether the PM
domain should be powered on during attachment. Likewise, the second
argument of dev_pm_domain_detach() indicates whether the domain should be
powered off during detachment.

Upcoming changes address the issue described above (initially for the
platform bus only) by deferring the call to dev_pm_domain_detach() until
after devres_release_all() in device_unbind_cleanup(). The detach_power_off
field in struct dev_pm_info stores the detach power off info from the
second argument of dev_pm_domain_attach().

Because there are cases where the device's PM domain power-on/off behavior
must be conditional (e.g., in i2c_device_probe()), the patch introduces
PD_FLAG_ATTACH_POWER_ON and PD_FLAG_DETACH_POWER_OFF flags to be passed
to dev_pm_domain_attach().

Finally, dev_pm_domain_attach() and its users are updated to use the newly
introduced PD_FLAG_ATTACH_POWER_ON and PD_FLAG_DETACH_POWER_OFF macros.

This change is preparatory.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com> # I2C
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://patch.msgid.link/20250703112708.1621607-2-claudiu.beznea.uj@bp.renesas.com
[ rjw: Changelog adjustments ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
13 files changed:
drivers/amba/bus.c
drivers/base/auxiliary.c
drivers/base/platform.c
drivers/base/power/common.c
drivers/clk/qcom/apcs-sdx55.c
drivers/gpu/drm/display/drm_dp_aux_bus.c
drivers/i2c/i2c-core-base.c
drivers/mmc/core/sdio_bus.c
drivers/rpmsg/rpmsg_core.c
drivers/soundwire/bus_type.c
drivers/spi/spi.c
drivers/tty/serdev/core.c
include/linux/pm_domain.h