[PATCH 07/23] interconnect: qcom: rpm: fix probe PM domain error handling

Johan Hovold posted 23 patches 2 years, 7 months ago
There is a newer version of this series
[PATCH 07/23] interconnect: qcom: rpm: fix probe PM domain error handling
Posted by Johan Hovold 2 years, 7 months ago
Make sure to disable clocks also in case attaching the power domain
fails.

Fixes: 7de109c0abe9 ("interconnect: icc-rpm: Add support for bus power domain")
Cc: stable@vger.kernel.org      # 5.17
Cc: Yassine Oudjana <y.oudjana@protonmail.com>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 drivers/interconnect/qcom/icc-rpm.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
index 91778cfcbc65..da595059cafd 100644
--- a/drivers/interconnect/qcom/icc-rpm.c
+++ b/drivers/interconnect/qcom/icc-rpm.c
@@ -498,8 +498,7 @@ int qnoc_probe(struct platform_device *pdev)
 
 	if (desc->has_bus_pd) {
 		ret = dev_pm_domain_attach(dev, true);
-		if (ret)
-			return ret;
+		goto err_disable_clks;
 	}
 
 	provider = &qp->provider;
@@ -514,8 +513,7 @@ int qnoc_probe(struct platform_device *pdev)
 	ret = icc_provider_add(provider);
 	if (ret) {
 		dev_err(dev, "error adding interconnect provider: %d\n", ret);
-		clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
-		return ret;
+		goto err_disable_clks;
 	}
 
 	for (i = 0; i < num_nodes; i++) {
@@ -550,8 +548,9 @@ int qnoc_probe(struct platform_device *pdev)
 	return 0;
 err:
 	icc_nodes_remove(provider);
-	clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
 	icc_provider_del(provider);
+err_disable_clks:
+	clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
 
 	return ret;
 }
-- 
2.39.1
Re: [PATCH 07/23] interconnect: qcom: rpm: fix probe PM domain error handling
Posted by Christophe JAILLET 2 years, 6 months ago
Le 01/02/2023 à 11:15, Johan Hovold a écrit :
> Make sure to disable clocks also in case attaching the power domain
> fails.
> 
> Fixes: 7de109c0abe9 ("interconnect: icc-rpm: Add support for bus power domain")
> Cc: stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org      # 5.17
> Cc: Yassine Oudjana <y.oudjana-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org>
> Signed-off-by: Johan Hovold <johan+linaro-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> ---
>   drivers/interconnect/qcom/icc-rpm.c | 9 ++++-----
>   1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
> index 91778cfcbc65..da595059cafd 100644
> --- a/drivers/interconnect/qcom/icc-rpm.c
> +++ b/drivers/interconnect/qcom/icc-rpm.c
> @@ -498,8 +498,7 @@ int qnoc_probe(struct platform_device *pdev)
>   
>   	if (desc->has_bus_pd) {
>   		ret = dev_pm_domain_attach(dev, true);
> -		if (ret)
> -			return ret;
> +		goto err_disable_clks;

Hi,
this change looks strange because we now skip the rest of the function.

Is it really intended?


Also, should dev_pm_domain_detach() be called somewhere in the error 
handling path and remove function ?

CJ


>   	}
>   
>   	provider = &qp->provider;
> @@ -514,8 +513,7 @@ int qnoc_probe(struct platform_device *pdev)
>   	ret = icc_provider_add(provider);
>   	if (ret) {
>   		dev_err(dev, "error adding interconnect provider: %d\n", ret);
> -		clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
> -		return ret;
> +		goto err_disable_clks;
>   	}
>   
>   	for (i = 0; i < num_nodes; i++) {
> @@ -550,8 +548,9 @@ int qnoc_probe(struct platform_device *pdev)
>   	return 0;
>   err:
>   	icc_nodes_remove(provider);
> -	clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
>   	icc_provider_del(provider);
> +err_disable_clks:
> +	clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
>   
>   	return ret;
>   }

Re: [PATCH 07/23] interconnect: qcom: rpm: fix probe PM domain error handling
Posted by Johan Hovold 2 years, 6 months ago
On Sat, Mar 11, 2023 at 07:17:50PM +0100, Christophe JAILLET wrote:
> Le 01/02/2023 à 11:15, Johan Hovold a écrit :
> > Make sure to disable clocks also in case attaching the power domain
> > fails.
> > 
> > Fixes: 7de109c0abe9 ("interconnect: icc-rpm: Add support for bus power domain")
> > Cc: stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org      # 5.17
> > Cc: Yassine Oudjana <y.oudjana-g/b1ySJe57IN+BqQ9rBEUg@public.gmane.org>
> > Signed-off-by: Johan Hovold <johan+linaro-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> > ---
> >   drivers/interconnect/qcom/icc-rpm.c | 9 ++++-----
> >   1 file changed, 4 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
> > index 91778cfcbc65..da595059cafd 100644
> > --- a/drivers/interconnect/qcom/icc-rpm.c
> > +++ b/drivers/interconnect/qcom/icc-rpm.c
> > @@ -498,8 +498,7 @@ int qnoc_probe(struct platform_device *pdev)
> >   
> >   	if (desc->has_bus_pd) {
> >   		ret = dev_pm_domain_attach(dev, true);
> > -		if (ret)
> > -			return ret;
> > +		goto err_disable_clks;
> 
> Hi,
> this change looks strange because we now skip the rest of the function.
> 
> Is it really intended?

No, this was definitely not intentional. Thanks for catching this. I'll
send a follow up fix for Georgi to fold in or apply on top.

> Also, should dev_pm_domain_detach() be called somewhere in the error 
> handling path and remove function ?

In principle, yes. (I think read the above as being another device
managed resource.)

It turns out, however, that this code is totally bogus as any power
domain would already have been attached by the platform bus code and the
above call would always just succeed. The platform code would also
handle detach on errors. 

I'll send a patch to remove this.

Johan
Re: [PATCH 07/23] interconnect: qcom: rpm: fix probe PM domain error handling
Posted by Konrad Dybcio 2 years, 7 months ago

On 1.02.2023 11:15, Johan Hovold wrote:
> Make sure to disable clocks also in case attaching the power domain
> fails.
> 
> Fixes: 7de109c0abe9 ("interconnect: icc-rpm: Add support for bus power domain")
> Cc: stable@vger.kernel.org      # 5.17
> Cc: Yassine Oudjana <y.oudjana@protonmail.com>
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>

Konrad
>  drivers/interconnect/qcom/icc-rpm.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
> index 91778cfcbc65..da595059cafd 100644
> --- a/drivers/interconnect/qcom/icc-rpm.c
> +++ b/drivers/interconnect/qcom/icc-rpm.c
> @@ -498,8 +498,7 @@ int qnoc_probe(struct platform_device *pdev)
>  
>  	if (desc->has_bus_pd) {
>  		ret = dev_pm_domain_attach(dev, true);
> -		if (ret)
> -			return ret;
> +		goto err_disable_clks;
>  	}
>  
>  	provider = &qp->provider;
> @@ -514,8 +513,7 @@ int qnoc_probe(struct platform_device *pdev)
>  	ret = icc_provider_add(provider);
>  	if (ret) {
>  		dev_err(dev, "error adding interconnect provider: %d\n", ret);
> -		clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
> -		return ret;
> +		goto err_disable_clks;
>  	}
>  
>  	for (i = 0; i < num_nodes; i++) {
> @@ -550,8 +548,9 @@ int qnoc_probe(struct platform_device *pdev)
>  	return 0;
>  err:
>  	icc_nodes_remove(provider);
> -	clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
>  	icc_provider_del(provider);
> +err_disable_clks:
> +	clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
>  
>  	return ret;
>  }