From nobody Tue Feb 10 05:10:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498468108700992.68529278025; Mon, 26 Jun 2017 02:08:28 -0700 (PDT) Received: from localhost ([::1]:45416 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dPQ0R-0001Fv-8J for importer@patchew.org; Mon, 26 Jun 2017 05:08:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dPPrT-0001vN-KB for qemu-devel@nongnu.org; Mon, 26 Jun 2017 04:59:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dPPrR-0004Qf-Ow for qemu-devel@nongnu.org; Mon, 26 Jun 2017 04:59:11 -0400 Received: from mga11.intel.com ([192.55.52.93]:44436) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dPPrR-0004PL-GG for qemu-devel@nongnu.org; Mon, 26 Jun 2017 04:59:09 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2017 01:59:07 -0700 Received: from yzhang13-kvm.sh.intel.com ([10.239.36.121]) by fmsmga006.fm.intel.com with ESMTP; 26 Jun 2017 01:59:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,394,1493708400"; d="scan'208";a="119263368" From: Yulei Zhang To: qemu-devel@nongnu.org Date: Tue, 4 Apr 2017 18:32:55 +0800 Message-Id: <1491301977-24481-8-git-send-email-yulei.zhang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491301977-24481-1-git-send-email-yulei.zhang@intel.com> References: <1491301977-24481-1-git-send-email-yulei.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Subject: [Qemu-devel] [Intel-gfx][RFC 7/9] drm/i915/gvt: Introduce new VFIO ioctl for device status control X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kevin.tian@intel.com, joonas.lahtinen@linux.intel.com, zhenyuw@linux.intel.com, Yulei Zhang , xiao.zheng@intel.com, zhi.a.wang@intel.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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(+) diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kv= mgt.c index c44b319..ac327f7 100644 --- a/drivers/gpu/drm/i915/gvt/kvmgt.c +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c @@ -1147,6 +1147,15 @@ static long intel_vgpu_ioctl(struct mdev_device *mde= v, unsigned int cmd, } else if (cmd =3D=3D VFIO_DEVICE_RESET) { intel_gvt_ops->vgpu_reset(vgpu); return 0; + } else if (cmd =3D=3D VFIO_DEVICE_PCI_STATUS_SET) { + struct vfio_pci_status_set status; + minsz =3D offsetofend(struct vfio_pci_status_set, flags); + if (copy_from_user(&status, (void __user *)arg, minsz)) + return -EFAULT; + if (status.flags =3D=3D VFIO_DEVICE_PCI_STOP) + intel_gvt_ops->vgpu_deactivate(vgpu); + else + intel_gvt_ops->vgpu_activate(vgpu); } =20 return 0; diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgp= u.c index 989f353..542bde9 100644 --- a/drivers/gpu/drm/i915/gvt/vgpu.c +++ b/drivers/gpu/drm/i915/gvt/vgpu.c @@ -205,6 +205,7 @@ void intel_gvt_activate_vgpu(struct intel_vgpu *vgpu) { mutex_lock(&vgpu->gvt->lock); vgpu->active =3D true; + intel_vgpu_start_schedule(vgpu); mutex_unlock(&vgpu->gvt->lock); } =20 diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index 9ad9ce1..4bb057d 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -503,6 +503,21 @@ struct vfio_pci_hot_reset { =20 #define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) =20 +/** + * 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 -------- */ =20 /** --=20 2.7.4