LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/2] soc: bcm: bcm2835-pm: Fix PM_IMAGE_PERI power domain support.
@ 2019-02-13  0:33 Eric Anholt
  2019-02-13  0:33 ` [PATCH 2/2] soc: bcm: bcm2835-pm: Fix error paths of initialization Eric Anholt
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Anholt @ 2019-02-13  0:33 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-kernel, Stefan Wahren,
	bcm-kernel-feedback-list, Eric Anholt

We don't have ASB master/slave regs for this domain, so just skip that
step.

Signed-off-by: Eric Anholt <eric@anholt.net>
Fixes: 670c672608a1 ("soc: bcm: bcm2835-pm: Add support for power domains under a new binding.")
---
 drivers/soc/bcm/bcm2835-power.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
index 48412957ec7a..4a1b99b773c0 100644
--- a/drivers/soc/bcm/bcm2835-power.c
+++ b/drivers/soc/bcm/bcm2835-power.c
@@ -150,7 +150,12 @@ struct bcm2835_power {
 
 static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
 {
-	u64 start = ktime_get_ns();
+	u64 start;
+
+	if (!reg)
+		return 0;
+
+	start = ktime_get_ns();
 
 	/* Enable the module's async AXI bridges. */
 	ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
@@ -165,7 +170,12 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
 
 static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg)
 {
-	u64 start = ktime_get_ns();
+	u64 start;
+
+	if (!reg)
+		return 0;
+
+	start = ktime_get_ns();
 
 	/* Enable the module's async AXI bridges. */
 	ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
-- 
2.20.1


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

* [PATCH 2/2] soc: bcm: bcm2835-pm: Fix error paths of initialization.
  2019-02-13  0:33 [PATCH 1/2] soc: bcm: bcm2835-pm: Fix PM_IMAGE_PERI power domain support Eric Anholt
@ 2019-02-13  0:33 ` Eric Anholt
  2019-02-13  8:46   ` Stefan Wahren
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Anholt @ 2019-02-13  0:33 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-kernel, Stefan Wahren,
	bcm-kernel-feedback-list, Eric Anholt

The clock driver may probe after ours and so we need to pass the
-EPROBE_DEFER out.  Fix the other error path while we're here.

Signed-off-by: Eric Anholt <eric@anholt.net>
Fixes: 670c672608a1 ("soc: bcm: bcm2835-pm: Add support for power domains under a new binding.")
---
 drivers/soc/bcm/bcm2835-power.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
index 4a1b99b773c0..11f9469423f7 100644
--- a/drivers/soc/bcm/bcm2835-power.c
+++ b/drivers/soc/bcm/bcm2835-power.c
@@ -485,7 +485,7 @@ static int bcm2835_power_pd_power_off(struct generic_pm_domain *domain)
 	}
 }
 
-static void
+static int
 bcm2835_init_power_domain(struct bcm2835_power *power,
 			  int pd_xlate_index, const char *name)
 {
@@ -493,6 +493,12 @@ bcm2835_init_power_domain(struct bcm2835_power *power,
 	struct bcm2835_power_domain *dom = &power->domains[pd_xlate_index];
 
 	dom->clk = devm_clk_get(dev->parent, name);
+	if (IS_ERR(dom->clk)) {
+		int ret = PTR_ERR(dom->clk);
+
+		if (ret == -EPROBE_DEFER)
+			return ret;
+	}
 
 	dom->base.name = name;
 	dom->base.power_on = bcm2835_power_pd_power_on;
@@ -505,6 +511,8 @@ bcm2835_init_power_domain(struct bcm2835_power *power,
 	pm_genpd_init(&dom->base, NULL, true);
 
 	power->pd_xlate.domains[pd_xlate_index] = &dom->base;
+
+	return 0;
 }
 
 /** bcm2835_reset_reset - Resets a block that has a reset line in the
@@ -602,7 +610,7 @@ static int bcm2835_power_probe(struct platform_device *pdev)
 		{ BCM2835_POWER_DOMAIN_IMAGE_PERI, BCM2835_POWER_DOMAIN_CAM0 },
 		{ BCM2835_POWER_DOMAIN_IMAGE_PERI, BCM2835_POWER_DOMAIN_CAM1 },
 	};
-	int ret, i;
+	int ret = 0, i;
 	u32 id;
 
 	power = devm_kzalloc(dev, sizeof(*power), GFP_KERNEL);
@@ -629,8 +637,11 @@ static int bcm2835_power_probe(struct platform_device *pdev)
 
 	power->pd_xlate.num_domains = ARRAY_SIZE(power_domain_names);
 
-	for (i = 0; i < ARRAY_SIZE(power_domain_names); i++)
-		bcm2835_init_power_domain(power, i, power_domain_names[i]);
+	for (i = 0; i < ARRAY_SIZE(power_domain_names); i++) {
+		ret = bcm2835_init_power_domain(power, i, power_domain_names[i]);
+		if (ret)
+			goto fail;
+	}
 
 	for (i = 0; i < ARRAY_SIZE(domain_deps); i++) {
 		pm_genpd_add_subdomain(&power->domains[domain_deps[i].parent].base,
@@ -644,12 +655,21 @@ static int bcm2835_power_probe(struct platform_device *pdev)
 
 	ret = devm_reset_controller_register(dev, &power->reset);
 	if (ret)
-		return ret;
+		goto fail;
 
 	of_genpd_add_provider_onecell(dev->parent->of_node, &power->pd_xlate);
 
 	dev_info(dev, "Broadcom BCM2835 power domains driver");
 	return 0;
+
+fail:
+	for (i = 0; i < ARRAY_SIZE(power_domain_names); i++) {
+		struct generic_pm_domain *dom = &power->domains[i].base;
+
+		if (dom->gov)
+			pm_genpd_remove(dom);
+	}
+	return ret;
 }
 
 static int bcm2835_power_remove(struct platform_device *pdev)
-- 
2.20.1


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

* [PATCH 2/2] soc: bcm: bcm2835-pm: Fix error paths of initialization.
  2019-02-13  0:33 ` [PATCH 2/2] soc: bcm: bcm2835-pm: Fix error paths of initialization Eric Anholt
@ 2019-02-13  8:46   ` Stefan Wahren
  2019-02-13 18:28     ` Eric Anholt
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Wahren @ 2019-02-13  8:46 UTC (permalink / raw)
  To: Eric Anholt, Florian Fainelli
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

Hi Eric,

Am 13.02.19 um 01:33 schrieb Eric Anholt:
> The clock driver may probe after ours and so we need to pass the
> -EPROBE_DEFER out.  Fix the other error path while we're here.
>
> Signed-off-by: Eric Anholt <eric@anholt.net>
> Fixes: 670c672608a1 ("soc: bcm: bcm2835-pm: Add support for power domains under a new binding.")
> ---
>  drivers/soc/bcm/bcm2835-power.c | 30 +++++++++++++++++++++++++-----
>  1 file changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
> index 4a1b99b773c0..11f9469423f7 100644
> --- a/drivers/soc/bcm/bcm2835-power.c
> +++ b/drivers/soc/bcm/bcm2835-power.c
> @@ -485,7 +485,7 @@ static int bcm2835_power_pd_power_off(struct generic_pm_domain *domain)
>  	}
>  }
>  
> -static void
> +static int
>  bcm2835_init_power_domain(struct bcm2835_power *power,
>  			  int pd_xlate_index, const char *name)
>  {
> @@ -493,6 +493,12 @@ bcm2835_init_power_domain(struct bcm2835_power *power,
>  	struct bcm2835_power_domain *dom = &power->domains[pd_xlate_index];
>  
>  	dom->clk = devm_clk_get(dev->parent, name);
> +	if (IS_ERR(dom->clk)) {
> +		int ret = PTR_ERR(dom->clk);
> +
> +		if (ret == -EPROBE_DEFER)
> +			return ret;
is it safe to proceed in the other error cases?
Even it would be more consistent with clk_prepare_enable() to print an
error here.
> +	}
>  
>  	

Thanks
Stefan


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

* Re: [PATCH 2/2] soc: bcm: bcm2835-pm: Fix error paths of initialization.
  2019-02-13  8:46   ` Stefan Wahren
@ 2019-02-13 18:28     ` Eric Anholt
  2019-02-13 22:33       ` Stefan Wahren
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Anholt @ 2019-02-13 18:28 UTC (permalink / raw)
  To: Stefan Wahren, Florian Fainelli
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

[-- Attachment #1: Type: text/plain, Size: 1611 bytes --]

Stefan Wahren <stefan.wahren@i2se.com> writes:

> Hi Eric,
>
> Am 13.02.19 um 01:33 schrieb Eric Anholt:
>> The clock driver may probe after ours and so we need to pass the
>> -EPROBE_DEFER out.  Fix the other error path while we're here.
>>
>> Signed-off-by: Eric Anholt <eric@anholt.net>
>> Fixes: 670c672608a1 ("soc: bcm: bcm2835-pm: Add support for power domains under a new binding.")
>> ---
>>  drivers/soc/bcm/bcm2835-power.c | 30 +++++++++++++++++++++++++-----
>>  1 file changed, 25 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
>> index 4a1b99b773c0..11f9469423f7 100644
>> --- a/drivers/soc/bcm/bcm2835-power.c
>> +++ b/drivers/soc/bcm/bcm2835-power.c
>> @@ -485,7 +485,7 @@ static int bcm2835_power_pd_power_off(struct generic_pm_domain *domain)
>>  	}
>>  }
>>  
>> -static void
>> +static int
>>  bcm2835_init_power_domain(struct bcm2835_power *power,
>>  			  int pd_xlate_index, const char *name)
>>  {
>> @@ -493,6 +493,12 @@ bcm2835_init_power_domain(struct bcm2835_power *power,
>>  	struct bcm2835_power_domain *dom = &power->domains[pd_xlate_index];
>>  
>>  	dom->clk = devm_clk_get(dev->parent, name);
>> +	if (IS_ERR(dom->clk)) {
>> +		int ret = PTR_ERR(dom->clk);
>> +
>> +		if (ret == -EPROBE_DEFER)
>> +			return ret;
> is it safe to proceed in the other error cases?
> Even it would be more consistent with clk_prepare_enable() to print an
> error here.

Yes, not all domains have a clk, so we want to ignore the other error.
And we shouldn't print for defers, generally.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: [PATCH 2/2] soc: bcm: bcm2835-pm: Fix error paths of initialization.
  2019-02-13 18:28     ` Eric Anholt
@ 2019-02-13 22:33       ` Stefan Wahren
  2019-02-15 19:29         ` Florian Fainelli
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Wahren @ 2019-02-13 22:33 UTC (permalink / raw)
  To: Eric Anholt, Florian Fainelli
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list


> Eric Anholt <eric@anholt.net> hat am 13. Februar 2019 um 19:28 geschrieben:
> 
> 
> Stefan Wahren <stefan.wahren@i2se.com> writes:
> 
> > Hi Eric,
> >
> > Am 13.02.19 um 01:33 schrieb Eric Anholt:
> >> The clock driver may probe after ours and so we need to pass the
> >> -EPROBE_DEFER out.  Fix the other error path while we're here.
> >>
> >> Signed-off-by: Eric Anholt <eric@anholt.net>
> >> Fixes: 670c672608a1 ("soc: bcm: bcm2835-pm: Add support for power domains under a new binding.")
> >> ---
> >>  drivers/soc/bcm/bcm2835-power.c | 30 +++++++++++++++++++++++++-----
> >>  1 file changed, 25 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
> >> index 4a1b99b773c0..11f9469423f7 100644
> >> --- a/drivers/soc/bcm/bcm2835-power.c
> >> +++ b/drivers/soc/bcm/bcm2835-power.c
> >> @@ -485,7 +485,7 @@ static int bcm2835_power_pd_power_off(struct generic_pm_domain *domain)
> >>  	}
> >>  }
> >>  
> >> -static void
> >> +static int
> >>  bcm2835_init_power_domain(struct bcm2835_power *power,
> >>  			  int pd_xlate_index, const char *name)
> >>  {
> >> @@ -493,6 +493,12 @@ bcm2835_init_power_domain(struct bcm2835_power *power,
> >>  	struct bcm2835_power_domain *dom = &power->domains[pd_xlate_index];
> >>  
> >>  	dom->clk = devm_clk_get(dev->parent, name);
> >> +	if (IS_ERR(dom->clk)) {
> >> +		int ret = PTR_ERR(dom->clk);
> >> +
> >> +		if (ret == -EPROBE_DEFER)
> >> +			return ret;
> > is it safe to proceed in the other error cases?
> > Even it would be more consistent with clk_prepare_enable() to print an
> > error here.
> 
> Yes, not all domains have a clk, so we want to ignore the other error.

But shouldn't we set dom->clk to NULL instead of keeping the error pointer? AFAIK clk_prepare_enable is aware of NULL instead of error pointer.

> And we shouldn't print for defers, generally.

Sure, i wanted to refer to all the other error cases.

Stefan

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

* Re: [PATCH 2/2] soc: bcm: bcm2835-pm: Fix error paths of initialization.
  2019-02-13 22:33       ` Stefan Wahren
@ 2019-02-15 19:29         ` Florian Fainelli
  2019-02-20 18:18           ` Eric Anholt
  0 siblings, 1 reply; 7+ messages in thread
From: Florian Fainelli @ 2019-02-15 19:29 UTC (permalink / raw)
  To: Stefan Wahren, Eric Anholt, Florian Fainelli
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On 2/13/19 2:33 PM, Stefan Wahren wrote:
> 
>> Eric Anholt <eric@anholt.net> hat am 13. Februar 2019 um 19:28 geschrieben:
>>
>>
>> Stefan Wahren <stefan.wahren@i2se.com> writes:
>>
>>> Hi Eric,
>>>
>>> Am 13.02.19 um 01:33 schrieb Eric Anholt:
>>>> The clock driver may probe after ours and so we need to pass the
>>>> -EPROBE_DEFER out.  Fix the other error path while we're here.
>>>>
>>>> Signed-off-by: Eric Anholt <eric@anholt.net>
>>>> Fixes: 670c672608a1 ("soc: bcm: bcm2835-pm: Add support for power domains under a new binding.")
>>>> ---
>>>>  drivers/soc/bcm/bcm2835-power.c | 30 +++++++++++++++++++++++++-----
>>>>  1 file changed, 25 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
>>>> index 4a1b99b773c0..11f9469423f7 100644
>>>> --- a/drivers/soc/bcm/bcm2835-power.c
>>>> +++ b/drivers/soc/bcm/bcm2835-power.c
>>>> @@ -485,7 +485,7 @@ static int bcm2835_power_pd_power_off(struct generic_pm_domain *domain)
>>>>  	}
>>>>  }
>>>>  
>>>> -static void
>>>> +static int
>>>>  bcm2835_init_power_domain(struct bcm2835_power *power,
>>>>  			  int pd_xlate_index, const char *name)
>>>>  {
>>>> @@ -493,6 +493,12 @@ bcm2835_init_power_domain(struct bcm2835_power *power,
>>>>  	struct bcm2835_power_domain *dom = &power->domains[pd_xlate_index];
>>>>  
>>>>  	dom->clk = devm_clk_get(dev->parent, name);
>>>> +	if (IS_ERR(dom->clk)) {
>>>> +		int ret = PTR_ERR(dom->clk);
>>>> +
>>>> +		if (ret == -EPROBE_DEFER)
>>>> +			return ret;
>>> is it safe to proceed in the other error cases?
>>> Even it would be more consistent with clk_prepare_enable() to print an
>>> error here.
>>
>> Yes, not all domains have a clk, so we want to ignore the other error.
> 
> But shouldn't we set dom->clk to NULL instead of keeping the error pointer? AFAIK clk_prepare_enable is aware of NULL instead of error pointer.

If the clock is really optional, then yes, this should be the way to go.
-- 
Florian

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

* Re: [PATCH 2/2] soc: bcm: bcm2835-pm: Fix error paths of initialization.
  2019-02-15 19:29         ` Florian Fainelli
@ 2019-02-20 18:18           ` Eric Anholt
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Anholt @ 2019-02-20 18:18 UTC (permalink / raw)
  To: Florian Fainelli, Stefan Wahren, Florian Fainelli
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

[-- Attachment #1: Type: text/plain, Size: 2167 bytes --]

Florian Fainelli <f.fainelli@gmail.com> writes:

> On 2/13/19 2:33 PM, Stefan Wahren wrote:
>> 
>>> Eric Anholt <eric@anholt.net> hat am 13. Februar 2019 um 19:28 geschrieben:
>>>
>>>
>>> Stefan Wahren <stefan.wahren@i2se.com> writes:
>>>
>>>> Hi Eric,
>>>>
>>>> Am 13.02.19 um 01:33 schrieb Eric Anholt:
>>>>> The clock driver may probe after ours and so we need to pass the
>>>>> -EPROBE_DEFER out.  Fix the other error path while we're here.
>>>>>
>>>>> Signed-off-by: Eric Anholt <eric@anholt.net>
>>>>> Fixes: 670c672608a1 ("soc: bcm: bcm2835-pm: Add support for power domains under a new binding.")
>>>>> ---
>>>>>  drivers/soc/bcm/bcm2835-power.c | 30 +++++++++++++++++++++++++-----
>>>>>  1 file changed, 25 insertions(+), 5 deletions(-)
>>>>>
>>>>> diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c
>>>>> index 4a1b99b773c0..11f9469423f7 100644
>>>>> --- a/drivers/soc/bcm/bcm2835-power.c
>>>>> +++ b/drivers/soc/bcm/bcm2835-power.c
>>>>> @@ -485,7 +485,7 @@ static int bcm2835_power_pd_power_off(struct generic_pm_domain *domain)
>>>>>  	}
>>>>>  }
>>>>>  
>>>>> -static void
>>>>> +static int
>>>>>  bcm2835_init_power_domain(struct bcm2835_power *power,
>>>>>  			  int pd_xlate_index, const char *name)
>>>>>  {
>>>>> @@ -493,6 +493,12 @@ bcm2835_init_power_domain(struct bcm2835_power *power,
>>>>>  	struct bcm2835_power_domain *dom = &power->domains[pd_xlate_index];
>>>>>  
>>>>>  	dom->clk = devm_clk_get(dev->parent, name);
>>>>> +	if (IS_ERR(dom->clk)) {
>>>>> +		int ret = PTR_ERR(dom->clk);
>>>>> +
>>>>> +		if (ret == -EPROBE_DEFER)
>>>>> +			return ret;
>>>> is it safe to proceed in the other error cases?
>>>> Even it would be more consistent with clk_prepare_enable() to print an
>>>> error here.
>>>
>>> Yes, not all domains have a clk, so we want to ignore the other error.
>> 
>> But shouldn't we set dom->clk to NULL instead of keeping the error
>> pointer? AFAIK clk_prepare_enable is aware of NULL instead of error
>> pointer.
>
> If the clock is really optional, then yes, this should be the way to go.

Sigh, error pointers.  Fixed, sending a v2.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

end of thread, other threads:[~2019-02-20 18:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-13  0:33 [PATCH 1/2] soc: bcm: bcm2835-pm: Fix PM_IMAGE_PERI power domain support Eric Anholt
2019-02-13  0:33 ` [PATCH 2/2] soc: bcm: bcm2835-pm: Fix error paths of initialization Eric Anholt
2019-02-13  8:46   ` Stefan Wahren
2019-02-13 18:28     ` Eric Anholt
2019-02-13 22:33       ` Stefan Wahren
2019-02-15 19:29         ` Florian Fainelli
2019-02-20 18:18           ` Eric Anholt

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