From patchwork Thu Mar 8 19:04:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 10268701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D3918602BD for ; Thu, 8 Mar 2018 19:04:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4D1729A97 for ; Thu, 8 Mar 2018 19:04:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B76B829A99; Thu, 8 Mar 2018 19:04:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B2A229A97 for ; Thu, 8 Mar 2018 19:04:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756125AbeCHTEN (ORCPT ); Thu, 8 Mar 2018 14:04:13 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:56297 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752173AbeCHTEJ (ORCPT ); Thu, 8 Mar 2018 14:04:09 -0500 Received: by mail-it0-f67.google.com with SMTP id n136so6377066itg.5; Thu, 08 Mar 2018 11:04:09 -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=68i5zWzVYqXun91nDXwf8CHf3I37XEKxFfn/1UvGzXw=; b=OsKyNFKXHBD7M3Kk2KGe70fEUYbhV9bFMPtXli8Dskm4x0jqdqpeN1qmdAR94POAFh bXX4EHrTzOdgWYYXKUrWzPtMHqpaiYIFwG9qyxiNEd5m1ngWQRZparPSbIPEe2nZ5i2R Wz+piR/az/3K2HHZ9n0FDcKZS2gwqcZ2cFCpgmEQf3ea9I20N3jh88vlPJbTIIUiSO/v yM3msJ6YrJ6nFM7EV3fOMAM4oeHfGrS5WoX0GQWi7yAhBxCocKRN3qpQDgIZPrWHykQ7 rVA1QjbWgErL03iT1oDdSktk8iWD9RWvzr+urEB/w6ZV6ML+Fehl4l/yQXU9xAoAQxT6 qINQ== 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=68i5zWzVYqXun91nDXwf8CHf3I37XEKxFfn/1UvGzXw=; b=bkZ/FrlEaiSm8jsA4Z9Q6HcxBuDu8BV7SwHC/UMlSCyKEonn3NpdopF89EI0lfeX2s f9o0+3rHBko3DKNamOThxbq/JcgYXAyZfDlP2++6j/6PXauo+2u6pxjKRKeV+G+vi0Rz r4h6qoM6BLFny+EhlthcArV01WKhvFqr2CvpS0fviAJCReJJMImmtfTTZhnBwQg9LFEv yeJNmuttbfy7qttuDqVyNKiTFqQwmUaSZfSfrxMv2vOizwKiuDVHxaIa8f1RXJnNn7Um WzIXzV8BI88s0jy2wvsRLrz+FGik4pyiKOt4oaqR7Ibvo5gYZ/tyaWULDbYRbCm6pQE2 GReg== X-Gm-Message-State: AElRT7H8t1ngWUH2+wqtqkRTUlkPZZUC1Iy9JVM9h1iZKReCtlQJkf4Z Vj16qYuAliu/+jbuVidPZxrlm62ekTI= X-Google-Smtp-Source: AG47ELtnoUN+YTPXRANzErx5jDa2p/eJguh74vVwFLgbthnG/+NySGdHccmEp02kLmIunHbNun3G9g== X-Received: by 10.36.131.72 with SMTP id d69mr28598466ite.21.1520535848637; Thu, 08 Mar 2018 11:04:08 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id i31sm14525147iod.78.2018.03.08.11.04.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Mar 2018 11:04:08 -0800 (PST) Subject: [pci PATCH v4 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: Thu, 08 Mar 2018 11:04:06 -0800 Message-ID: <20180308190401.5433.13861.stgit@localhost.localdomain> In-Reply-To: <20180308185507.5433.98830.stgit@localhost.localdomain> References: <20180308185507.5433.98830.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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_unmanaged function. Signed-off-by: Alexander Duyck --- 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 6fe7af00a1f4..2c753ccc1771 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2570,24 +2570,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) { @@ -2706,7 +2688,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_unmanaged, +#endif .err_handler = &nvme_err_handler, };