*/
#include <linux/dma-buf.h>
-#include <linux/vfio.h>
+#include <linux/mdev.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_plane.h>
dmabuf_obj = list_entry(pos, struct intel_vgpu_dmabuf_obj, list);
if (dmabuf_obj == obj) {
list_del(pos);
- intel_gvt_hypervisor_put_vfio_device(vgpu);
+ vfio_device_put(vgpu->vfio_device);
idr_remove(&vgpu->object_idr,
dmabuf_obj->dmabuf_id);
kfree(dmabuf_obj->info);
kref_init(&dmabuf_obj->kref);
mutex_lock(&vgpu->dmabuf_lock);
- if (intel_gvt_hypervisor_get_vfio_device(vgpu)) {
- gvt_vgpu_err("get vfio device failed\n");
+ vgpu->vfio_device = vfio_device_get_from_dev(mdev_dev(vgpu->mdev));
+ if (!vgpu->vfio_device) {
+ gvt_vgpu_err("failed to get vfio device\n");
mutex_unlock(&vgpu->dmabuf_lock);
+ ret = -ENODEV;
goto out_free_info;
}
mutex_unlock(&vgpu->dmabuf_lock);
dmabuf_obj->vgpu = NULL;
idr_remove(&vgpu->object_idr, dmabuf_obj->dmabuf_id);
- intel_gvt_hypervisor_put_vfio_device(vgpu);
+ vfio_device_put(vgpu->vfio_device);
list_del(pos);
/* dmabuf_obj might be freed in dmabuf_obj_put */
int (*set_opregion)(struct intel_vgpu *vgpu);
int (*set_edid)(struct intel_vgpu *vgpu, int port_num);
- int (*get_vfio_device)(struct intel_vgpu *vgpu);
- void (*put_vfio_device)(struct intel_vgpu *vgpu);
bool (*is_valid_gfn)(struct intel_vgpu *vgpu, unsigned long gfn);
};
return 0;
}
-static int kvmgt_get_vfio_device(struct intel_vgpu *vgpu)
-{
- vgpu->vfio_device = vfio_device_get_from_dev(
- mdev_dev(vgpu->mdev));
- if (!vgpu->vfio_device) {
- gvt_vgpu_err("failed to get vfio device\n");
- return -ENODEV;
- }
- return 0;
-}
-
-
static int kvmgt_set_opregion(struct intel_vgpu *vgpu)
{
void *base;
return ret;
}
-static void kvmgt_put_vfio_device(struct intel_vgpu *vgpu)
-{
- if (WARN_ON(!vgpu->vfio_device))
- return;
-
- vfio_device_put(vgpu->vfio_device);
-}
-
static int intel_vgpu_create(struct mdev_device *mdev)
{
struct intel_vgpu *vgpu = NULL;
.dma_pin_guest_page = kvmgt_dma_pin_guest_page,
.set_opregion = kvmgt_set_opregion,
.set_edid = kvmgt_set_edid,
- .get_vfio_device = kvmgt_get_vfio_device,
- .put_vfio_device = kvmgt_put_vfio_device,
.is_valid_gfn = kvmgt_is_valid_gfn,
};
return intel_gvt_host.mpt->set_edid(vgpu, port_num);
}
-/**
- * intel_gvt_hypervisor_get_vfio_device - increase vfio device ref count
- * @vgpu: a vGPU
- *
- * Returns:
- * Zero on success, negative error code if failed.
- */
-static inline int intel_gvt_hypervisor_get_vfio_device(struct intel_vgpu *vgpu)
-{
- if (!intel_gvt_host.mpt->get_vfio_device)
- return 0;
-
- return intel_gvt_host.mpt->get_vfio_device(vgpu);
-}
-
-/**
- * intel_gvt_hypervisor_put_vfio_device - decrease vfio device ref count
- * @vgpu: a vGPU
- *
- * Returns:
- * Zero on success, negative error code if failed.
- */
-static inline void intel_gvt_hypervisor_put_vfio_device(struct intel_vgpu *vgpu)
-{
- if (!intel_gvt_host.mpt->put_vfio_device)
- return;
-
- intel_gvt_host.mpt->put_vfio_device(vgpu);
-}
-
/**
* intel_gvt_hypervisor_is_valid_gfn - check if a visible gfn
* @vgpu: a vGPU