linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] virtio_pci: use common helper to configure SR-IOV
@ 2022-09-28 23:40 Max Gurtovoy
  2022-09-29  6:35 ` Johannes Thumshirn
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Max Gurtovoy @ 2022-09-28 23:40 UTC (permalink / raw)
  To: mst, stefanha, jasowang, virtualization; +Cc: linux-block, Max Gurtovoy

This is instead of re-writing the same logic in virtio driver.

Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
---
 drivers/virtio/virtio_pci_common.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
index ad258a9d3b9f..67d3970e57f2 100644
--- a/drivers/virtio/virtio_pci_common.c
+++ b/drivers/virtio/virtio_pci_common.c
@@ -607,7 +607,6 @@ static int virtio_pci_sriov_configure(struct pci_dev *pci_dev, int num_vfs)
 {
 	struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
 	struct virtio_device *vdev = &vp_dev->vdev;
-	int ret;
 
 	if (!(vdev->config->get_status(vdev) & VIRTIO_CONFIG_S_DRIVER_OK))
 		return -EBUSY;
@@ -615,19 +614,7 @@ static int virtio_pci_sriov_configure(struct pci_dev *pci_dev, int num_vfs)
 	if (!__virtio_test_bit(vdev, VIRTIO_F_SR_IOV))
 		return -EINVAL;
 
-	if (pci_vfs_assigned(pci_dev))
-		return -EPERM;
-
-	if (num_vfs == 0) {
-		pci_disable_sriov(pci_dev);
-		return 0;
-	}
-
-	ret = pci_enable_sriov(pci_dev, num_vfs);
-	if (ret < 0)
-		return ret;
-
-	return num_vfs;
+	return pci_sriov_configure_simple(pci_dev, num_vfs);
 }
 
 static struct pci_driver virtio_pci_driver = {
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-10-12 23:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-28 23:40 [PATCH 1/1] virtio_pci: use common helper to configure SR-IOV Max Gurtovoy
2022-09-29  6:35 ` Johannes Thumshirn
2022-10-12  2:31 ` Jason Wang
2022-10-12  5:02 ` Michael S. Tsirkin
2022-10-12  8:42   ` Max Gurtovoy
2022-10-12 10:01     ` Max Gurtovoy
2022-10-12 21:20       ` Bjorn Helgaas
2022-10-12 23:01         ` Max Gurtovoy
2022-10-12 23:19           ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).