@@ -1147,6 +1147,15 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
} else if (cmd == VFIO_DEVICE_RESET) {
intel_gvt_ops->vgpu_reset(vgpu);
return 0;
+ } else if (cmd == VFIO_DEVICE_PCI_STATUS_SET) {
+ struct vfio_pci_status_set status;
+ minsz = offsetofend(struct vfio_pci_status_set, flags);
+ if (copy_from_user(&status, (void __user *)arg, minsz))
+ return -EFAULT;
+ if (status.flags == VFIO_DEVICE_PCI_STOP)
+ intel_gvt_ops->vgpu_deactivate(vgpu);
+ else
+ intel_gvt_ops->vgpu_activate(vgpu);
}
return 0;
@@ -205,6 +205,7 @@ void intel_gvt_activate_vgpu(struct intel_vgpu *vgpu)
{
mutex_lock(&vgpu->gvt->lock);
vgpu->active = true;
+ intel_vgpu_start_schedule(vgpu);
mutex_unlock(&vgpu->gvt->lock);
}
@@ -503,6 +503,21 @@ struct vfio_pci_hot_reset {
#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13)
+/**
+ * VFIO_DEVICE_PCI_STATUS_SET - _IOW(VFIO_TYPE, VFIO_BASE + 14,
+ * struct vfio_pci_status_set)
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+struct vfio_pci_status_set{
+ __u32 argsz;
+ __u32 flags;
+#define VFIO_DEVICE_PCI_STOP (1 << 0)
+#define VFIO_DEVICE_PCI_START (1 << 1)
+};
+
+#define VFIO_DEVICE_PCI_STATUS_SET _IO(VFIO_TYPE, VFIO_BASE + 14)
+
/* -------- API for Type1 VFIO IOMMU -------- */
/**
Add handling for new VFIO ioctl VFIO_DEVICE_PCI_STATUS_SET to control the status of mdev device vGPU. vGPU will stop/start rendering according to the command comes along with the ioctl. Signed-off-by: Yulei Zhang <yulei.zhang@intel.com> --- drivers/gpu/drm/i915/gvt/kvmgt.c | 9 +++++++++ drivers/gpu/drm/i915/gvt/vgpu.c | 1 + include/uapi/linux/vfio.h | 15 +++++++++++++++ 3 files changed, 25 insertions(+)