Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI: sg2042: Fix a reference count issue in sg2042_pcie_remove()
@ 2025-09-29 18:13 Christophe JAILLET
  2025-09-30  0:43 ` Chen Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Christophe JAILLET @ 2025-09-29 18:13 UTC (permalink / raw)
  To: Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Chen Wang
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-pci

devm_pm_runtime_enable() is used in the probe, so pm_runtime_disable()
should not be called explicitly in the remove function.

Fixes: 1c72774df028 ("PCI: sg2042: Add Sophgo SG2042 PCIe driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only
---
 drivers/pci/controller/cadence/pcie-sg2042.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/pci/controller/cadence/pcie-sg2042.c b/drivers/pci/controller/cadence/pcie-sg2042.c
index a077b28d4894..0c50c74d03ee 100644
--- a/drivers/pci/controller/cadence/pcie-sg2042.c
+++ b/drivers/pci/controller/cadence/pcie-sg2042.c
@@ -74,15 +74,12 @@ static int sg2042_pcie_probe(struct platform_device *pdev)
 static void sg2042_pcie_remove(struct platform_device *pdev)
 {
 	struct cdns_pcie *pcie = platform_get_drvdata(pdev);
-	struct device *dev = &pdev->dev;
 	struct cdns_pcie_rc *rc;
 
 	rc = container_of(pcie, struct cdns_pcie_rc, pcie);
 	cdns_pcie_host_disable(rc);
 
 	cdns_pcie_disable_phy(pcie);
-
-	pm_runtime_disable(dev);
 }
 
 static int sg2042_pcie_suspend_noirq(struct device *dev)
-- 
2.51.0


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

* Re: [PATCH] PCI: sg2042: Fix a reference count issue in sg2042_pcie_remove()
  2025-09-29 18:13 [PATCH] PCI: sg2042: Fix a reference count issue in sg2042_pcie_remove() Christophe JAILLET
@ 2025-09-30  0:43 ` Chen Wang
       [not found] ` <f1887014-17b5-405c-bba2-1a441d50e1f8@outlook.com>
  2025-10-20  5:18 ` Manivannan Sadhasivam
  2 siblings, 0 replies; 7+ messages in thread
From: Chen Wang @ 2025-09-30  0:43 UTC (permalink / raw)
  To: Christophe JAILLET, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas
  Cc: linux-kernel, kernel-janitors, linux-pci


On 9/30/2025 2:13 AM, Christophe JAILLET wrote:
> devm_pm_runtime_enable() is used in the probe, so pm_runtime_disable()
> should not be called explicitly in the remove function.
>
> Fixes: 1c72774df028 ("PCI: sg2042: Add Sophgo SG2042 PCIe driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

LGTM.

Acked-by: Chen Wang <unicorn_wang@outlook.com>

Tested-by: Chen Wang <unicorn_wang@outlook.com> # on Pioneerbox.

Thanks,

Chen

> ---
> Compile tested only
> ---
>   drivers/pci/controller/cadence/pcie-sg2042.c | 3 ---
>   1 file changed, 3 deletions(-)
>
> diff --git a/drivers/pci/controller/cadence/pcie-sg2042.c b/drivers/pci/controller/cadence/pcie-sg2042.c
> index a077b28d4894..0c50c74d03ee 100644
> --- a/drivers/pci/controller/cadence/pcie-sg2042.c
> +++ b/drivers/pci/controller/cadence/pcie-sg2042.c
> @@ -74,15 +74,12 @@ static int sg2042_pcie_probe(struct platform_device *pdev)
>   static void sg2042_pcie_remove(struct platform_device *pdev)
>   {
>   	struct cdns_pcie *pcie = platform_get_drvdata(pdev);
> -	struct device *dev = &pdev->dev;
>   	struct cdns_pcie_rc *rc;
>   
>   	rc = container_of(pcie, struct cdns_pcie_rc, pcie);
>   	cdns_pcie_host_disable(rc);
>   
>   	cdns_pcie_disable_phy(pcie);
> -
> -	pm_runtime_disable(dev);
>   }
>   
>   static int sg2042_pcie_suspend_noirq(struct device *dev)

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

* Re: [PATCH] PCI: sg2042: Fix a reference count issue in sg2042_pcie_remove()
       [not found] ` <f1887014-17b5-405c-bba2-1a441d50e1f8@outlook.com>
@ 2025-10-13  2:31   ` Chen Wang
  2025-10-20 15:27     ` Bjorn Helgaas
       [not found]   ` <0e9b75d5-a1a6-4c5e-ad69-8e189af69bf3@outlook.com>
  1 sibling, 1 reply; 7+ messages in thread
From: Chen Wang @ 2025-10-13  2:31 UTC (permalink / raw)
  To: Christophe JAILLET, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas
  Cc: linux-kernel, kernel-janitors, linux-pci

Hi,Manivannan,

I see 6.18-rc1 is released. Could you please pick this fix for 6.18-rcX?

Thanks,

Chen

On 9/30/2025 8:43 AM, Chen Wang wrote:
>
> On 9/30/2025 2:13 AM, Christophe JAILLET wrote:
>> devm_pm_runtime_enable() is used in the probe, so pm_runtime_disable()
>> should not be called explicitly in the remove function.
>>
>> Fixes: 1c72774df028 ("PCI: sg2042: Add Sophgo SG2042 PCIe driver")
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>
> LGTM.
>
> Acked-by: Chen Wang <unicorn_wang@outlook.com>
>
> Tested-by: Chen Wang <unicorn_wang@outlook.com> # on Pioneerbox.
>
> Thanks,
>
> Chen
>
>> ---
>> Compile tested only
>> ---
>>   drivers/pci/controller/cadence/pcie-sg2042.c | 3 ---
>>   1 file changed, 3 deletions(-)
>>
>> diff --git a/drivers/pci/controller/cadence/pcie-sg2042.c 
>> b/drivers/pci/controller/cadence/pcie-sg2042.c
>> index a077b28d4894..0c50c74d03ee 100644
>> --- a/drivers/pci/controller/cadence/pcie-sg2042.c
>> +++ b/drivers/pci/controller/cadence/pcie-sg2042.c
>> @@ -74,15 +74,12 @@ static int sg2042_pcie_probe(struct 
>> platform_device *pdev)
>>   static void sg2042_pcie_remove(struct platform_device *pdev)
>>   {
>>       struct cdns_pcie *pcie = platform_get_drvdata(pdev);
>> -    struct device *dev = &pdev->dev;
>>       struct cdns_pcie_rc *rc;
>>         rc = container_of(pcie, struct cdns_pcie_rc, pcie);
>>       cdns_pcie_host_disable(rc);
>>         cdns_pcie_disable_phy(pcie);
>> -
>> -    pm_runtime_disable(dev);
>>   }
>>     static int sg2042_pcie_suspend_noirq(struct device *dev)

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

* Re: [PATCH] PCI: sg2042: Fix a reference count issue in sg2042_pcie_remove()
       [not found]   ` <0e9b75d5-a1a6-4c5e-ad69-8e189af69bf3@outlook.com>
@ 2025-10-19  0:36     ` Chen Wang
  0 siblings, 0 replies; 7+ messages in thread
From: Chen Wang @ 2025-10-19  0:36 UTC (permalink / raw)
  To: Christophe JAILLET, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Bjorn Helgaas
  Cc: linux-kernel, kernel-janitors, linux-pci

Hi,Bjorn,

I see you raise some fixes PRs for PCI for 6.18,  can you please pick 
this one also?

Thanks,

Chen

On 10/13/2025 10:31 AM, Chen Wang wrote:
> Hi,Manivannan,
>
> I see 6.18-rc1 is released. Could you please pick this fix for 6.18-rcX?
>
> Thanks,
>
> Chen
>
> On 9/30/2025 8:43 AM, Chen Wang wrote:
>>
>> On 9/30/2025 2:13 AM, Christophe JAILLET wrote:
>>> devm_pm_runtime_enable() is used in the probe, so pm_runtime_disable()
>>> should not be called explicitly in the remove function.
>>>
>>> Fixes: 1c72774df028 ("PCI: sg2042: Add Sophgo SG2042 PCIe driver")
>>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>
>> LGTM.
>>
>> Acked-by: Chen Wang <unicorn_wang@outlook.com>
>>
>> Tested-by: Chen Wang <unicorn_wang@outlook.com> # on Pioneerbox.
>>
>> Thanks,
>>
>> Chen
>>
>>> ---
>>> Compile tested only
>>> ---
>>>   drivers/pci/controller/cadence/pcie-sg2042.c | 3 ---
>>>   1 file changed, 3 deletions(-)
>>>
>>> diff --git a/drivers/pci/controller/cadence/pcie-sg2042.c 
>>> b/drivers/pci/controller/cadence/pcie-sg2042.c
>>> index a077b28d4894..0c50c74d03ee 100644
>>> --- a/drivers/pci/controller/cadence/pcie-sg2042.c
>>> +++ b/drivers/pci/controller/cadence/pcie-sg2042.c
>>> @@ -74,15 +74,12 @@ static int sg2042_pcie_probe(struct 
>>> platform_device *pdev)
>>>   static void sg2042_pcie_remove(struct platform_device *pdev)
>>>   {
>>>       struct cdns_pcie *pcie = platform_get_drvdata(pdev);
>>> -    struct device *dev = &pdev->dev;
>>>       struct cdns_pcie_rc *rc;
>>>         rc = container_of(pcie, struct cdns_pcie_rc, pcie);
>>>       cdns_pcie_host_disable(rc);
>>>         cdns_pcie_disable_phy(pcie);
>>> -
>>> -    pm_runtime_disable(dev);
>>>   }
>>>     static int sg2042_pcie_suspend_noirq(struct device *dev)

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

* Re: [PATCH] PCI: sg2042: Fix a reference count issue in sg2042_pcie_remove()
  2025-09-29 18:13 [PATCH] PCI: sg2042: Fix a reference count issue in sg2042_pcie_remove() Christophe JAILLET
  2025-09-30  0:43 ` Chen Wang
       [not found] ` <f1887014-17b5-405c-bba2-1a441d50e1f8@outlook.com>
@ 2025-10-20  5:18 ` Manivannan Sadhasivam
  2 siblings, 0 replies; 7+ messages in thread
From: Manivannan Sadhasivam @ 2025-10-20  5:18 UTC (permalink / raw)
  To: Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
	Bjorn Helgaas, Chen Wang, Christophe JAILLET
  Cc: linux-kernel, kernel-janitors, linux-pci


On Mon, 29 Sep 2025 20:13:22 +0200, Christophe JAILLET wrote:
> devm_pm_runtime_enable() is used in the probe, so pm_runtime_disable()
> should not be called explicitly in the remove function.
> 
> 

Applied, thanks!

[1/1] PCI: sg2042: Fix a reference count issue in sg2042_pcie_remove()
      commit: 932ec9dff6da40382ee63049a11a6ff047bdc259

Best regards,
-- 
Manivannan Sadhasivam <mani@kernel.org>


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

* Re: [PATCH] PCI: sg2042: Fix a reference count issue in sg2042_pcie_remove()
  2025-10-13  2:31   ` Chen Wang
@ 2025-10-20 15:27     ` Bjorn Helgaas
  2025-10-21  1:22       ` Manivannan Sadhasivam
  0 siblings, 1 reply; 7+ messages in thread
From: Bjorn Helgaas @ 2025-10-20 15:27 UTC (permalink / raw)
  To: Chen Wang
  Cc: Christophe JAILLET, Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, linux-kernel,
	kernel-janitors, linux-pci

On Mon, Oct 13, 2025 at 10:31:22AM +0800, Chen Wang wrote:
> Hi,Manivannan,
> 
> I see 6.18-rc1 is released. Could you please pick this fix for 6.18-rcX?

Mani queued this for v6.19.  Is there a reason it should be in v6.18
instead?  We're after the v6.18 merge window now, so we only add
things to v6.18 if they fix a serious issue.

> On 9/30/2025 8:43 AM, Chen Wang wrote:
> > 
> > On 9/30/2025 2:13 AM, Christophe JAILLET wrote:
> > > devm_pm_runtime_enable() is used in the probe, so pm_runtime_disable()
> > > should not be called explicitly in the remove function.
> > > 
> > > Fixes: 1c72774df028 ("PCI: sg2042: Add Sophgo SG2042 PCIe driver")
> > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > 
> > LGTM.
> > 
> > Acked-by: Chen Wang <unicorn_wang@outlook.com>
> > 
> > Tested-by: Chen Wang <unicorn_wang@outlook.com> # on Pioneerbox.
> > 
> > Thanks,
> > 
> > Chen
> > 
> > > ---
> > > Compile tested only
> > > ---
> > >   drivers/pci/controller/cadence/pcie-sg2042.c | 3 ---
> > >   1 file changed, 3 deletions(-)
> > > 
> > > diff --git a/drivers/pci/controller/cadence/pcie-sg2042.c
> > > b/drivers/pci/controller/cadence/pcie-sg2042.c
> > > index a077b28d4894..0c50c74d03ee 100644
> > > --- a/drivers/pci/controller/cadence/pcie-sg2042.c
> > > +++ b/drivers/pci/controller/cadence/pcie-sg2042.c
> > > @@ -74,15 +74,12 @@ static int sg2042_pcie_probe(struct
> > > platform_device *pdev)
> > >   static void sg2042_pcie_remove(struct platform_device *pdev)
> > >   {
> > >       struct cdns_pcie *pcie = platform_get_drvdata(pdev);
> > > -    struct device *dev = &pdev->dev;
> > >       struct cdns_pcie_rc *rc;
> > >         rc = container_of(pcie, struct cdns_pcie_rc, pcie);
> > >       cdns_pcie_host_disable(rc);
> > >         cdns_pcie_disable_phy(pcie);
> > > -
> > > -    pm_runtime_disable(dev);
> > >   }
> > >     static int sg2042_pcie_suspend_noirq(struct device *dev)

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

* Re: [PATCH] PCI: sg2042: Fix a reference count issue in sg2042_pcie_remove()
  2025-10-20 15:27     ` Bjorn Helgaas
@ 2025-10-21  1:22       ` Manivannan Sadhasivam
  0 siblings, 0 replies; 7+ messages in thread
From: Manivannan Sadhasivam @ 2025-10-21  1:22 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Chen Wang, Christophe JAILLET, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
	linux-kernel, kernel-janitors, linux-pci

On Mon, Oct 20, 2025 at 10:27:38AM -0500, Bjorn Helgaas wrote:
> On Mon, Oct 13, 2025 at 10:31:22AM +0800, Chen Wang wrote:
> > Hi,Manivannan,
> > 
> > I see 6.18-rc1 is released. Could you please pick this fix for 6.18-rcX?
> 
> Mani queued this for v6.19.  Is there a reason it should be in v6.18
> instead?  We're after the v6.18 merge window now, so we only add
> things to v6.18 if they fix a serious issue.
> 

The implication of calling pm_runtime_disable() manually in the remove() path
is, 'dev->power.disable_depth' will be incremented twice. When the driver gets
probed again, devm_pm_runtime_enable() will not enable runtime PM for the 'dev',
but just decrement 'dev->power.disable_depth'.

So this will result in an imbalanced runtime PM state. This is an issue, but
the severity is less since the driver is not itself making use of runtime PM.
So the driver should continue to work fine, but the runtime PM chain might be
broken.

- Mani

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

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

end of thread, other threads:[~2025-10-21  1:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-29 18:13 [PATCH] PCI: sg2042: Fix a reference count issue in sg2042_pcie_remove() Christophe JAILLET
2025-09-30  0:43 ` Chen Wang
     [not found] ` <f1887014-17b5-405c-bba2-1a441d50e1f8@outlook.com>
2025-10-13  2:31   ` Chen Wang
2025-10-20 15:27     ` Bjorn Helgaas
2025-10-21  1:22       ` Manivannan Sadhasivam
     [not found]   ` <0e9b75d5-a1a6-4c5e-ad69-8e189af69bf3@outlook.com>
2025-10-19  0:36     ` Chen Wang
2025-10-20  5:18 ` Manivannan Sadhasivam

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