* [PATCH] PCI: starfive: Fix unchecked pm_runtime_get_sync() in probe
@ 2026-07-12 17:54 Ali Tariq
2026-07-18 15:33 ` [PATCH v2] " Ali Tariq
0 siblings, 1 reply; 4+ messages in thread
From: Ali Tariq @ 2026-07-12 17:54 UTC (permalink / raw)
To: Kevin Xie
Cc: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, linux-pci,
linux-kernel, Ali Tariq
pm_runtime_get_sync() is called in starfive_pcie_probe() without
checking its return value. If runtime resume fails, the driver
proceeds to configure PCIe hardware through regmap_update_bits(),
enable clocks and resets, and power on the PHY, even though the
device may not actually be powered.
pm_runtime_get_sync() also increments the usage counter even when
resume fails, which would leave the counter unbalanced if this
error path were later handled without additional cleanup.
Switch to pm_runtime_resume_and_get(), which balances the usage
counter internally on failure, and bail out of probe before any
hardware is touched if resume does not succeed.
Tested on StarFive VisionFive 2 v1.2A board.
Signed-off-by: Ali Tariq <alitariq45892@gmail.com>
---
drivers/pci/controller/plda/pcie-starfive.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/controller/plda/pcie-starfive.c b/drivers/pci/controller/plda/pcie-starfive.c
index 298036c3e7f9..e9a472985b8a 100644
--- a/drivers/pci/controller/plda/pcie-starfive.c
+++ b/drivers/pci/controller/plda/pcie-starfive.c
@@ -410,7 +410,11 @@ static int starfive_pcie_probe(struct platform_device *pdev)
return ret;
pm_runtime_enable(&pdev->dev);
- pm_runtime_get_sync(&pdev->dev);
+ ret = pm_runtime_resume_and_get(&pdev->dev);
+ if (ret < 0) {
+ pm_runtime_disable(&pdev->dev);
+ return dev_err_probe(dev, ret, "failed to resume device\n");
+ }
plda->host_ops = &sf_host_ops;
plda->num_events = PLDA_MAX_EVENT_NUM;
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] PCI: starfive: Fix unchecked pm_runtime_get_sync() in probe
2026-07-12 17:54 [PATCH] PCI: starfive: Fix unchecked pm_runtime_get_sync() in probe Ali Tariq
@ 2026-07-18 15:33 ` Ali Tariq
2026-07-29 15:33 ` Ali Tariq
2026-07-29 16:43 ` Manivannan Sadhasivam
0 siblings, 2 replies; 4+ messages in thread
From: Ali Tariq @ 2026-07-18 15:33 UTC (permalink / raw)
To: Kevin Xie
Cc: Ali Tariq, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Mayank Rana,
open list:PCIE DRIVER FOR STARFIVE JH71x0, open list
pm_runtime_get_sync() is called in starfive_pcie_probe() without
checking its return value. If runtime resume fails, the driver
proceeds to configure PCIe hardware through regmap_update_bits(),
enable clocks and resets, and power on the PHY, even though the
device may not actually be powered.
pm_runtime_get_sync() also increments the usage counter even when
resume fails, which would leave the counter unbalanced if this
error path were later handled without additional cleanup.
Switch to pm_runtime_resume_and_get(), which balances the usage
counter internally on failure, and bail out of probe before any
hardware is touched if resume does not succeed.
Tested on StarFive VisionFive 2 v1.2A board.
Fixes: 6168efbebace ("PCI: starfive: Enable controller runtime PM before probing host bridge")
Signed-off-by: Ali Tariq <alitariq45892@gmail.com>
---
Changes in v2:
- Added Fixes tag to commit message
---
drivers/pci/controller/plda/pcie-starfive.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/controller/plda/pcie-starfive.c b/drivers/pci/controller/plda/pcie-starfive.c
index 298036c3e7f9..e9a472985b8a 100644
--- a/drivers/pci/controller/plda/pcie-starfive.c
+++ b/drivers/pci/controller/plda/pcie-starfive.c
@@ -410,7 +410,11 @@ static int starfive_pcie_probe(struct platform_device *pdev)
return ret;
pm_runtime_enable(&pdev->dev);
- pm_runtime_get_sync(&pdev->dev);
+ ret = pm_runtime_resume_and_get(&pdev->dev);
+ if (ret < 0) {
+ pm_runtime_disable(&pdev->dev);
+ return dev_err_probe(dev, ret, "failed to resume device\n");
+ }
plda->host_ops = &sf_host_ops;
plda->num_events = PLDA_MAX_EVENT_NUM;
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] PCI: starfive: Fix unchecked pm_runtime_get_sync() in probe
2026-07-18 15:33 ` [PATCH v2] " Ali Tariq
@ 2026-07-29 15:33 ` Ali Tariq
2026-07-29 16:43 ` Manivannan Sadhasivam
1 sibling, 0 replies; 4+ messages in thread
From: Ali Tariq @ 2026-07-29 15:33 UTC (permalink / raw)
To: Kevin Xie
Cc: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Mayank Rana,
open list:PCIE DRIVER FOR STARFIVE JH71x0, open list
Gentle ping.
Did anyone get a chance to review this patch?
Happy to send v3 with new changes if required.
Regards,
Ali
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] PCI: starfive: Fix unchecked pm_runtime_get_sync() in probe
2026-07-18 15:33 ` [PATCH v2] " Ali Tariq
2026-07-29 15:33 ` Ali Tariq
@ 2026-07-29 16:43 ` Manivannan Sadhasivam
1 sibling, 0 replies; 4+ messages in thread
From: Manivannan Sadhasivam @ 2026-07-29 16:43 UTC (permalink / raw)
To: Kevin Xie, Ali Tariq
Cc: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Mayank Rana,
linux-pci, linux-kernel
On Sat, 18 Jul 2026 20:33:51 +0500, Ali Tariq wrote:
> pm_runtime_get_sync() is called in starfive_pcie_probe() without
> checking its return value. If runtime resume fails, the driver
> proceeds to configure PCIe hardware through regmap_update_bits(),
> enable clocks and resets, and power on the PHY, even though the
> device may not actually be powered.
>
> pm_runtime_get_sync() also increments the usage counter even when
> resume fails, which would leave the counter unbalanced if this
> error path were later handled without additional cleanup.
>
> [...]
Applied, thanks!
[1/1] PCI: starfive: Fix unchecked pm_runtime_get_sync() in probe
commit: aaae917990623a6ca6b638557056606a1ae4a8d6
Best regards,
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-29 16:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-12 17:54 [PATCH] PCI: starfive: Fix unchecked pm_runtime_get_sync() in probe Ali Tariq
2026-07-18 15:33 ` [PATCH v2] " Ali Tariq
2026-07-29 15:33 ` Ali Tariq
2026-07-29 16:43 ` Manivannan Sadhasivam
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®