* [PATCH v2 0/2] PCI: qcom: Add support for firmware-managed PCIe controller recovery
@ 2026-11-27 14:40 Mrinmay Sarkar
2026-11-27 14:40 ` [PATCH v2 1/2] PCI: qcom: Implement .reset_root_port() for firmware-managed controllers Mrinmay Sarkar
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Mrinmay Sarkar @ 2026-11-27 14:40 UTC (permalink / raw)
To: Manivannan Sadhasivam, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bjorn Helgaas
Cc: linux-pci, linux-arm-msm, linux-kernel, Rama Krishna,
Nitesh Gupta, Ayiluri Naga Rashmi, Krishna Chaitanya Chundru,
Shazad Hussain, Mrinmay Sarkar
This series adds recovery support for firmware-managed Qualcomm PCIe
controllers.
For these controllers, firmware manages resources such as PHY, clocks,
resets and LTSSM through the power-domain framework.
Patch 1 adds Root Port reset support by power-cycling the controller
through Runtime PM, allowing firmware to reset and reinitialize the
hardware.
Patch 2 restores the DesignWare MSI configuration after resume, as MSI
register contents are lost across the controller power cycle.
Signed-off-by: Mrinmay Sarkar <mrinmay.sarkar@oss.qualcomm.com>
---
Changes in v2:
- Guard reset_root_port() registration with CONFIG_PM_SLEEP and mention
the same in commit text too.
- Link to v1: https://patch.msgid.link/20261016-pcie-controller-reset-v1-0-51779736cf12@oss.qualcomm.com
---
Mrinmay Sarkar (2):
PCI: qcom: Implement .reset_root_port() for firmware-managed controllers
PCI: qcom: Reinitialize MSI on resume for firmware-managed controllers
drivers/pci/controller/dwc/pcie-qcom.c | 42 +++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
---
base-commit: b810335a0699d1810683796b0e3ffe8827ddfe6c
change-id: 20261016-pcie-controller-reset-8938e4bac060
Best regards,
--
Mrinmay Sarkar <mrinmay.sarkar@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 1/2] PCI: qcom: Implement .reset_root_port() for firmware-managed controllers 2026-11-27 14:40 [PATCH v2 0/2] PCI: qcom: Add support for firmware-managed PCIe controller recovery Mrinmay Sarkar @ 2026-11-27 14:40 ` Mrinmay Sarkar 2026-11-27 15:02 ` sashiko-bot 2026-11-27 14:40 ` [PATCH v2 2/2] PCI: qcom: Reinitialize MSI on resume " Mrinmay Sarkar 2026-11-27 15:02 ` [PATCH v2 0/2] PCI: qcom: Add support for firmware-managed PCIe controller recovery sashiko-bot 2 siblings, 1 reply; 5+ messages in thread From: Mrinmay Sarkar @ 2026-11-27 14:40 UTC (permalink / raw) To: Manivannan Sadhasivam, Lorenzo Pieralisi, Krzysztof Wilczyński, Bjorn Helgaas Cc: linux-pci, linux-arm-msm, linux-kernel, Rama Krishna, Nitesh Gupta, Ayiluri Naga Rashmi, Krishna Chaitanya Chundru, Shazad Hussain, Mrinmay Sarkar During PCIe recovery events, such as a fatal AER event or other platform-specific PCIe failures, the controller may enter a state that requires a full reset before normal link operation can be restored. On firmware-managed PCIe controllers, Linux does not control the PHY, clocks, resets, or LTSSM state directly. Instead, these resources are managed by firmware through the power-domain framework. Implement the reset_root_port() callback by performing a Runtime PM power cycle of the controller. This allows firmware to reset and reinitialize the hardware before bringing the controller back online. Since controller state is lost across the power cycle, reinitialize the DWC MSI configuration after resume. The callback is only registered when CONFIG_PM_SLEEP is enabled, as the required PM support is unavailable otherwise. This enables Root Port reset and recovery support for firmware-managed controllers. Signed-off-by: Mrinmay Sarkar <mrinmay.sarkar@oss.qualcomm.com> --- drivers/pci/controller/dwc/pcie-qcom.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index d903f10211c2..fe86b8fbc895 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -1855,6 +1855,35 @@ static int qcom_pcie_set_max_opp(struct device *dev) return ret; } +/* + * Reset for firmware-managed controllers: power-cycle via runtime PM and + * reprogram DWC MSI registers on resume. + */ +static int qcom_pcie_fw_reset_root_port(struct pci_host_bridge *bridge, + struct pci_dev *pdev) +{ + struct pci_config_window *cfg = bridge->sysdata; + struct device *dev = bridge->dev.parent; + struct dw_pcie_rp *pp = cfg->priv; + int ret; + + ret = pm_runtime_force_suspend(dev); + if (ret) { + dev_err(dev, "Failed to force runtime suspend for reset: %d\n", ret); + return ret; + } + + ret = pm_runtime_force_resume(dev); + if (ret) { + dev_err(dev, "Failed to force runtime resume after reset: %d\n", ret); + return ret; + } + + dw_pcie_msi_init(pp); + + return 0; +} + /* * Qcom PCIe controllers only support one Root Port per controller instance. So * this function ignores the 'pci_dev' associated with the Root Port and just @@ -2031,6 +2060,8 @@ static int qcom_pcie_ecam_host_init(struct pci_config_window *cfg) dw_pcie_msi_init(pp); + cfg->priv = pp; + return devm_add_action_or_reset(dev, qcom_pci_free_msi, pp); } @@ -2292,6 +2323,8 @@ static int qcom_pcie_probe(struct platform_device *pdev) bridge->sysdata = cfg; bridge->ops = (struct pci_ops *)&pci_qcom_ecam_ops.pci_ops; bridge->msi_domain = true; + if (IS_ENABLED(CONFIG_PM_SLEEP)) + bridge->reset_root_port = qcom_pcie_fw_reset_root_port; ret = pci_host_probe(bridge); if (ret) -- 2.43.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] PCI: qcom: Implement .reset_root_port() for firmware-managed controllers 2026-11-27 14:40 ` [PATCH v2 1/2] PCI: qcom: Implement .reset_root_port() for firmware-managed controllers Mrinmay Sarkar @ 2026-11-27 15:02 ` sashiko-bot 0 siblings, 0 replies; 5+ messages in thread From: sashiko-bot @ 2026-11-27 15:02 UTC (permalink / raw) To: Mrinmay Sarkar; +Cc: linux-pci Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] PCI: qcom: unpowered MMIO access in qcom_pcie_fw_reset_root_port() - [High] PCI: qcom: concurrent unpowered MMIO in qcom_pcie_fw_reset_root_port() -- commit d192484df4b90b14ad3c75da5b46d87d0d0f79dc Author: Mrinmay Sarkar <mrinmay.sarkar@oss.qualcomm.com> PCI: qcom: Implement .reset_root_port() for firmware-managed controllers This commit implements the .reset_root_port() callback for firmware-managed Qualcomm PCIe controllers by force-suspending and force-resuming the controller via runtime PM and reinitializing DWC MSI registers. > diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c > index d903f10211c23..fe86b8fbc8950 100644 > --- a/drivers/pci/controller/dwc/pcie-qcom.c > +++ b/drivers/pci/controller/dwc/pcie-qcom.c > @@ -1855,6 +1855,35 @@ static int qcom_pcie_set_max_opp(struct device *dev) > return ret; > } > > +/* > + * Reset for firmware-managed controllers: power-cycle via runtime PM and > + * reprogram DWC MSI registers on resume. > + */ > +static int qcom_pcie_fw_reset_root_port(struct pci_host_bridge *bridge, > + struct pci_dev *pdev) > +{ > + struct pci_config_window *cfg = bridge->sysdata; > + struct device *dev = bridge->dev.parent; > + struct dw_pcie_rp *pp = cfg->priv; > + int ret; > + > + ret = pm_runtime_force_suspend(dev); > + if (ret) { > + dev_err(dev, "Failed to force runtime suspend for reset: %d\n", ret); > + return ret; > + } [Severity: High] Can pm_runtime_force_suspend(dev) allow concurrent callers to access ECAM registers while the controller power domain is off? When active child devices are present (dev->power.child_count > 0), pm_runtime_need_not_resume(dev) is false, so pm_runtime_force_suspend(dev) disables runtime PM and powers off the domain while leaving dev->power.runtime_status and dev->power.last_status set to RPM_ACTIVE: drivers/base/power/runtime.c:pm_runtime_force_suspend() { ... if (pm_runtime_need_not_resume(dev)) pm_runtime_set_suspended(dev); else dev->power.needs_force_resume = true; ... } Because rpm_resume() returns 1 immediately when disable_depth > 0 and both status fields are RPM_ACTIVE, a concurrent config-space access happens while the controller is powered down: CPU0 CPU1 qcom_pcie_fw_reset_root_port() pm_runtime_force_suspend(dev) pm_runtime_disable(dev) callback(dev) [powers off domain] current_link_speed_show() pci_config_pm_runtime_get() pm_runtime_get_sync() rpm_resume() -> returns 1 pci_read_config_word() <-- unpowered ECAM read (SError) pm_runtime_force_resume(dev) > + > + ret = pm_runtime_force_resume(dev); > + if (ret) { > + dev_err(dev, "Failed to force runtime resume after reset: %d\n", ret); > + return ret; > + } > + > + dw_pcie_msi_init(pp); > + > + return 0; > +} [Severity: High] Can pm_runtime_force_resume(dev) skip resuming the controller and leave it powered off when dw_pcie_msi_init(pp) accesses DBI registers? pm_runtime_force_suspend() and pm_runtime_force_resume() are system sleep helpers that assume device_prepare() has taken an extra runtime PM reference. At runtime, dev->power.usage_count is 1 (from qcom_pcie_probe()). If the Root Port is runtime-suspended so dev->power.child_count is 0 (for example, during a bus reset or recovery when no downstream devices are active), pm_runtime_need_not_resume(dev) returns true: drivers/base/power/runtime.c:pm_runtime_need_not_resume() { return atomic_read(&dev->power.usage_count) <= 1 && (atomic_read(&dev->power.child_count) == 0 || dev->power.ignore_children); } pm_runtime_force_suspend(dev) then sets the status to RPM_SUSPENDED without setting dev->power.needs_force_resume. When pm_runtime_force_resume(dev) runs next, it sees !dev->power.needs_force_resume and pm_runtime_status_suspended(dev), skips the resume callback, and returns 0 with the power domain still off. dw_pcie_msi_init(pp) and the subsequent config-space restore in pcibios_reset_secondary_bus() then write to unpowered DBI and ECAM registers, causing a synchronous external abort. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261127-pcie-controller-reset-v2-0-17467b64f5f5@oss.qualcomm.com?part=1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] PCI: qcom: Reinitialize MSI on resume for firmware-managed controllers 2026-11-27 14:40 [PATCH v2 0/2] PCI: qcom: Add support for firmware-managed PCIe controller recovery Mrinmay Sarkar 2026-11-27 14:40 ` [PATCH v2 1/2] PCI: qcom: Implement .reset_root_port() for firmware-managed controllers Mrinmay Sarkar @ 2026-11-27 14:40 ` Mrinmay Sarkar 2026-11-27 15:02 ` [PATCH v2 0/2] PCI: qcom: Add support for firmware-managed PCIe controller recovery sashiko-bot 2 siblings, 0 replies; 5+ messages in thread From: Mrinmay Sarkar @ 2026-11-27 14:40 UTC (permalink / raw) To: Manivannan Sadhasivam, Lorenzo Pieralisi, Krzysztof Wilczyński, Bjorn Helgaas Cc: linux-pci, linux-arm-msm, linux-kernel, Rama Krishna, Nitesh Gupta, Ayiluri Naga Rashmi, Krishna Chaitanya Chundru, Shazad Hussain, Mrinmay Sarkar On firmware-managed PCIe controllers, hardware context is lost across system suspend. While firmware reinitializes the controller through the power domain framework during resume, the DesignWare MSI registers are not preserved across the power cycle and must be reprogrammed by the driver. Reinitialize the DesignWare MSI configuration during resume for firmware-managed controllers to restore MSI functionality after the controller is power-cycled. Signed-off-by: Mrinmay Sarkar <mrinmay.sarkar@oss.qualcomm.com> --- drivers/pci/controller/dwc/pcie-qcom.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index fe86b8fbc895..51299dfd574c 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -2325,6 +2325,7 @@ static int qcom_pcie_probe(struct platform_device *pdev) bridge->msi_domain = true; if (IS_ENABLED(CONFIG_PM_SLEEP)) bridge->reset_root_port = qcom_pcie_fw_reset_root_port; + dev_set_drvdata(dev, cfg); ret = pci_host_probe(bridge); if (ret) @@ -2552,8 +2553,14 @@ static int qcom_pcie_resume_noirq(struct device *dev) int ret; const struct qcom_pcie_cfg *pcie_cfg = of_device_get_match_data(dev); - if (pcie_cfg && pcie_cfg->firmware_managed) + if (pcie_cfg && pcie_cfg->firmware_managed) { + struct pci_config_window *cfg = dev_get_drvdata(dev); + + if (cfg && cfg->priv) + dw_pcie_msi_init(cfg->priv); + return 0; + } pcie = dev_get_drvdata(dev); if (!pcie) -- 2.43.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/2] PCI: qcom: Add support for firmware-managed PCIe controller recovery 2026-11-27 14:40 [PATCH v2 0/2] PCI: qcom: Add support for firmware-managed PCIe controller recovery Mrinmay Sarkar 2026-11-27 14:40 ` [PATCH v2 1/2] PCI: qcom: Implement .reset_root_port() for firmware-managed controllers Mrinmay Sarkar 2026-11-27 14:40 ` [PATCH v2 2/2] PCI: qcom: Reinitialize MSI on resume " Mrinmay Sarkar @ 2026-11-27 15:02 ` sashiko-bot 2 siblings, 0 replies; 5+ messages in thread From: sashiko-bot @ 2026-11-27 15:02 UTC (permalink / raw) To: Mrinmay Sarkar; +Cc: linux-pci Sashiko has finished reviewing this 2-patch series: - Patch 2: no issues found. - Patch 1 ("PCI: qcom: Implement .reset_root_port() for firmware..."): 2 potential issues (2 High) A detailed review has been sent as a separate reply to patch 1. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261127-pcie-controller-reset-v2-0-17467b64f5f5@oss.qualcomm.com ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-27 15:02 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-27 14:40 [PATCH v2 0/2] PCI: qcom: Add support for firmware-managed PCIe controller recovery Mrinmay Sarkar 2026-11-27 14:40 ` [PATCH v2 1/2] PCI: qcom: Implement .reset_root_port() for firmware-managed controllers Mrinmay Sarkar 2026-11-27 15:02 ` sashiko-bot 2026-11-27 14:40 ` [PATCH v2 2/2] PCI: qcom: Reinitialize MSI on resume " Mrinmay Sarkar 2026-11-27 15:02 ` [PATCH v2 0/2] PCI: qcom: Add support for firmware-managed PCIe controller recovery sashiko-bot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox