]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
PCI: Set SR-IOV NumVFs to zero after enumeration
authorBjorn Helgaas <bhelgaas@google.com>
Mon, 26 Oct 2015 03:43:22 +0000 (12:43 +0900)
committerSantosh Shilimkar <santosh.shilimkar@oracle.com>
Fri, 13 Nov 2015 17:23:50 +0000 (09:23 -0800)
Orabug: 21547430

The enumeration path should leave NumVFs set to zero.  But after
4449f079722c ("PCI: Calculate maximum number of buses required for VFs"),
we call virtfn_max_buses() in the enumeration path, which changes NumVFs.
This NumVFs change is visible via lspci and sysfs until a driver enables
SR-IOV.

Set NumVFs to zero after virtfn_max_buses() computes the maximum number of
buses.

Fixes: 4449f079722c ("PCI: Calculate maximum number of buses required for VFs")
Based-on-patch-by: Ethan Zhao <ethan.zhao@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
drivers/pci/iov.c

index ee0ebff103a412bc3db69c05f0a30ecc1872be48..3abe15e46dc63e39db33356e1c120a95fc3c5a3b 100644 (file)
@@ -384,7 +384,7 @@ static int sriov_init(struct pci_dev *dev, int pos)
        int rc;
        int nres;
        u32 pgsz;
-       u16 ctrl, total, offset, stride;
+       u16 ctrl, total;
        struct pci_sriov *iov;
        struct resource *res;
        struct pci_dev *pdev;
@@ -414,11 +414,6 @@ static int sriov_init(struct pci_dev *dev, int pos)
 
 found:
        pci_write_config_word(dev, pos + PCI_SRIOV_CTRL, ctrl);
-       pci_write_config_word(dev, pos + PCI_SRIOV_NUM_VF, 0);
-       pci_read_config_word(dev, pos + PCI_SRIOV_VF_OFFSET, &offset);
-       pci_read_config_word(dev, pos + PCI_SRIOV_VF_STRIDE, &stride);
-       if (!offset || (total > 1 && !stride))
-               return -EIO;
 
        pci_read_config_dword(dev, pos + PCI_SRIOV_SUP_PGSIZE, &pgsz);
        i = PAGE_SHIFT > 12 ? PAGE_SHIFT - 12 : 0;
@@ -456,8 +451,6 @@ found:
        iov->nres = nres;
        iov->ctrl = ctrl;
        iov->total_VFs = total;
-       iov->offset = offset;
-       iov->stride = stride;
        iov->pgsz = pgsz;
        iov->self = dev;
        pci_read_config_dword(dev, pos + PCI_SRIOV_CAP, &iov->cap);
@@ -475,6 +468,11 @@ found:
        dev->sriov = iov;
        dev->is_physfn = 1;
        iov->max_VF_buses = virtfn_max_buses(dev);
+       pci_iov_set_numvfs(dev, 0);
+       if (!iov->offset || (total > 1 && !iov->stride)) {
+               rc = -EIO;
+               goto failed;
+       }
 
        return 0;
 
@@ -483,7 +481,7 @@ failed:
                res = &dev->resource[i + PCI_IOV_RESOURCES];
                res->flags = 0;
        }
-
+       dev->sriov = NULL;
        kfree(iov);
        return rc;
 }