aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/vfio.h
diff options
context:
space:
mode:
authorJike Song <jike.song@intel.com>2016-12-01 13:20:05 +0800
committerAlex Williamson <alex.williamson@redhat.com>2016-12-01 09:38:47 -0700
commit22195cbd3451a75abaf30651a61cf85c89061327 (patch)
tree9178b97be1c3800c8832adabde709868e452a130 /include/linux/vfio.h
parentvfio: Fix handling of error returned by 'vfio_group_get_from_dev()' (diff)
downloadlinux-dev-22195cbd3451a75abaf30651a61cf85c89061327.tar.xz
linux-dev-22195cbd3451a75abaf30651a61cf85c89061327.zip
vfio: vfio_register_notifier: classify iommu notifier
Currently vfio_register_notifier assumes that there is only one notifier chain, which is in vfio_iommu. However, the user might also be interested in events other than vfio_iommu, for example, vfio_group. Refactor vfio_{un}register_notifier implementation to make it feasible. Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Xiao Guangrong <guangrong.xiao@linux.intel.com> Reviewed-by: Kirti Wankhede <kwankhede@nvidia.com> Signed-off-by: Jike Song <jike.song@intel.com> [aw: merge with commit 816ca69ea9c7 ("vfio: Fix handling of error returned by 'vfio_group_get_from_dev()'"), remove typedef] Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'include/linux/vfio.h')
-rw-r--r--include/linux/vfio.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/include/linux/vfio.h b/include/linux/vfio.h
index 15ff0421b423..0e5201f207d3 100644
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -81,6 +81,7 @@ struct vfio_iommu_driver_ops {
int (*unpin_pages)(void *iommu_data,
unsigned long *user_pfn, int npage);
int (*register_notifier)(void *iommu_data,
+ unsigned long *events,
struct notifier_block *nb);
int (*unregister_notifier)(void *iommu_data,
struct notifier_block *nb);
@@ -107,12 +108,20 @@ extern int vfio_pin_pages(struct device *dev, unsigned long *user_pfn,
extern int vfio_unpin_pages(struct device *dev, unsigned long *user_pfn,
int npage);
-#define VFIO_IOMMU_NOTIFY_DMA_UNMAP (1)
+/* 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)
extern int vfio_register_notifier(struct device *dev,
+ enum vfio_notify_type type,
+ unsigned long *required_events,
struct notifier_block *nb);
-
extern int vfio_unregister_notifier(struct device *dev,
+ enum vfio_notify_type type,
struct notifier_block *nb);
/*