Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3066512ybb; Sun, 12 Apr 2020 23:08:19 -0700 (PDT) X-Google-Smtp-Source: APiQypI5R/cRnJrJTDiKWFX/CrgTeblKGaLh2CuZ1Bs8HSMYbvF9KLN8DKFuOoo6f3K+IV3Cv9LF X-Received: by 2002:ac8:3254:: with SMTP id y20mr6876114qta.67.1586758099677; Sun, 12 Apr 2020 23:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586758099; cv=none; d=google.com; s=arc-20160816; b=VuZMObebLXS/QzdtTbjtNwUlGHsBGUpoPkvMvdYi6nXPZi2dbu8QeHvBQLkVXq9TqO +wQxNTdOMX8LYS09B6a/ZP+s0wt7nd1YUelBxflsq8sDTDPIvUgWPpljwftt9cpuOIiF MexLg5LIDYj/UA/gG0BdZMDPlpotT/D8cTCz4zyjY86PsfK2/Z+EXWAUVuDSGVmuUdDb 64R5uzxXKK60HCPcSOCOUTb9ImxpO5vfheGDVJ1WJ+/kzGPHtctxObXr47WhZmGWPzw+ 0gRKxjrpn+Q9QFxSxlyM1tcapn0oELeOwkcr26fBTucw5rikh5ZBXSKIJajczTMGnVae FgrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:ironport-sdr; bh=AkyBfEcaj9/7lBPDRDdTeke8ojZLQ92tLu/PwX+778w=; b=Jq9u8qITR2+XFqr7vYVG4umarAJGd3nQbiIFygZMKuQTXV5TxfIUr1G8+xHfbpPy3o wxyp5XNRGRvVKShbbWLM5BUTxfWjvPrvUsLfviE/CTr3ISfXotqgmHEIAcUWenzygmaC x/P07zTkx5vaUEnWEtl3sQcGcnMxOuDkf4eXIkaPE51964hXGRKcFVP2QGse0RWG9MFU /eK3IpZ4SZ1PhZ/GQMHUi3huyzsq53zzAW45BQhdRShTrzT4g+Qos5qX1giKl0o3Odl0 jvFVgCzGyTY9kwuEVJLYW2jWmorcCtbvDf1GpCmte0r5LDdezopJ26gE7SkWGidqYhyY esWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 209.132.180.67 is neither permitted nor denied by best guess record for domain of linux-kernel-owner@vger.kernel.org) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org ([209.132.180.67]) by mx.google.com with ESMTP id j31si5303058qtd.68.2020.04.12.23.08.04; Sun, 12 Apr 2020 23:08:19 -0700 (PDT) Received-SPF: neutral (google.com: 209.132.180.67 is neither permitted nor denied by best guess record for domain of linux-kernel-owner@vger.kernel.org) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.132.180.67 is neither permitted nor denied by best guess record for domain of linux-kernel-owner@vger.kernel.org) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728230AbgDMGFS (ORCPT + 99 others); Mon, 13 Apr 2020 02:05:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.18]:46800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726967AbgDMGFS (ORCPT ); Mon, 13 Apr 2020 02:05:18 -0400 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEBDFC0A3BE0; Sun, 12 Apr 2020 23:05:17 -0700 (PDT) IronPort-SDR: FRepka7+hZp85/uLRdpjNCgcSugSrwuqA5aWIX//Rzqn4gX0sN2zYKL35ofY3K1Ln8+3VRKW9z OpoLOYxnV25w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2020 23:05:17 -0700 IronPort-SDR: roeKVt03RrchyMNuA8CrXSyOrbiZ5X+JKJ9kqReJE3JUUjKofhNcZ7rvaWNpS8f5VdpZlMviVm 2Are1mH2PCgw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,377,1580803200"; d="scan'208";a="245065924" Received: from joy-optiplex-7040.sh.intel.com ([10.239.13.16]) by fmsmga008.fm.intel.com with ESMTP; 12 Apr 2020 23:05:10 -0700 From: Yan Zhao To: intel-gvt-dev@lists.freedesktop.org Cc: libvir-list@redhat.com, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, aik@ozlabs.ru, Zhengxiao.zx@alibaba-inc.com, shuangtai.tst@alibaba-inc.com, qemu-devel@nongnu.org, eauger@redhat.com, yi.l.liu@intel.com, xin.zeng@intel.com, ziye.yang@intel.com, mlevitsk@redhat.com, pasic@linux.ibm.com, felipe@nutanix.com, changpeng.liu@intel.com, Ken.Xue@amd.com, jonathan.davies@nutanix.com, shaopeng.he@intel.com, alex.williamson@redhat.com, eskultet@redhat.com, dgilbert@redhat.com, cohuck@redhat.com, kevin.tian@intel.com, zhenyuw@linux.intel.com, zhi.a.wang@intel.com, cjia@nvidia.com, kwankhede@nvidia.com, berrange@redhat.com, dinechin@redhat.com, corbet@lwn.net, Yan Zhao Subject: [PATCH v5 4/4] drm/i915/gvt: export migration_version to mdev sysfs (under mdev device node) Date: Mon, 13 Apr 2020 01:55:32 -0400 Message-Id: <20200413055532.27363-1-yan.y.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200413055201.27053-1-yan.y.zhao@intel.com> References: <20200413055201.27053-1-yan.y.zhao@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org mdev device par of migration_version attribute for Intel vGPU is rw. It is located at /sys/bus/pci/devices/0000\:00\:02.0/$mdev_UUID/migration_version, or /sys/bus/mdev/devices/$mdev_UUID/migration_version It's used to check migration compatibility for two vGPUs. migration_version string is defined by vendor driver and opaque to userspace. For Intel vGPU of gen8 and gen9, the format of migration_version string is: ---. For future software versions, e.g. when vGPUs have aggregations, it may also include aggregation count into migration_version string of a vGPU. For future platforms, the format of migration_version string is to be expanded to include more meta data to identify Intel vGPUs for live migration compatibility check For old platforms, and for GVT not supporting vGPU live migration feature, -ENODEV is returned on read(2)/write(2) of migration_version attribute. For vGPUs running old GVT who do not expose migration_version attribute, live migration is regarded as not supported for those vGPUs. Cc: Alex Williamson Cc: Erik Skultety Cc: "Dr. David Alan Gilbert" Cc: Cornelia Huck Cc: "Tian, Kevin" Cc: Zhenyu Wang Cc: "Wang, Zhi A" c: Neo Jia Cc: Kirti Wankhede Signed-off-by: Yan Zhao --- drivers/gpu/drm/i915/gvt/gvt.h | 2 ++ drivers/gpu/drm/i915/gvt/kvmgt.c | 55 ++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h index b26e42596565..664efc83f82e 100644 --- a/drivers/gpu/drm/i915/gvt/gvt.h +++ b/drivers/gpu/drm/i915/gvt/gvt.h @@ -205,6 +205,8 @@ struct intel_vgpu { struct idr object_idr; u32 scan_nonprivbb; + + char *migration_version; }; static inline void *intel_vgpu_vdev(struct intel_vgpu *vgpu) diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c index 2f2d4c40f966..4903599cb0ef 100644 --- a/drivers/gpu/drm/i915/gvt/kvmgt.c +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c @@ -728,8 +728,13 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev) kvmgt_vdev(vgpu)->mdev = mdev; mdev_set_drvdata(mdev, vgpu); + vgpu->migration_version = + intel_gvt_get_vfio_migration_version(gvt, type->name); + gvt_dbg_core("intel_vgpu_create succeeded for mdev: %s\n", dev_name(mdev_dev(mdev))); + + ret = 0; out: @@ -744,6 +749,7 @@ static int intel_vgpu_remove(struct mdev_device *mdev) return -EBUSY; intel_gvt_ops->vgpu_destroy(vgpu); + kfree(vgpu->migration_version); return 0; } @@ -1964,8 +1970,57 @@ static const struct attribute_group intel_vgpu_group = { .attrs = intel_vgpu_attrs, }; +static ssize_t migration_version_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct mdev_device *mdev = mdev_from_dev(dev); + struct intel_vgpu *vgpu = mdev_get_drvdata(mdev); + + if (!vgpu->migration_version) { + gvt_vgpu_err("Migration not supported on this vgpu. Please search previous detailed log\n"); + return -ENODEV; + } + + return snprintf(buf, strlen(vgpu->migration_version) + 2, + "%s\n", vgpu->migration_version); + +} + +static ssize_t migration_version_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct mdev_device *mdev = mdev_from_dev(dev); + struct intel_vgpu *vgpu = mdev_get_drvdata(mdev); + struct intel_gvt *gvt = vgpu->gvt; + int ret = 0; + + if (!vgpu->migration_version) { + gvt_vgpu_err("Migration not supported on this vgpu. Please search previous detailed log\n"); + return -ENODEV; + } + + ret = intel_gvt_check_vfio_migration_version(gvt, + vgpu->migration_version, buf); + return (ret < 0 ? ret : count); +} + +static DEVICE_ATTR_RW(migration_version); + +static struct attribute *intel_vgpu_migration_attrs[] = { + &dev_attr_migration_version.attr, + NULL, +}; +/* this group has no name, so will be displayed + * immediately under sysfs node of the mdev device + */ +static const struct attribute_group intel_vgpu_group_empty_name = { + .attrs = intel_vgpu_migration_attrs, +}; + static const struct attribute_group *intel_vgpu_groups[] = { &intel_vgpu_group, + &intel_vgpu_group_empty_name, NULL, }; -- 2.17.1