linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] PCI/ERR: s390/pci: Use pci_uevent_ers() in PCI recovery
@ 2025-06-23  8:41 Niklas Schnelle
  2025-06-23  8:41 ` [PATCH v2 1/2] PCI/AER: Fix missing uevent on recovery when a reset is requested Niklas Schnelle
  2025-06-23  8:41 ` [PATCH v2 2/2] PCI/ERR: s390/pci: Use pci_uevent_ers() in PCI recovery Niklas Schnelle
  0 siblings, 2 replies; 3+ messages in thread
From: Niklas Schnelle @ 2025-06-23  8:41 UTC (permalink / raw)
  To: Lukas Wunner, Bjorn Helgaas, Mahesh J Salgaonkar,
	Ilpo Järvinen, Gerald Schaefer, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev, Christian Borntraeger,
	Sven Schnelle, Peter Oberparleiter, Matthew Rosato,
	Oliver O'Halloran, Sinan Kaya, Keith Busch
  Cc: linuxppc-dev, linux-s390, linux-kernel, linux-pci,
	Niklas Schnelle

Hi All,

This series adds issuing of uevents during PCI recovery on s390. In
developing this I noticed that pci_uevent_ers() ignores
PCI_ERS_RESULT_NEED_RESET which  results in
AER not generating a uevent at the beginning of recovery if drivers
request a reset as it uses the result of error_detected() as parameter
to pci_uevent_ers(). This is fixed in the first patch and relied upon by
the s390 recovery code as it also uses the result of error_detected().

Thanks,
Niklas

Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
Changes in v2:
- Add a patch fixing pci_uevent_ers() mistakenly ignoring PCI_ERS_RESULT_NEED_RESET
- Use the result of error_detected() for initial pci_uevent_ers()
- Drop fixes tag in s390 patch
- Rebase and re-test on current master
- Link to v1: https://lore.kernel.org/r/20250424-add_err_uevents-v1-1-3384d6b779c6@linux.ibm.com

---
Niklas Schnelle (2):
      PCI/AER: Fix missing uevent on recovery when a reset is requested
      PCI/ERR: s390/pci: Use pci_uevent_ers() in PCI recovery

 arch/s390/pci/pci_event.c | 3 +++
 drivers/pci/pci-driver.c  | 3 ++-
 include/linux/pci.h       | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)
---
base-commit: 86731a2a651e58953fc949573895f2fa6d456841
change-id: 20250417-add_err_uevents-6f8d4d7ce09c

Best regards,
-- 
Niklas Schnelle


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

* [PATCH v2 1/2] PCI/AER: Fix missing uevent on recovery when a reset is requested
  2025-06-23  8:41 [PATCH v2 0/2] PCI/ERR: s390/pci: Use pci_uevent_ers() in PCI recovery Niklas Schnelle
@ 2025-06-23  8:41 ` Niklas Schnelle
  2025-06-23  8:41 ` [PATCH v2 2/2] PCI/ERR: s390/pci: Use pci_uevent_ers() in PCI recovery Niklas Schnelle
  1 sibling, 0 replies; 3+ messages in thread
From: Niklas Schnelle @ 2025-06-23  8:41 UTC (permalink / raw)
  To: Lukas Wunner, Bjorn Helgaas, Mahesh J Salgaonkar,
	Ilpo Järvinen, Gerald Schaefer, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev, Christian Borntraeger,
	Sven Schnelle, Peter Oberparleiter, Matthew Rosato,
	Oliver O'Halloran, Sinan Kaya, Keith Busch
  Cc: linuxppc-dev, linux-s390, linux-kernel, linux-pci,
	Niklas Schnelle

Since commit 7b42d97e99d3 ("PCI/ERR: Always report current recovery
status for udev") AER uses the result of error_detected() as parameter
to pci_uevent_ers(). As pci_uevent_ers() however does not handle
PCI_ERS_RESULT_NEED_RESET this results in a missing uevent for the
beginning of recovery if drivers request a reset. Fix this by treating
PCI_ERS_RESULT_NEED_RESET as beginning recovery.

Cc: stable@vger.kernel.org
Fixes: 7b42d97e99d3 ("PCI/ERR: Always report current recovery status for udev")
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
 drivers/pci/pci-driver.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 67db34fd10ee7101baeeaae1bb9bec3b13e2fdeb..94ba6938b7c6271b557cc7f17ffb89631d83827e 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1592,6 +1592,7 @@ void pci_uevent_ers(struct pci_dev *pdev, enum pci_ers_result err_type)
 	switch (err_type) {
 	case PCI_ERS_RESULT_NONE:
 	case PCI_ERS_RESULT_CAN_RECOVER:
+	case PCI_ERS_RESULT_NEED_RESET:
 		envp[idx++] = "ERROR_EVENT=BEGIN_RECOVERY";
 		envp[idx++] = "DEVICE_ONLINE=0";
 		break;

-- 
2.48.1


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

* [PATCH v2 2/2] PCI/ERR: s390/pci: Use pci_uevent_ers() in PCI recovery
  2025-06-23  8:41 [PATCH v2 0/2] PCI/ERR: s390/pci: Use pci_uevent_ers() in PCI recovery Niklas Schnelle
  2025-06-23  8:41 ` [PATCH v2 1/2] PCI/AER: Fix missing uevent on recovery when a reset is requested Niklas Schnelle
@ 2025-06-23  8:41 ` Niklas Schnelle
  1 sibling, 0 replies; 3+ messages in thread
From: Niklas Schnelle @ 2025-06-23  8:41 UTC (permalink / raw)
  To: Lukas Wunner, Bjorn Helgaas, Mahesh J Salgaonkar,
	Ilpo Järvinen, Gerald Schaefer, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev, Christian Borntraeger,
	Sven Schnelle, Peter Oberparleiter, Matthew Rosato,
	Oliver O'Halloran, Sinan Kaya, Keith Busch
  Cc: linuxppc-dev, linux-s390, linux-kernel, linux-pci,
	Niklas Schnelle

Issue uevents 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>
---
 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 2fbee3887d13aa28e0621aa7b6d673f4517b5461..cdbe603ec2f59d95ff92210742d39d7c20f26186 100644
--- a/arch/s390/pci/pci_event.c
+++ b/arch/s390/pci/pci_event.c
@@ -91,6 +91,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)
@@ -226,6 +227,7 @@ static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev)
 		ers_res = zpci_event_do_reset(pdev, driver);
 
 	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)";
@@ -235,6 +237,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 94ba6938b7c6271b557cc7f17ffb89631d83827e..2f3037050fd011108ef93e39d2d78a5c7e22fd05 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1578,7 +1578,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 05e68f35f39238f8b9ce08df97b384d1c1e89bbe..bcc412a21d93a6dcc566f011258ed39d80d896c2 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -2737,7 +2737,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
 

-- 
2.48.1


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

end of thread, other threads:[~2025-06-23  8:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-23  8:41 [PATCH v2 0/2] PCI/ERR: s390/pci: Use pci_uevent_ers() in PCI recovery Niklas Schnelle
2025-06-23  8:41 ` [PATCH v2 1/2] PCI/AER: Fix missing uevent on recovery when a reset is requested Niklas Schnelle
2025-06-23  8:41 ` [PATCH v2 2/2] PCI/ERR: s390/pci: Use pci_uevent_ers() in PCI recovery Niklas Schnelle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).