Re: [PATCH 3/9] vfio/mdev: Pass in a struct vfio_device * to vfio_pin/unpin_pages()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 4/12/22 11:53 AM, Jason Gunthorpe wrote:
Every caller has a readily available vfio_device pointer, use that instead
of passing in a generic struct device. The struct vfio_device already
contains the group we need so this avoids complexity, extra refcountings,
and a confusing lifecycle model.

Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
---
  .../driver-api/vfio-mediated-device.rst       |  4 +-
  drivers/s390/cio/vfio_ccw_cp.c                |  6 +--
  drivers/s390/crypto/vfio_ap_ops.c             |  8 ++--
  drivers/vfio/vfio.c                           | 40 ++++++-------------
  include/linux/vfio.h                          |  4 +-
  5 files changed, 24 insertions(+), 38 deletions(-)

diff --git a/Documentation/driver-api/vfio-mediated-device.rst b/Documentation/driver-api/vfio-mediated-device.rst
index 9f26079cacae35..6aeca741dc9be1 100644
--- a/Documentation/driver-api/vfio-mediated-device.rst
+++ b/Documentation/driver-api/vfio-mediated-device.rst
@@ -279,10 +279,10 @@ Translation APIs for Mediated Devices
  The following APIs are provided for translating user pfn to host pfn in a VFIO
  driver::
- extern int vfio_pin_pages(struct device *dev, unsigned long *user_pfn,
+	extern int vfio_pin_pages(struct vfio_device *vdev, unsigned long *user_pfn,
  				  int npage, int prot, unsigned long *phys_pfn);
- extern int vfio_unpin_pages(struct device *dev, unsigned long *user_pfn,
+	extern int vfio_unpin_pages(struct vfio_device *vdev, unsigned long *user_pfn,
  				    int npage);
These functions call back into the back-end IOMMU module by using the pin_pages

diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
index 69768061cd7bd9..a10b3369d76c41 100644
--- a/drivers/s390/crypto/vfio_ap_ops.c
+++ b/drivers/s390/crypto/vfio_ap_ops.c
@@ -124,7 +124,7 @@ static void vfio_ap_free_aqic_resources(struct vfio_ap_queue *q)
  		q->saved_isc = VFIO_AP_ISC_INVALID;
  	}
  	if (q->saved_pfn && !WARN_ON(!q->matrix_mdev)) {
-		vfio_unpin_pages(mdev_dev(q->matrix_mdev->mdev),
+		vfio_unpin_pages(&q->matrix_mdev->vdev,
  				 &q->saved_pfn, 1);
  		q->saved_pfn = 0;
  	}
@@ -258,7 +258,7 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
  		return status;
  	}
- ret = vfio_pin_pages(mdev_dev(q->matrix_mdev->mdev), &g_pfn, 1,
+	ret = vfio_pin_pages(&q->matrix_mdev->vdev, &g_pfn, 1,
  			     IOMMU_READ | IOMMU_WRITE, &h_pfn);
  	switch (ret) {
  	case 1:
@@ -301,7 +301,7 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
  		break;
  	case AP_RESPONSE_OTHERWISE_CHANGED:
  		/* We could not modify IRQ setings: clear new configuration */
-		vfio_unpin_pages(mdev_dev(q->matrix_mdev->mdev), &g_pfn, 1);
+		vfio_unpin_pages(&q->matrix_mdev->vdev, &g_pfn, 1);
  		kvm_s390_gisc_unregister(kvm, isc);
  		break;
  	default:
@@ -1250,7 +1250,7 @@ static int vfio_ap_mdev_iommu_notifier(struct notifier_block *nb,
  		struct vfio_iommu_type1_dma_unmap *unmap = data;
  		unsigned long g_pfn = unmap->iova >> PAGE_SHIFT;
- vfio_unpin_pages(mdev_dev(matrix_mdev->mdev), &g_pfn, 1);
+		vfio_unpin_pages(&matrix_mdev->vdev, &g_pfn, 1);
  		return NOTIFY_OK;
  	}

The vfio_ap snippet:
Reviewed-by: Tony Krowiak <akrowiak@xxxxxxxxxxxxx>





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux