linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thara Gopinath <thara.gopinath@linaro.org>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Zhang Rui <rui.zhang@intel.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Andy Gross <agross@kernel.org>,
	Amit Kucheria <amit.kucheria@verdurent.com>,
	Mark Rutland <mark.rutland@arm.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Linux PM <linux-pm@vger.kernel.org>,
	DTML <devicetree@vger.kernel.org>,
	linux-arm-msm <linux-arm-msm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [Patch v4 5/7] soc: qcom: Extend RPMh power controller driver to register warming devices.
Date: Sun, 1 Mar 2020 18:36:02 -0500	[thread overview]
Message-ID: <6292d698-38f4-6a75-551c-629bbfa3c896@linaro.org> (raw)
In-Reply-To: <CAPDyKFopiajhFymXo3q558AYBkdDYzU6Ye9HU9XSdN4r8j+qaw@mail.gmail.com>



On 2/4/20 12:40 PM, Ulf Hansson wrote:
> On Wed, 20 Nov 2019 at 13:56, Thara Gopinath <thara.gopinath@linaro.org> wrote:
>>
>> RPMh power control hosts power domains that can be used as
>> thermal warming devices. Register these power domains
>> with the generic power domain warming device thermal framework.
>>
>> Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
>> ---
>> v3->v4:
>>          - Introduce a boolean value is_warming_dev in rpmhpd structure to
>>            indicate if a generic power domain can be used as a warming
>>            device or not.With this change, device tree no longer has to
>>            specify which power domain inside the rpmh power domain provider
>>            is a warming device.
>>          - Move registering of warming devices into a late initcall to
>>            ensure that warming devices are registerd after thermal
>>            framework is initialized.
>>
>>   drivers/soc/qcom/rpmhpd.c | 38 +++++++++++++++++++++++++++++++++++++-
>>   1 file changed, 37 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c
>> index 9d37534..5666d1f 100644
>> --- a/drivers/soc/qcom/rpmhpd.c
>> +++ b/drivers/soc/qcom/rpmhpd.c
>> @@ -11,6 +11,7 @@
>>   #include <linux/of_device.h>
>>   #include <linux/platform_device.h>
>>   #include <linux/pm_opp.h>
>> +#include <linux/pwr_domain_warming.h>
>>   #include <soc/qcom/cmd-db.h>
>>   #include <soc/qcom/rpmh.h>
>>   #include <dt-bindings/power/qcom-rpmpd.h>
>> @@ -48,6 +49,7 @@ struct rpmhpd {
>>          bool            enabled;
>>          const char      *res_name;
>>          u32             addr;
>> +       bool            is_warming_dev;
>>   };
>>
>>   struct rpmhpd_desc {
>> @@ -55,6 +57,8 @@ struct rpmhpd_desc {
>>          size_t num_pds;
>>   };
>>
>> +const struct rpmhpd_desc *global_desc;
>> +
>>   static DEFINE_MUTEX(rpmhpd_lock);
>>
>>   /* SDM845 RPMH powerdomains */
>> @@ -89,6 +93,7 @@ static struct rpmhpd sdm845_mx = {
>>          .pd = { .name = "mx", },
>>          .peer = &sdm845_mx_ao,
>>          .res_name = "mx.lvl",
>> +       .is_warming_dev = true,
>>   };
>>
>>   static struct rpmhpd sdm845_mx_ao = {
>> @@ -396,7 +401,14 @@ static int rpmhpd_probe(struct platform_device *pdev)
>>                                                 &rpmhpds[i]->pd);
>>          }
>>
>> -       return of_genpd_add_provider_onecell(pdev->dev.of_node, data);
>> +       ret = of_genpd_add_provider_onecell(pdev->dev.of_node, data);
>> +
>> +       if (ret)
>> +               return ret;
>> +
>> +       global_desc = desc;
> 
> I assume this works fine, for now.
> 
> Although, nothing prevents this driver from being probed for two
> different compatibles for the same platform. Thus the global_desc
> could be overwritten with the last one being probed, so then how do
> you know which one to use?

Yes. It works fine for now. There are multiple ways to fix this in 
future. One is to make global_desc an array. Other would be to move
the code in rpmhpd_init_warming_device to this init and make this a 
post_core init considering thermal subsytem uses core init. Like you 
said I will leave this at this for now and we can fix this if a need 
arises. I don't think there is a need for multiple compatibles for the 
same platform now. Thanks for the reviewed by! I will add it in the next 
version.

> 
>> +
>> +       return 0;
>>   }
>>
>>   static struct platform_driver rpmhpd_driver = {
>> @@ -413,3 +425,27 @@ static int __init rpmhpd_init(void)
>>          return platform_driver_register(&rpmhpd_driver);
>>   }
>>   core_initcall(rpmhpd_init);
>> +
>> +static int __init rpmhpd_init_warming_device(void)
>> +{
>> +       size_t num_pds;
>> +       struct rpmhpd **rpmhpds;
>> +       int i;
>> +
>> +       if (!global_desc)
>> +               return -EINVAL;
>> +
>> +       rpmhpds = global_desc->rpmhpds;
>> +       num_pds = global_desc->num_pds;
>> +
>> +       if (!of_find_property(rpmhpds[0]->dev->of_node, "#cooling-cells", NULL))
>> +               return 0;
>> +
>> +       for (i = 0; i < num_pds; i++)
>> +               if (rpmhpds[i]->is_warming_dev)
>> +                       pwr_domain_warming_register(rpmhpds[i]->dev,
>> +                                                   rpmhpds[i]->res_name, i);
>> +
>> +       return 0;
>> +}
>> +late_initcall(rpmhpd_init_warming_device);
> 
> For the record, there are limitations with this approach, for example
> you can't deal with -EPROBE_DEFER.
> 
> On the other hand, I don't have anything better to suggest, from the
> top of my head. So, feel free to add:
> 
> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
> 
> Kind regards
> Uffe
> 

-- 
Warm Regards
Thara

  reply	other threads:[~2020-03-01 23:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-20 12:56 [Patch v4 0/7] Introduce Power domain based warming device driver Thara Gopinath
2019-11-20 12:56 ` [Patch v4 1/7] PM/Domains: Add support for retrieving genpd performance states information Thara Gopinath
2019-11-20 12:56 ` [Patch v4 2/7] soc: qcom: rpmhpd: Introduce function to retrieve power domain performance state count Thara Gopinath
2020-02-04 16:10   ` Ulf Hansson
2019-11-20 12:56 ` [Patch v4 3/7] thermal: core: Allow cooling devices to register a parent Thara Gopinath
2020-02-04 16:22   ` Ulf Hansson
2019-11-20 12:56 ` [Patch v4 4/7] thermal: Add generic power domain warming device driver Thara Gopinath
2020-02-04 16:54   ` Ulf Hansson
2020-03-01 23:00     ` Thara Gopinath
2020-03-13 13:13       ` Ulf Hansson
2020-03-13 15:02         ` Thara Gopinath
2019-11-20 12:56 ` [Patch v4 5/7] soc: qcom: Extend RPMh power controller driver to register warming devices Thara Gopinath
2020-02-04 17:40   ` Ulf Hansson
2020-03-01 23:36     ` Thara Gopinath [this message]
2019-11-20 12:56 ` [Patch v4 6/7] dt-bindings: soc: qcom: Extend RPMh power controller binding to describe thermal warming device Thara Gopinath
2019-11-22 23:59   ` Rob Herring
2020-02-04 17:41   ` Ulf Hansson
2020-03-01 23:37     ` Thara Gopinath
2019-11-20 12:56 ` [Patch v4 7/7] arm64: dts: qcom: Indicate rpmhpd hosts a power domain that can be used as a " Thara Gopinath
2020-02-04 17:40   ` Ulf Hansson
2020-01-09 15:02 ` [Patch v4 0/7] Introduce Power domain based warming device driver Thara Gopinath

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=6292d698-38f4-6a75-551c-629bbfa3c896@linaro.org \
    --to=thara.gopinath@linaro.org \
    --cc=agross@kernel.org \
    --cc=amit.kucheria@verdurent.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=rjw@rjwysocki.net \
    --cc=rui.zhang@intel.com \
    --cc=ulf.hansson@linaro.org \
    --subject='Re: [Patch v4 5/7] soc: qcom: Extend RPMh power controller driver to register warming devices.' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).