linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] OPP: Fix handling of multiple power domains
@ 2019-03-06  4:07 Rajendra Nayak
  2019-03-06 18:02 ` Stephen Boyd
  2019-03-08  4:37 ` Viresh Kumar
  0 siblings, 2 replies; 4+ messages in thread
From: Rajendra Nayak @ 2019-03-06  4:07 UTC (permalink / raw)
  To: viresh.kumar, nm, sboyd
  Cc: linux-pm, linux-arm-msm, linux-kernel, Rajendra Nayak

We seem to rely on the number of phandles specified in the
'required-opps' property to identify cases where a device is
associated with multiple power domains and hence would have
multiple virtual devices that have to be dealt with.

In cases where we do have devices with multiple power domains
but with only one of them being scalable, this logic seems to
fail.

Instead read the number of power domains from DT to identify
such cases.

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
---
 drivers/opp/of.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/opp/of.c b/drivers/opp/of.c
index 06f0f632ec47..443c305ae100 100644
--- a/drivers/opp/of.c
+++ b/drivers/opp/of.c
@@ -172,7 +172,7 @@ static void _opp_table_alloc_required_tables(struct opp_table *opp_table,
 	struct opp_table **required_opp_tables;
 	struct device **genpd_virt_devs = NULL;
 	struct device_node *required_np, *np;
-	int count, i;
+	int count, count_pd, i;
 
 	/* Traversing the first OPP node is all we need */
 	np = of_get_next_available_child(opp_np, NULL);
@@ -185,7 +185,19 @@ static void _opp_table_alloc_required_tables(struct opp_table *opp_table,
 	if (!count)
 		goto put_np;
 
-	if (count > 1) {
+	/*
+	 * Check the number of power-domains to know if we need to deal
+	 * with virtual devices. In some cases we have devices with multiple
+	 * power domains but with only one of them being scalable, hence
+	 * 'count' could be 1, but we still have to deal with multiple genpds
+	 * and virtual devices.
+	 */
+	count_pd = of_count_phandle_with_args(dev->of_node, "power-domains",
+					      "#power-domain-cells");
+	if (!count_pd)
+		goto put_np;
+
+	if (count_pd > 1) {
 		genpd_virt_devs = kcalloc(count, sizeof(*genpd_virt_devs),
 					GFP_KERNEL);
 		if (!genpd_virt_devs)
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] OPP: Fix handling of multiple power domains
  2019-03-06  4:07 [PATCH] OPP: Fix handling of multiple power domains Rajendra Nayak
@ 2019-03-06 18:02 ` Stephen Boyd
  2019-03-08  4:37 ` Viresh Kumar
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2019-03-06 18:02 UTC (permalink / raw)
  To: Rajendra Nayak, nm, viresh.kumar
  Cc: linux-pm, linux-arm-msm, linux-kernel, Rajendra Nayak

Quoting Rajendra Nayak (2019-03-05 20:07:26)
> We seem to rely on the number of phandles specified in the
> 'required-opps' property to identify cases where a device is
> associated with multiple power domains and hence would have
> multiple virtual devices that have to be dealt with.
> 
> In cases where we do have devices with multiple power domains
> but with only one of them being scalable, this logic seems to
> fail.
> 
> Instead read the number of power domains from DT to identify
> such cases.
> 
> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
> ---

Reviewed-by: Stephen Boyd <sboyd@kernel.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] OPP: Fix handling of multiple power domains
  2019-03-06  4:07 [PATCH] OPP: Fix handling of multiple power domains Rajendra Nayak
  2019-03-06 18:02 ` Stephen Boyd
@ 2019-03-08  4:37 ` Viresh Kumar
  2019-03-12  9:36   ` Rafael J. Wysocki
  1 sibling, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2019-03-08  4:37 UTC (permalink / raw)
  To: Rajendra Nayak, rjw; +Cc: nm, sboyd, linux-pm, linux-arm-msm, linux-kernel

On 06-03-19, 09:37, Rajendra Nayak wrote:
> We seem to rely on the number of phandles specified in the
> 'required-opps' property to identify cases where a device is
> associated with multiple power domains and hence would have
> multiple virtual devices that have to be dealt with.
> 
> In cases where we do have devices with multiple power domains
> but with only one of them being scalable, this logic seems to
> fail.
> 
> Instead read the number of power domains from DT to identify
> such cases.
> 
> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
> ---
>  drivers/opp/of.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/opp/of.c b/drivers/opp/of.c
> index 06f0f632ec47..443c305ae100 100644
> --- a/drivers/opp/of.c
> +++ b/drivers/opp/of.c
> @@ -172,7 +172,7 @@ static void _opp_table_alloc_required_tables(struct opp_table *opp_table,
>  	struct opp_table **required_opp_tables;
>  	struct device **genpd_virt_devs = NULL;
>  	struct device_node *required_np, *np;
> -	int count, i;
> +	int count, count_pd, i;
>  
>  	/* Traversing the first OPP node is all we need */
>  	np = of_get_next_available_child(opp_np, NULL);
> @@ -185,7 +185,19 @@ static void _opp_table_alloc_required_tables(struct opp_table *opp_table,
>  	if (!count)
>  		goto put_np;
>  
> -	if (count > 1) {
> +	/*
> +	 * Check the number of power-domains to know if we need to deal
> +	 * with virtual devices. In some cases we have devices with multiple
> +	 * power domains but with only one of them being scalable, hence
> +	 * 'count' could be 1, but we still have to deal with multiple genpds
> +	 * and virtual devices.
> +	 */
> +	count_pd = of_count_phandle_with_args(dev->of_node, "power-domains",
> +					      "#power-domain-cells");
> +	if (!count_pd)
> +		goto put_np;
> +
> +	if (count_pd > 1) {
>  		genpd_virt_devs = kcalloc(count, sizeof(*genpd_virt_devs),
>  					GFP_KERNEL);
>  		if (!genpd_virt_devs)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

@Rafael, please pick this up for 5.1-rc2 directly. Thanks.

-- 
viresh

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] OPP: Fix handling of multiple power domains
  2019-03-08  4:37 ` Viresh Kumar
@ 2019-03-12  9:36   ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2019-03-12  9:36 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Rajendra Nayak, nm, sboyd, linux-pm, linux-arm-msm, linux-kernel

On Friday, March 8, 2019 5:37:12 AM CET Viresh Kumar wrote:
> On 06-03-19, 09:37, Rajendra Nayak wrote:
> > We seem to rely on the number of phandles specified in the
> > 'required-opps' property to identify cases where a device is
> > associated with multiple power domains and hence would have
> > multiple virtual devices that have to be dealt with.
> > 
> > In cases where we do have devices with multiple power domains
> > but with only one of them being scalable, this logic seems to
> > fail.
> > 
> > Instead read the number of power domains from DT to identify
> > such cases.
> > 
> > Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
> > ---
> >  drivers/opp/of.c | 16 ++++++++++++++--
> >  1 file changed, 14 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/opp/of.c b/drivers/opp/of.c
> > index 06f0f632ec47..443c305ae100 100644
> > --- a/drivers/opp/of.c
> > +++ b/drivers/opp/of.c
> > @@ -172,7 +172,7 @@ static void _opp_table_alloc_required_tables(struct opp_table *opp_table,
> >  	struct opp_table **required_opp_tables;
> >  	struct device **genpd_virt_devs = NULL;
> >  	struct device_node *required_np, *np;
> > -	int count, i;
> > +	int count, count_pd, i;
> >  
> >  	/* Traversing the first OPP node is all we need */
> >  	np = of_get_next_available_child(opp_np, NULL);
> > @@ -185,7 +185,19 @@ static void _opp_table_alloc_required_tables(struct opp_table *opp_table,
> >  	if (!count)
> >  		goto put_np;
> >  
> > -	if (count > 1) {
> > +	/*
> > +	 * Check the number of power-domains to know if we need to deal
> > +	 * with virtual devices. In some cases we have devices with multiple
> > +	 * power domains but with only one of them being scalable, hence
> > +	 * 'count' could be 1, but we still have to deal with multiple genpds
> > +	 * and virtual devices.
> > +	 */
> > +	count_pd = of_count_phandle_with_args(dev->of_node, "power-domains",
> > +					      "#power-domain-cells");
> > +	if (!count_pd)
> > +		goto put_np;
> > +
> > +	if (count_pd > 1) {
> >  		genpd_virt_devs = kcalloc(count, sizeof(*genpd_virt_devs),
> >  					GFP_KERNEL);
> >  		if (!genpd_virt_devs)
> 
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> 
> @Rafael, please pick this up for 5.1-rc2 directly. Thanks.

Done, thanks!


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-12  9:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-06  4:07 [PATCH] OPP: Fix handling of multiple power domains Rajendra Nayak
2019-03-06 18:02 ` Stephen Boyd
2019-03-08  4:37 ` Viresh Kumar
2019-03-12  9:36   ` Rafael J. Wysocki

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).