Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4653502imm; Wed, 30 May 2018 09:23:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLNKKWy39/B54PEoMyZMewWQUXbxtBZLMnmk31UqqEOV4LgLofJq7F/yGPT0J7d4Q5nPuvx X-Received: by 2002:a65:4bcd:: with SMTP id p13-v6mr2773169pgr.114.1527697415457; Wed, 30 May 2018 09:23:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527697415; cv=none; d=google.com; s=arc-20160816; b=VDMBINip+WDpulLQLWI0mGJXSHaL3Ma8XjZJ0ocXeS6Gyy4DUuaCvat4iwzFRaHM8U UQEJ4x+Az2eXSWDCuGn0PmvxFA6NeIs8J3v+oNOOOTBS3rdnVtt6xk9AB1Au9PkrNghU hT+YVmkjOLYzsnhQiDv97926iYF92R+5i4UqBSIN3k8Ymv/k1ex9/MQHExBuonMLNjfu uCrucxN7EP5HCHqbIejB6vp6ZKBvopmTao7/QERWuA89iA211tTzecfRkYqtP0Of/sOi Ud47w7HCFKdwdjvZO75GVyz8OeLyp2otxFOFCDZXdmz3OPA4UnFRc89G4Ps9DWMxJgHA xshg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=lUJJslCtqNtxk2eXVqX9CVbpe3npazGItvgzFIG6agk=; b=cOc4+jyFT5vaShp8emGQLQWorESIxoJspyb8hMuBWYMP9E9ihQlBRikq5eEDoeFwE4 UcOEFrtTsptg+6Oc7Z57ZNRLV152zVgOLzv9mgtvSASrXjimIPqfp2uTnckIMoUQRA/g UKqujEYZES8ph0QIU/gTmv3oJl/5w0CDkHxpbyFEztUAUTSswnhk7zQLlNfm4KnnSQIe uyGwZ+fZDC9nrBsjl/RnsNDGeIjOlN3JFwJ1tyvpZV5C8mj9pX9ZDZo9NmAhYLkMJhmT 5ICTJpb3+oWJlgFlJt7coPOxe8nPMrXJXuwC5e+woplxPlHkv7jaXZZJc0eeV3wtuQTW jIGg== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t13-v6si14571419pgs.242.2018.05.30.09.23.20; Wed, 30 May 2018 09:23:35 -0700 (PDT) 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932073AbeE3QWh (ORCPT + 99 others); Wed, 30 May 2018 12:22:37 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45616 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753427AbeE3QWg (ORCPT ); Wed, 30 May 2018 12:22:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC3947C6B1; Wed, 30 May 2018 16:22:35 +0000 (UTC) Received: from redhat.com (ovpn-120-96.rdu2.redhat.com [10.10.120.96]) by smtp.corp.redhat.com (Postfix) with SMTP id 1459C111AF28; Wed, 30 May 2018 16:22:35 +0000 (UTC) Date: Wed, 30 May 2018 19:22:34 +0300 From: "Michael S. Tsirkin" To: Alexander Duyck Cc: Tiwei Bie , Bjorn Helgaas , virtualization@lists.linux-foundation.org, LKML , virtio-dev@lists.oasis-open.org, linux-pci@vger.kernel.org, "Daly, Dan" , "Rustad, Mark D" , "Duyck, Alexander H" , cunming.liang@intel.com, zhihong.wang@intel.com Subject: Re: [virtio-dev] [PATCH] virtio_pci: support enabling VFs Message-ID: <20180530192215-mutt-send-email-mst@kernel.org> References: <20180530085521.26583-1-tiwei.bie@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 30 May 2018 16:22:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 30 May 2018 16:22:35 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mst@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 30, 2018 at 09:10:57AM -0700, Alexander Duyck wrote: > On Wed, May 30, 2018 at 1:55 AM, Tiwei Bie wrote: > > There is a new feature bit allocated in virtio spec to > > support SR-IOV (Single Root I/O Virtualization): > > > > https://github.com/oasis-tcs/virtio-spec/issues/11 > > > > This patch enables the support for this feature bit in > > virtio driver. > > > > Signed-off-by: Tiwei Bie > > So from a quick glance it looks like we are leaving SR-IOV enabled if > the driver is removed. Do we want to have that behavior or should we > be adding the code to disable SR-IOV and free the VFs on driver > removal? Could pci core handle it for us somehow? > > --- > > This patch depends on below proposal: > > https://lists.oasis-open.org/archives/virtio-dev/201805/msg00154.html > > > > This patch depends on below patch: > > https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git/commit/?h=pci/virtualization&id=8effc395c2097e258fcedfc02ed4a66d45fb4238 > > > > drivers/virtio/virtio_pci_common.c | 20 ++++++++++++++++++++ > > drivers/virtio/virtio_pci_modern.c | 14 ++++++++++++++ > > include/uapi/linux/virtio_config.h | 7 ++++++- > > 3 files changed, 40 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c > > index 48d4d1cf1cb6..023da80a7a3e 100644 > > --- a/drivers/virtio/virtio_pci_common.c > > +++ b/drivers/virtio/virtio_pci_common.c > > @@ -588,6 +588,25 @@ static void virtio_pci_remove(struct pci_dev *pci_dev) > > put_device(dev); > > } > > > > +static int virtio_pci_sriov_configure(struct pci_dev *pci_dev, int num_vfs) > > +{ > > + struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); > > + struct virtio_device *vdev = &vp_dev->vdev; > > + int (*sriov_configure)(struct pci_dev *pci_dev, int num_vfs); > > + > > + if (!(vdev->config->get_status(vdev) & VIRTIO_CONFIG_S_DRIVER_OK)) > > + return -EBUSY; > > + > > + if (!__virtio_test_bit(vdev, VIRTIO_F_SR_IOV)) > > + return -EINVAL; > > + > > + sriov_configure = pci_sriov_configure_simple; > > + if (sriov_configure == NULL) > > + return -ENOENT; > > + > > + return sriov_configure(pci_dev, num_vfs); > > +} > > + > > static struct pci_driver virtio_pci_driver = { > > .name = "virtio-pci", > > .id_table = virtio_pci_id_table, > > @@ -596,6 +615,7 @@ static struct pci_driver virtio_pci_driver = { > > #ifdef CONFIG_PM_SLEEP > > .driver.pm = &virtio_pci_pm_ops, > > #endif > > + .sriov_configure = virtio_pci_sriov_configure, > > }; > > > > module_pci_driver(virtio_pci_driver); > > diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c > > index 2555d80f6eec..07571daccfec 100644 > > --- a/drivers/virtio/virtio_pci_modern.c > > +++ b/drivers/virtio/virtio_pci_modern.c > > @@ -153,14 +153,28 @@ static u64 vp_get_features(struct virtio_device *vdev) > > return features; > > } > > > > +static void vp_transport_features(struct virtio_device *vdev, u64 features) > > +{ > > + struct virtio_pci_device *vp_dev = to_vp_device(vdev); > > + struct pci_dev *pci_dev = vp_dev->pci_dev; > > + > > + if ((features & BIT_ULL(VIRTIO_F_SR_IOV)) && > > + pci_find_ext_capability(pci_dev, PCI_EXT_CAP_ID_SRIOV)) > > + __virtio_set_bit(vdev, VIRTIO_F_SR_IOV); > > +} > > + > > /* virtio config->finalize_features() implementation */ > > static int vp_finalize_features(struct virtio_device *vdev) > > { > > struct virtio_pci_device *vp_dev = to_vp_device(vdev); > > + u64 features = vdev->features; > > > > /* Give virtio_ring a chance to accept features. */ > > vring_transport_features(vdev); > > > > + /* Give virtio_pci a chance to accept features. */ > > + vp_transport_features(vdev, features); > > + > > if (!__virtio_test_bit(vdev, VIRTIO_F_VERSION_1)) { > > dev_err(&vdev->dev, "virtio: device uses modern interface " > > "but does not have VIRTIO_F_VERSION_1\n"); > > diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h > > index 308e2096291f..b7c1f4e7d59e 100644 > > --- a/include/uapi/linux/virtio_config.h > > +++ b/include/uapi/linux/virtio_config.h > > @@ -49,7 +49,7 @@ > > * transport being used (eg. virtio_ring), the rest are per-device feature > > * bits. */ > > #define VIRTIO_TRANSPORT_F_START 28 > > -#define VIRTIO_TRANSPORT_F_END 34 > > +#define VIRTIO_TRANSPORT_F_END 38 > > > > #ifndef VIRTIO_CONFIG_NO_LEGACY > > /* Do we get callbacks when the ring is completely used, even if we've > > @@ -71,4 +71,9 @@ > > * this is for compatibility with legacy systems. > > */ > > #define VIRTIO_F_IOMMU_PLATFORM 33 > > + > > +/* > > + * Does the device support Single Root I/O Virtualization? > > + */ > > +#define VIRTIO_F_SR_IOV 37 > > #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */ > > -- > > 2.17.0 > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org > >