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 Duyck X-Patchwork-Id: 10276815 X-Patchwork-Delegate: bhelgaas@google.com 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 C2FA1603B5 for ; Mon, 12 Mar 2018 17:24:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADB38285A4 for ; Mon, 12 Mar 2018 17:24:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A09DB286A4; Mon, 12 Mar 2018 17:24:31 +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 5A6C0285A4 for ; Mon, 12 Mar 2018 17:24:31 +0000 (UTC) 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 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_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, };