[PATCH v2 08/13] memory: tegra186-emc: Simplify and handle deferred probe with dev_err_probe()

Krzysztof Kozlowski posted 13 patches 5 months ago
[PATCH v2 08/13] memory: tegra186-emc: Simplify and handle deferred probe with dev_err_probe()
Posted by Krzysztof Kozlowski 5 months ago
Certain calls, like clk_get, can cause probe deferral and driver should
handle it.  Use dev_err_probe() to fix that and also change other
non-deferred errors cases to make the code simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/memory/tegra/tegra186-emc.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/memory/tegra/tegra186-emc.c b/drivers/memory/tegra/tegra186-emc.c
index 00baa7ab89214b1a151ab0c0a9ab76f90f922478..a0de80afe3e90531fcfb29d20773aed0d04478c5 100644
--- a/drivers/memory/tegra/tegra186-emc.c
+++ b/drivers/memory/tegra/tegra186-emc.c
@@ -302,9 +302,8 @@ static int tegra_emc_interconnect_init(struct tegra186_emc *emc)
 
 remove_nodes:
 	icc_nodes_remove(&emc->provider);
-	dev_err(emc->dev, "failed to initialize ICC: %d\n", err);
 
-	return err;
+	return dev_err_probe(emc->dev, err, "failed to initialize ICC\n");
 }
 
 static int tegra186_emc_probe(struct platform_device *pdev)
@@ -319,14 +318,13 @@ static int tegra186_emc_probe(struct platform_device *pdev)
 
 	emc->bpmp = tegra_bpmp_get(&pdev->dev);
 	if (IS_ERR(emc->bpmp))
-		return dev_err_probe(&pdev->dev, PTR_ERR(emc->bpmp), "failed to get BPMP\n");
+		return dev_err_probe(&pdev->dev, PTR_ERR(emc->bpmp),
+				     "failed to get BPMP\n");
 
 	emc->clk = devm_clk_get(&pdev->dev, "emc");
-	if (IS_ERR(emc->clk)) {
-		err = PTR_ERR(emc->clk);
-		dev_err(&pdev->dev, "failed to get EMC clock: %d\n", err);
-		goto put_bpmp;
-	}
+	if (IS_ERR(emc->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(emc->clk),
+				     "failed to get EMC clock\n");
 
 	platform_set_drvdata(pdev, emc);
 	emc->dev = &pdev->dev;

-- 
2.48.1
Re: [PATCH v2 08/13] memory: tegra186-emc: Simplify and handle deferred probe with dev_err_probe()
Posted by Jon Hunter 3 months ago
On 11/09/2025 10:43, Krzysztof Kozlowski wrote:
> Certain calls, like clk_get, can cause probe deferral and driver should
> handle it.  Use dev_err_probe() to fix that and also change other
> non-deferred errors cases to make the code simpler.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
>   drivers/memory/tegra/tegra186-emc.c | 14 ++++++--------
>   1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/memory/tegra/tegra186-emc.c b/drivers/memory/tegra/tegra186-emc.c
> index 00baa7ab89214b1a151ab0c0a9ab76f90f922478..a0de80afe3e90531fcfb29d20773aed0d04478c5 100644
> --- a/drivers/memory/tegra/tegra186-emc.c
> +++ b/drivers/memory/tegra/tegra186-emc.c
> @@ -302,9 +302,8 @@ static int tegra_emc_interconnect_init(struct tegra186_emc *emc)
>   
>   remove_nodes:
>   	icc_nodes_remove(&emc->provider);
> -	dev_err(emc->dev, "failed to initialize ICC: %d\n", err);
>   
> -	return err;
> +	return dev_err_probe(emc->dev, err, "failed to initialize ICC\n");
>   }
>   
>   static int tegra186_emc_probe(struct platform_device *pdev)
> @@ -319,14 +318,13 @@ static int tegra186_emc_probe(struct platform_device *pdev)
>   
>   	emc->bpmp = tegra_bpmp_get(&pdev->dev);
>   	if (IS_ERR(emc->bpmp))
> -		return dev_err_probe(&pdev->dev, PTR_ERR(emc->bpmp), "failed to get BPMP\n");
> +		return dev_err_probe(&pdev->dev, PTR_ERR(emc->bpmp),
> +				     "failed to get BPMP\n");
>   
>   	emc->clk = devm_clk_get(&pdev->dev, "emc");
> -	if (IS_ERR(emc->clk)) {
> -		err = PTR_ERR(emc->clk);
> -		dev_err(&pdev->dev, "failed to get EMC clock: %d\n", err);
> -		goto put_bpmp;
> -	}
> +	if (IS_ERR(emc->clk))
> +		return dev_err_probe(&pdev->dev, PTR_ERR(emc->clk),
> +				     "failed to get EMC clock\n");

I see now that we dropped a 'put_bpmp' here and we should not have. I 
see this is in -next, do you want fix up or I can send a patch?

Thanks
Jon

-- 
nvpublic
Re: [PATCH v2 08/13] memory: tegra186-emc: Simplify and handle deferred probe with dev_err_probe()
Posted by Krzysztof Kozlowski 3 months ago
On 06/11/2025 13:04, Jon Hunter wrote:
> 
> On 11/09/2025 10:43, Krzysztof Kozlowski wrote:
>> Certain calls, like clk_get, can cause probe deferral and driver should
>> handle it.  Use dev_err_probe() to fix that and also change other
>> non-deferred errors cases to make the code simpler.
>>
>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>> ---
>>   drivers/memory/tegra/tegra186-emc.c | 14 ++++++--------
>>   1 file changed, 6 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/memory/tegra/tegra186-emc.c b/drivers/memory/tegra/tegra186-emc.c
>> index 00baa7ab89214b1a151ab0c0a9ab76f90f922478..a0de80afe3e90531fcfb29d20773aed0d04478c5 100644
>> --- a/drivers/memory/tegra/tegra186-emc.c
>> +++ b/drivers/memory/tegra/tegra186-emc.c
>> @@ -302,9 +302,8 @@ static int tegra_emc_interconnect_init(struct tegra186_emc *emc)
>>   
>>   remove_nodes:
>>   	icc_nodes_remove(&emc->provider);
>> -	dev_err(emc->dev, "failed to initialize ICC: %d\n", err);
>>   
>> -	return err;
>> +	return dev_err_probe(emc->dev, err, "failed to initialize ICC\n");
>>   }
>>   
>>   static int tegra186_emc_probe(struct platform_device *pdev)
>> @@ -319,14 +318,13 @@ static int tegra186_emc_probe(struct platform_device *pdev)
>>   
>>   	emc->bpmp = tegra_bpmp_get(&pdev->dev);
>>   	if (IS_ERR(emc->bpmp))
>> -		return dev_err_probe(&pdev->dev, PTR_ERR(emc->bpmp), "failed to get BPMP\n");
>> +		return dev_err_probe(&pdev->dev, PTR_ERR(emc->bpmp),
>> +				     "failed to get BPMP\n");
>>   
>>   	emc->clk = devm_clk_get(&pdev->dev, "emc");
>> -	if (IS_ERR(emc->clk)) {
>> -		err = PTR_ERR(emc->clk);
>> -		dev_err(&pdev->dev, "failed to get EMC clock: %d\n", err);
>> -		goto put_bpmp;
>> -	}
>> +	if (IS_ERR(emc->clk))
>> +		return dev_err_probe(&pdev->dev, PTR_ERR(emc->clk),
>> +				     "failed to get EMC clock\n");
> 
> I see now that we dropped a 'put_bpmp' here and we should not have. I 
> see this is in -next, do you want fix up or I can send a patch?

Great thanks!

Best regards,
Krzysztof
Re: [PATCH v2 08/13] memory: tegra186-emc: Simplify and handle deferred probe with dev_err_probe()
Posted by Krzysztof Kozlowski 3 months ago
On 06/11/2025 13:04, Jon Hunter wrote:
>> @@ -319,14 +318,13 @@ static int tegra186_emc_probe(struct platform_device *pdev)
>>   
>>   	emc->bpmp = tegra_bpmp_get(&pdev->dev);
>>   	if (IS_ERR(emc->bpmp))
>> -		return dev_err_probe(&pdev->dev, PTR_ERR(emc->bpmp), "failed to get BPMP\n");
>> +		return dev_err_probe(&pdev->dev, PTR_ERR(emc->bpmp),
>> +				     "failed to get BPMP\n");
>>   
>>   	emc->clk = devm_clk_get(&pdev->dev, "emc");
>> -	if (IS_ERR(emc->clk)) {
>> -		err = PTR_ERR(emc->clk);
>> -		dev_err(&pdev->dev, "failed to get EMC clock: %d\n", err);
>> -		goto put_bpmp;
>> -	}
>> +	if (IS_ERR(emc->clk))
>> +		return dev_err_probe(&pdev->dev, PTR_ERR(emc->clk),
>> +				     "failed to get EMC clock\n");
> 
> I see now that we dropped a 'put_bpmp' here and we should not have. I 
> see this is in -next, do you want fix up or I can send a patch?


Indeed, thanks for noticing this. Please send a patch with Fixes tag.
Will you also take a look at other patches from this patchset, if I did
not make same mistake?

Best regards,
Krzysztof
Re: [PATCH v2 08/13] memory: tegra186-emc: Simplify and handle deferred probe with dev_err_probe()
Posted by Jon Hunter 3 months ago
On 06/11/2025 12:13, Krzysztof Kozlowski wrote:
> On 06/11/2025 13:04, Jon Hunter wrote:
>>> @@ -319,14 +318,13 @@ static int tegra186_emc_probe(struct platform_device *pdev)
>>>    
>>>    	emc->bpmp = tegra_bpmp_get(&pdev->dev);
>>>    	if (IS_ERR(emc->bpmp))
>>> -		return dev_err_probe(&pdev->dev, PTR_ERR(emc->bpmp), "failed to get BPMP\n");
>>> +		return dev_err_probe(&pdev->dev, PTR_ERR(emc->bpmp),
>>> +				     "failed to get BPMP\n");
>>>    
>>>    	emc->clk = devm_clk_get(&pdev->dev, "emc");
>>> -	if (IS_ERR(emc->clk)) {
>>> -		err = PTR_ERR(emc->clk);
>>> -		dev_err(&pdev->dev, "failed to get EMC clock: %d\n", err);
>>> -		goto put_bpmp;
>>> -	}
>>> +	if (IS_ERR(emc->clk))
>>> +		return dev_err_probe(&pdev->dev, PTR_ERR(emc->clk),
>>> +				     "failed to get EMC clock\n");
>>
>> I see now that we dropped a 'put_bpmp' here and we should not have. I
>> see this is in -next, do you want fix up or I can send a patch?
> 
> 
> Indeed, thanks for noticing this. Please send a patch with Fixes tag.
> Will you also take a look at other patches from this patchset, if I did
> not make same mistake?

Yes I will send a patch. All the others look good.

Thanks
Jon

-- 
nvpublic