@@ -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) {
@@ -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;
@@ -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)
{
}
@@ -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;
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@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(-)