Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp357088ybl; Thu, 5 Dec 2019 22:00:28 -0800 (PST) X-Google-Smtp-Source: APXvYqyqH+0oTE5LHp0r+q0ahpE0gG8ua3jyY6049zbd77RoieXr+FxoI8OcG4kxpeqnJkwfeDJU X-Received: by 2002:a05:6808:197:: with SMTP id w23mr11182937oic.46.1575612027955; Thu, 05 Dec 2019 22:00:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575612027; cv=none; d=google.com; s=arc-20160816; b=i/ITKBKM1AtDNUwVYudvG5ZPJeWh4yLzh3Y7VGuPQY+Sdc8bo7icscRPgTRrVrioty XjiWSEIJ5eLcgJ9l1lLP92voVZdnlaTqZtjW7Nh1Z10/DIE+6TzgYg+Cqs7FC8oVhWkV j0/eB+4NuN+bMf5LQnXJK5t1brBWmBzX71sTxCke2uzOHMCPXCxqwlzhrwubfJLr+pNl 6oshsgr1djV25t6B0D6dCHvodWbaVPBY9tZgfJPh3dese10TlpKcqhavCJ5jGPkUu/K5 YCnF0zV6TgZXCQiY+un0UFp+mOxIxSioNzbTMkURocU5txvqDz3mF0r82FQi/8AiNtzq 62cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date; bh=WhL7Y2f71Xpi1Dy6RzuFN/Im5qzIL054SVowFDB62eQ=; b=bH8OgDoA70EtzHB8w+UfVjVMkE9zvbgUeudp/+nyun5Vbb78cxYvoo7aUFpfvQvxyc 1gxZhSiZGVl6FeYzWNPyEM53UUKRQwiJneR1uWAD91S/ORlKElFxFcClT9vyPyIQOEfS o5lWpp+jnqwWI0swwyKdCtk/HePCwgsVWj9r0jJteQ642VQV8cCkZ3kuZAumToYoat2I NZ+5aZMiXdXAHAiVvE7n9duy9TXm/38Rr9PZbQF3lfioqS2Iw3uFWdPW/5t7iDjIEK1O PM3WN5DjNqXiArpfhgltbwfcn0e/HMBBQyQG/xlsBY9RJtNd4Y/fDRSt2n7yJByFE6t6 Giew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) 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 (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n65si2193666oib.262.2019.12.05.22.00.01; Thu, 05 Dec 2019 22:00:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) 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 S1726206AbfLFF7J (ORCPT + 99 others); Fri, 6 Dec 2019 00:59:09 -0500 Received: from mga01.intel.com ([192.55.52.88]:56909 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbfLFF7J (ORCPT ); Fri, 6 Dec 2019 00:59:09 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Dec 2019 21:59:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,283,1571727600"; d="scan'208";a="413229029" Received: from joy-optiplex-7040.sh.intel.com (HELO joy-OptiPlex-7040) ([10.239.13.9]) by fmsmga006.fm.intel.com with ESMTP; 05 Dec 2019 21:59:06 -0800 Date: Fri, 6 Dec 2019 00:50:57 -0500 From: Yan Zhao To: Alex Williamson Cc: "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "libvir-list@redhat.com" , "qemu-devel@nongnu.org" , "cohuck@redhat.com" , "zhenyuw@linux.intel.com" , "Wang, Zhi A" , "Tian, Kevin" , "He, Shaopeng" Subject: Re: [RFC PATCH 3/9] vfio/pci: register a default migration region Message-ID: <20191206055057.GE31791@joy-OptiPlex-7040> Reply-To: Yan Zhao References: <20191205032419.29606-1-yan.y.zhao@intel.com> <20191205032638.29747-1-yan.y.zhao@intel.com> <20191205165515.3a9ac7b6@x1.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191205165515.3a9ac7b6@x1.home> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 06, 2019 at 07:55:15AM +0800, Alex Williamson wrote: > On Wed, 4 Dec 2019 22:26:38 -0500 > Yan Zhao wrote: > > > Vendor driver specifies when to support a migration region through cap > > VFIO_PCI_DEVICE_CAP_MIGRATION in vfio_pci_mediate_ops->open(). > > > > If vfio-pci detects this cap, it creates a default migration region on > > behalf of vendor driver with region len=0 and region->ops=null. > > Vendor driver should override this region's len, flags, rw, mmap in > > its vfio_pci_mediate_ops. > > > > This migration region definition is aligned to QEMU vfio migration code v8: > > (https://lists.gnu.org/archive/html/qemu-devel/2019-08/msg05542.html) > > > > Cc: Kevin Tian > > > > Signed-off-by: Yan Zhao > > --- > > drivers/vfio/pci/vfio_pci.c | 15 ++++ > > include/linux/vfio.h | 1 + > > include/uapi/linux/vfio.h | 149 ++++++++++++++++++++++++++++++++++++ > > 3 files changed, 165 insertions(+) > > > > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c > > index f3730252ee82..059660328be2 100644 > > --- a/drivers/vfio/pci/vfio_pci.c > > +++ b/drivers/vfio/pci/vfio_pci.c > > @@ -115,6 +115,18 @@ static inline bool vfio_pci_is_vga(struct pci_dev *pdev) > > return (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA; > > } > > > > +/** > > + * init a region to hold migration ctl & data > > + */ > > +void init_migration_region(struct vfio_pci_device *vdev) > > +{ > > + vfio_pci_register_dev_region(vdev, VFIO_REGION_TYPE_MIGRATION, > > + VFIO_REGION_SUBTYPE_MIGRATION, > > + NULL, 0, > > + VFIO_REGION_INFO_FLAG_READ | VFIO_REGION_INFO_FLAG_WRITE, > > + NULL); > > +} > > + > > static void vfio_pci_probe_mmaps(struct vfio_pci_device *vdev) > > { > > struct resource *res; > > @@ -523,6 +535,9 @@ static int vfio_pci_open(void *device_data) > > vdev->mediate_ops = mentry->ops; > > vdev->mediate_handle = handle; > > > > + if (caps & VFIO_PCI_DEVICE_CAP_MIGRATION) > > + init_migration_region(vdev); > > No. We're not going to add a cap flag for every region the mediation > driver wants to add. The mediation driver should have the ability to > add regions and irqs to the device itself. Thanks, > > Alex > ok. got it. will do it. Thanks Yan > > + > > pr_info("vfio pci found mediate_ops %s, caps=%llx, handle=%x for %x:%x\n", > > vdev->mediate_ops->name, caps, > > handle, vdev->pdev->vendor, >