From patchwork Mon Mar 12 17:21:29 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: 884613 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="G9hyUF5F"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 400PtB4G9Kz9sBb for ; Tue, 13 Mar 2018 04:21:54 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932565AbeCLRVe (ORCPT ); Mon, 12 Mar 2018 13:21:34 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:38524 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932511AbeCLRVc (ORCPT ); Mon, 12 Mar 2018 13:21:32 -0400 Received: by mail-io0-f196.google.com with SMTP id d21so4978524ioc.5; Mon, 12 Mar 2018 10:21:32 -0700 (PDT) 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=2LGJgbgl6u1OCLZfjZ0NOomgN8bhiurlFQNN85cUQ8E=; b=G9hyUF5FuQmBovDHZq8gFenfTsin/j64q399ifTR7H4J9FTJwH/Q7oYUlfYL4a672Z HpiTZtbwlvMk3QpUrCQAb7l+pSlWroQnD44/rYfnHBDPwAM0IShDz2NsuVdIkatSqEUI nfOiSFlooIl6YW8/+tjzLzxGz7WAvZU51ZYmPzk3771bMu32Jy1eigg1Ks4CGGhWfFwH g11Ii4IeZ6Jj3HIE8GcpQxq8GWzgKlAVMRcxH3eTJjc5PQyYeeh1jQDU3Gxes8eZrZhu JjS2IB1uQGJHfmeW8VmjprFvEvnZ7ljLN2dwkEp/eO6tE9fnLUHGHzCiGdJldUvX3LEn b6+g== 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=2LGJgbgl6u1OCLZfjZ0NOomgN8bhiurlFQNN85cUQ8E=; b=lA+wOUGio43sp9ing7/kioQF7JfGnbIPKZqaw9Lg4rEVS/4U+O6if3b1UE042k7TW1 wN5uoIHkWk6HGmor7c5eDV+yzx+jwSbojFka8reW16oxtmcL3VLUen9tnR09+oKpKHS6 mAQOgOwKyTtGn6iNQvfkK5WzcTDsESGL9g1Yon2xw0zpoAXBfZr0gOkDGdAQnUv88RPU i2zwVFD6jWnqBfNAUWbnDrx1wXcxTb68saPcu+nL9M0EBWOEn5V6Anf7dVaeAd+ZMPeU lfz8P4E9WQMez87wWNpHJ5URyXavT9XpMSzuWzUSL0ZOvksw3lMCwPS+Rz+8rV5Qa8mq 3mXg== X-Gm-Message-State: AElRT7GwkCXAPFNAURUW25RLY1igBuncnZPGEttLRFRRabXvk6I1MLMl ka47NxjV5vbh/nKwfJEkrdA= X-Google-Smtp-Source: AG47ELsnmrsCLVWpAubV9D2ft/kfh0cd7arMgQO+SI055AiUyAh+hAUa/b2yk0VXYvZUFp5nLHDudQ== X-Received: by 10.107.163.204 with SMTP id m195mr9694442ioe.295.1520875291725; Mon, 12 Mar 2018 10:21:31 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id f76sm5433814ioi.41.2018.03.12.10.21.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 10:21:31 -0700 (PDT) Subject: [pci PATCH v5 1/4] pci: Add pci_sriov_configure_simple for PFs that don't manage VF resources 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, linux-nvme@lists.infradead.org, keith.busch@intel.com, netanel@amazon.com, mheyne@amazon.de, liang-min.wang@intel.com, mark.d.rustad@intel.com, dwmw2@infradead.org, hch@lst.de, dwmw@amazon.co.uk Date: Mon, 12 Mar 2018 10:21:29 -0700 Message-ID: <20180312172031.3487.20651.stgit@localhost.localdomain> In-Reply-To: <20180312171813.3487.94803.stgit@localhost.localdomain> References: <20180312171813.3487.94803.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 This patch adds a common configuration function called pci_sriov_configure_simple that will allow for managing VFs on devices where the PF is not capable of managing VF resources. Signed-off-by: Alexander Duyck --- v5: New patch replacing pci_sriov_configure_unmanaged with pci_sriov_configure_simple Dropped bits related to autoprobe changes drivers/pci/iov.c | 32 ++++++++++++++++++++++++++++++++ include/linux/pci.h | 1 + 2 files changed, 33 insertions(+) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 677924ae0350..bd7021491fdb 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -807,3 +807,35 @@ int pci_sriov_get_totalvfs(struct pci_dev *dev) return dev->sriov->total_VFs; } EXPORT_SYMBOL_GPL(pci_sriov_get_totalvfs); + +/** + * pci_sriov_configure_simple - helper to configure unmanaged SR-IOV + * @dev: the PCI device + * @nr_virtfn: number of virtual functions to enable, 0 to disable + * + * Used to provide generic enable/disable SR-IOV option for devices + * that do not manage the VFs generated by their driver + */ +int pci_sriov_configure_simple(struct pci_dev *dev, int nr_virtfn) +{ + int err = -EINVAL; + + might_sleep(); + + if (!dev->is_physfn) + return -ENODEV; + + if (pci_vfs_assigned(dev)) { + pci_warn(dev, + "Cannot modify SR-IOV while VFs are assigned\n"); + err = -EPERM; + } else if (!nr_virtfn) { + sriov_disable(dev); + err = 0; + } else if (!dev->sriov->num_VFs) { + err = sriov_enable(dev, nr_virtfn); + } + + return err ? err : nr_virtfn; +} +EXPORT_SYMBOL_GPL(pci_sriov_configure_simple); diff --git a/include/linux/pci.h b/include/linux/pci.h index 024a1beda008..9cab9d0d51dc 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1953,6 +1953,7 @@ static inline void pci_mmcfg_late_init(void) { } int pci_vfs_assigned(struct pci_dev *dev); int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs); int pci_sriov_get_totalvfs(struct pci_dev *dev); +int pci_sriov_configure_simple(struct pci_dev *dev, int nr_virtfn); resource_size_t pci_iov_resource_size(struct pci_dev *dev, int resno); void pci_vf_drivers_autoprobe(struct pci_dev *dev, bool probe); #else From patchwork Mon Mar 12 17:23:02 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: 884618 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="rCuYO3cu"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 400Pvc48xZz9sRG for ; Tue, 13 Mar 2018 04:23:08 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932551AbeCLRXG (ORCPT ); Mon, 12 Mar 2018 13:23:06 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:45298 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932386AbeCLRXF (ORCPT ); Mon, 12 Mar 2018 13:23:05 -0400 Received: by mail-pf0-f196.google.com with SMTP id h19so4627626pfd.12; Mon, 12 Mar 2018 10:23:04 -0700 (PDT) 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=GLbk1dPDPkbmVuSmBKN0IkqkTzu578dWEqiTnimtC1Q=; b=rCuYO3cuzaAM6Bcj5aDIkl1EWfucVtrTLkbFPltiVbMmk7+njQDpVdWVRRf8bc1gxv qepNR0UCMay8STtLAKcCTu+KGNuMwtMEfMPMUqbli4l29bn2lf6ac8+qdc8ZUF0ChCYm crscMWZ8NPAPRlOJDYS5n6WsjUGWUPBqSQHKC7VVlzR5qxGTZsMOKOSSdM7pD102Z/L/ tPQ0gn4SFN5hyPataJQmM+3sDATnN30tafBnWNFVgy5c8o0HoKy1a/yXtc2FVoHcv5f3 L+5GR6cbQe8SKzxJvy/a/DS7J5ejXix6GWLLCl3v3mLmsDfNN7Ism7Mtm4fyWJeoYgoq juzg== 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=GLbk1dPDPkbmVuSmBKN0IkqkTzu578dWEqiTnimtC1Q=; b=p3kL122XZNtcnY2N8EuG7jIf8tuPRAi4bG8AqgrIEiKjIjavYVQikcUzIWiZQQMkmV KHWfd0sWJBrrrKtllxaPWcitjI++bhkGtX5NOYkxliG3LAZyXCRJoR1bHVtnrxyvu3dx ISRoWoSBm8DDtjbN3Y8FZteKtqDB+M3xbU+DOWBocl5AKG0xYZgAlI6o5Th0ezZto8ra WZNJoR9240PcYMuNdwB38n/CJKcOkJdrU3htZvrlRZSbl1G0/Kr3oUkIQRbmHcKORl7O CD6nm+ze0hVC/w3JTvFXV651UQ1rrLiHcV9ZfLv7Ubq6JxFAkolutoqUk15Upaa38uiV YU8Q== X-Gm-Message-State: AElRT7Eo9sOPZSYhb0vIhpqlLtW7rDRZe1kxgDn6IRRFGd80pbVLEXdM fLOMXDMxT+UjECJWcoxdGZw= X-Google-Smtp-Source: AG47ELvyAxjrX86Pwt+OZ1ktOZiXYotmpC1VdGOwse2XpTwI9tk/5K8AkwGqqlJB6pfuEwlF55vFxg== X-Received: by 10.98.33.76 with SMTP id h73mr8651697pfh.144.1520875384238; Mon, 12 Mar 2018 10:23:04 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id r30sm18391118pff.7.2018.03.12.10.23.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 10:23:03 -0700 (PDT) Subject: [pci PATCH v5 2/4] 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, linux-nvme@lists.infradead.org, keith.busch@intel.com, netanel@amazon.com, mheyne@amazon.de, liang-min.wang@intel.com, mark.d.rustad@intel.com, dwmw2@infradead.org, hch@lst.de, dwmw@amazon.co.uk Date: Mon, 12 Mar 2018 10:23:02 -0700 Message-ID: <20180312172136.3487.95702.stgit@localhost.localdomain> In-Reply-To: <20180312171813.3487.94803.stgit@localhost.localdomain> References: <20180312171813.3487.94803.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 --- v4: Dropped call to pci_disable_sriov in virtio_pci_remove function v5: Replaced call to pci_sriov_configure_unmanaged with pci_sriov_configure_simple drivers/virtio/virtio_pci_common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c index 48d4d1cf1cb6..41938d36b0cb 100644 --- a/drivers/virtio/virtio_pci_common.c +++ b/drivers/virtio/virtio_pci_common.c @@ -596,6 +596,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_simple, +#endif }; module_pci_driver(virtio_pci_driver); From patchwork Mon Mar 12 17:23:28 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: 884620 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="LQBKFcfP"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 400Pw916mgz9sRG for ; Tue, 13 Mar 2018 04:23:36 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932589AbeCLRXe (ORCPT ); Mon, 12 Mar 2018 13:23:34 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:46848 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932525AbeCLRXd (ORCPT ); Mon, 12 Mar 2018 13:23:33 -0400 Received: by mail-pg0-f66.google.com with SMTP id r26so6769922pgv.13; Mon, 12 Mar 2018 10:23:33 -0700 (PDT) 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=yPOrNFIaknCHLL4ErcPDEjpH2V2R0WMcQsgm9ohgL6g=; b=LQBKFcfPAktY2h0QRvVEn35P13m+VsK66BNmJN56Z9mD9v1BRGudbRdtjhs2aMu2Er +D+zhcZ4hFFKS6C98QFA/sXkjQnZNRBxZoTwF1An/eoe3cBt84QiLjaZZDCOayXG8hAG K3DpIUdq7sR0D2jH4vxWpYDL4x03ptG5LelQc1twBw68LADXz1+RV3dt2ErWV0NFx1GM y22hfnFOvaB6GUPi0EVUdZeTxuxscfj1vDzX7o5h3qAN0Hk/MTgqnpgkU7EzfbZtTo2v BJZ5H3XskrMPJQ15vagoKK7wRa4hs2s8prHbyhBQq1G+XV5c4L5Y6auDFEQvWOqZB8wo oZmQ== 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=yPOrNFIaknCHLL4ErcPDEjpH2V2R0WMcQsgm9ohgL6g=; b=nimsck0IyAeTCAAnK7l8HyPXl6ClnozhJbEdeB5pdbDs0nS/serWR1k7Zv5bzBTRfs uPZlHaxdUiFXjozRNp3SawuTQ7B4zlG/BJeZ2gaY2a8cOPhZWHoyIphkgWAzA8ALeHFI zI3PQMVRSSOVv2hrs4Tee+OVoWilok7eYkD8+S9sDvBucLc43CUZTROpWQR78o9P+WeQ 3bLNja/T3gd3MnR1J9Lgcb8vUih3/NBoqPy3mIFyboLIsxoND9dao7W4ut6QcC+RvUpj Lqk/z2Udp2Ih8Vj6aGkRvPE8Z89zdl17TIk4w8cmXyr27Vsyqakw7YaNVzWHKVURkf73 j/1Q== X-Gm-Message-State: AElRT7EmQ2E822FEmJMhHZR7kOHsS2jJrC1EhMYa6pFslAKOFDYlTv0O /sZ39z+IjSrGlnZc+VQuC3o= X-Google-Smtp-Source: AG47ELvLzWh5t9/4BuH9FJ4+iXSzwWqTa8RWGDqm05YAlDt8iZaQB21LuWu51EH5nXmV9aF1xzE3Yw== X-Received: by 10.98.159.85 with SMTP id g82mr8697827pfe.15.1520875412841; Mon, 12 Mar 2018 10:23:32 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id e125sm14282564pgc.76.2018.03.12.10.23.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 10:23:32 -0700 (PDT) Subject: [pci PATCH v5 3/4] ena: Migrate over to unmanaged SR-IOV support 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, linux-nvme@lists.infradead.org, keith.busch@intel.com, netanel@amazon.com, mheyne@amazon.de, liang-min.wang@intel.com, mark.d.rustad@intel.com, dwmw2@infradead.org, hch@lst.de, dwmw@amazon.co.uk Date: Mon, 12 Mar 2018 10:23:28 -0700 Message-ID: <20180312172309.3487.76690.stgit@localhost.localdomain> In-Reply-To: <20180312171813.3487.94803.stgit@localhost.localdomain> References: <20180312171813.3487.94803.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 Instead of implementing our own version of a SR-IOV configuration stub in the ena driver we can just reuse the existing pci_sriov_configure_simple function. Signed-off-by: Alexander Duyck --- v5: Replaced call to pci_sriov_configure_unmanaged with pci_sriov_configure_simple drivers/net/ethernet/amazon/ena/ena_netdev.c | 30 +++----------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index 6975150d144e..868069363bdd 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -3385,32 +3385,6 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } /*****************************************************************************/ -static int ena_sriov_configure(struct pci_dev *dev, int numvfs) -{ - int rc; - - if (numvfs > 0) { - rc = pci_enable_sriov(dev, numvfs); - if (rc != 0) { - dev_err(&dev->dev, - "pci_enable_sriov failed to enable: %d vfs with the error: %d\n", - numvfs, rc); - return rc; - } - - return numvfs; - } - - if (numvfs == 0) { - pci_disable_sriov(dev); - return 0; - } - - return -EINVAL; -} - -/*****************************************************************************/ -/*****************************************************************************/ /* ena_remove - Device Removal Routine * @pdev: PCI device information struct @@ -3525,7 +3499,9 @@ static int ena_resume(struct pci_dev *pdev) .suspend = ena_suspend, .resume = ena_resume, #endif - .sriov_configure = ena_sriov_configure, +#ifdef CONFIG_PCI_IOV + .sriov_configure = pci_sriov_configure_simple, +#endif }; static int __init ena_init(void) From patchwork Mon Mar 12 17:23:43 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: 884623 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="IsLC/tKn"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 400PxC5lhzz9sBb for ; Tue, 13 Mar 2018 04:24:31 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932724AbeCLRXt (ORCPT ); Mon, 12 Mar 2018 13:23:49 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:35736 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932525AbeCLRXq (ORCPT ); Mon, 12 Mar 2018 13:23:46 -0400 Received: by mail-io0-f195.google.com with SMTP id k21so8415297ioc.2; Mon, 12 Mar 2018 10:23:46 -0700 (PDT) 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=GBkpve6/5pAIZOqNWwRZbUtNg0PNjrl7Q83xIfxgp6U=; b=IsLC/tKnpB2EEVKdeChiwzCYS0pRNARrJAHPGboPeLW1Rkbd2/5oK54VnaECoBX09M DZP3mmwv9fToJFAQqBj1v5ueDMB+kTE8lRrhy31FkYWSQy2raLcrkF+pdoiNhbR3jx1l e/L6JEJxwzSSuPmeGb7flEDzzRfY2jH260G8dmzmH0/K0TEf+QqUtBsfZVolInqap6qQ 1ESXTYOd6xH+7iymYa8HV3+9a97UWSagJ7roOnJ3fmw6ELThYPSf7nVRkLDMfC5wLFym ORLE9HXW5PQOYr0Wo1F7c34QjElhniVQe9CrKyF9IAZu1DqEEFLotp4Fj+bRaEdfaumG Qb7A== 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=GBkpve6/5pAIZOqNWwRZbUtNg0PNjrl7Q83xIfxgp6U=; b=M8LqGGr919TNEfJJzvQOL92rTo4thhIrHn7S45K6GSGVDVrn34n58hREZbb4DxBZ0E q5zxcOQCIA7rdJy0atQjxesmSLd6oampcBOpxQZCrHAhCIkE0hIP+RAy4vxlvwPVXZ/J aiwzAiSggFVOFQErIxjDPTTWYS9RrS1GAbUakqtmxSN/9RIW1MGR2KUAniwOKJuVG6c+ vezWbfoFAvDW+vqjLdb9hsT67sNBtCOlbsTUBeZKUE6/EnLULXgnq2Qzs3X+6e/soEkV O7NLbTX6O3/Vq2A07dO3Xw/wqQxDUBCgCdV07DhrL2vKt7x+SJ3vYvmOE6v5bKUpy6zJ FuXw== X-Gm-Message-State: AElRT7GJOYpYj9IB2A01f0dMqFzsnOaBbehRrWkBUMKFn5BeL2gEYXFw hoPg6Cj6l1m1b85cwr1a3mw= X-Google-Smtp-Source: AG47ELvU/7+S8C76IvoYpKV9FImNJR/v18OGsCbN3xqmiWEJHp0UO6no868HXdERw75lpEj6LO9RrA== X-Received: by 10.107.63.131 with SMTP id m125mr9448574ioa.211.1520875425628; Mon, 12 Mar 2018 10:23:45 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id i81sm3849367itb.21.2018.03.12.10.23.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 10:23:45 -0700 (PDT) Subject: [pci PATCH v5 4/4] nvme: Migrate over to unmanaged SR-IOV support 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, linux-nvme@lists.infradead.org, keith.busch@intel.com, netanel@amazon.com, mheyne@amazon.de, liang-min.wang@intel.com, mark.d.rustad@intel.com, dwmw2@infradead.org, hch@lst.de, dwmw@amazon.co.uk Date: Mon, 12 Mar 2018 10:23:43 -0700 Message-ID: <20180312172337.3487.95817.stgit@localhost.localdomain> In-Reply-To: <20180312171813.3487.94803.stgit@localhost.localdomain> References: <20180312171813.3487.94803.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 Instead of implementing our own version of a SR-IOV configuration stub in the nvme driver we can just reuse the existing pci_sriov_configure_simple function. Signed-off-by: Alexander Duyck --- v5: Replaced call to pci_sriov_configure_unmanaged with pci_sriov_configure_simple drivers/nvme/host/pci.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 5933a5c732e8..3b582f9f8cac 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2580,24 +2580,6 @@ static void nvme_remove(struct pci_dev *pdev) nvme_put_ctrl(&dev->ctrl); } -static int nvme_pci_sriov_configure(struct pci_dev *pdev, int numvfs) -{ - int ret = 0; - - if (numvfs == 0) { - if (pci_vfs_assigned(pdev)) { - dev_warn(&pdev->dev, - "Cannot disable SR-IOV VFs while assigned\n"); - return -EPERM; - } - pci_disable_sriov(pdev); - return 0; - } - - ret = pci_enable_sriov(pdev, numvfs); - return ret ? ret : numvfs; -} - #ifdef CONFIG_PM_SLEEP static int nvme_suspend(struct device *dev) { @@ -2716,7 +2698,9 @@ static void nvme_error_resume(struct pci_dev *pdev) .driver = { .pm = &nvme_dev_pm_ops, }, - .sriov_configure = nvme_pci_sriov_configure, +#ifdef CONFIG_PCI_IOV + .sriov_configure = pci_sriov_configure_simple, +#endif .err_handler = &nvme_err_handler, };