Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp101259ybl; Thu, 5 Dec 2019 15:56:23 -0800 (PST) X-Google-Smtp-Source: APXvYqzXcdVC+urjisy5swamQvSVZ59EPtBn2N9y8HNYZY3kIwXtNYWQuOoVURxJ0bUyy7Bv5hQX X-Received: by 2002:a9d:7410:: with SMTP id n16mr9232183otk.23.1575590183660; Thu, 05 Dec 2019 15:56:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575590183; cv=none; d=google.com; s=arc-20160816; b=u/61pog32p2foeU9iGd8ntobT9vB1tMx8I33BJq2pJP0/6Hhdu+qPQ+m+s48QIcD0u YYwN6pkipyz2+qoMYYGEQ0M7Ae8ueRmg9V+GDJw3BG2I7HZekv/PfIRglZHmP/XUuQuL NLXm6jfd+r8FIlrfVz/+kesSGBPz3ICTzGk+OWujojsqL+bzD0jrVH4m6HAwx15XhRPu ALmqH/tk+uH5xzO4nZVzoNFuSo+RLNaRmagpYAksPh6gwSvkNAvziFHC4EWcDIlK9EJY UJGf1oMPBn7XNKaQliu1eDDrbRhDdIkmc8vJyCuJgp8ZxG5cSZm1sZ+90nP1lSi2SRQa Ee4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=e3JjvtBETMSq5X8ccPeP+yWghLInl+q64B1bKihIixk=; b=JjZYZHZKfC/DzTuPJT1ysMWxqRHRiJ+cT+4gjHvRqP6BYFa8UDnCFi5JfjMRwZeod4 6Ppq3+RmpDej0/0C/NuXI312SfgI2Wei8/9NeihilP7xSlFk8zl/ru/eoFCb7/rJ4Vep evt3DAQe+v6Cixlpd7T3MHO5ixtqhav7vuftuTwjVGvslCCORvTTs3yXR5h2NEMtDe5D GUMpckGg1ryGPfQXUJ+524jQrvtawd/c6uqUm6pomvRmnvaaCiPtW3wnUETdjSFN3PYp RM54y6lTlKoA3yEQy0ggubzVxz6EzXfbsu9AfAyX8QZAw2e2akccDBSU4Kzmbfy/NF2+ 3J2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=isAPFlCy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4si5149595ote.135.2019.12.05.15.56.06; Thu, 05 Dec 2019 15:56:23 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=isAPFlCy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726070AbfLEXzX (ORCPT + 99 others); Thu, 5 Dec 2019 18:55:23 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:49968 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725926AbfLEXzX (ORCPT ); Thu, 5 Dec 2019 18:55:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575590121; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e3JjvtBETMSq5X8ccPeP+yWghLInl+q64B1bKihIixk=; b=isAPFlCyX3aM+VaIiLOt/YEpf1eSSO8AjER56xCxKD6WbN8rzLQndxapgh4DD/xVc716o1 YsEzPUfSpI/Z3ZPhioA0P24KBUbRBwAfe3RXjhzTLysx4hqIXkh2zxWGiAgHM9qrFeuqG2 izf2Z77+seytvOmd6Ax/oLwY9/tsWqU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-395-0we2EaDoMcuog2U-Xez0fg-1; Thu, 05 Dec 2019 18:55:20 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10B5E19057A2; Thu, 5 Dec 2019 23:55:19 +0000 (UTC) Received: from x1.home (ovpn-116-56.phx2.redhat.com [10.3.116.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0A1E5C1C3; Thu, 5 Dec 2019 23:55:15 +0000 (UTC) Date: Thu, 5 Dec 2019 16:55:15 -0700 From: Alex Williamson To: Yan Zhao 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, zhi.a.wang@intel.com, kevin.tian@intel.com, shaopeng.he@intel.com Subject: Re: [RFC PATCH 3/9] vfio/pci: register a default migration region Message-ID: <20191205165515.3a9ac7b6@x1.home> In-Reply-To: <20191205032638.29747-1-yan.y.zhao@intel.com> References: <20191205032419.29606-1-yan.y.zhao@intel.com> <20191205032638.29747-1-yan.y.zhao@intel.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: 0we2EaDoMcuog2U-Xez0fg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > + > 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,