mbox series

[v2,0/6] OPP/pmdomain: Assign required_devs for required OPPs through genpd

Message ID 20240718234319.356451-1-ulf.hansson@linaro.org
Headers show
Series OPP/pmdomain: Assign required_devs for required OPPs through genpd | expand

Message

Ulf Hansson July 18, 2024, 11:43 p.m. UTC
Through dev_pm_opp_set_config() the _opp_attach_genpd() allows consumer drivers
to hook up a device to its PM domains. Their corresponding virtual devices that
are created by genpd during attach, are later being assigned as the
required_devs for the corresponding required OPPs.

In _opp_attach_genpd() we are also cross-checking whether the attached device's
required OPPs really belongs to its PM domain's OPP table - and tries to fix it
up if possible. In principle this works fine, but sometimes it's not convenient
for consumer drivers to use _opp_attach_genpd().  Especially in the single PM
domain case, when a device is usually attached by the bus-level ->probe()
callbacks.

Moreover, we now have dev_pm_domain_attach|detach_list() that helps consumer
drivers to attach their devices to their PM domains.

To improve the situation, this series moves genpd to assign the required_devs
during device attach in genpd, which makes the cross-check of the OPP table to
always get done.

Note that, we still need to support the existing users of _opp_attach_genpd(),
which makes this series slightly complicated. Once we have migrated those users
to dev_pm_domain_attach|detach_list(), we should be able to remove
_opp_attach_genpd() altogether.

To test this, I have used a QEMU setup, with local PM test-drivers to try to
test all various combinations of single/multi power/performance PM domains for
a device. Hopefully I have covered it all, but I would certainly appreciate if
someone could help to run a slew of tests on some HWs.

Kind regards
Ulf Hansson

Ulf Hansson (6):
  OPP: Fix support for required OPPs for multiple PM domains
  OPP: Rework _set_required_devs() to manage a single device per call
  pmdomain: core: Manage the default required OPP from a separate
    function
  OPP/pmdomain: Set the required_dev for a required OPP during genpd
    attach
  pmdomain: core: Drop the redundant dev_to_genpd_dev()
  OPP: Drop redundant code in _link_required_opps()

 drivers/opp/core.c        | 182 ++++++++++++++++++--------------------
 drivers/opp/of.c          |  39 +-------
 drivers/opp/opp.h         |   4 +-
 drivers/pmdomain/core.c   | 107 +++++++++++++++++-----
 include/linux/pm_domain.h |   6 --
 include/linux/pm_opp.h    |  10 ++-
 6 files changed, 183 insertions(+), 165 deletions(-)