[RFC PATCH v2 5/9] vfio/pci: let vfio_pci know how many vendor regions are registered

From: Yan Zhao
Date: Thu Jan 30 2020 - 21:21:34 EST


This allows a simpler VFIO_DEVICE_GET_INFO ioctl in vendor driver

Cc: Kevin Tian <kevin.tian@xxxxxxxxx>
Signed-off-by: Yan Zhao <yan.y.zhao@xxxxxxxxx>
---
drivers/vfio/pci/vfio_pci.c | 3 ++-
include/linux/vfio.h | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 1a08b7cc9246..7530cceaeaa5 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -719,7 +719,8 @@ long vfio_pci_ioctl(void *device_data,
if (vdev->priv->reset_works)
info.flags |= VFIO_DEVICE_FLAGS_RESET;

- info.num_regions = VFIO_PCI_NUM_REGIONS + vdev->num_regions;
+ info.num_regions = VFIO_PCI_NUM_REGIONS + vdev->num_regions +
+ vdev->num_vendor_regions;
info.num_irqs = VFIO_PCI_NUM_IRQS;

return copy_to_user((void __user *)arg, &info, minsz) ?
diff --git a/include/linux/vfio.h b/include/linux/vfio.h
index 386d1b19da3d..4bb101ac3fff 100644
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -210,6 +210,7 @@ struct vfio_pci_device_private;
struct vfio_pci_device {
struct pci_dev *pdev;
int num_regions;
+ int num_vendor_regions;
int irq_type;
struct vfio_pci_device_private *priv;
struct vfio_pci_vendor_driver *vendor_driver;
--
2.17.1