From patchwork Wed Dec 13 13:05:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Heyne X-Patchwork-Id: 10109935 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 B7BCD60352 for ; Wed, 13 Dec 2017 13:06:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB16A28809 for ; Wed, 13 Dec 2017 13:06:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F1AF28B8F; Wed, 13 Dec 2017 13:06:00 +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, RCVD_IN_DNSWL_HI autolearn=ham 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 27F1628809 for ; Wed, 13 Dec 2017 13:06:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752861AbdLMNF7 (ORCPT ); Wed, 13 Dec 2017 08:05:59 -0500 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:5134 "EHLO smtp-fw-6002.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752847AbdLMNF6 (ORCPT ); Wed, 13 Dec 2017 08:05:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1513170358; x=1544706358; h=from:to:cc:subject:date:message-id; bh=a7cGHXAkvzTl37XpxfOEXJbGTlpgML9RGanAn+O2al4=; b=jtfN8/thQh7SZkFi0hWM1zPvbeKNqji7Uysk0GoMFqdJY366exWvb6oJ E8nfISLPy3mCO+Il1sZWvCKfZVvHSirEuJ1uQLn7v0wxODFPAd2P9LZSe U4i/HDZoDhDn6JtxSdAeHEPE86jZfYwNNm7XWehBBeAMVpn8/Evc0nxuF o=; X-IronPort-AV: E=Sophos;i="5.45,397,1508803200"; d="scan'208";a="322115219" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-c7c08562.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 13 Dec 2017 13:05:49 +0000 Received: from u54e1ad169d435975afaa.ant.amazon.com (iad1-ws-svc-lb91-vlan2.amazon.com [10.0.103.146]) by email-inbound-relay-1e-c7c08562.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id vBDD5jhG058381 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 13 Dec 2017 13:05:47 GMT Received: from u54e1ad169d435975afaa.ant.amazon.com (localhost [127.0.0.1]) by u54e1ad169d435975afaa.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id vBDD5jCL019243; Wed, 13 Dec 2017 14:05:45 +0100 Received: (from mheyne@localhost) by u54e1ad169d435975afaa.ant.amazon.com (8.15.2/8.15.2/Submit) id vBDD5iC8019240; Wed, 13 Dec 2017 14:05:44 +0100 From: Maximilian Heyne To: linux-pci@vger.kernel.org Cc: Maximilian Heyne Subject: [PATCH] pci-stub: enable SR-IOV configuration through sysfs Date: Wed, 13 Dec 2017 14:05:33 +0100 Message-Id: <1513170333-19102-1-git-send-email-mheyne@amazon.de> X-Mailer: git-send-email 2.7.4 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 Currently, SR-IOV VFs can only be configured through sysfs, if a driver is loaded for the device. Sometimes we don't care about the PF, but only want to assign VFs to guests, which is now possible with this patch. Signed-off-by: Maximilian Heyne --- drivers/pci/pci-stub.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/pci/pci-stub.c b/drivers/pci/pci-stub.c index 886fb35..aa007c3 100644 --- a/drivers/pci/pci-stub.c +++ b/drivers/pci/pci-stub.c @@ -32,10 +32,27 @@ static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id) return 0; } +static void pci_stub_remove(struct pci_dev *dev) +{ + pci_disable_sriov(dev); +} + +static int pci_stub_sriov_configure(struct pci_dev *dev, int num_vfs) +{ + if (!num_vfs) { + pci_disable_sriov(dev); + return 0; + } + + return pci_enable_sriov(dev, num_vfs); +} + static struct pci_driver stub_driver = { - .name = "pci-stub", - .id_table = NULL, /* only dynamic id's */ - .probe = pci_stub_probe, + .name = "pci-stub", + .id_table = NULL, /* only dynamic IDs */ + .probe = pci_stub_probe, + .remove = pci_stub_remove, + .sriov_configure = pci_stub_sriov_configure, }; static int __init pci_stub_init(void)