Merge branch 'pci/controller/plda-starfive'

- Fix resource leaks on error paths in host_init() (Ali Tariq)

- Fix runtime PM handling and teardown ordering to avoid register access
  while power or clocks are disabled (Ali Tariq)

- Check for runtime PM resume failure to avoid register access while power
  or clocks are disabled (Ali Tariq)

* pci/controller/plda-starfive:
  PCI: starfive: Fix unchecked pm_runtime_get_sync() in probe
  PCI: starfive: Fix Runtime PM handling and teardown ordering
  PCI: starfive: Fix resource leaks on error paths in host_init()
This commit is contained in:
Bjorn Helgaas 2026-08-21 16:40:45 -05:00
commit 2d022e66d5

View File

@ -304,12 +304,14 @@ static int starfive_pcie_host_init(struct plda_pcie_rp *plda)
ret = starfive_pcie_clk_rst_init(pcie);
if (ret)
return ret;
goto err_disable_phy;
if (pcie->vpcie3v3) {
ret = regulator_enable(pcie->vpcie3v3);
if (ret)
if (ret) {
dev_err_probe(dev, ret, "failed to enable vpcie3v3 regulator\n");
goto err_clk_rst;
}
}
if (pcie->reset_gpio)
@ -379,6 +381,13 @@ static int starfive_pcie_host_init(struct plda_pcie_rp *plda)
dev_info(dev, "port link down\n");
return 0;
err_clk_rst:
starfive_pcie_clk_rst_deinit(pcie);
err_disable_phy:
starfive_pcie_disable_phy(pcie);
return ret;
}
static const struct plda_pcie_host_ops sf_host_ops = {
@ -410,7 +419,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;
@ -436,9 +449,9 @@ static void starfive_pcie_remove(struct platform_device *pdev)
{
struct starfive_jh7110_pcie *pcie = platform_get_drvdata(pdev);
pm_runtime_put(&pdev->dev);
pm_runtime_disable(&pdev->dev);
plda_pcie_host_deinit(&pcie->plda);
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
platform_set_drvdata(pdev, NULL);
}