Received: by 10.192.165.148 with SMTP id m20csp750146imm; Fri, 20 Apr 2018 15:09:55 -0700 (PDT) X-Google-Smtp-Source: AIpwx49KyRcquDGAcAKY62KZ7aDg7/maolx5YeXUBnJlch/6SQRCFPKtP5Wwp7TALUo+a0GMwUGX X-Received: by 10.98.245.139 with SMTP id b11mr10894338pfm.113.1524262195448; Fri, 20 Apr 2018 15:09:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524262195; cv=none; d=google.com; s=arc-20160816; b=Mo3XNgk4vofO3Pvr5zS2Ppruab/W35F7l5y9xH+1jYyGpFRmB24iVpCn3szWT62/NZ gkWfpxmHcjOAnOfKRSIeNBYuEBo2zG9p1ZLVMsGViCQt1N50NSLP4yUAFpG5MMiDQxdv BWm0kMShZPhczSRWC5ejQIcBbHY+Bg3e18fRjvEEy4SgIquqamMBkas9hemd0QxAZpUE qViRaz4dfoH4jSqBxD1Zqo7hiUDHOG5Ep9UJt0EvJtzB/t5EbW6wLY7llCyzCUXG+sfp PRkp90ncDsNvqehcIpuXH/fuhti7oFN72f/HSimmFEYr4UNYQtSivWkMqeR9OVhj740R bhyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=5JPaFO1+peaKr2TKVTgjhPWGXtmYACrMTBibTdRhfog=; b=zuAonvB8ZFLhz45LNl/pnYBTrEJnPv3J1zDZeQR+qDZv2+07TNe7HpQgm7j2/tp6wr ylKEFQ9baEEOLKLYIiC0M/D6tEAm6sQBQp5fyOpHM6hL1449DdEJe+nmwY/J5/z4FCix 4gK1c8gkhf6yGvjlQaC2B1M5fc08jeknltMV5xTxki9hcKPa/CyUMGq0tGRGHeXeouDy Spo/o2H8BaAum24h1BvaAw3bh6Am8ftrvta7uSkZoi0KE29oXgD5TEJkkfr8qla2Mnu9 tLFfiR9ThM4HfFU7bWNLmuaju0MMWtWhCy6mk9R8wWmQYDyTBVNhhb65s/kur+uggzb1 iZyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QiBu/tIx; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g85si6207257pfg.192.2018.04.20.15.09.17; Fri, 20 Apr 2018 15:09:55 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QiBu/tIx; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752686AbeDTWG3 (ORCPT + 99 others); Fri, 20 Apr 2018 18:06:29 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:35748 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751865AbeDTWG1 (ORCPT ); Fri, 20 Apr 2018 18:06:27 -0400 Received: by mail-pl0-f65.google.com with SMTP id w21-v6so5949871plq.2; Fri, 20 Apr 2018 15:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=5JPaFO1+peaKr2TKVTgjhPWGXtmYACrMTBibTdRhfog=; b=QiBu/tIxFIkCJ4rqOopsMLffY1zril7JesEOSIxvT5uG4kSXjzpNB1x48Ulb2+Fj4u o9491um6s0E38sy+0D80PxRYa5+MPgYbjzBgC2PQb0zJVr21HHBnjexZOJ3/ZupyqXdJ jjvcce3tc8C8l42jJ6qerUhsVTkA5v8Sts39Wxi8CmSlKVLQ5vpduMZxmM18J1L9L7iq N5gg1fI50CwQ0DHF52Md9AyzKnb75ZzLGjo51YWv/qTl+9DHBoiiJNaEPLUb5IbvGyF7 5FFGLW2hTOxhelTxkCVE39lj9/8Dk95javhb9Q5JTnakANOnG0GJGKgJxUC4m8BWKwLm DmwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=5JPaFO1+peaKr2TKVTgjhPWGXtmYACrMTBibTdRhfog=; b=XS00kVof5hVynnI1iuAvE2D967mGlqg3xu9AyMkv2JpqzMBnaJiTDkv5RbBrh+b8id KS9RbQgNum/rJMMFDjtiiiih99y2gWfCQ9Gu6/yEFqzH2LZboJkDKCLZr0Q6gqt5W6tV z53YtxtINkh0NDU4I2bDg2pDYyI6Yh2bnAr/JenUY/qNXbyn0ZK6P+FH8sV23rIgRI6t BRDZ0bhDarTPYPMhb7xq3MCi+NgORHnmIPWIwh+wY7dQFtThqXtAVYVHnQd7j3v0gRC8 yW7b5MIQ1aaGa1gf87ywJdcTZtZMcFvq6Nxjb8d5hTFjZ026l39yADgkoeZlEQIerskI gcKg== X-Gm-Message-State: ALQs6tCaiQPhzP+/en+OWZlDmjA8QUSB/wNhfOobtOqvUTZkt53PAZGl FFRQus5lR1P0HT8E9jOcoZcNGzzOuVo= X-Received: by 2002:a17:902:7b84:: with SMTP id w4-v6mr3654049pll.116.1524261986785; Fri, 20 Apr 2018 15:06:26 -0700 (PDT) Received: from [192.168.0.16] (67-5-146-204.ptld.qwest.net. [67.5.146.204]) by smtp.gmail.com with ESMTPSA id w1sm8177435pfb.39.2018.04.20.15.06.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 15:06:26 -0700 (PDT) Subject: Re: [pci PATCH v8 1/4] pci: Add pci_sriov_configure_simple for PFs that don't manage VF resources To: Alexander Duyck , bhelgaas@google.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, ddutile@redhat.com, mheyne@amazon.de, liang-min.wang@intel.com, mark.d.rustad@intel.com, dwmw2@infradead.org, hch@lst.de, dwmw@amazon.co.uk References: <20180420162633.46077.49012.stgit@ahduyck-green-test.jf.intel.com> <20180420162814.46077.11939.stgit@ahduyck-green-test.jf.intel.com> From: Gregory Rose Message-ID: <2f23908d-13c6-55c8-217f-d8be5bd450c5@gmail.com> Date: Fri, 20 Apr 2018 15:06:24 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180420162814.46077.11939.stgit@ahduyck-green-test.jf.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/20/2018 9:28 AM, Alexander Duyck wrote: > 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 > Tested-by: Mark Rustad > --- > > v5: New patch replacing pci_sriov_configure_unmanaged with > pci_sriov_configure_simple > Dropped bits related to autoprobe changes > v6: Defined pci_sriov_configure_simple as NULL if IOV is disabled > v7: Updated pci_sriov_configure_simple to drop need for err value > Fixed comment explaining why pci_sriov_configure_simple is NULL > > drivers/pci/iov.c | 31 +++++++++++++++++++++++++++++++ > include/linux/pci.h | 3 +++ > 2 files changed, 34 insertions(+) > > diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c > index 677924a..3e0a7fd 100644 > --- a/drivers/pci/iov.c > +++ b/drivers/pci/iov.c > @@ -807,3 +807,34 @@ 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. Return value > + * is negative on error, or number of VFs allocated on success. > + */ > +int pci_sriov_configure_simple(struct pci_dev *dev, int nr_virtfn) > +{ > + 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"); > + return -EPERM; > + } > + > + if (!nr_virtfn) { > + sriov_disable(dev); > + return 0; > + } > + > + return sriov_enable(dev, nr_virtfn) ? : nr_virtfn; > +} > +EXPORT_SYMBOL_GPL(pci_sriov_configure_simple); > diff --git a/include/linux/pci.h b/include/linux/pci.h > index ae42289..7d36e39 100644 > --- a/include/linux/pci.h > +++ b/include/linux/pci.h > @@ -1955,6 +1955,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 > @@ -1982,6 +1983,8 @@ static inline int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs) > { return 0; } > static inline int pci_sriov_get_totalvfs(struct pci_dev *dev) > { return 0; } > +/* this is expected to be used as a function pointer, just define as NULL */ > +#define pci_sriov_configure_simple NULL > static inline resource_size_t pci_iov_resource_size(struct pci_dev *dev, int resno) > { return 0; } > static inline void pci_vf_drivers_autoprobe(struct pci_dev *dev, bool probe) { } > Thanks Alex! Reviewed-by: Greg Rose