Commit cdc71fe4 authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Alex Williamson

vfio: Move container code into drivers/vfio/container.c

All the functions that dereference struct vfio_container are moved into
container.c.

Simple code motion, no functional change.
Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/8-v3-297af71838d2+b9-vfio_container_split_jgg@nvidia.comSigned-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent 9446162e
...@@ -5,6 +5,7 @@ obj-$(CONFIG_VFIO) += vfio.o ...@@ -5,6 +5,7 @@ obj-$(CONFIG_VFIO) += vfio.o
vfio-y += vfio_main.o \ vfio-y += vfio_main.o \
iova_bitmap.o \ iova_bitmap.o \
container.o
obj-$(CONFIG_VFIO_VIRQFD) += vfio_virqfd.o obj-$(CONFIG_VFIO_VIRQFD) += vfio_virqfd.o
obj-$(CONFIG_VFIO_IOMMU_TYPE1) += vfio_iommu_type1.o obj-$(CONFIG_VFIO_IOMMU_TYPE1) += vfio_iommu_type1.o
......
This diff is collapsed.
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include <linux/module.h> #include <linux/module.h>
struct iommu_group; struct iommu_group;
struct vfio_device;
struct vfio_container;
enum vfio_group_type { enum vfio_group_type {
/* /*
...@@ -36,6 +38,24 @@ enum vfio_group_type { ...@@ -36,6 +38,24 @@ enum vfio_group_type {
VFIO_NO_IOMMU, VFIO_NO_IOMMU,
}; };
struct vfio_group {
struct device dev;
struct cdev cdev;
refcount_t users;
unsigned int container_users;
struct iommu_group *iommu_group;
struct vfio_container *container;
struct list_head device_list;
struct mutex device_lock;
struct list_head vfio_next;
struct list_head container_next;
enum vfio_group_type type;
struct rw_semaphore group_rwsem;
struct kvm *kvm;
struct file *opened_file;
struct blocking_notifier_head notifier;
};
/* events for the backend driver notify callback */ /* events for the backend driver notify callback */
enum vfio_iommu_notify_type { enum vfio_iommu_notify_type {
VFIO_IOMMU_CONTAINER_CLOSE = 0, VFIO_IOMMU_CONTAINER_CLOSE = 0,
...@@ -75,7 +95,33 @@ struct vfio_iommu_driver_ops { ...@@ -75,7 +95,33 @@ struct vfio_iommu_driver_ops {
enum vfio_iommu_notify_type event); enum vfio_iommu_notify_type event);
}; };
struct vfio_iommu_driver {
const struct vfio_iommu_driver_ops *ops;
struct list_head vfio_next;
};
int vfio_register_iommu_driver(const struct vfio_iommu_driver_ops *ops); int vfio_register_iommu_driver(const struct vfio_iommu_driver_ops *ops);
void vfio_unregister_iommu_driver(const struct vfio_iommu_driver_ops *ops); void vfio_unregister_iommu_driver(const struct vfio_iommu_driver_ops *ops);
bool vfio_assert_device_open(struct vfio_device *device);
struct vfio_container *vfio_container_from_file(struct file *filep);
int vfio_device_assign_container(struct vfio_device *device);
void vfio_device_unassign_container(struct vfio_device *device);
int vfio_container_attach_group(struct vfio_container *container,
struct vfio_group *group);
void vfio_group_detach_container(struct vfio_group *group);
void vfio_device_container_register(struct vfio_device *device);
void vfio_device_container_unregister(struct vfio_device *device);
long vfio_container_ioctl_check_extension(struct vfio_container *container,
unsigned long arg);
int __init vfio_container_init(void);
void vfio_container_cleanup(void);
#ifdef CONFIG_VFIO_NOIOMMU
extern bool vfio_noiommu __read_mostly;
#else
enum { vfio_noiommu = false };
#endif
#endif #endif
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment