[Intel-gfx] [PATCH 1/2] vfio: Replace the DMA unmapping notifier with a callback
Christoph Hellwig
hch at lst.de
Tue Jun 7 05:39:55 UTC 2022
On Mon, Jun 06, 2022 at 09:34:35PM -0300, Jason Gunthorpe wrote:
> +static void intel_vgpu_dma_unmap(struct vfio_device *vfio_dev, u64 iova,
> + u64 length)
> {
> + struct intel_vgpu *vgpu = vfio_dev_to_vgpu(vfio_dev);
> + struct gvt_dma *entry;
> + u64 iov_pfn, end_iov_pfn;
>
> + iov_pfn = iova >> PAGE_SHIFT;
> + end_iov_pfn = iov_pfn + length / PAGE_SIZE;
I'd just initialize these at declaration time. The mix between
shifting and division here is also kind weird, but we probably
shouldn't change too much from the original version.
> + /* Vendor drivers MUST unpin pages in response to an invalidation. */
s/Vendor//g
> /**
> + * vfio_ap_mdev_dma_unmap - Notifier that IOVA has been unmapped
> + * @vdev: The VFIO device
> + * @unmap: IOVA range unmapped
> *
> + * Unpin the guest IOVA (the NIB guest address we pinned before).
> */
kerneldoc comments for method instances are a bit silly..
> +static int vfio_iommu_notifier(struct notifier_block *nb, unsigned long action,
> + void *data)
> +{
> + struct vfio_device *vfio_device =
> + container_of(nb, struct vfio_device, iommu_nb);
> + struct vfio_iommu_type1_dma_unmap *unmap = data;
Using the iommu type 1 UAPI structure in the core vfio code for a
subset of its field is kinda weird. But we can fix this later.
Otherwise looks good:
Reviewed-by: Christoph Hellwig <hch at lst.de>
More information about the Intel-gfx
mailing list