[PATCH 1/2] drivers/vfio: Support EEH API revision

Gavin Shan gwshan at linux.vnet.ibm.com
Fri Sep 18 16:24:28 AEST 2015


This extends the return value from container's IOCTL command
(VFIO_CHECK_EXTENSION + VFIO_EEH) to EEH API revision. Also,
extra check is applied to return -ENOTTY if EEH functionality
is disabled in vfio_spapr_iommu_eeh_ioctl().

Signed-off-by: Gavin Shan <gwshan at linux.vnet.ibm.com>
---
 drivers/vfio/vfio_iommu_spapr_tce.c | 5 +++++
 drivers/vfio/vfio_spapr_eeh.c       | 9 ++++++++-
 include/linux/vfio.h                | 6 ++++++
 include/uapi/linux/vfio.h           | 3 +++
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
index 0582b72..812b43b 100644
--- a/drivers/vfio/vfio_iommu_spapr_tce.c
+++ b/drivers/vfio/vfio_iommu_spapr_tce.c
@@ -954,6 +954,11 @@ static long tce_iommu_ioctl(void *iommu_data,
 
 	case VFIO_EEH_PE_OP: {
 		struct tce_iommu_group *tcegrp;
+		int eeh_enabled;
+
+		eeh_enabled = vfio_spapr_pci_eeh_enabled();
+		if (eeh_enabled == VFIO_EEH_DISABLED)
+			return -ENOTTY;
 
 		ret = 0;
 		list_for_each_entry(tcegrp, &container->group_list, next) {
diff --git a/drivers/vfio/vfio_spapr_eeh.c b/drivers/vfio/vfio_spapr_eeh.c
index 38edeb4..d208d77 100644
--- a/drivers/vfio/vfio_spapr_eeh.c
+++ b/drivers/vfio/vfio_spapr_eeh.c
@@ -18,6 +18,12 @@
 #define DRIVER_AUTHOR	"Gavin Shan, IBM Corporation"
 #define DRIVER_DESC	"VFIO IOMMU SPAPR EEH"
 
+int vfio_spapr_pci_eeh_enabled(void)
+{
+	return VFIO_EEH_ENABLED_V1;
+}
+EXPORT_SYMBOL_GPL(vfio_spapr_pci_eeh_enabled);
+
 /* We might build address mapping here for "fast" path later */
 void vfio_spapr_pci_eeh_open(struct pci_dev *pdev)
 {
@@ -42,7 +48,8 @@ long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group,
 	switch (cmd) {
 	case VFIO_CHECK_EXTENSION:
 		if (arg == VFIO_EEH)
-			ret = eeh_enabled() ? 1 : 0;
+			ret = eeh_enabled() ? vfio_spapr_pci_eeh_enabled() :
+					      VFIO_EEH_DISABLED;
 		else
 			ret = 0;
 		break;
diff --git a/include/linux/vfio.h b/include/linux/vfio.h
index ddb4409..ff036ca 100644
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -91,12 +91,18 @@ extern long vfio_external_check_extension(struct vfio_group *group,
 
 struct pci_dev;
 #ifdef CONFIG_EEH
+extern int vfio_spapr_pci_eeh_enabled(void);
 extern void vfio_spapr_pci_eeh_open(struct pci_dev *pdev);
 extern void vfio_spapr_pci_eeh_release(struct pci_dev *pdev);
 extern long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group,
 				       unsigned int cmd,
 				       unsigned long arg);
 #else
+static inline int vfio_spapr_pci_eeh_enabled(void)
+{
+	return VFIO_EEH_DISABLED;
+}
+
 static inline void vfio_spapr_pci_eeh_open(struct pci_dev *pdev)
 {
 }
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index 9fd7b5d..74f5b8b 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -495,6 +495,9 @@ struct vfio_iommu_spapr_tce_info {
  * - configure PE;
  * - inject EEH error.
  */
+#define VFIO_EEH_DISABLED	0
+#define VFIO_EEH_ENABLED_V1	1
+
 struct vfio_eeh_pe_err {
 	__u32 type;
 	__u32 func;
-- 
2.1.0



More information about the Linuxppc-dev mailing list