mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RESEND] PCI: cadence: Fix runtime atomic count underflow.
@ 2025-03-01 12:44 Hans Zhang
  2025-04-19 10:05 ` Manivannan Sadhasivam
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Zhang @ 2025-03-01 12:44 UTC (permalink / raw)
  To: lpieralisi
  Cc: kw, manivannan.sadhasivam, robh, bhelgaas, s-vadapalli,
	thomas.richard, linux-pci, linux-kernel, rockswang7, Hans Zhang

From: "Hans Zhang" <18255117159@163.com>

If the pci_host_probe fails to be executed and run one time
pm_runtime_put_sync. Run pm_runtime_put_sync or pm_runtime_put again in
cdns_plat_pcie_probe or j721e_pcie_probe. Finally, it will print log
"runtime PM usage count underflow!".

Signed-off-by: Hans Zhang <18255117159@163.com>
---
 drivers/pci/controller/cadence/pcie-cadence-host.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pci/controller/cadence/pcie-cadence-host.c b/drivers/pci/controller/cadence/pcie-cadence-host.c
index 8af95e9da7ce..fe0b8d76005e 100644
--- a/drivers/pci/controller/cadence/pcie-cadence-host.c
+++ b/drivers/pci/controller/cadence/pcie-cadence-host.c
@@ -576,8 +576,6 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)
 
 	return 0;
 
- err_init:
-	pm_runtime_put_sync(dev);
-
+err_init:
 	return ret;
 }

base-commit: bb066fe812d6fb3a9d01c073d9f1e2fd5a63403b
-- 
2.47.1


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

* Re: [RESEND] PCI: cadence: Fix runtime atomic count underflow.
  2025-03-01 12:44 [RESEND] PCI: cadence: Fix runtime atomic count underflow Hans Zhang
@ 2025-04-19 10:05 ` Manivannan Sadhasivam
  2025-04-19 13:14   ` Hans Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Manivannan Sadhasivam @ 2025-04-19 10:05 UTC (permalink / raw)
  To: Hans Zhang
  Cc: lpieralisi, kw, robh, bhelgaas, s-vadapalli, thomas.richard,
	linux-pci, linux-kernel, rockswang7

On Sat, Mar 01, 2025 at 08:44:18PM +0800, Hans Zhang wrote:
> From: "Hans Zhang" <18255117159@163.com>
> 
> If the pci_host_probe fails to be executed and run one time
> pm_runtime_put_sync. Run pm_runtime_put_sync or pm_runtime_put again in
> cdns_plat_pcie_probe or j721e_pcie_probe. Finally, it will print log
> "runtime PM usage count underflow!".
> 

Please reword the description as:

"If the call to pci_host_probe() in cdns_pcie_host_setup() fails, PM runtime
count is decremented in the error path using pm_runtime_put_sync(). But the
runtime count is not incremented by this driver, but only by the callers
(cdns_plat_pcie_probe/j721e_pcie_probe). And the callers also decrement the
runtime PM count in their error path. So this leads to the below warning from
the PM core:

runtime PM usage count underflow!

So fix it by getting rid of pm_runtime_put_sync() in the error path and directly
return the errno."

> Signed-off-by: Hans Zhang <18255117159@163.com>

Fixes tag?

> ---
>  drivers/pci/controller/cadence/pcie-cadence-host.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/controller/cadence/pcie-cadence-host.c b/drivers/pci/controller/cadence/pcie-cadence-host.c
> index 8af95e9da7ce..fe0b8d76005e 100644
> --- a/drivers/pci/controller/cadence/pcie-cadence-host.c
> +++ b/drivers/pci/controller/cadence/pcie-cadence-host.c
> @@ -576,8 +576,6 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)
>  
>  	return 0;
>  
> - err_init:
> -	pm_runtime_put_sync(dev);
> -
> +err_init:
>  	return ret;

You can now directly do 'return ret' instead of using label.

- Mani

-- 
மணிவண்ணன் சதாசிவம்

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

* Re: [RESEND] PCI: cadence: Fix runtime atomic count underflow.
  2025-04-19 10:05 ` Manivannan Sadhasivam
@ 2025-04-19 13:14   ` Hans Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Hans Zhang @ 2025-04-19 13:14 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: lpieralisi, kw, robh, bhelgaas, s-vadapalli, thomas.richard,
	linux-pci, linux-kernel, rockswang7



On 2025/4/19 18:05, Manivannan Sadhasivam wrote:
> On Sat, Mar 01, 2025 at 08:44:18PM +0800, Hans Zhang wrote:
>> From: "Hans Zhang" <18255117159@163.com>
>>
>> If the pci_host_probe fails to be executed and run one time
>> pm_runtime_put_sync. Run pm_runtime_put_sync or pm_runtime_put again in
>> cdns_plat_pcie_probe or j721e_pcie_probe. Finally, it will print log
>> "runtime PM usage count underflow!".
>>
> 
> Please reword the description as:
> 
> "If the call to pci_host_probe() in cdns_pcie_host_setup() fails, PM runtime
> count is decremented in the error path using pm_runtime_put_sync(). But the
> runtime count is not incremented by this driver, but only by the callers
> (cdns_plat_pcie_probe/j721e_pcie_probe). And the callers also decrement the
> runtime PM count in their error path. So this leads to the below warning from
> the PM core:
> 
> runtime PM usage count underflow!
> 
> So fix it by getting rid of pm_runtime_put_sync() in the error path and directly
> return the errno."
> 

Hi Mani,

Thank you very much for your reply and suggestions.

>> Signed-off-by: Hans Zhang <18255117159@163.com>
> 
> Fixes tag?

Will add.

> 
>> ---
>>   drivers/pci/controller/cadence/pcie-cadence-host.c | 4 +---
>>   1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/drivers/pci/controller/cadence/pcie-cadence-host.c b/drivers/pci/controller/cadence/pcie-cadence-host.c
>> index 8af95e9da7ce..fe0b8d76005e 100644
>> --- a/drivers/pci/controller/cadence/pcie-cadence-host.c
>> +++ b/drivers/pci/controller/cadence/pcie-cadence-host.c
>> @@ -576,8 +576,6 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)
>>   
>>   	return 0;
>>   
>> - err_init:
>> -	pm_runtime_put_sync(dev);
>> -
>> +err_init:
>>   	return ret;
> 
> You can now directly do 'return ret' instead of using label.

Will change.

Best regards,
Hans


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

end of thread, other threads:[~2025-04-19 13:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-01 12:44 [RESEND] PCI: cadence: Fix runtime atomic count underflow Hans Zhang
2025-04-19 10:05 ` Manivannan Sadhasivam
2025-04-19 13:14   ` Hans Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®