Skip to contentSkip to conversation

Error recovery for vfio-pci devices on s390x

PATCH Superseded Farhan Ali 3 participants 11 messages Jun 30 – Aug 17

Subsystems (5)
PCI s390 VFIO driver s390 PCI +1 more subsystems

v20 of 23 Superseded Latest is v23 →

lore
Share & tools
lore

Farhan Ali

author maintainer
#0 lore raw

v20 cover Error recovery for vfio-pci devices on s390x

Hi Alex,

This patch set includes only the VFIO patches of the original series for error recovery for vfio-pci devices on s390x [1]. Breaking up the patch series into PCI and VFIO only patches to make merging easier based on our discussion [2].

Thanks
Farhan

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

ChangeLog
---------
v19 https://lore.kernel.org/all/[email protected]/
v19 -> v20
- Change device feature uapi to pass the error data as opaque to userspace (patch 2).
- Rebase on 7.2-rc1

v18 https://lore.kernel.org/all/[email protected]/
v18 -> v19
- Fix hole in struct vfio_device_feature_zpci_err.
- Remove reset_done() callback for vfio-pci driver.
- Rebase on 7.1-rc7

v17 -> v18
- Print a warn with dev_warn_ratelimited() for copy_to_user failure.
- Rebase on 7.1-rc6.
- Break patch series into VFIO patch set.

Farhan Ali (3):
s390/pci: Store PCI error information for passthrough devices vfio-pci/zdev: Add a device feature for error information vfio/pci: Remove the pcie check for VFIO_PCI_ERR_IRQ_INDEX

 arch/s390/include/asm/pci.h       |  32 +++++++
 arch/s390/pci/pci.c               |   1 +
 arch/s390/pci/pci_event.c         | 137 +++++++++++++++++++-----------
 drivers/vfio/pci/vfio_pci_core.c  |  10 +--
 drivers/vfio/pci/vfio_pci_intrs.c |   3 +-
 drivers/vfio/pci/vfio_pci_priv.h  |   9 ++
 drivers/vfio/pci/vfio_pci_zdev.c  |  63 ++++++++++++--
 include/uapi/linux/vfio.h         |  23 +++++
 include/uapi/linux/vfio_zdev.h    |   2 +
 9 files changed, 216 insertions(+), 64 deletions(-)
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v20 1/3 s390/pci: Store PCI error information for passthrough devices

For a passthrough device we need co-operation from user space to recover the device. This would require to bubble up any error information to user space. Let's store this error information for passthrough devices, so it can be retrieved later.

We can now have userspace drivers (vfio-pci based) on s390x. The userspace drivers will not have any KVM fd and so no kzdev associated with them. So we need to update the logic for detecting passthrough devices to not depend on struct kvm_zdev.

---
 arch/s390/include/asm/pci.h      |  30 ++++++++
 arch/s390/pci/pci.c              |   1 +
 arch/s390/pci/pci_event.c        | 118 ++++++++++++++++++-------------
 drivers/vfio/pci/vfio_pci_zdev.c |  18 ++++-
 4 files changed, 113 insertions(+), 54 deletions(-)
arch/s390/include/asm/pci.h +30 -0
index 5dcf35f0f325..016386f7ef4a 100644
@@ -118,6 +118,32 @@ struct zpci_bus {
 	enum pci_bus_speed	max_bus_speed;
 };
 
+/* Content Code Description for PCI Function Error */
+struct zpci_ccdf_err {
+	u32 reserved1;
+	u32 fh;                         /* function handle */
+	u32 fid;                        /* function id */
+	u32 ett         :  4;           /* expected table type */
+	u32 mvn         : 12;           /* MSI vector number */
+	u32 dmaas       :  8;           /* DMA address space */
+	u32 reserved2   :  6;
+	u32 q           :  1;           /* event qualifier */
+	u32 rw          :  1;           /* read/write */
+	u64 faddr;                      /* failing address */
+	u32 reserved3;
+	u16 reserved4;
+	u16 pec;                        /* PCI event code */
+} __packed;
+
+#define ZPCI_ERR_PENDING_MAX 4
+struct zpci_ccdf_pending {
+	bool mediated_recovery;
+	u8 count;
+	u8 head;
+	u8 tail;
+	struct zpci_ccdf_err err[ZPCI_ERR_PENDING_MAX];
+};
+
 /* Private data per function */
 struct zpci_dev {
 	struct zpci_bus *zbus;
@@ -192,6 +218,8 @@ struct zpci_dev {
 	struct iommu_domain *s390_domain; /* attached IOMMU domain */
 	struct kvm_zdev *kzdev;
 	struct mutex kzdev_lock;
+	struct zpci_ccdf_pending pending_errs;
+	struct mutex pending_errs_lock;
 	spinlock_t dom_lock;		/* protect s390_domain change */
 };
 
@@ -334,6 +362,8 @@ void zpci_debug_exit_device(struct zpci_dev *);
 int zpci_report_error(struct pci_dev *, struct zpci_report_error_header *);
 int zpci_clear_error_state(struct zpci_dev *zdev);
 int zpci_reset_load_store_blocked(struct zpci_dev *zdev);
+void zpci_start_mediated_recovery(struct zpci_dev *zdev);
+void zpci_stop_mediated_recovery(struct zpci_dev *zdev);
 
 #ifdef CONFIG_NUMA
 
arch/s390/pci/pci.c +1 -0
index 39bd2adfc240..2d377c2e194d 100644
@@ -842,6 +842,7 @@ struct zpci_dev *zpci_create_device(u32 fid, u32 fh, enum zpci_state state)
 	mutex_init(&zdev->state_lock);
 	mutex_init(&zdev->fmb_lock);
 	mutex_init(&zdev->kzdev_lock);
+	mutex_init(&zdev->pending_errs_lock);
 
 	return zdev;
 
arch/s390/pci/pci_event.c +67 -51

188 lines not on this page · raw message

drivers/vfio/pci/vfio_pci_zdev.c +15 -3
index 0990fdb146b7..78a28db00c6d 100644
@@ -144,24 +144,36 @@ int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
 int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev)
 {
 	struct zpci_dev *zdev = to_zpci(vdev->pdev);
+	int ret;
 
 	if (!zdev)
 		return -ENODEV;
 
+	zpci_start_mediated_recovery(zdev);
+
 	if (!vdev->vdev.kvm)
 		return 0;
 
+	ret = -ENOENT;
 	if (zpci_kvm_hook.kvm_register)
-		return zpci_kvm_hook.kvm_register(zdev, vdev->vdev.kvm);
+		ret = zpci_kvm_hook.kvm_register(zdev, vdev->vdev.kvm);
 
-	return -ENOENT;
+	if (ret)
+		zpci_stop_mediated_recovery(zdev);
+
+	return ret;
 }
 
 void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev)
 {
 	struct zpci_dev *zdev = to_zpci(vdev->pdev);
 
-	if (!zdev || !vdev->vdev.kvm)
+	if (!zdev)
+		return;
+
+	zpci_stop_mediated_recovery(zdev);
+
+	if (!vdev->vdev.kvm)
 		return;
 
 	if (zpci_kvm_hook.kvm_unregister)
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH v20 1/3] s390/pci: Store PCI error information for passthrough devices

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines

For a passthrough device we need co-operation from user space to recover the device. This would require to bubble up any error information to user space. Let's store this error information for passthrough devices, so it can be retrieved later.

Quoted 8 lines

We can now have userspace drivers (vfio-pci based) on s390x. The userspace drivers will not have any KVM fd and so no kzdev associated with them. So we need to update the logic for detecting passthrough devices to not depend on struct kvm_zdev.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#3 lore raw

PATCH v20 2/3 vfio-pci/zdev: Add a device feature for error information

In reply to Farhan Ali

For zPCI devices, we have platform specific error information. The platform firmware provides this error information to the operating system in an architecture specific mechanism. To enable recovery from userspace for these devices, we want to expose this error information to userspace. Add a new device feature to expose this information.

Userspace needs to be provide a buffer of fixed size. This size is provided to userspace via the VFIO_DEVICE_INFO_CAP_ZPCI_BASE capability.

---
 arch/s390/include/asm/pci.h      |  2 ++
 arch/s390/pci/pci_event.c        | 19 ++++++++++++++
 drivers/vfio/pci/vfio_pci_core.c |  2 ++
 drivers/vfio/pci/vfio_pci_priv.h |  9 +++++++
 drivers/vfio/pci/vfio_pci_zdev.c | 45 ++++++++++++++++++++++++++++++--
 include/uapi/linux/vfio.h        | 23 ++++++++++++++++
 include/uapi/linux/vfio_zdev.h   |  2 ++
 7 files changed, 100 insertions(+), 2 deletions(-)
arch/s390/include/asm/pci.h +2 -0
index 016386f7ef4a..88a125b92bdd 100644
@@ -364,6 +364,8 @@ int zpci_clear_error_state(struct zpci_dev *zdev);
 int zpci_reset_load_store_blocked(struct zpci_dev *zdev);
 void zpci_start_mediated_recovery(struct zpci_dev *zdev);
 void zpci_stop_mediated_recovery(struct zpci_dev *zdev);
+int zpci_get_pending_error(struct zpci_dev *zdev,
+			   struct zpci_ccdf_err *ccdf);
 
 #ifdef CONFIG_NUMA
 
arch/s390/pci/pci_event.c +19 -0
index 8934b640a095..3ad16038e005 100644
@@ -77,6 +77,25 @@ static int zpci_store_pci_error(struct pci_dev *pdev,
 	return 0;
 }
 
+int zpci_get_pending_error(struct zpci_dev *zdev,
+			   struct zpci_ccdf_err *ccdf)
+{
+	int head = 0;
+
+	guard(mutex)(&zdev->pending_errs_lock);
+
+	if (!zdev->pending_errs.count)
+		return -ENOMSG;
+
+	head = zdev->pending_errs.head % ZPCI_ERR_PENDING_MAX;
+	memcpy(ccdf, &zdev->pending_errs.err[head],
+	       sizeof(struct zpci_ccdf_err));
+	zdev->pending_errs.head++;
+	zdev->pending_errs.count--;
+	return 0;
+}
+EXPORT_SYMBOL_GPL(zpci_get_pending_error);
+
 void zpci_start_mediated_recovery(struct zpci_dev *zdev)
 {
 	guard(mutex)(&zdev->pending_errs_lock);
drivers/vfio/pci/vfio_pci_core.c +2 -0
index a28f1e99362c..5a6786feadd7 100644
@@ -1572,6 +1572,8 @@ int vfio_pci_core_ioctl_feature(struct vfio_device *device, u32 flags,
 		return vfio_pci_core_feature_token(vdev, flags, arg, argsz);
 	case VFIO_DEVICE_FEATURE_DMA_BUF:
 		return vfio_pci_core_feature_dma_buf(vdev, flags, arg, argsz);
+	case VFIO_DEVICE_FEATURE_ZPCI_ERROR:
+		return vfio_pci_zdev_feature_err(device, flags, arg, argsz);
 	default:
 		return -ENOTTY;
 	}
drivers/vfio/pci/vfio_pci_priv.h +9 -0
index fca9d0dfac90..4e7162234a2e 100644
@@ -93,6 +93,8 @@ int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
 				struct vfio_info_cap *caps);
 int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev);
 void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev);
+int vfio_pci_zdev_feature_err(struct vfio_device *device, u32 flags,
+			      void __user *arg, size_t argsz);
 #else
 static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
 					      struct vfio_info_cap *caps)
@@ -107,6 +109,13 @@ static inline int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev)
 
 static inline void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev)
 {}
+
+static inline int vfio_pci_zdev_feature_err(struct vfio_device *device,
+					    u32 flags, void __user *arg,
+					    size_t argsz)
+{
+	return -ENOTTY;
+}
 #endif
 
 static inline bool vfio_pci_is_vga(struct pci_dev *pdev)
drivers/vfio/pci/vfio_pci_zdev.c +43 -2

63 lines not on this page · raw message

include/uapi/linux/vfio.h +23 -0
index 5de618a3a5ee..6d224e7e9fa2 100644
@@ -1534,6 +1534,29 @@ struct vfio_device_feature_dma_buf {
  */
 #define VFIO_DEVICE_FEATURE_MIG_PRECOPY_INFOv2  12
 
+/**
+ * VFIO_DEVICE_FEATURE_ZPCI_ERROR feature provides PCI error information to
+ * userspace for vfio-pci devices on s390. On s390, PCI error recovery
+ * involves platform firmware and notification to operating systems is done
+ * by architecture specific mechanism. Exposing this information to
+ * userspace allows it to take appropriate actions to handle an
+ * error on the device.
+ *
+ * Userspace provides an opaque buffer of fixed length, and the kernel
+ * fills it with the zpci_ccdf_err data structure. The length of
+ * zpci_ccdf_err is provided to userspace via the
+ * VFIO_DEVICE_INFO_CAP_ZPCI_BASE capability.
+ *
+ * The ioctl returns -ENOMSG if there are no pending PCI errors.
+ */
+
+
+struct vfio_device_feature_zpci_err {
+	__aligned_u64 data;
+};
+
+#define VFIO_DEVICE_FEATURE_ZPCI_ERROR 13
+
 /* -------- API for Type1 VFIO IOMMU -------- */
 
 /**
include/uapi/linux/vfio_zdev.h +2 -0
index 77f2aff1f27e..d6c1175c884e 100644
@@ -32,6 +32,8 @@ struct vfio_device_info_cap_zpci_base {
 	/* End of version 1 */
 	__u32 fh;		/* PCI function handle */
 	/* End of version 2 */
+	__u32 ccdf_err_length;	/* PCI CCDF length */
+	/* End of version 3 */
 };
 
 /**
Signature · 1 line
2.43.0
#4 lore raw

Re: [PATCH v20 2/3] vfio-pci/zdev: Add a device feature for error information

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 6 lines

For zPCI devices, we have platform specific error information. The platform firmware provides this error information to the operating system in an architecture specific mechanism. To enable recovery from userspace for these devices, we want to expose this error information to userspace. Add a new device feature to expose this information.

Quoted 6 lines

Userspace needs to be provide a buffer of fixed size. This size is provided to userspace via the VFIO_DEVICE_INFO_CAP_ZPCI_BASE capability.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
maintainer
#5 lore raw

Re: [PATCH v20 2/3] vfio-pci/zdev: Add a device feature for error information

In reply to Farhan Ali
Quoted 40 lines · On Tue, 30 Jun 2026 09:55:52 -0700 Farhan Ali <[email protected]> wrote:

For zPCI devices, we have platform specific error information. The platform firmware provides this error information to the operating system in an architecture specific mechanism. To enable recovery from userspace for these devices, we want to expose this error information to userspace. Add a new device feature to expose this information.

Userspace needs to be provide a buffer of fixed size. This size is provided to userspace via the VFIO_DEVICE_INFO_CAP_ZPCI_BASE capability.

---
 arch/s390/include/asm/pci.h      |  2 ++
 arch/s390/pci/pci_event.c        | 19 ++++++++++++++
 drivers/vfio/pci/vfio_pci_core.c |  2 ++
 drivers/vfio/pci/vfio_pci_priv.h |  9 +++++++
 drivers/vfio/pci/vfio_pci_zdev.c | 45 ++++++++++++++++++++++++++++++--
 include/uapi/linux/vfio.h        | 23 ++++++++++++++++
 include/uapi/linux/vfio_zdev.h   |  2 ++
 7 files changed, 100 insertions(+), 2 deletions(-)
arch/s390/include/asm/pci.h +2 -0
index 016386f7ef4a..88a125b92bdd 100644
@@ -364,6 +364,8 @@ int zpci_clear_error_state(struct zpci_dev *zdev);
 int zpci_reset_load_store_blocked(struct zpci_dev *zdev);
 void zpci_start_mediated_recovery(struct zpci_dev *zdev);
 void zpci_stop_mediated_recovery(struct zpci_dev *zdev);
+int zpci_get_pending_error(struct zpci_dev *zdev,
+			   struct zpci_ccdf_err *ccdf);
 
 #ifdef CONFIG_NUMA
 
arch/s390/pci/pci_event.c +0 -0
index 8934b640a095..3ad16038e005 100644

arch/s390/pci/pci_event.c static int zpci_store_pci_error(struct pci_dev *pdev, · line 83

Quoted 7 lines
arch/s390/pci/pci_event.c +4 -0
@@ -77,6 +77,25 @@ static int zpci_store_pci_error(struct pci_dev *pdev,
 	return 0;
 }
 
+int zpci_get_pending_error(struct zpci_dev *zdev,
+			   struct zpci_ccdf_err *ccdf)
+{
+	int head = 0;

Nit, unnecessary initialization.

Otherwise LGTM and I can drop the initialization on commit if there's no other reason for respin. I think we just need a branch from Bjorn to base this on once he's happy with the PCI series. Thanks,

Alex

Quoted 18 lines
arch/s390/pci/pci_event.c +15 -0
+
+	guard(mutex)(&zdev->pending_errs_lock);
+
+	if (!zdev->pending_errs.count)
+		return -ENOMSG;
+
+	head = zdev->pending_errs.head % ZPCI_ERR_PENDING_MAX;
+	memcpy(ccdf, &zdev->pending_errs.err[head],
+	       sizeof(struct zpci_ccdf_err));
+	zdev->pending_errs.head++;
+	zdev->pending_errs.count--;
+	return 0;
+}
+EXPORT_SYMBOL_GPL(zpci_get_pending_error);
+
 void zpci_start_mediated_recovery(struct zpci_dev *zdev)
 {
 	guard(mutex)(&zdev->pending_errs_lock);
author maintainer
#6 lore raw

Re: [PATCH v20 2/3] vfio-pci/zdev: Add a device feature for error information

Quoted 52 lines · Alex Williamson
Quoted 40 lines · On Tue, 30 Jun 2026 09:55:52 -0700 Farhan Ali <[email protected]> wrote:

For zPCI devices, we have platform specific error information. The platform firmware provides this error information to the operating system in an architecture specific mechanism. To enable recovery from userspace for these devices, we want to expose this error information to userspace. Add a new device feature to expose this information.

Userspace needs to be provide a buffer of fixed size. This size is provided to userspace via the VFIO_DEVICE_INFO_CAP_ZPCI_BASE capability.

---
  arch/s390/include/asm/pci.h      |  2 ++
  arch/s390/pci/pci_event.c        | 19 ++++++++++++++
  drivers/vfio/pci/vfio_pci_core.c |  2 ++
  drivers/vfio/pci/vfio_pci_priv.h |  9 +++++++
  drivers/vfio/pci/vfio_pci_zdev.c | 45 ++++++++++++++++++++++++++++++--
  include/uapi/linux/vfio.h        | 23 ++++++++++++++++
  include/uapi/linux/vfio_zdev.h   |  2 ++
  7 files changed, 100 insertions(+), 2 deletions(-)
arch/s390/include/asm/pci.h +2 -0
index 016386f7ef4a..88a125b92bdd 100644
@@ -364,6 +364,8 @@ int zpci_clear_error_state(struct zpci_dev *zdev);
  int zpci_reset_load_store_blocked(struct zpci_dev *zdev);
  void zpci_start_mediated_recovery(struct zpci_dev *zdev);
  void zpci_stop_mediated_recovery(struct zpci_dev *zdev);
+int zpci_get_pending_error(struct zpci_dev *zdev,
+			   struct zpci_ccdf_err *ccdf);
 
  #ifdef CONFIG_NUMA
 
arch/s390/pci/pci_event.c +0 -0
index 8934b640a095..3ad16038e005 100644

arch/s390/pci/pci_event.c static int zpci_store_pci_error(struct pci_dev *pdev, · line 83

Quoted 7 lines
arch/s390/pci/pci_event.c +4 -0
@@ -77,6 +77,25 @@ static int zpci_store_pci_error(struct pci_dev *pdev,
  	return 0;
  }
 
+int zpci_get_pending_error(struct zpci_dev *zdev,
+			   struct zpci_ccdf_err *ccdf)
+{
+	int head = 0;

Nit, unnecessary initialization.

Quoted 5 lines

Otherwise LGTM and I can drop the initialization on commit if there's no other reason for respin. I think we just need a branch from Bjorn to base this on once he's happy with the PCI series. Thanks,

Alex

Hi Alex,

Bjorn has accepted the PCI patches and merged it to his pci/slot tree[1]. Would you be able to merge the vfio patches? I was able to apply these patches on 7.2-rc7 and didn't have any conflicts. But let me know if you need me to respin.

Thanks again for all your help reviewing this series.

Thanks

Farhan

Quoted 19 lines
Quoted 19 lines
arch/s390/pci/pci_event.c +15 -0
+
+	guard(mutex)(&zdev->pending_errs_lock);
+
+	if (!zdev->pending_errs.count)
+		return -ENOMSG;
+
+	head = zdev->pending_errs.head % ZPCI_ERR_PENDING_MAX;
+	memcpy(ccdf, &zdev->pending_errs.err[head],
+	       sizeof(struct zpci_ccdf_err));
+	zdev->pending_errs.head++;
+	zdev->pending_errs.count--;
+	return 0;
+}
+EXPORT_SYMBOL_GPL(zpci_get_pending_error);
+
  void zpci_start_mediated_recovery(struct zpci_dev *zdev)
  {
  	guard(mutex)(&zdev->pending_errs_lock);
maintainer
#7 lore raw

Re: [PATCH v20 2/3] vfio-pci/zdev: Add a device feature for error information

Quoted 6 lines · On Thu, 13 Aug 2026 09:26:14 -0700 Farhan Ali <[email protected]> wrote:
Quoted 5 lines · Alex Williamson

Otherwise LGTM and I can drop the initialization on commit if there's no other reason for respin. I think we just need a branch from Bjorn to base this on once he's happy with the PCI series. Thanks,

Quoted 8 lines
Quoted 1 line

Alex

Hi Alex,

Bjorn has accepted the PCI patches and merged it to his pci/slot tree[1]. Would you be able to merge the vfio patches? I was able to apply these patches on 7.2-rc7 and didn't have any conflicts. But let me know if you need me to respin.

It wasn't clear that the pci/slot branch was going to get merged into pci/next given the discussion last week, but that has finally occurred. I merged Bjorn's branch, applied this, and pushed it out to the vfio next branch as hopefully the last changes for v7.3. Thanks,

Alex

author maintainer
#8 lore raw

PATCH v20 3/3 vfio/pci: Remove the pcie check for VFIO_PCI_ERR_IRQ_INDEX

In reply to Farhan Ali

The error signaling is configured for the vast majority of devices and it's extremely rare that it fires anyway. Removing the pcie check will allow userspace to be notified on errors for legacy PCI devices. The Internal Shared Memory (ISM) device on s390 is one such device. For PCI devices on IBM s390 error recovery involves platform firmware and notification to operating system is done by architecture specific way. So the ISM device can still be recovered when notified of an error.

---
 drivers/vfio/pci/vfio_pci_core.c  | 8 ++------
 drivers/vfio/pci/vfio_pci_intrs.c | 3 +--
 2 files changed, 3 insertions(+), 8 deletions(-)
drivers/vfio/pci/vfio_pci_core.c +2 -6
index 5a6786feadd7..077a122fb602 100644
@@ -824,8 +824,7 @@ static int vfio_pci_get_irq_count(struct vfio_pci_core_device *vdev, int irq_typ
 			return (flags & PCI_MSIX_FLAGS_QSIZE) + 1;
 		}
 	} else if (irq_type == VFIO_PCI_ERR_IRQ_INDEX) {
-		if (pci_is_pcie(vdev->pdev))
-			return 1;
+		return 1;
 	} else if (irq_type == VFIO_PCI_REQ_IRQ_INDEX) {
 		return 1;
 	}
@@ -1201,11 +1200,8 @@ static int vfio_pci_ioctl_get_irq_info(struct vfio_pci_core_device *vdev,
 	switch (info.index) {
 	case VFIO_PCI_INTX_IRQ_INDEX ... VFIO_PCI_MSIX_IRQ_INDEX:
 	case VFIO_PCI_REQ_IRQ_INDEX:
-		break;
 	case VFIO_PCI_ERR_IRQ_INDEX:
-		if (pci_is_pcie(vdev->pdev))
-			break;
-		fallthrough;
+		break;
 	default:
 		return -EINVAL;
 	}
drivers/vfio/pci/vfio_pci_intrs.c +1 -2
index 33944d4d9dc4..64f80f64ff57 100644
@@ -859,8 +859,7 @@ int vfio_pci_set_irqs_ioctl(struct vfio_pci_core_device *vdev, uint32_t flags,
 	case VFIO_PCI_ERR_IRQ_INDEX:
 		switch (flags & VFIO_IRQ_SET_ACTION_TYPE_MASK) {
 		case VFIO_IRQ_SET_ACTION_TRIGGER:
-			if (pci_is_pcie(vdev->pdev))
-				func = vfio_pci_set_err_trigger;
+			func = vfio_pci_set_err_trigger;
 			break;
 		}
 		break;
Signature · 1 line
2.43.0
#9 lore raw

Re: [PATCH v20 3/3] vfio/pci: Remove the pcie check for VFIO_PCI_ERR_IRQ_INDEX

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines

The error signaling is configured for the vast majority of devices and it's extremely rare that it fires anyway. Removing the pcie check will allow userspace to be notified on errors for legacy PCI devices. The Internal Shared Memory (ISM) device on s390 is one such device. For PCI devices on IBM s390 error recovery involves platform firmware and notification to operating system is done by architecture specific way. So the ISM device can still be recovered when notified of an error.

Quoted 4 lines

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
author maintainer
#10 lore raw
In reply to Farhan Ali

Polite ping for the series.

Thanks

Farhan

Quoted 49 lines · Farhan Ali

Hi Alex,

This patch set includes only the VFIO patches of the original series for error recovery for vfio-pci devices on s390x [1]. Breaking up the patch series into PCI and VFIO only patches to make merging easier based on our discussion [2].

Thanks
Farhan

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

ChangeLog
---------
v19 https://lore.kernel.org/all/[email protected]/
v19 -> v20
- Change device feature uapi to pass the error data as opaque to userspace (patch 2).
- Rebase on 7.2-rc1

v18 https://lore.kernel.org/all/[email protected]/
v18 -> v19
- Fix hole in struct vfio_device_feature_zpci_err.
- Remove reset_done() callback for vfio-pci driver.
- Rebase on 7.1-rc7

v17 -> v18
- Print a warn with dev_warn_ratelimited() for copy_to_user failure.
- Rebase on 7.1-rc6.
- Break patch series into VFIO patch set.

Farhan Ali (3):
s390/pci: Store PCI error information for passthrough devices vfio-pci/zdev: Add a device feature for error information vfio/pci: Remove the pcie check for VFIO_PCI_ERR_IRQ_INDEX

  arch/s390/include/asm/pci.h       |  32 +++++++
  arch/s390/pci/pci.c               |   1 +
  arch/s390/pci/pci_event.c         | 137 +++++++++++++++++++-----------
  drivers/vfio/pci/vfio_pci_core.c  |  10 +--
  drivers/vfio/pci/vfio_pci_intrs.c |   3 +-
  drivers/vfio/pci/vfio_pci_priv.h  |   9 ++
  drivers/vfio/pci/vfio_pci_zdev.c  |  63 ++++++++++++--
  include/uapi/linux/vfio.h         |  23 +++++
  include/uapi/linux/vfio_zdev.h    |   2 +
  9 files changed, 216 insertions(+), 64 deletions(-)