Skip to contentSkip to conversation

EEH Support for VFIO PCI device

RFC PATCH Superseded Gavin Shan 4 participants 32 messages May 20, 2014 – Jun 3, 2014

Subsystems (3)

v4 of 19 Superseded Latest is v19 →

lore
Share & tools
lore

Gavin Shan

author
#0 lore raw

v4 cover EEH Support for VFIO PCI device

The series of patches intends to support EEH for PCI devices, which are passed through to PowerKVM based guest via VFIO. The implementation is straightforward based on the issues or problems we have to resolve to support EEH for PowerKVM based guest.

- Emulation for EEH RTAS requests. All EEH RTAS requests goes to QEMU firstly. If QEMU can't handle it, the request will be sent to host via newly introduced VFIO container IOCTL command (VFIO_EEH_OP) and gets handled in host kernel.

The series of patches requires corresponding QEMU changes.

Change log
=====
v1 -> v2:
* EEH RTAS requests are routed to QEMU, and then possiblly to host kerenl. The mechanism KVM in-kernel handling is dropped.
* Error injection is reimplemented based syscall, instead of KVM in-kerenl handling. The logic for error injection token management is moved to QEMU. The error injection request is routed to QEMU and then possiblly to host kernel.
v2 -> v3:
* Make the fields in struct eeh_vfio_pci_addr, struct vfio_eeh_info based on the comments from Alexey.
* Define macros for EEH VFIO operations (Alexey).
* Clear frozen state after successful PE reset.
* Merge original [PATCH 1/2/3] to one.
v3 -> v4:
* Remove the error injection from the patchset. Mike or I will work on that later.
* Rename CONFIG_VFIO_EEH to VFIO_PCI_EEH.
* Rename the IOCTL command to VFIO_EEH_OP and it's handled by VFIO-PCI device instead of VFIO container.
* Rename the IOCTL argument structure to "vfio_eeh_op" accordingly. Also, more fields added to hold return values for RTAS requests.
* The address mapping stuff is totally removed. When opening or releasing VFIO PCI device, notification sent to EEH to update the flags indicates the device is passed to guest or not.
* Change pr_warn() to pr_debug() to avoid DOS as pointed by Alex.W
* Argument size check issue pointed by Alex.W.

Testing on P7
======
- Emulex adapter

Testing on P8
======Need testing for more after the code is finalized. The logic is required by P7/P8 machines shouldn't be different.

Gavin Shan (4):
drivers/vfio: Introduce CONFIG_VFIO_PCI_EEH
powerpc/eeh: Flags for passed device and PE
drivers/vfio: New IOCTL command VFIO_EEH_INFO
powerpc/eeh: Avoid event on passed PE

 arch/powerpc/include/asm/eeh.h            |  32 +++
 arch/powerpc/kernel/eeh.c                 |   8 +
 arch/powerpc/platforms/powernv/Makefile   |   1 +
 arch/powerpc/platforms/powernv/eeh-ioda.c |   3 +-
 arch/powerpc/platforms/powernv/eeh-vfio.c | 445 ++++++++++++++++++++++++++++++
 drivers/vfio/pci/Kconfig                  |   6 +
 drivers/vfio/pci/vfio_pci.c               |  24 +-
 drivers/vfio/pci/vfio_pci_private.h       |  16 ++
 include/uapi/linux/vfio.h                 |  43 +++
 9 files changed, 571 insertions(+), 7 deletions(-)
 create mode 100644 arch/powerpc/platforms/powernv/eeh-vfio.c
Signature · 1 line
1.8.3.2
author
#1 lore raw

PATCH v4 1/4 drivers/vfio: Introduce CONFIG_VFIO_PCI_EEH

The patch introduces CONFIG_VFIO_PCI_EEH for more IOCTL commands on VFIO PCI device support EEH funtionality for PCI devices that are passed through from host to guest.

---
 drivers/vfio/pci/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/vfio/pci/Kconfig +6 -0
index c41b01e..dd0e0f0 100644
@@ -1,6 +1,7 @@
 config VFIO_PCI
 	tristate "VFIO support for PCI devices"
 	depends on VFIO && PCI && EVENTFD
+	select VFIO_PCI_EEH if PPC_POWERNV
 	help
 	  Support for the PCI VFIO bus driver.  This is required to make
 	  use of PCI drivers using the VFIO framework.
@@ -16,3 +17,8 @@ config VFIO_PCI_VGA
 	  BIOS and generic video drivers.
 
 	  If you don't know what to do here, say N.
+
+config VFIO_PCI_EEH
+	tristate
+	depends on EEH && VFIO_IOMMU_SPAPR_TCE
+	default n
Signature · 1 line
1.8.3.2
author
#2 lore raw

PATCH v4 2/4 powerpc/eeh: Flags for passed device and PE

In reply to Gavin Shan

The patch introduces new flags for EEH device and PE to indicate that the device or PE has been passed through to guest. In turn, we will deliver EEH errors to guest for further handling, which will be done in subsequent patches.

---
 arch/powerpc/include/asm/eeh.h | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
arch/powerpc/include/asm/eeh.h +32 -0
index 7782056..34a2d83 100644
@@ -72,6 +72,7 @@ struct device_node;
 #define EEH_PE_RESET		(1 << 2)	/* PE reset in progress	*/
 
 #define EEH_PE_KEEP		(1 << 8)	/* Keep PE on hotplug	*/
+#define EEH_PE_PASSTHROUGH	(1 << 9)	/* PE owned by guest	*/
 
 struct eeh_pe {
 	int type;			/* PE type: PHB/Bus/Device	*/
@@ -93,6 +94,21 @@ struct eeh_pe {
 #define eeh_pe_for_each_dev(pe, edev, tmp) \
 		list_for_each_entry_safe(edev, tmp, &pe->edevs, list)
 
+static inline bool eeh_pe_passed(struct eeh_pe *pe)
+{
+	return pe ? !!(pe->state & EEH_PE_PASSTHROUGH) : false;
+}
+
+static inline void eeh_pe_set_passed(struct eeh_pe *pe, bool passed)
+{
+	if (pe) {
+		if (passed)
+			pe->state |= EEH_PE_PASSTHROUGH;
+		else
+			pe->state &= ~EEH_PE_PASSTHROUGH;
+	}
+}
+
 /*
  * The struct is used to trace EEH state for the associated
  * PCI device node or PCI device. In future, it might
@@ -110,6 +126,7 @@ struct eeh_pe {
 #define EEH_DEV_SYSFS		(1 << 9)	/* Sysfs created	*/
 #define EEH_DEV_REMOVED		(1 << 10)	/* Removed permanently	*/
 #define EEH_DEV_FRESET		(1 << 11)	/* Fundamental reset	*/
+#define EEH_DEV_PASSTHROUGH	(1 << 12)	/* Owned by guest	*/
 
 struct eeh_dev {
 	int mode;			/* EEH mode			*/
@@ -138,6 +155,21 @@ static inline struct pci_dev *eeh_dev_to_pci_dev(struct eeh_dev *edev)
 	return edev ? edev->pdev : NULL;
 }
 
+static inline bool eeh_dev_passed(struct eeh_dev *dev)
+{
+	return dev ? !!(dev->mode & EEH_DEV_PASSTHROUGH) : false;
+}
+
+static inline void eeh_dev_set_passed(struct eeh_dev *dev, bool passed)
+{
+	if (dev) {
+		if (passed)
+			dev->mode |= EEH_DEV_PASSTHROUGH;
+		else
+			dev->mode &= ~EEH_DEV_PASSTHROUGH;
+	}
+}
+
 /* Return values from eeh_ops::next_error */
 enum {
 	EEH_NEXT_ERR_NONE = 0,
Signature · 1 line
1.8.3.2
author
#3 lore raw

PATCH v4 3/4 drivers/vfio: New IOCTL command VFIO_EEH_INFO

In reply to Gavin Shan

The patch adds new IOCTL command VFIO_EEH_OP to VFIO PCI device to support EEH functionality for PCI devices, which have been passed from host to guest via VFIO.

---
 arch/powerpc/platforms/powernv/Makefile   |   1 +
 arch/powerpc/platforms/powernv/eeh-vfio.c | 445 ++++++++++++++++++++++++++++++
 drivers/vfio/pci/vfio_pci.c               |  24 +-
 drivers/vfio/pci/vfio_pci_private.h       |  16 ++
 include/uapi/linux/vfio.h                 |  43 +++
 5 files changed, 523 insertions(+), 6 deletions(-)
 create mode 100644 arch/powerpc/platforms/powernv/eeh-vfio.c
arch/powerpc/platforms/powernv/Makefile +1 -0
index 63cebb9..45cd833 100644
@@ -6,5 +6,6 @@ obj-y			+= opal-msglog.o
 obj-$(CONFIG_SMP)	+= smp.o
 obj-$(CONFIG_PCI)	+= pci.o pci-p5ioc2.o pci-ioda.o
 obj-$(CONFIG_EEH)	+= eeh-ioda.o eeh-powernv.o
+obj-$(CONFIG_VFIO_PCI_EEH)	+= eeh-vfio.o
 obj-$(CONFIG_PPC_SCOM)	+= opal-xscom.o
 obj-$(CONFIG_MEMORY_FAILURE)	+= opal-memory-errors.o
arch/powerpc/platforms/powernv/eeh-vfio.c new file +445 -0

445 lines not on this page · raw message

drivers/vfio/pci/vfio_pci.c +18 -6
index 7ba0424..ee82c7f 100644
@@ -156,8 +156,11 @@ static void vfio_pci_release(void *device_data)
 {
 	struct vfio_pci_device *vdev = device_data;
 
-	if (atomic_dec_and_test(&vdev->refcnt))
+
+	if (atomic_dec_and_test(&vdev->refcnt)) {
+		eeh_vfio_pci_release(vdev->pdev);
 		vfio_pci_disable(vdev);
+	}
 
 	module_put(THIS_MODULE);
 }
@@ -165,19 +168,26 @@ static void vfio_pci_release(void *device_data)
 static int vfio_pci_open(void *device_data)
 {
 	struct vfio_pci_device *vdev = device_data;
+	int ret;
 
 	if (!try_module_get(THIS_MODULE))
 		return -ENODEV;
 
 	if (atomic_inc_return(&vdev->refcnt) = 1) {
-		int ret = vfio_pci_enable(vdev);
-		if (ret) {
-			module_put(THIS_MODULE);
-			return ret;
-		}
+		ret = vfio_pci_enable(vdev);
+		if (ret)
+			goto error;
+
+		ret = eeh_vfio_pci_open(vdev->pdev);
+		if (ret)
+			goto error;
 	}
 
 	return 0;
+
+error:
+	module_put(THIS_MODULE);
+	return ret;
 }
 
 static int vfio_pci_get_irq_count(struct vfio_pci_device *vdev, int irq_type)
@@ -682,6 +692,8 @@ hot_reset_release:
 
 		kfree(groups);
 		return ret;
+	} else if (cmd = VFIO_EEH_OP) {
+		return eeh_vfio_pci_ioctl(vdev->pdev, arg);
 	}
 
 	return -ENOTTY;
drivers/vfio/pci/vfio_pci_private.h +16 -0
index 9c6d5d0..1273bb6 100644
@@ -90,4 +90,20 @@ extern void vfio_pci_virqfd_exit(void);
 
 extern int vfio_config_init(struct vfio_pci_device *vdev);
 extern void vfio_config_free(struct vfio_pci_device *vdev);
+
+#ifdef CONFIG_VFIO_PCI_EEH
+extern int eeh_vfio_pci_open(struct pci_dev *pdev);
+extern void eeh_vfio_pci_release(struct pci_dev *pdev);
+extern int eeh_vfio_pci_ioctl(struct pci_dev *pdev, unsigned long arg);
+#else
+static inline int eeh_vfio_pci_open(struct pci_dev *pdev)
+{
+	return 0;
+}
+static inline eeh_vfio_pci_release(struct pci_dev *pdev) { }
+static int eeh_vfio_pci_ioctl(struct pci_dev *pdev, unsigned long arg)
+{
+	return -ENOENT;
+}
+#endif /* COFNIG_VFIO_PCI_EEH */
 #endif /* VFIO_PCI_PRIVATE_H */
include/uapi/linux/vfio.h +43 -0

49 lines not on this page · raw message

Signature · 1 line
1.8.3.2
#4 lore raw

Re: [PATCH 3/4] drivers/vfio: New IOCTL command VFIO_EEH_INFO

Quoted 5 lines · Gavin Shan

The patch adds new IOCTL command VFIO_EEH_OP to VFIO PCI device to support EEH functionality for PCI devices, which have been passed from host to guest via VFIO.

Quoted 8 lines
---
  arch/powerpc/platforms/powernv/Makefile   |   1 +
  arch/powerpc/platforms/powernv/eeh-vfio.c | 445 ++++++++++++++++++++++++++++++
  drivers/vfio/pci/vfio_pci.c               |  24 +-
  drivers/vfio/pci/vfio_pci_private.h       |  16 ++
  include/uapi/linux/vfio.h                 |  43 +++
  5 files changed, 523 insertions(+), 6 deletions(-)

create mode 100644 arch/powerpc/platforms/powernv/eeh-vfio.c

Why doesn't this code live inside the vfio module? If I don't load the vfio module, I don't need that code to waste memory in my kernel, no?

Alex

#5 lore raw

Re: [PATCH 3/4] drivers/vfio: New IOCTL command VFIO_EEH_INFO

Quoted 17 lines · Alexander Graf
Quoted 13 lines · Gavin Shan

The patch adds new IOCTL command VFIO_EEH_OP to VFIO PCI device to support EEH functionality for PCI devices, which have been passed from host to guest via VFIO.

---
  arch/powerpc/platforms/powernv/Makefile   |   1 +
  arch/powerpc/platforms/powernv/eeh-vfio.c | 445 
++++++++++++++++++++++++++++++
  drivers/vfio/pci/vfio_pci.c               |  24 +-
  drivers/vfio/pci/vfio_pci_private.h       |  16 ++
  include/uapi/linux/vfio.h                 |  43 +++
  5 files changed, 523 insertions(+), 6 deletions(-)
Quoted 1 line

create mode 100644 arch/powerpc/platforms/powernv/eeh-vfio.c

Quoted 2 lines

Why doesn't this code live inside the vfio module? If I don't load the vfio module, I don't need that code to waste memory in my kernel, no?

So I think from a modeling point of view, you want VFIO code that calls reasonably generic helpers inside the kernel to deal with errors.

The "generic helpers" don't have anything to do with VFIO. Everything that interfaces via ioctls with user space is 100% VFIO code.

The latter should be tristate inside vfio.ko, the former can be =y.

Alex

author
#6 lore raw

Re: [PATCH 3/4] drivers/vfio: New IOCTL command VFIO_EEH_INFO

Quoted 19 lines · Alexander Graf
Quoted 17 lines · Alexander Graf
Quoted 14 lines · Gavin Shan

The patch adds new IOCTL command VFIO_EEH_OP to VFIO PCI device to support EEH functionality for PCI devices, which have been passed from host to guest via VFIO.

---
 arch/powerpc/platforms/powernv/Makefile   |   1 +
 arch/powerpc/platforms/powernv/eeh-vfio.c | 445
++++++++++++++++++++++++++++++
 drivers/vfio/pci/vfio_pci.c               |  24 +-
 drivers/vfio/pci/vfio_pci_private.h       |  16 ++
 include/uapi/linux/vfio.h                 |  43 +++
 5 files changed, 523 insertions(+), 6 deletions(-)
 create mode 100644 arch/powerpc/platforms/powernv/eeh-vfio.c
Quoted 3 lines
Quoted 3 lines

Why doesn't this code live inside the vfio module? If I don't load the vfio module, I don't need that code to waste memory in my kernel, no?

Yes, It saves some memory.

Quoted 10 lines

So I think from a modeling point of view, you want VFIO code that calls reasonably generic helpers inside the kernel to deal with errors.

The "generic helpers" don't have anything to do with VFIO. Everything that interfaces via ioctls with user space is 100% VFIO code.

The latter should be tristate inside vfio.ko, the former can be =y.

The main reason I put eeh-vfio.c to arch/powerpc/platforms/powernv/ is the source file needs access data structures (struct pnv_phb) defined in "pci.h" under that directory.

Thanks,
Gavin

#7 lore raw

Re: [PATCH 3/4] drivers/vfio: New IOCTL command VFIO_EEH_INFO

Quoted 26 lines · Gavin Shan
Quoted 16 lines · Alexander Graf
Quoted 15 lines · Alexander Graf
Quoted 14 lines · Gavin Shan

The patch adds new IOCTL command VFIO_EEH_OP to VFIO PCI device to support EEH functionality for PCI devices, which have been passed from host to guest via VFIO.

---
  arch/powerpc/platforms/powernv/Makefile   |   1 +
  arch/powerpc/platforms/powernv/eeh-vfio.c | 445
++++++++++++++++++++++++++++++
  drivers/vfio/pci/vfio_pci.c               |  24 +-
  drivers/vfio/pci/vfio_pci_private.h       |  16 ++
  include/uapi/linux/vfio.h                 |  43 +++
  5 files changed, 523 insertions(+), 6 deletions(-)

create mode 100644 arch/powerpc/platforms/powernv/eeh-vfio.c

Quoted 3 lines
Quoted 3 lines

Why doesn't this code live inside the vfio module? If I don't load the vfio module, I don't need that code to waste memory in my kernel, no?

Yes, It saves some memory.

Quoted 4 lines

So I think from a modeling point of view, you want VFIO code that calls reasonably generic helpers inside the kernel to deal with errors.

Quoted 8 lines
Quoted 5 lines

The "generic helpers" don't have anything to do with VFIO. Everything that interfaces via ioctls with user space is 100% VFIO code.

The latter should be tristate inside vfio.ko, the former can be =y.

The main reason I put eeh-vfio.c to arch/powerpc/platforms/powernv/ is the source file needs access data structures (struct pnv_phb) defined in "pci.h" under that directory.

Then create a good in-kernel framework from that directory and make use of it from the VFIO code :). But please don't mesh together VFIO, powernv EEH handling and RTAS.

Alex

author
#8 lore raw

Re: [PATCH 3/4] drivers/vfio: New IOCTL command VFIO_EEH_INFO

Quoted 33 lines · Alexander Graf
Quoted 31 lines · Gavin Shan
Quoted 16 lines · Alexander Graf
Quoted 15 lines · Alexander Graf
Quoted 14 lines · Gavin Shan

The patch adds new IOCTL command VFIO_EEH_OP to VFIO PCI device to support EEH functionality for PCI devices, which have been passed from host to guest via VFIO.

---
 arch/powerpc/platforms/powernv/Makefile   |   1 +
 arch/powerpc/platforms/powernv/eeh-vfio.c | 445
++++++++++++++++++++++++++++++
 drivers/vfio/pci/vfio_pci.c               |  24 +-
 drivers/vfio/pci/vfio_pci_private.h       |  16 ++
 include/uapi/linux/vfio.h                 |  43 +++
 5 files changed, 523 insertions(+), 6 deletions(-)
 create mode 100644 arch/powerpc/platforms/powernv/eeh-vfio.c
Quoted 3 lines
Quoted 3 lines

Why doesn't this code live inside the vfio module? If I don't load the vfio module, I don't need that code to waste memory in my kernel, no?

Yes, It saves some memory.

Quoted 9 lines

So I think from a modeling point of view, you want VFIO code that calls reasonably generic helpers inside the kernel to deal with errors.

The "generic helpers" don't have anything to do with VFIO. Everything that interfaces via ioctls with user space is 100% VFIO code.

The latter should be tristate inside vfio.ko, the former can be =y.

Quoted 8 lines
Quoted 3 lines

The main reason I put eeh-vfio.c to arch/powerpc/platforms/powernv/ is the source file needs access data structures (struct pnv_phb) defined in "pci.h" under that directory.

Then create a good in-kernel framework from that directory and make use of it from the VFIO code :). But please don't mesh together VFIO, powernv EEH handling and RTAS.

Yeah. How about this? :-)

- Move eeh-vfio.c to drivers/vfio/pci/
- From eeh-vfio.c, dereference arch/powerpc/kernel/eeh.c::eeh_ops, which is arch/powerpc/plaforms/powernv/eeh-powernv.c::powernv_eeh_ops. Call to the corresponding callbacks in "eeh_ops" based on incoming RTAS request.

The file would be renamed to "vfio_eeh.c" as well after moving to VFIO driver directory.

Thanks,
Gavin

#9 lore raw

Re: [PATCH 3/4] drivers/vfio: New IOCTL command VFIO_EEH_INFO

Quoted 40 lines · Gavin Shan
Quoted 30 lines · Alexander Graf
Quoted 29 lines · Gavin Shan
Quoted 16 lines · Alexander Graf
Quoted 15 lines · Alexander Graf
Quoted 14 lines · Gavin Shan

The patch adds new IOCTL command VFIO_EEH_OP to VFIO PCI device to support EEH functionality for PCI devices, which have been passed from host to guest via VFIO.

---
  arch/powerpc/platforms/powernv/Makefile   |   1 +
  arch/powerpc/platforms/powernv/eeh-vfio.c | 445
++++++++++++++++++++++++++++++
  drivers/vfio/pci/vfio_pci.c               |  24 +-
  drivers/vfio/pci/vfio_pci_private.h       |  16 ++
  include/uapi/linux/vfio.h                 |  43 +++
  5 files changed, 523 insertions(+), 6 deletions(-)

create mode 100644 arch/powerpc/platforms/powernv/eeh-vfio.c

Quoted 3 lines
Quoted 3 lines

Why doesn't this code live inside the vfio module? If I don't load the vfio module, I don't need that code to waste memory in my kernel, no?

Yes, It saves some memory.

Quoted 7 lines

So I think from a modeling point of view, you want VFIO code that calls reasonably generic helpers inside the kernel to deal with errors.

The "generic helpers" don't have anything to do with VFIO. Everything that interfaces via ioctls with user space is 100% VFIO code.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

The latter should be tristate inside vfio.ko, the former can be =y.

The main reason I put eeh-vfio.c to arch/powerpc/platforms/powernv/ is the source file needs access data structures (struct pnv_phb) defined in "pci.h" under that directory.

Then create a good in-kernel framework from that directory and make use of it from the VFIO code :). But please don't mesh together VFIO, powernv EEH handling and RTAS.

Quoted 5 lines

Yeah. How about this? :-)

- Move eeh-vfio.c to drivers/vfio/pci/
- From eeh-vfio.c, dereference arch/powerpc/kernel/eeh.c::eeh_ops, which is arch/powerpc/plaforms/powernv/eeh-powernv.c::powernv_eeh_ops. Call

Hrm, I think it'd be nicer to just export individual functions that do thing you want to do from eeh.c.

Alex

Quoted 12 lines

to the corresponding callbacks in "eeh_ops" based on incoming RTAS request.

The file would be renamed to "vfio_eeh.c" as well after moving to VFIO driver directory.

Thanks,
Gavin

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#10 lore raw

Re: [PATCH 3/4] drivers/vfio: New IOCTL command VFIO_EEH_INFO

Quoted 42 lines · Alexander Graf
Quoted 40 lines · Gavin Shan
Quoted 39 lines · Alexander Graf
Quoted 26 lines · Gavin Shan
Quoted 16 lines · Alexander Graf
Quoted 15 lines · Alexander Graf
Quoted 14 lines · Gavin Shan

The patch adds new IOCTL command VFIO_EEH_OP to VFIO PCI device to support EEH functionality for PCI devices, which have been passed from host to guest via VFIO.

---
 arch/powerpc/platforms/powernv/Makefile   |   1 +
 arch/powerpc/platforms/powernv/eeh-vfio.c | 445
++++++++++++++++++++++++++++++
 drivers/vfio/pci/vfio_pci.c               |  24 +-
 drivers/vfio/pci/vfio_pci_private.h       |  16 ++
 include/uapi/linux/vfio.h                 |  43 +++
 5 files changed, 523 insertions(+), 6 deletions(-)
 create mode 100644 arch/powerpc/platforms/powernv/eeh-vfio.c
Quoted 3 lines
Quoted 3 lines

Why doesn't this code live inside the vfio module? If I don't load the vfio module, I don't need that code to waste memory in my kernel, no?

Yes, It saves some memory.

Quoted 4 lines

So I think from a modeling point of view, you want VFIO code that calls reasonably generic helpers inside the kernel to deal with errors.

Quoted 8 lines
Quoted 5 lines

The "generic helpers" don't have anything to do with VFIO. Everything that interfaces via ioctls with user space is 100% VFIO code.

The latter should be tristate inside vfio.ko, the former can be =y.

The main reason I put eeh-vfio.c to arch/powerpc/platforms/powernv/ is the source file needs access data structures (struct pnv_phb) defined in "pci.h" under that directory.

Then create a good in-kernel framework from that directory and make use of it from the VFIO code :). But please don't mesh together VFIO, powernv EEH handling and RTAS.

Quoted 9 lines
Quoted 5 lines

Yeah. How about this? :-)

- Move eeh-vfio.c to drivers/vfio/pci/
- From eeh-vfio.c, dereference arch/powerpc/kernel/eeh.c::eeh_ops, which is arch/powerpc/plaforms/powernv/eeh-powernv.c::powernv_eeh_ops. Call

Hrm, I think it'd be nicer to just export individual functions that do thing you want to do from eeh.c.

Ok. Got it. Thanks for your comments :)

Thanks,
Gavin

Quoted 21 lines

Alex

Quoted 5 lines

to the corresponding callbacks in "eeh_ops" based on incoming RTAS request.

The file would be renamed to "vfio_eeh.c" as well after moving to VFIO driver directory.

Quoted 7 lines

Thanks,
Gavin

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw

Re: [PATCH 3/4] drivers/vfio: New IOCTL command VFIO_EEH_INFO

Quoted 11 lines · Gavin Shan
Quoted 9 lines
Quoted 5 lines

Yeah. How about this? :-)

- Move eeh-vfio.c to drivers/vfio/pci/
- From eeh-vfio.c, dereference arch/powerpc/kernel/eeh.c::eeh_ops, which is arch/powerpc/plaforms/powernv/eeh-powernv.c::powernv_eeh_ops. Call

Hrm, I think it'd be nicer to just export individual functions that do thing you want to do from eeh.c.

Ok. Got it. Thanks for your comments :)

The interesting thing with this approach is that VFIO per-se can work with EEH RTAS backend too in the host.

IE, with PR KVM for example or with non-KVM uses of VFIO, it would be possible to use a device in a user process and exploit EEH even when running under a PAPR hypervisor.

That is, vfio-eeh uses "generic" exported EEH APIs from the EEH core that will work on both powernv and RTAS backends.

Note to Alex: This definitely kills the notifier idea for now though, at least as a first class citizen of the design. We can add it as an optional optimization on top later.

Cheers,
Ben.

author
#12 lore raw

Re: [PATCH 3/4] drivers/vfio: New IOCTL command VFIO_EEH_INFO

Quoted 7 lines · Benjamin Herrenschmidt
Quoted 6 lines · Gavin Shan
Quoted 6 lines
Quoted 5 lines

Yeah. How about this? :-)

- Move eeh-vfio.c to drivers/vfio/pci/
- From eeh-vfio.c, dereference arch/powerpc/kernel/eeh.c::eeh_ops, which is arch/powerpc/plaforms/powernv/eeh-powernv.c::powernv_eeh_ops. Call

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Hrm, I think it'd be nicer to just export individual functions that do thing you want to do from eeh.c.

Ok. Got it. Thanks for your comments :)

The interesting thing with this approach is that VFIO per-se can work with EEH RTAS backend too in the host.

Yeah, it's another benefit for the approach. I need think about it later. Thanks, Ben. It's really good point.

Quoted 11 lines

IE, with PR KVM for example or with non-KVM uses of VFIO, it would be possible to use a device in a user process and exploit EEH even when running under a PAPR hypervisor.

That is, vfio-eeh uses "generic" exported EEH APIs from the EEH core that will work on both powernv and RTAS backends.

Note to Alex: This definitely kills the notifier idea for now though, at least as a first class citizen of the design. We can add it as an optional optimization on top later.

Yeah, I'll address the notifier later.

Thanks,
Gavin

#13 lore raw

Re: [PATCH 3/4] drivers/vfio: New IOCTL command VFIO_EEH_INFO

In reply to Benjamin Herrenschmidt
Quoted 23 lines

Am 21.05.2014 um 02:23 schrieb Benjamin Herrenschmidt <[email protected]>:

Quoted 10 lines · Gavin Shan
Quoted 8 lines
Quoted 5 lines

Yeah. How about this? :-)

- Move eeh-vfio.c to drivers/vfio/pci/
- From eeh-vfio.c, dereference arch/powerpc/kernel/eeh.c::eeh_ops, which is arch/powerpc/plaforms/powernv/eeh-powernv.c::powernv_eeh_ops. Call

Hrm, I think it'd be nicer to just export individual functions that do thing you want to do from eeh.c.

Ok. Got it. Thanks for your comments :)

The interesting thing with this approach is that VFIO per-se can work with EEH RTAS backend too in the host.

IE, with PR KVM for example or with non-KVM uses of VFIO, it would be possible to use a device in a user process and exploit EEH even when running under a PAPR hypervisor.

Quoted 6 lines

That is, vfio-eeh uses "generic" exported EEH APIs from the EEH core that will work on both powernv and RTAS backends.

Note to Alex: This definitely kills the notifier idea for now though, at least as a first class citizen of the design. We can add it as an optional optimization on top later.

I don't think it does. The notifier would just get triggered on config space read failures for example :). It's really just an aid for the vfio user to have a common code path for error handling.

Alex

#14 lore raw

Re: [PATCH 3/4] drivers/vfio: New IOCTL command VFIO_EEH_INFO

Quoted 8 lines · Alexander Graf
Quoted 1 line

Note to Alex: This definitely kills the notifier idea for now

though,

Quoted 2 lines

at least as a first class citizen of the design. We can add it as an optional optimization on top later.

I don't think it does. The notifier would just get triggered on config space read failures for example :). It's really just an aid for the vfio user to have a common code path for error handling.

I'll let Gavin make the final call on that one, if he thinks we can reliably trigger it and there isn't too much code churn as a consequence.

Cheers,
Ben.

author
#15 lore raw

Re: [PATCH 3/4] drivers/vfio: New IOCTL command VFIO_EEH_INFO

Quoted 6 lines · Benjamin Herrenschmidt
Quoted 5 lines · Alexander Graf
Quoted 1 line

Note to Alex: This definitely kills the notifier idea for now

though,

Quoted 2 lines

at least as a first class citizen of the design. We can add it as an optional optimization on top later.

Quoted 8 lines
Quoted 3 lines

I don't think it does. The notifier would just get triggered on config space read failures for example :). It's really just an aid for the vfio user to have a common code path for error handling.

I'll let Gavin make the final call on that one, if he thinks we can reliably trigger it and there isn't too much code churn as a consequence.

Lets postpone it as future improvement. It's not hard to send the event (EEH errors) out, but I need think about how to extend the existing guest's infrastructure to accept event. As Ben mentioned, event-scan might be potential mechanism for that. We can discuss for more later :-)

Thanks,
Gavin

#16 lore raw

Re: [PATCH 3/4] drivers/vfio: New IOCTL command VFIO_EEH_INFO

In reply to Alexander Graf
Quoted 8 lines · Alexander Graf
Quoted 2 lines

- Move eeh-vfio.c to drivers/vfio/pci/
- From eeh-vfio.c, dereference arch/powerpc/kernel/eeh.c::eeh_ops,

which

Quoted 1 line

is arch/powerpc/plaforms/powernv/eeh-powernv.c::powernv_eeh_ops.

Call

Hrm, I think it'd be nicer to just export individual functions that do thing you want to do from eeh.c.

We already have an eeh_ops backend system with callbacks since we have different backends for RTAS and powernv, so we could do what you suggest but it would probably just boil down to wrappers around the EEH ops.

No big opinion either way on my side though.

Cheers,
Ben.

author
#17 lore raw

PATCH v4 4/4 powerpc/eeh: Avoid event on passed PE

In reply to Gavin Shan

If we detects frozen state on PE that has been passed to guest, we needn't handle it. Instead, we rely on the guest to detect and recover it. The patch avoid EEH event on the frozen passed PE so that the guest can have chance to handle that.

---
 arch/powerpc/kernel/eeh.c                 | 8 ++++++++
 arch/powerpc/platforms/powernv/eeh-ioda.c | 3 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)
arch/powerpc/kernel/eeh.c +8 -0
index 9c6b899..6543f05 100644
@@ -400,6 +400,14 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
 	if (ret > 0)
 		return ret;
 
+	/*
+	 * If the PE has been passed to guest, we won't check the
+	 * state. Instead, let the guest handle it if the PE has
+	 * been frozen.
+	 */
+	if (eeh_pe_passed(pe))
+		return 0;
+
 	/* If we already have a pending isolation event for this
 	 * slot, we know it's bad already, we don't need to check.
 	 * Do this checking under a lock; as multiple PCI devices
arch/powerpc/platforms/powernv/eeh-ioda.c +2 -1
index 1b5982f..03a3ed2 100644
@@ -890,7 +890,8 @@ static int ioda_eeh_next_error(struct eeh_pe **pe)
 				opal_pci_eeh_freeze_clear(phb->opal_id, frozen_pe_no,
 					OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);
 				ret = EEH_NEXT_ERR_NONE;
-			} else if ((*pe)->state & EEH_PE_ISOLATED) {
+			} else if ((*pe)->state & EEH_PE_ISOLATED ||
+				   eeh_pe_passed(*pe)) {
 				ret = EEH_NEXT_ERR_NONE;
 			} else {
 				pr_err("EEH: Frozen PHB#%x-PE#%x (%s) detected\n",
Signature · 1 line
1.8.3.2
#18 lore raw

Re: [PATCH 4/4] powerpc/eeh: Avoid event on passed PE

Quoted 6 lines · Gavin Shan

If we detects frozen state on PE that has been passed to guest, we needn't handle it. Instead, we rely on the guest to detect and recover it. The patch avoid EEH event on the frozen passed PE so that the guest can have chance to handle that.

How does the guest learn about this failure? We'd need to inject an error into it, no?

I think what you want is an irqfd that the in-kernel eeh code notifies when it sees a failure. When such an fd exists, the kernel skips its own error handling.

Alex

Quoted 38 lines
---
  arch/powerpc/kernel/eeh.c                 | 8 ++++++++
  arch/powerpc/platforms/powernv/eeh-ioda.c | 3 ++-
  2 files changed, 10 insertions(+), 1 deletion(-)
arch/powerpc/kernel/eeh.c +8 -0
index 9c6b899..6543f05 100644
@@ -400,6 +400,14 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
  	if (ret > 0)
  		return ret;
 
+	/*
+	 * If the PE has been passed to guest, we won't check the
+	 * state. Instead, let the guest handle it if the PE has
+	 * been frozen.
+	 */
+	if (eeh_pe_passed(pe))
+		return 0;
+
  	/* If we already have a pending isolation event for this
  	 * slot, we know it's bad already, we don't need to check.
  	 * Do this checking under a lock; as multiple PCI devices
arch/powerpc/platforms/powernv/eeh-ioda.c +2 -1
index 1b5982f..03a3ed2 100644
@@ -890,7 +890,8 @@ static int ioda_eeh_next_error(struct eeh_pe **pe)
  				opal_pci_eeh_freeze_clear(phb->opal_id, frozen_pe_no,
  					OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);
  				ret = EEH_NEXT_ERR_NONE;
-			} else if ((*pe)->state & EEH_PE_ISOLATED) {
+			} else if ((*pe)->state & EEH_PE_ISOLATED ||
+				   eeh_pe_passed(*pe)) {
  				ret = EEH_NEXT_ERR_NONE;
  			} else {
  				pr_err("EEH: Frozen PHB#%x-PE#%x (%s) detected\n",
author
#19 lore raw

Re: [PATCH 4/4] powerpc/eeh: Avoid event on passed PE

Quoted 7 lines · Alexander Graf
Quoted 5 lines · Gavin Shan

If we detects frozen state on PE that has been passed to guest, we needn't handle it. Instead, we rely on the guest to detect and recover it. The patch avoid EEH event on the frozen passed PE so that the guest can have chance to handle that.

Quoted 5 lines
Quoted 1 line

How does the guest learn about this failure? We'd need to inject an error into it, no?

When error is existing in HW level, 0xFF's will be turned on reading PCI config space or memory BARs. Guest retrieves the failure state, which is captured by HW automatically, via RTAS call "ibm,read-slot-reset-state2" when seeing 0xFF's on reading PCI config space or memory BARs. If "ibm,read-slot-reset-state2" reports errors in HW, the guest kernel starts to recovery.

It can be called as "passive" reporting. There possible has one case that the error can't be reported for ever: No device driver binding to the VFIO PCI device and no access to device's config space and memory BARs. However, it doesn't matter. As we don't use the device, we needn't detect and recover the error at all.

Quoted 4 lines

I think what you want is an irqfd that the in-kernel eeh code notifies when it sees a failure. When such an fd exists, the kernel skips its own error handling.

Yeah, it's a good idea and something for me to improve in phase II. We can discuss for more later. For now, what I have in my head is something like this:

      [ Host ] -> Error detected -> irqfd (or eventfd) -> QEMU 
                                                           |
                                   -------------(A)---------
                                   |
                        Send one EEH event to guest kernel
                                   |
                        Guest kernel starts the recovery

(A): I didn't figure out one convienent way to do the EEH event injection yet.

Thanks,
Gavin

Quoted 38 lines
Quoted 37 lines
---
 arch/powerpc/kernel/eeh.c                 | 8 ++++++++
 arch/powerpc/platforms/powernv/eeh-ioda.c | 3 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)
arch/powerpc/kernel/eeh.c +8 -0
index 9c6b899..6543f05 100644
@@ -400,6 +400,14 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
 	if (ret > 0)
 		return ret;
+	/*
+	 * If the PE has been passed to guest, we won't check the
+	 * state. Instead, let the guest handle it if the PE has
+	 * been frozen.
+	 */
+	if (eeh_pe_passed(pe))
+		return 0;
+
 	/* If we already have a pending isolation event for this
 	 * slot, we know it's bad already, we don't need to check.
 	 * Do this checking under a lock; as multiple PCI devices
arch/powerpc/platforms/powernv/eeh-ioda.c +2 -1
index 1b5982f..03a3ed2 100644
@@ -890,7 +890,8 @@ static int ioda_eeh_next_error(struct eeh_pe **pe)
 				opal_pci_eeh_freeze_clear(phb->opal_id, frozen_pe_no,
 					OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);
 				ret = EEH_NEXT_ERR_NONE;
-			} else if ((*pe)->state & EEH_PE_ISOLATED) {
+			} else if ((*pe)->state & EEH_PE_ISOLATED ||
+				   eeh_pe_passed(*pe)) {
 				ret = EEH_NEXT_ERR_NONE;
 			} else {
 				pr_err("EEH: Frozen PHB#%x-PE#%x (%s) detected\n",
#20 lore raw

Re: [PATCH 4/4] powerpc/eeh: Avoid event on passed PE

Quoted 18 lines · Gavin Shan
Quoted 10 lines · Alexander Graf
Quoted 6 lines · Gavin Shan

If we detects frozen state on PE that has been passed to guest, we needn't handle it. Instead, we rely on the guest to detect and recover it. The patch avoid EEH event on the frozen passed PE so that the guest can have chance to handle that.

How does the guest learn about this failure? We'd need to inject an error into it, no?

When error is existing in HW level, 0xFF's will be turned on reading PCI config space or memory BARs. Guest retrieves the failure state, which is captured by HW automatically, via RTAS call "ibm,read-slot-reset-state2" when seeing 0xFF's on reading PCI config space or memory BARs. If "ibm,read-slot-reset-state2" reports errors in HW, the guest kernel starts to recovery.

Quoted 5 lines

It can be called as "passive" reporting. There possible has one case that the error can't be reported for ever: No device driver binding to the VFIO PCI device and no access to device's config space and memory BARs. However, it doesn't matter. As we don't use the device, we needn't detect and recover the error at all.

So if the guest is waiting for an interrupt to happen it will wait forever? Not really nice.

Quoted 6 lines
Quoted 4 lines

I think what you want is an irqfd that the in-kernel eeh code notifies when it sees a failure. When such an fd exists, the kernel skips its own error handling.

Yeah, it's a good idea and something for me to improve in phase II. We can discuss for more later.

I think it makes sense to at least walk into that direction immediately. The reason I brought it up in the context of this patch is that with an irqfd you wouldn't need the passed flag at all.

Quoted 11 lines

For now, what I have in my head is something
like this:

       [ Host ] -> Error detected -> irqfd (or eventfd) -> QEMU
                                                            |
                                    -------------(A)---------
                                    |
                         Send one EEH event to guest kernel
                                    |
                         Guest kernel starts the recovery
Quoted 1 line

(A): I didn't figure out one convienent way to do the EEH event injection yet.

How does the guest learn about errors in pHyp?

Alex

author
#21 lore raw

Re: [PATCH 4/4] powerpc/eeh: Avoid event on passed PE

Quoted 20 lines · Alexander Graf
Quoted 18 lines · Gavin Shan
Quoted 10 lines · Alexander Graf
Quoted 6 lines · Gavin Shan

If we detects frozen state on PE that has been passed to guest, we needn't handle it. Instead, we rely on the guest to detect and recover it. The patch avoid EEH event on the frozen passed PE so that the guest can have chance to handle that.

How does the guest learn about this failure? We'd need to inject an error into it, no?

When error is existing in HW level, 0xFF's will be turned on reading PCI config space or memory BARs. Guest retrieves the failure state, which is captured by HW automatically, via RTAS call "ibm,read-slot-reset-state2" when seeing 0xFF's on reading PCI config space or memory BARs. If "ibm,read-slot-reset-state2" reports errors in HW, the guest kernel starts to recovery.

Quoted 9 lines
Quoted 5 lines

It can be called as "passive" reporting. There possible has one case that the error can't be reported for ever: No device driver binding to the VFIO PCI device and no access to device's config space and memory BARs. However, it doesn't matter. As we don't use the device, we needn't detect and recover the error at all.

So if the guest is waiting for an interrupt to happen it will wait forever? Not really nice.

Nope, the error reporting in guest isn't interrupt-driven. It's always "polling" :-)

Quoted 11 lines
Quoted 6 lines
Quoted 4 lines

I think what you want is an irqfd that the in-kernel eeh code notifies when it sees a failure. When such an fd exists, the kernel skips its own error handling.

Yeah, it's a good idea and something for me to improve in phase II. We can discuss for more later.

I think it makes sense to at least walk into that direction immediately. The reason I brought it up in the context of this patch is that with an irqfd you wouldn't need the passed flag at all.

I don't see how it can avoid the "passed" flag. Without the flag, any PCI config and memory BAR access on host side could trigger EEH recovery for those PCI devices passed to guest. That's unexpected behaviour.

For host, we have 2 ways to report errors: interrupt driven and polling. For the guest, we only have "polling" :-)

Quoted 11 lines
Quoted 11 lines

For now, what I have in my head is something
like this:

      [ Host ] -> Error detected -> irqfd (or eventfd) -> QEMU
                                                           |
                                   -------------(A)---------
                                   |
                        Send one EEH event to guest kernel
                                   |
                        Guest kernel starts the recovery
Quoted 4 lines
Quoted 1 line

(A): I didn't figure out one convienent way to do the EEH event injection yet.

How does the guest learn about errors in pHyp?

It relies on "polling".

Thanks,
Gavin

#22 lore raw

Re: [PATCH 4/4] powerpc/eeh: Avoid event on passed PE

Quoted 25 lines · Gavin Shan
Quoted 24 lines · Alexander Graf
Quoted 23 lines · Gavin Shan
Quoted 10 lines · Alexander Graf
Quoted 6 lines · Gavin Shan

If we detects frozen state on PE that has been passed to guest, we needn't handle it. Instead, we rely on the guest to detect and recover it. The patch avoid EEH event on the frozen passed PE so that the guest can have chance to handle that.

How does the guest learn about this failure? We'd need to inject an error into it, no?

When error is existing in HW level, 0xFF's will be turned on reading PCI config space or memory BARs. Guest retrieves the failure state, which is captured by HW automatically, via RTAS call "ibm,read-slot-reset-state2" when seeing 0xFF's on reading PCI config space or memory BARs. If "ibm,read-slot-reset-state2" reports errors in HW, the guest kernel starts to recovery.

It can be called as "passive" reporting. There possible has one case that the error can't be reported for ever: No device driver binding to the VFIO PCI device and no access to device's config space and memory BARs. However, it doesn't matter. As we don't use the device, we needn't detect and recover the error at all.

Quoted 5 lines
Quoted 3 lines

So if the guest is waiting for an interrupt to happen it will wait forever? Not really nice.

Nope, the error reporting in guest isn't interrupt-driven. It's always "polling" :-)

That sucks :).

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

I think what you want is an irqfd that the in-kernel eeh code notifies when it sees a failure. When such an fd exists, the kernel skips its own error handling.

Yeah, it's a good idea and something for me to improve in phase II. We can discuss for more later.

Quoted 7 lines
Quoted 4 lines

I think it makes sense to at least walk into that direction immediately. The reason I brought it up in the context of this patch is that with an irqfd you wouldn't need the passed flag at all.

I don't see how it can avoid the "passed" flag. Without the flag, any PCI config and memory BAR access on host side could trigger EEH recovery for those PCI devices passed to guest. That's unexpected behaviour.

Instead of

if (passed_flag)

     return;

you would do

   if (trigger_irqfd) {
     trigger_irqfd();
     return;
   }

which would be a much nicer, generic interface.

Quoted 2 lines

For host, we have 2 ways to report errors: interrupt driven and polling. For the guest, we only have "polling" :-)

And the interrupt path is powernv specific? Does sPAPR specify anything here?

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

For now, what I have in my head is something
like this:

       [ Host ] -> Error detected -> irqfd (or eventfd) -> QEMU
                                                            |
                                    -------------(A)---------
                                    |
                         Send one EEH event to guest kernel
                                    |
                         Guest kernel starts the recovery
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

(A): I didn't figure out one convienent way to do the EEH event injection yet.

How does the guest learn about errors in pHyp?

It relies on "polling".

Sigh ;).

So how about we just implement this whole thing properly as irqfd? Whether QEMU can actually do anything with the interrupt is a different question - we can leave it be for now. But we could model all the code with the assumption that it should either handle the error itself or trigger and irqfd write.

Alex

#23 lore raw

Re: [PATCH 4/4] powerpc/eeh: Avoid event on passed PE

Quoted 5 lines · Alexander Graf

Instead of

   if (passed_flag)
     return;
Quoted 8 lines

you would do

   if (trigger_irqfd) {
     trigger_irqfd();
     return;
   }

which would be a much nicer, generic interface.

But that's not how PAPR works.

Cheers,
Ben.

#24 lore raw

Re: [PATCH 4/4] powerpc/eeh: Avoid event on passed PE

Quoted 12 lines

Am 21.05.2014 um 02:13 schrieb Benjamin Herrenschmidt <[email protected]>:

Quoted 8 lines · Alexander Graf

Instead of

if (passed_flag)

    return;

you would do

Quoted 8 lines
Quoted 6 lines
  if (trigger_irqfd) {
    trigger_irqfd();
    return;
  }

which would be a much nicer, generic interface.

But that's not how PAPR works.

But it's what a non-QEMU VFIO user would want, and it should be easy to implement.

Alex

#25 lore raw

Re: [PATCH 4/4] powerpc/eeh: Avoid event on passed PE

In reply to Alexander Graf
Quoted 5 lines · Alexander Graf

So how about we just implement this whole thing properly as irqfd? Whether QEMU can actually do anything with the interrupt is a different question - we can leave it be for now. But we could model all the code with the assumption that it should either handle the error itself or trigger and irqfd write.

I don't object to the idea... however this smells of Deja Vu...

You often tend to want to turn something submitted that fills a specific gap and implements a specific spec/function into some kind of idealized grand design :-) And that means nothing gets upstream for weeks or monthes as we churn and churn...

Sometimes it's probably worth it. Here I would argue against it and would advocate for doing the basic functionality first, as it is used by guests, and later add the irqfd option. I don't see any emergency here and adding the irqfd will not cause fundamental design changes:

The "passed" flag (though I'm not fan of the name) is really something we want in the low level handlers to avoid triggering host side EEH in various places, regardless of whether we use irqfd or not.

This is totally orthogonal from the mechanism used for notifications.

Even in host, the detection path doesn't always involve interrupts, and we can detect some things as a result of a host side config space access for example etc...

So let's keep things nice and separate here. The interrupt notification is just an "optimization" which will speed up discovery of the error in *some* cases later on (but adds its own complexity since we have multiple discovery path in host, so we need to keep track whether we have notified yet or not etc...) so let's keep it for later.

Cheers,
Ben.

#26 lore raw

Re: [PATCH 4/4] powerpc/eeh: Avoid event on passed PE

Quoted 33 lines

Am 21.05.2014 um 02:19 schrieb Benjamin Herrenschmidt <[email protected]>:

Quoted 6 lines · Alexander Graf

So how about we just implement this whole thing properly as irqfd? Whether QEMU can actually do anything with the interrupt is a different question - we can leave it be for now. But we could model all the code with the assumption that it should either handle the error itself or trigger and irqfd write.

I don't object to the idea... however this smells of Deja Vu...

You often tend to want to turn something submitted that fills a specific gap and implements a specific spec/function into some kind of idealized grand design :-) And that means nothing gets upstream for weeks or monthes as we churn and churn...

Sometimes it's probably worth it. Here I would argue against it and would advocate for doing the basic functionality first, as it is used by guests, and later add the irqfd option. I don't see any emergency here and adding the irqfd will not cause fundamental design changes:

The "passed" flag (though I'm not fan of the name) is really something we want in the low level handlers to avoid triggering host side EEH in various places, regardless of whether we use irqfd or not.

This is totally orthogonal from the mechanism used for notifications.

Even in host, the detection path doesn't always involve interrupts, and we can detect some things as a result of a host side config space access for example etc...

Quoted 5 lines

So let's keep things nice and separate here. The interrupt notification is just an "optimization" which will speed up discovery of the error in *some* cases later on (but adds its own complexity since we have multiple discovery path in host, so we need to keep track whether we have notified yet or not etc...) so let's keep it for later.

EEH handling is your call, but I only see reduced complexity here. I won't nak the current approach though.

Alex

#27 lore raw

Re: [PATCH 4/4] powerpc/eeh: Avoid event on passed PE

In reply to Gavin Shan

On Tue, 2014-05-20 at 21:56 +1000, Gavin Shan wrote:

.../...

Quoted 8 lines
Quoted 4 lines

I think what you want is an irqfd that the in-kernel eeh code notifies when it sees a failure. When such an fd exists, the kernel skips its own error handling.

Yeah, it's a good idea and something for me to improve in phase II. We can discuss for more later. For now, what I have in my head is something like this:

However, this would be a deviation from (or extension of) PAPR. At the moment, the way things work in PAPR is that the guest is responsible for querying the EEH state when something "looks" like an error (ie, getting ff's back). This is also how it works in pHyp.

We have an interrupt path in the host when doing "native" EEH, and it would be nice to extend PAPR to also be able to shoot an event to the guest possibly using RTAS events, but let's get the basics working and upstream first.

Cheers,
Ben.

author
#28 lore raw

Re: [PATCH 4/4] powerpc/eeh: Avoid event on passed PE

Quoted 18 lines · Benjamin Herrenschmidt

On Tue, 2014-05-20 at 21:56 +1000, Gavin Shan wrote:

.../...

Quoted 8 lines
Quoted 4 lines

I think what you want is an irqfd that the in-kernel eeh code notifies when it sees a failure. When such an fd exists, the kernel skips its own error handling.

Yeah, it's a good idea and something for me to improve in phase II. We can discuss for more later. For now, what I have in my head is something like this:

However, this would be a deviation from (or extension of) PAPR. At the moment, the way things work in PAPR is that the guest is responsible for querying the EEH state when something "looks" like an error (ie, getting ff's back). This is also how it works in pHyp.

Quoted 5 lines

We have an interrupt path in the host when doing "native" EEH, and it would be nice to extend PAPR to also be able to shoot an event to the guest possibly using RTAS events, but let's get the basics working and upstream first.

Got it. Thanks, Ben :-)

Thanks,
Gavin

#29 lore raw

Re: [PATCH 4/4] powerpc/eeh: Avoid event on passed PE

In reply to Alexander Graf
Quoted 7 lines · Alexander Graf
Quoted 5 lines · Gavin Shan

If we detects frozen state on PE that has been passed to guest, we needn't handle it. Instead, we rely on the guest to detect and recover it. The patch avoid EEH event on the frozen passed PE so that the guest can have chance to handle that.

Quoted 8 lines
Quoted 1 line

How does the guest learn about this failure? We'd need to inject an error into it, no?

I think what you want is an irqfd that the in-kernel eeh code notifies when it sees a failure. When such an fd exists, the kernel skips its own error handling.

Well... we don't have irqfd support for book3s HV upstream yet. The way the current code is, we have to turn on GSI routing, which puts a hard and relatively small limit on the hardware IRQ numbers we can use as it uses a flat array indexed by hardware IRQ number. Which is a problem that I need to solve somehow, but it makes using an irqfd unattractive in the short term.

Paul.

#30 lore raw

Re: [PATCH 4/4] powerpc/eeh: Avoid event on passed PE

Quoted 21 lines

Am 03.06.2014 um 07:54 schrieb Paul Mackerras <[email protected]>:

Quoted 8 lines · Alexander Graf
Quoted 7 lines · Gavin Shan

If we detects frozen state on PE that has been passed to guest, we needn't handle it. Instead, we rely on the guest to detect and recover it. The patch avoid EEH event on the frozen passed PE so that the guest can have chance to handle that.

Quoted 8 lines
Quoted 1 line

How does the guest learn about this failure? We'd need to inject an error into it, no?

I think what you want is an irqfd that the in-kernel eeh code notifies when it sees a failure. When such an fd exists, the kernel skips its own error handling.

Quoted 5 lines

Well... we don't have irqfd support for book3s HV upstream yet. The way the current code is, we have to turn on GSI routing, which puts a hard and relatively small limit on the hardware IRQ numbers we can use as it uses a flat array indexed by hardware IRQ number. Which is a problem that I need to solve somehow,

Please sync up with the ARM folks on this - they were also unhappy about the routing requirements for irqfd ;).

Quoted 2 lines

but it makes using an irqfd
unattractive in the short term.

For EEH it could as well be a dumb eventfd - really just a side channel that can tell user space that something happened asynchronously :).

Alex

#31 lore raw

Re: [PATCH 4/4] powerpc/eeh: Avoid event on passed PE

Quoted 3 lines · Alexander Graf

For EEH it could as well be a dumb eventfd - really just a side channel that can tell user space that something happened asynchronously :).

Which the host kernel may have no way to detect without actively poking at the device (fences in powernv or anything in PAPR host) and the only user of this for now has no use for.

I insist don't bother.

Cheers,
Ben.