From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C94A1C43603 for ; Fri, 6 Dec 2019 05:59:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A2D0A24676 for ; Fri, 6 Dec 2019 05:59:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726237AbfLFF7J (ORCPT ); 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, >