From: Niklas Schnelle schnelle@linux.ibm.com
[ Upstream commit dab32f2576a39d5f54f3dbbbc718d92fa5109ce9 ]
Issue uevents on s390 during PCI recovery using pci_uevent_ers() as done by EEH and AER PCIe recovery routines.
Signed-off-by: Niklas Schnelle schnelle@linux.ibm.com Signed-off-by: Bjorn Helgaas bhelgaas@google.com Reviewed-by: Lukas Wunner lukas@wunner.de Link: https://patch.msgid.link/20250807-add_err_uevents-v5-2-adf85b0620b0@linux.ib... Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES
Explanation - What it changes - arch/s390/pci/pci_event.c: Adds uevent notifications to the s390 PCI error recovery path, mirroring existing AER/EEH behavior: - After driver’s error_detected() returns, emit a recovery-begin uevent: the patch inserts pci_uevent_ers(pdev, ers_res) in zpci_event_notify_error_detected() (arch/s390/pci/pci_event.c:85). - On recovery failure, emit FAILED_RECOVERY: the patch calls pci_uevent_ers(pdev, PCI_ERS_RESULT_DISCONNECT) in zpci_event_attempt_error_recovery() (arch/s390/pci/pci_event.c:178). - On recovery success, emit SUCCESSFUL_RECOVERY: the patch calls pci_uevent_ers(pdev, PCI_ERS_RESULT_RECOVERED) after an optional resume() in zpci_event_attempt_error_recovery() (arch/s390/pci/pci_event.c:178). - drivers/pci/pci-driver.c: Makes pci_uevent_ers() available when building for s390 by expanding the ifdef to include CONFIG_S390 (drivers/pci/pci-driver.c:1591). - include/linux/pci.h: Similarly expands the prototype guard to include CONFIG_S390 so arch/s390 code can call it (include/linux/pci.h:2768).
- Why it matters (user-visible impact) - Brings s390 PCI recovery uevents to parity with AER and PowerPC EEH: - pci_uevent_ers() already emits ERROR_EVENT=BEGIN_RECOVERY / SUCCESSFUL_RECOVERY / FAILED_RECOVERY and DEVICE_ONLINE=0/1 to userspace (drivers/pci/pci-driver.c:1591). - AER and EEH already use these notifications; s390 previously did not. This omission prevents userspace from reacting consistently to PCI recovery events on s390 systems. - The change enables standard userspace tooling (udev rules, monitoring scripts) to receive the same recovery lifecycle events on s390 that they already get elsewhere, which can help automate remediation or logging. It’s a clear correctness/observability improvement, not a feature addition that changes kernel behavior.
- Scope and risk assessment - Small, contained change: - Adds three calls to pci_uevent_ers() in the s390 recovery path; no core recovery logic changed. - Only adjusts preprocessor guards to build pci_uevent_ers() for s390. No behavior change on non-s390. - Consistent with established patterns: - AER calls pci_uevent_ers() after error_detected() and on resume/failure; this patch mirrors that sequencing for s390. - Low regression risk: - Only additional KOBJ_CHANGE uevents are emitted during rare error recovery flows. - Calls occur under the same locking pattern used in AER (s390 uses pci_dev_lock/pci_dev_unlock, which wraps device_lock, consistent with AER’s device_lock usage), so no new locking hazards. - No ABI change; only adds uevents that other architectures already emit.
- Stable backport considerations - Dependencies: pci_uevent_ers() exists and is implemented in pci- driver.c (drivers/pci/pci-driver.c:1591) with a prototype in include/linux/pci.h (include/linux/pci.h:2768). Older stable series where pci_uevent_ers() lived in different guards may need the guard expansions this patch includes. For supported long-term series (4.19+, 5.4+, 5.10+, 5.15+, 6.1+), pci_uevent_ers() is already present; just ensure to add CONFIG_S390 to both the definition and the prototype guards as in this patch. - No major architectural changes; change is limited to s390 PCI recovery and one generic helper being compiled for s390. - While the commit message does not include Fixes:/Cc: stable tags, this is a correctness/behavior-parity fix affecting real userspace observability and is minimal risk, making it suitable for stable.
- Conclusion - This patch fixes a real behavioral gap on s390 by emitting standard PCI recovery uevents that already exist on other platforms. It is small, self-contained, and low risk, with clear user benefit. It should be backported to stable.
arch/s390/pci/pci_event.c | 3 +++ drivers/pci/pci-driver.c | 2 +- include/linux/pci.h | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c index d930416d4c903..b95376041501f 100644 --- a/arch/s390/pci/pci_event.c +++ b/arch/s390/pci/pci_event.c @@ -88,6 +88,7 @@ static pci_ers_result_t zpci_event_notify_error_detected(struct pci_dev *pdev, pci_ers_result_t ers_res = PCI_ERS_RESULT_DISCONNECT;
ers_res = driver->err_handler->error_detected(pdev, pdev->error_state); + pci_uevent_ers(pdev, ers_res); if (ers_result_indicates_abort(ers_res)) pr_info("%s: Automatic recovery failed after initial reporting\n", pci_name(pdev)); else if (ers_res == PCI_ERS_RESULT_NEED_RESET) @@ -244,6 +245,7 @@ static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev) ers_res = PCI_ERS_RESULT_RECOVERED;
if (ers_res != PCI_ERS_RESULT_RECOVERED) { + pci_uevent_ers(pdev, PCI_ERS_RESULT_DISCONNECT); pr_err("%s: Automatic recovery failed; operator intervention is required\n", pci_name(pdev)); status_str = "failed (driver can't recover)"; @@ -253,6 +255,7 @@ static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev) pr_info("%s: The device is ready to resume operations\n", pci_name(pdev)); if (driver->err_handler->resume) driver->err_handler->resume(pdev); + pci_uevent_ers(pdev, PCI_ERS_RESULT_RECOVERED); out_unlock: pci_dev_unlock(pdev); zpci_report_status(zdev, "recovery", status_str); diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 6405acdb5d0f3..302d61783f6c0 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -1582,7 +1582,7 @@ static int pci_uevent(const struct device *dev, struct kobj_uevent_env *env) return 0; }
-#if defined(CONFIG_PCIEAER) || defined(CONFIG_EEH) +#if defined(CONFIG_PCIEAER) || defined(CONFIG_EEH) || defined(CONFIG_S390) /** * pci_uevent_ers - emit a uevent during recovery path of PCI device * @pdev: PCI device undergoing error recovery diff --git a/include/linux/pci.h b/include/linux/pci.h index 59876de13860d..7735acf6f3490 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2764,7 +2764,7 @@ static inline bool pci_is_thunderbolt_attached(struct pci_dev *pdev) return false; }
-#if defined(CONFIG_PCIEPORTBUS) || defined(CONFIG_EEH) +#if defined(CONFIG_PCIEPORTBUS) || defined(CONFIG_EEH) || defined(CONFIG_S390) void pci_uevent_ers(struct pci_dev *pdev, enum pci_ers_result err_type); #endif