[PATCH v4 0/5] drivers/vfio: EEH Compile and compatibility

STALE4383d

Revision v4 of 2 in this series.

10 messages, 3 authors, 2014-08-08 · open the first message on its own page

[PATCH v4 0/5] drivers/vfio: EEH Compile and compatibility

From: Gavin Shan <hidden>
Date: 2014-08-07 02:47:29

The patchset is mainly for fixing errors from building VFIO compoments
as dynamic modules. PATCH[4/4] allows VFIO can be used though EEH fails
to initialize for VFIO PCI devices.


Alexey Kardashevskiy (2):
  drivers/vfio: Allow EEH to be built as module
  drivers/vfio: Enable VFIO if EEH is not supported

Gavin Shan (3):
  powerpc/eeh: Export eeh_iommu_group_to_pe()
  powerpc/eeh: Add warning message in eeh_dev_open()
  drivers/vfio: Fix EEH build error

 arch/powerpc/kernel/eeh.c     |  6 +++++-
 drivers/vfio/Kconfig          |  6 ++++++
 drivers/vfio/Makefile         |  2 +-
 drivers/vfio/pci/vfio_pci.c   |  6 +-----
 drivers/vfio/vfio_spapr_eeh.c | 17 +++++++++++++++--
 include/linux/vfio.h          |  6 +++---
 6 files changed, 31 insertions(+), 12 deletions(-)

--=20
1.8.3.2

[PATCH v4 2/5] powerpc/eeh: Add warning message in eeh_dev_open()

From: Gavin Shan <hidden>
Date: 2014-08-07 02:47:29

The patch adds one warning message in eeh_dev_open() in case the
PCI device can't be marked as passed through.

Suggested-by: Alexey Kardashevskiy <redacted>
Signed-off-by: Gavin Shan <redacted>
---
 arch/powerpc/kernel/eeh.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 59a64f8..5d73a49 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1162,8 +1162,11 @@ int eeh_dev_open(struct pci_dev *pdev)
 
 	/* No EEH device or PE ? */
 	edev = pci_dev_to_eeh_dev(pdev);
-	if (!edev || !edev->pe)
+	if (!edev || !edev->pe) {
+		pr_warn_once("%s: PCI device %s not supported\n",
+			     __func__, pci_name(pdev));
 		goto out;
+	}
 
 	/* Increase PE's pass through count */
 	atomic_inc(&edev->pe->pass_dev_cnt);
-- 
1.8.3.2

[PATCH v4 4/5] drivers/vfio: Allow EEH to be built as module

From: Gavin Shan <hidden>
Date: 2014-08-07 02:47:31

From: Alexey Kardashevskiy <redacted>

This adds necessary declarations to the SPAPR VFIO EEH module,
otherwise multiple dynamic linker errors reported:

vfio_spapr_eeh: Unknown symbol eeh_pe_set_option (err 0)
vfio_spapr_eeh: Unknown symbol eeh_pe_configure (err 0)
vfio_spapr_eeh: Unknown symbol eeh_pe_reset (err 0)
vfio_spapr_eeh: Unknown symbol eeh_pe_get_state (err 0)
vfio_spapr_eeh: Unknown symbol eeh_iommu_group_to_pe (err 0)
vfio_spapr_eeh: Unknown symbol eeh_dev_open (err 0)
vfio_spapr_eeh: Unknown symbol eeh_pe_set_option (err 0)
vfio_spapr_eeh: Unknown symbol eeh_pe_configure (err 0)
vfio_spapr_eeh: Unknown symbol eeh_pe_reset (err 0)
vfio_spapr_eeh: Unknown symbol eeh_pe_get_state (err 0)
vfio_spapr_eeh: Unknown symbol eeh_iommu_group_to_pe (err 0)
vfio_spapr_eeh: Unknown symbol eeh_dev_open (err 0)

Signed-off-by: Alexey Kardashevskiy <redacted>
Signed-off-by: Gavin Shan <redacted>
---
 drivers/vfio/vfio_spapr_eeh.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff --git a/drivers/vfio/vfio_spapr_eeh.c b/drivers/vfio/vfio_spapr_eeh.c
index 949f98e..4779cac 100644
--- a/drivers/vfio/vfio_spapr_eeh.c
+++ b/drivers/vfio/vfio_spapr_eeh.c
@@ -9,10 +9,15 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/module.h>
 #include <linux/uaccess.h>
 #include <linux/vfio.h>
 #include <asm/eeh.h>
 
+#define DRIVER_VERSION	"0.1"
+#define DRIVER_AUTHOR	"Gavin Shan, IBM Corporation"
+#define DRIVER_DESC	"VFIO IOMMU SPAPR EEH"
+
 /* We might build address mapping here for "fast" path later */
 int vfio_spapr_pci_eeh_open(struct pci_dev *pdev)
 {
@@ -88,3 +93,8 @@ long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group,
 	return ret;
 }
 EXPORT_SYMBOL(vfio_spapr_iommu_eeh_ioctl);
+
+MODULE_VERSION(DRIVER_VERSION);
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
-- 
1.8.3.2

[PATCH v4 5/5] drivers/vfio: Enable VFIO if EEH is not supported

From: Gavin Shan <hidden>
Date: 2014-08-07 02:47:31

From: Alexey Kardashevskiy <redacted>

The existing vfio_pci_open() fails upon error returned from
vfio_spapr_pci_eeh_open(), which breaks POWER7's P5IOC2 PHB
support which this patch brings back.

The patch fixes the issue by dropping the return value of
vfio_spapr_pci_eeh_open().

Signed-off-by: Alexey Kardashevskiy <redacted>
Signed-off-by: Gavin Shan <redacted>
---
v3: Drop return value of vfio_spapr_pci_eeh_open()
v4: Add warning message in eeh_dev_open() in PATCH[2/5]
---
 drivers/vfio/pci/vfio_pci.c   | 6 +-----
 drivers/vfio/vfio_spapr_eeh.c | 4 ++--
 include/linux/vfio.h          | 5 ++---
 3 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index e2ee80f..32d69c8 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -178,11 +178,7 @@ static int vfio_pci_open(void *device_data)
 		if (ret)
 			goto error;
 
-		ret = vfio_spapr_pci_eeh_open(vdev->pdev);
-		if (ret) {
-			vfio_pci_disable(vdev);
-			goto error;
-		}
+		vfio_spapr_pci_eeh_open(vdev->pdev);
 	}
 
 	return 0;
diff --git a/drivers/vfio/vfio_spapr_eeh.c b/drivers/vfio/vfio_spapr_eeh.c
index 4779cac..86dfceb 100644
--- a/drivers/vfio/vfio_spapr_eeh.c
+++ b/drivers/vfio/vfio_spapr_eeh.c
@@ -19,9 +19,9 @@
 #define DRIVER_DESC	"VFIO IOMMU SPAPR EEH"
 
 /* We might build address mapping here for "fast" path later */
-int vfio_spapr_pci_eeh_open(struct pci_dev *pdev)
+void vfio_spapr_pci_eeh_open(struct pci_dev *pdev)
 {
-	return eeh_dev_open(pdev);
+	eeh_dev_open(pdev);
 }
 EXPORT_SYMBOL_GPL(vfio_spapr_pci_eeh_open);
 
diff --git a/include/linux/vfio.h b/include/linux/vfio.h
index 224128a..d320411 100644
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -100,15 +100,14 @@ extern long vfio_external_check_extension(struct vfio_group *group,
 
 struct pci_dev;
 #ifdef CONFIG_EEH
-extern int vfio_spapr_pci_eeh_open(struct pci_dev *pdev);
+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_open(struct pci_dev *pdev)
+static inline void vfio_spapr_pci_eeh_open(struct pci_dev *pdev)
 {
-	return 0;
 }
 
 static inline void vfio_spapr_pci_eeh_release(struct pci_dev *pdev)
-- 
1.8.3.2

[PATCH v4 1/5] powerpc/eeh: Export eeh_iommu_group_to_pe()

From: Gavin Shan <hidden>
Date: 2014-08-07 02:47:31

The function is used by VFIO driver, which might be built as a
dynamic module. So it should be exported.

Signed-off-by: Gavin Shan <redacted>
---
 arch/powerpc/kernel/eeh.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 6043879..59a64f8 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1254,6 +1254,7 @@ struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group)
 
 	return edev->pe;
 }
+EXPORT_SYMBOL_GPL(eeh_iommu_group_to_pe);
 
 #endif /* CONFIG_IOMMU_API */
 
-- 
1.8.3.2

[PATCH v4 3/5] drivers/vfio: Fix EEH build error

From: Gavin Shan <hidden>
Date: 2014-08-07 02:47:36

The VFIO related components could be built as dynamic modules.
Unfortunately, CONFIG_EEH can't be configured to "m". The patch
fixes the build errors when configuring VFIO related components
as dynamic modules as follows:

  CC [M]  drivers/vfio/vfio_iommu_spapr_tce.o
In file included from drivers/vfio/vfio.c:33:0:
include/linux/vfio.h:101:43: warning: =E2=80=98struct pci_dev=E2=80=99 de=
clared \
inside parameter list [enabled by default]
   :
  WRAP    arch/powerpc/boot/zImage.pseries
  WRAP    arch/powerpc/boot/zImage.maple
  WRAP    arch/powerpc/boot/zImage.pmac
  WRAP    arch/powerpc/boot/zImage.epapr
  MODPOST 1818 modules
ERROR: ".vfio_spapr_iommu_eeh_ioctl" [drivers/vfio/vfio_iommu_spapr_tce.k=
o]\
undefined!
ERROR: ".vfio_spapr_pci_eeh_open" [drivers/vfio/pci/vfio-pci.ko] undefine=
d!
ERROR: ".vfio_spapr_pci_eeh_release" [drivers/vfio/pci/vfio-pci.ko] undef=
ined!

Reported-by: Alexey Kardashevskiy <redacted>
Signed-off-by: Gavin Shan <redacted>
Signed-off-by: Alexey Kardashevskiy <redacted>
---
v3: Introduce CONFIG_VFIO_SPAPR_EEH and add "struct pci_dev" in vfio.h
v2: remove #include <linux/pci.h> from vfio.c
---
 drivers/vfio/Kconfig          | 6 ++++++
 drivers/vfio/Makefile         | 2 +-
 drivers/vfio/vfio_spapr_eeh.c | 3 +++
 include/linux/vfio.h          | 1 +
 4 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig
index af7b204..d8c5763 100644
--- a/drivers/vfio/Kconfig
+++ b/drivers/vfio/Kconfig
@@ -8,11 +8,17 @@ config VFIO_IOMMU_SPAPR_TCE
 	depends on VFIO && SPAPR_TCE_IOMMU
 	default n
=20
+config VFIO_SPAPR_EEH
+	tristate
+	depends on EEH && VFIO_IOMMU_SPAPR_TCE
+	default n
+
 menuconfig VFIO
 	tristate "VFIO Non-Privileged userspace driver framework"
 	depends on IOMMU_API
 	select VFIO_IOMMU_TYPE1 if X86
 	select VFIO_IOMMU_SPAPR_TCE if (PPC_POWERNV || PPC_PSERIES)
+	select VFIO_SPAPR_EEH if (PPC_POWERNV || PPC_PSERIES)
 	select ANON_INODES
 	help
 	  VFIO provides a framework for secure userspace device drivers.
diff --git a/drivers/vfio/Makefile b/drivers/vfio/Makefile
index 50e30bc..0b035b1 100644
--- a/drivers/vfio/Makefile
+++ b/drivers/vfio/Makefile
@@ -1,5 +1,5 @@
 obj-$(CONFIG_VFIO) +=3D vfio.o
 obj-$(CONFIG_VFIO_IOMMU_TYPE1) +=3D vfio_iommu_type1.o
 obj-$(CONFIG_VFIO_IOMMU_SPAPR_TCE) +=3D vfio_iommu_spapr_tce.o
-obj-$(CONFIG_EEH) +=3D vfio_spapr_eeh.o
+obj-$(CONFIG_VFIO_SPAPR_EEH) +=3D vfio_spapr_eeh.o
 obj-$(CONFIG_VFIO_PCI) +=3D pci/
diff --git a/drivers/vfio/vfio_spapr_eeh.c b/drivers/vfio/vfio_spapr_eeh.=
c
index f834b4c..949f98e 100644
--- a/drivers/vfio/vfio_spapr_eeh.c
+++ b/drivers/vfio/vfio_spapr_eeh.c
@@ -18,11 +18,13 @@ int vfio_spapr_pci_eeh_open(struct pci_dev *pdev)
 {
 	return eeh_dev_open(pdev);
 }
+EXPORT_SYMBOL_GPL(vfio_spapr_pci_eeh_open);
=20
 void vfio_spapr_pci_eeh_release(struct pci_dev *pdev)
 {
 	eeh_dev_release(pdev);
 }
+EXPORT_SYMBOL_GPL(vfio_spapr_pci_eeh_release);
=20
 long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group,
 				unsigned int cmd, unsigned long arg)
@@ -85,3 +87,4 @@ long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *gro=
up,
=20
 	return ret;
 }
+EXPORT_SYMBOL(vfio_spapr_iommu_eeh_ioctl);
diff --git a/include/linux/vfio.h b/include/linux/vfio.h
index 25a0fbd..224128a 100644
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -98,6 +98,7 @@ extern int vfio_external_user_iommu_id(struct vfio_grou=
p *group);
 extern long vfio_external_check_extension(struct vfio_group *group,
 					  unsigned long arg);
=20
+struct pci_dev;
 #ifdef CONFIG_EEH
 extern int vfio_spapr_pci_eeh_open(struct pci_dev *pdev);
 extern void vfio_spapr_pci_eeh_release(struct pci_dev *pdev);
--=20
1.8.3.2

Re: [PATCH v4 1/5] powerpc/eeh: Export eeh_iommu_group_to_pe()

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2014-08-08 03:49:56

On Thu, 2014-08-07 at 12:47 +1000, Gavin Shan wrote:
The function is used by VFIO driver, which might be built as a
dynamic module. So it should be exported.

Signed-off-by: Gavin Shan <redacted>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Alex, are you taking this or should I ?
quoted hunk
---
 arch/powerpc/kernel/eeh.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 6043879..59a64f8 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1254,6 +1254,7 @@ struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group)
 
 	return edev->pe;
 }
+EXPORT_SYMBOL_GPL(eeh_iommu_group_to_pe);
 
 #endif /* CONFIG_IOMMU_API */
 

Re: [PATCH v4 2/5] powerpc/eeh: Add warning message in eeh_dev_open()

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2014-08-08 03:55:23

On Thu, 2014-08-07 at 12:47 +1000, Gavin Shan wrote:
The patch adds one warning message in eeh_dev_open() in case the
PCI device can't be marked as passed through.

Suggested-by: Alexey Kardashevskiy <redacted>
Signed-off-by: Gavin Shan <redacted>
---
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Alex, are you taking this or should I ?
quoted hunk
 arch/powerpc/kernel/eeh.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 59a64f8..5d73a49 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1162,8 +1162,11 @@ int eeh_dev_open(struct pci_dev *pdev)
 
 	/* No EEH device or PE ? */
 	edev = pci_dev_to_eeh_dev(pdev);
-	if (!edev || !edev->pe)
+	if (!edev || !edev->pe) {
+		pr_warn_once("%s: PCI device %s not supported\n",
+			     __func__, pci_name(pdev));
 		goto out;
+	}
 
 	/* Increase PE's pass through count */
 	atomic_inc(&edev->pe->pass_dev_cnt);

Re: [PATCH v4 2/5] powerpc/eeh: Add warning message in eeh_dev_open()

From: Alex Williamson <hidden>
Date: 2014-08-08 04:06:24

On Fri, 2014-08-08 at 13:50 +1000, Benjamin Herrenschmidt wrote:
On Thu, 2014-08-07 at 12:47 +1000, Gavin Shan wrote:
quoted
The patch adds one warning message in eeh_dev_open() in case the
PCI device can't be marked as passed through.

Suggested-by: Alexey Kardashevskiy <redacted>
Signed-off-by: Gavin Shan <redacted>
---
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Alex, are you taking this or should I ?
You should take 1 & 2, AFAICT there's no dependencies between anything
in this series.  Thanks,

Alex
quoted
 arch/powerpc/kernel/eeh.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 59a64f8..5d73a49 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1162,8 +1162,11 @@ int eeh_dev_open(struct pci_dev *pdev)
 
 	/* No EEH device or PE ? */
 	edev = pci_dev_to_eeh_dev(pdev);
-	if (!edev || !edev->pe)
+	if (!edev || !edev->pe) {
+		pr_warn_once("%s: PCI device %s not supported\n",
+			     __func__, pci_name(pdev));
 		goto out;
+	}
 
 	/* Increase PE's pass through count */
 	atomic_inc(&edev->pe->pass_dev_cnt);

Re: [PATCH v4 0/5] drivers/vfio: EEH Compile and compatibility

From: Alex Williamson <hidden>
Date: 2014-08-08 17:13:32

On Thu, 2014-08-07 at 12:47 +1000, Gavin Shan wrote:
The patchset is mainly for fixing errors from building VFIO compoments
as dynamic modules. PATCH[4/4] allows VFIO can be used though EEH fails
to initialize for VFIO PCI devices.


Alexey Kardashevskiy (2):
  drivers/vfio: Allow EEH to be built as module
  drivers/vfio: Enable VFIO if EEH is not supported

Gavin Shan (3):
  powerpc/eeh: Export eeh_iommu_group_to_pe()
  powerpc/eeh: Add warning message in eeh_dev_open()
  drivers/vfio: Fix EEH build error

 arch/powerpc/kernel/eeh.c     |  6 +++++-
 drivers/vfio/Kconfig          |  6 ++++++
 drivers/vfio/Makefile         |  2 +-
 drivers/vfio/pci/vfio_pci.c   |  6 +-----
 drivers/vfio/vfio_spapr_eeh.c | 17 +++++++++++++++--
 include/linux/vfio.h          |  6 +++---
 6 files changed, 31 insertions(+), 12 deletions(-)
Applied 3-5 to vfio next branch for 3.17.  Thanks,

Alex
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help