From patchwork Tue Mar 6 19:30:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander H Duyck X-Patchwork-Id: 882197 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="AtqU4oXl"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zwn1f5mjQz9sgt for ; Wed, 7 Mar 2018 06:30:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754085AbeCFTaY (ORCPT ); Tue, 6 Mar 2018 14:30:24 -0500 Received: from mail-it0-f66.google.com ([209.85.214.66]:54699 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753466AbeCFTaU (ORCPT ); Tue, 6 Mar 2018 14:30:20 -0500 Received: by mail-it0-f66.google.com with SMTP id c11so240919ith.4; Tue, 06 Mar 2018 11:30:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=CuLv+rs5mWy18or5XaHfw+elVLJSsYvA3+3YSK4r3rg=; b=AtqU4oXlp14dq8zYensoWMSZquvyvLj95ddpv5pKnWPtxMwaWBj8sY4t6R+DnPsHKE LKOg4ptgV1gwnk/wggXlQOtY3eoLOp6D5yUzB1cO9xjftXO2ky4xnqpWWzGDWfpE6cTt 3UTkMXW78oU+awFFbnZarVb3aaLkbMk4tNtgnvHkgNdpIWkGcnG7Qkegd2z9YOL9M/V1 IWhmVhBr140lQ8oPH9ZG9xDIFARiHgztZQTEG80D4Dj1XN6TRh1dtljAGhPXmwijuaZG xXw0ysxYxvPx1Od4ckbguz5tyUNL2q0JoGgxQvkvcBe1aQHUxIvVky8OHkM5LJi0CAnX SyVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=CuLv+rs5mWy18or5XaHfw+elVLJSsYvA3+3YSK4r3rg=; b=cYKmlWtKJVinQDMmDfOgwLlbNSKU/dNxPvaauTXGfQ+rwcarcQjdYZ58lpfKAzSQql Pj6UxPtuBWxTa/kgoAkLKnzUrrKk+5H7v+7c8KNIgbRVNYn5dg03ALlQpcUBy5khyOl3 PK+D3L8kVSavJwT+PTMdqj2Vl456v98Gnc5eaY7XMUWDj+WgVT192ZDSBb3Nrqgef944 Fo0JcsS+u/2eVMneuw6VSVV/k0MzVoXlSWHAGx2LwkZHScZwZZwOUsxHyoDY8zShnjd6 ugsAM8XkIwlkMCcXf6KwMLtKRfDdlYVHwtDi/7eKiBgdP+jNbi2stGrtV3yHDXU3p87Q kvUg== X-Gm-Message-State: AElRT7GV8ox021l9XOQB2RvX55l84yEAY+BOJfSrmJr9zA5AHVZEQuWl 4kM4eF/HKdB4cZN2K7NDH+c= X-Google-Smtp-Source: AG47ELsO7zHOYB5OcA9UsX8MGwO2Qkj2x3nRO7i04UpJKkDeVr+E6R0tyAzPbEhCsWgjRA2EIpo91w== X-Received: by 10.36.53.197 with SMTP id k188mr20138612ita.30.1520364619461; Tue, 06 Mar 2018 11:30:19 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id v198sm7281006ita.29.2018.03.06.11.30.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 11:30:18 -0800 (PST) Subject: [pci PATCH v3 3/3] virtio_pci: Add support for unmanaged SR-IOV on virtio_pci devices From: Alexander Duyck To: bhelgaas@google.com, alexander.h.duyck@intel.com, linux-pci@vger.kernel.org Cc: virtio-dev@lists.oasis-open.org, kvm@vger.kernel.org, netdev@vger.kernel.org, dan.daly@intel.com, linux-kernel@vger.kernel.org, mheyne@amazon.de, liang-min.wang@intel.com, mark.d.rustad@intel.com, dwmw2@infradead.org, dwmw@amazon.co.uk Date: Tue, 06 Mar 2018 11:30:17 -0800 Message-ID: <20180306192957.3153.60365.stgit@localhost.localdomain> In-Reply-To: <20180306192423.3153.42741.stgit@localhost.localdomain> References: <20180306192423.3153.42741.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Alexander Duyck Hardware-realized virtio_pci devices can implement SR-IOV, so this patch enables its use. The device in question is an upcoming Intel NIC that implements both a virtio_net PF and virtio_net VFs. These are hardware realizations of what has been up to now been a software interface. The device in question has the following 4-part PCI IDs: PF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 15fe VF: vendor: 1af4 device: 1041 subvendor: 8086 subdevice: 05fe The patch currently needs no check for device ID, because the callback will never be made for devices that do not assert the capability or when run on a platform incapable of SR-IOV. One reason for this patch is because the hardware requires the vendor ID of a VF to be the same as the vendor ID of the PF that created it. So it seemed logical to simply have a fully-functioning virtio_net PF create the VFs. This patch makes that possible. Signed-off-by: Mark Rustad Signed-off-by: Alexander Duyck --- drivers/virtio/virtio_pci_common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c index 48d4d1cf1cb6..ca1549393255 100644 --- a/drivers/virtio/virtio_pci_common.c +++ b/drivers/virtio/virtio_pci_common.c @@ -584,6 +584,7 @@ static void virtio_pci_remove(struct pci_dev *pci_dev) else virtio_pci_modern_remove(vp_dev); + pci_disable_sriov(pci_dev); pci_disable_device(pci_dev); put_device(dev); } @@ -596,6 +597,9 @@ static void virtio_pci_remove(struct pci_dev *pci_dev) #ifdef CONFIG_PM_SLEEP .driver.pm = &virtio_pci_pm_ops, #endif +#ifdef CONFIG_PCI_IOV + .sriov_configure = pci_sriov_configure_unmanaged, +#endif }; module_pci_driver(virtio_pci_driver);