All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maximilian Heyne <mheyne@amazon.de>
To: linux-pci@vger.kernel.org
Cc: Maximilian Heyne <mheyne@amazon.de>
Subject: [PATCH] pci-stub: enable SR-IOV configuration through sysfs
Date: Wed, 13 Dec 2017 14:05:33 +0100	[thread overview]
Message-ID: <1513170333-19102-1-git-send-email-mheyne@amazon.de> (raw)

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 <mheyne@amazon.de>
---
 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)
-- 
2.7.4

             reply	other threads:[~2017-12-13 13:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13 13:05 Maximilian Heyne [this message]
2018-01-10 23:35 ` Bjorn Helgaas
2018-01-11  0:05   ` Alexander Duyck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1513170333-19102-1-git-send-email-mheyne@amazon.de \
    --to=mheyne@amazon.de \
    --cc=linux-pci@vger.kernel.org \
    --subject='Re: [PATCH] pci-stub: enable SR-IOV configuration through sysfs' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.