mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
vfio: Replace the DMA unmapping notifier with a callback
Instead of having drivers register the notifier with explicit code just have them provide a dma_unmap callback op in their driver ops and rely on the core code to wire it up. Suggested-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Tony Krowiak <akrowiak@linux.ibm.com> Reviewed-by: Eric Farman <farman@linux.ibm.com> Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/1-v4-681e038e30fd+78-vfio_unmap_notif_jgg@nvidia.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
committed by
Alex Williamson
parent
2a8ed7ef00
commit
ce4b4657ff
@@ -49,6 +49,7 @@ struct vfio_device {
|
||||
unsigned int open_count;
|
||||
struct completion comp;
|
||||
struct list_head group_next;
|
||||
struct notifier_block iommu_nb;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -65,6 +66,8 @@ struct vfio_device {
|
||||
* @match: Optional device name match callback (return: 0 for no-match, >0 for
|
||||
* match, -errno for abort (ex. match with insufficient or incorrect
|
||||
* additional args)
|
||||
* @dma_unmap: Called when userspace unmaps IOVA from the container
|
||||
* this device is attached to.
|
||||
* @device_feature: Optional, fill in the VFIO_DEVICE_FEATURE ioctl
|
||||
*/
|
||||
struct vfio_device_ops {
|
||||
@@ -80,6 +83,7 @@ struct vfio_device_ops {
|
||||
int (*mmap)(struct vfio_device *vdev, struct vm_area_struct *vma);
|
||||
void (*request)(struct vfio_device *vdev, unsigned int count);
|
||||
int (*match)(struct vfio_device *vdev, char *buf);
|
||||
void (*dma_unmap)(struct vfio_device *vdev, u64 iova, u64 length);
|
||||
int (*device_feature)(struct vfio_device *device, u32 flags,
|
||||
void __user *arg, size_t argsz);
|
||||
};
|
||||
@@ -164,23 +168,6 @@ int vfio_unpin_pages(struct vfio_device *device, unsigned long *user_pfn,
|
||||
int vfio_dma_rw(struct vfio_device *device, dma_addr_t user_iova,
|
||||
void *data, size_t len, bool write);
|
||||
|
||||
/* each type has independent events */
|
||||
enum vfio_notify_type {
|
||||
VFIO_IOMMU_NOTIFY = 0,
|
||||
};
|
||||
|
||||
/* events for VFIO_IOMMU_NOTIFY */
|
||||
#define VFIO_IOMMU_NOTIFY_DMA_UNMAP BIT(0)
|
||||
|
||||
int vfio_register_notifier(struct vfio_device *device,
|
||||
enum vfio_notify_type type,
|
||||
unsigned long *required_events,
|
||||
struct notifier_block *nb);
|
||||
int vfio_unregister_notifier(struct vfio_device *device,
|
||||
enum vfio_notify_type type,
|
||||
struct notifier_block *nb);
|
||||
|
||||
|
||||
/*
|
||||
* Sub-module helpers
|
||||
*/
|
||||
|
Reference in New Issue
Block a user