mbox series

[v2,00/14] Introduce devm_pm_opp_* API

Message ID 20210311192105.14998-1-digetx@gmail.com
Headers show
Series Introduce devm_pm_opp_* API | expand

Message

Dmitry Osipenko March 11, 2021, 7:20 p.m. UTC
This series adds resource-managed OPP API helpers and makes drivers
to use them.

Changelog:

v2: - This is a continuation of the work that was started by Yangtao Li.
      Apparently Yangtao doesn't have time to finish it, so I
      (Dmitry Osipenko) picked up the effort since these patches are
      wanted by the NVIDIA Tegra voltage-scaling series that I'm
      working on.

    - Fixed the double put of OPP resources.

    - Dropped all patches that are unrelated to OPP API. I also dropped
      the Tegra memory patch since it doesn't apply now and because I plan
      to switch all Tegra drivers soon to a common tegra-specific OPP helper
      that will use the resource-managed OPP API anyways.

    - Squashed couple patches into a single ones since there was no
      good reason to separate them.

    - Added acks that were given to a couple of v1 patches.

Yangtao Li (14):
  opp: Add devres wrapper for dev_pm_opp_set_clkname
  opp: Add devres wrapper for dev_pm_opp_set_regulators
  opp: Add devres wrapper for dev_pm_opp_set_supported_hw
  opp: Add devres wrapper for dev_pm_opp_of_add_table
  opp: Add devres wrapper for dev_pm_opp_register_notifier
  serial: qcom_geni_serial: Convert to use resource-managed OPP API
  spi: spi-geni-qcom: Convert to use resource-managed OPP API
  spi: spi-qcom-qspi: Convert to use resource-managed OPP API
  mmc: sdhci-msm: Convert to use resource-managed OPP API
  drm/msm: Convert to use resource-managed OPP API
  drm/lima: Convert to use resource-managed OPP API
  drm/panfrost: Convert to use resource-managed OPP API
  media: venus: Convert to use resource-managed OPP API
  memory: samsung: exynos5422-dmc: Convert to use resource-managed OPP
    API

 drivers/gpu/drm/lima/lima_devfreq.c           |  43 ++---
 drivers/gpu/drm/lima/lima_devfreq.h           |   2 -
 drivers/gpu/drm/msm/adreno/a5xx_gpu.c         |   2 +-
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c         |   2 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.c       |   2 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c       |  24 ++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h       |   2 -
 drivers/gpu/drm/msm/dp/dp_ctrl.c              |  31 +---
 drivers/gpu/drm/msm/dp/dp_ctrl.h              |   1 -
 drivers/gpu/drm/msm/dp/dp_display.c           |   5 +-
 drivers/gpu/drm/msm/dsi/dsi_host.c            |  14 +-
 drivers/gpu/drm/panfrost/panfrost_devfreq.c   |  33 +---
 drivers/gpu/drm/panfrost/panfrost_devfreq.h   |   1 -
 .../media/platform/qcom/venus/pm_helpers.c    |  18 +--
 drivers/memory/samsung/exynos5422-dmc.c       |  13 +-
 drivers/mmc/host/sdhci-msm.c                  |  20 +--
 drivers/opp/core.c                            | 151 ++++++++++++++++++
 drivers/opp/of.c                              |  36 +++++
 drivers/spi/spi-geni-qcom.c                   |  17 +-
 drivers/spi/spi-qcom-qspi.c                   |  19 +--
 drivers/tty/serial/qcom_geni_serial.c         |  24 ++-
 include/linux/pm_opp.h                        |  34 ++++
 include/linux/qcom-geni-se.h                  |   2 -
 23 files changed, 300 insertions(+), 196 deletions(-)

Comments

Mark Brown March 11, 2021, 7:44 p.m. UTC | #1
On Thu, Mar 11, 2021 at 10:20:58PM +0300, Dmitry Osipenko wrote:

> Acked-by: Mark brown <broonie@kernel.org>

Typo there.
Viresh Kumar March 12, 2021, 5:33 a.m. UTC | #2
On 11-03-21, 22:20, Dmitry Osipenko wrote:
> +struct opp_table *devm_pm_opp_set_clkname(struct device *dev, const char *name)
> +{
> +	struct opp_table *opp_table;
> +	int err;
> +
> +	opp_table = dev_pm_opp_set_clkname(dev, name);
> +	if (IS_ERR(opp_table))
> +		return opp_table;
> +
> +	err = devm_add_action_or_reset(dev, devm_pm_opp_clkname_release, opp_table);
> +	if (err)
> +		opp_table = ERR_PTR(err);
> +
> +	return opp_table;
> +}

I wonder if we still need to return opp_table from here, or a simple
integer is fine.. The callers shouldn't be required to use the OPP
table directly anymore I believe and so better simplify the return
part of this and all other routines you are adding here..

If there is a user which needs the opp_table, let it use the regular
non-devm variant.
Ulf Hansson March 12, 2021, 10:36 a.m. UTC | #3
On Fri, 12 Mar 2021 at 06:33, Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> On 11-03-21, 22:20, Dmitry Osipenko wrote:
> > +struct opp_table *devm_pm_opp_set_clkname(struct device *dev, const char *name)
> > +{
> > +     struct opp_table *opp_table;
> > +     int err;
> > +
> > +     opp_table = dev_pm_opp_set_clkname(dev, name);
> > +     if (IS_ERR(opp_table))
> > +             return opp_table;
> > +
> > +     err = devm_add_action_or_reset(dev, devm_pm_opp_clkname_release, opp_table);
> > +     if (err)
> > +             opp_table = ERR_PTR(err);
> > +
> > +     return opp_table;
> > +}
>
> I wonder if we still need to return opp_table from here, or a simple
> integer is fine.. The callers shouldn't be required to use the OPP
> table directly anymore I believe and so better simplify the return
> part of this and all other routines you are adding here..

Yes, please. I was thinking along the same lines, when I reviewed the
mmc patch (patch9).

>
> If there is a user which needs the opp_table, let it use the regular
> non-devm variant.

Kind regards
Uffe
Dmitry Osipenko March 12, 2021, 1:17 p.m. UTC | #4
12.03.2021 08:26, Viresh Kumar пишет:
> On 11-03-21, 22:20, Dmitry Osipenko wrote:
>> From: Yangtao Li <tiny.windzz@gmail.com>
>>
>> Add devres wrapper for dev_pm_opp_register_notifier() to simplify driver
>> code.
>>
>> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  drivers/opp/core.c     | 38 ++++++++++++++++++++++++++++++++++++++
>>  include/linux/pm_opp.h |  6 ++++++
>>  2 files changed, 44 insertions(+)
> 
> As I said in the previous version, I am not sure if we need this patch
> at all. This has only one user.
> 

I'll drop this patch in v3, thanks.
Dmitry Osipenko March 12, 2021, 1:19 p.m. UTC | #5
12.03.2021 13:36, Ulf Hansson пишет:
> On Fri, 12 Mar 2021 at 06:33, Viresh Kumar <viresh.kumar@linaro.org> wrote:
>>
>> On 11-03-21, 22:20, Dmitry Osipenko wrote:
>>> +struct opp_table *devm_pm_opp_set_clkname(struct device *dev, const char *name)
>>> +{
>>> +     struct opp_table *opp_table;
>>> +     int err;
>>> +
>>> +     opp_table = dev_pm_opp_set_clkname(dev, name);
>>> +     if (IS_ERR(opp_table))
>>> +             return opp_table;
>>> +
>>> +     err = devm_add_action_or_reset(dev, devm_pm_opp_clkname_release, opp_table);
>>> +     if (err)
>>> +             opp_table = ERR_PTR(err);
>>> +
>>> +     return opp_table;
>>> +}
>>
>> I wonder if we still need to return opp_table from here, or a simple
>> integer is fine.. The callers shouldn't be required to use the OPP
>> table directly anymore I believe and so better simplify the return
>> part of this and all other routines you are adding here..
> 
> Yes, please. I was thinking along the same lines, when I reviewed the
> mmc patch (patch9).
> 
>>
>> If there is a user which needs the opp_table, let it use the regular
>> non-devm variant.

Indeed, that's a very good suggestion! The opp_table isn't needed by the
devm users, I'll change it in v3, thanks!