[PATCH v2] PCI: Don't update VF's BAR

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



VF BARs are RO zero, so updating VF BARs will not take any effect.
See the SR-IOV spec r1.1, sec 3.4.1.11.

Also this patch adds a warning in pci_update_resource() in case someone
really tries to update it.

Signed-off-by: Wei Yang <weiyang@xxxxxxxxxxxxxxxxxx>
---
 drivers/pci/pci.c       |    7 +++++++
 drivers/pci/setup-res.c |    5 +++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 0008c95..93c0d24 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -483,6 +483,13 @@ static void pci_restore_bars(struct pci_dev *dev)
 {
 	int i;
 
+        /* 
+	 * Per SRIOV SPEC 3.4.1.11, VF BARs are RO zero.
+	 * If this is a VF, just return.
+	 */
+	if (dev->is_virtfn)
+		return;
+
 	for (i = 0; i < PCI_BRIDGE_RESOURCES; i++)
 		pci_update_resource(dev, i);
 }
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 232f925..ebe57db 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -36,6 +36,11 @@ void pci_update_resource(struct pci_dev *dev, int resno)
 	enum pci_bar_type type;
 	struct resource *res = dev->resource + resno;
 
+	if (dev->is_virtfn) {
+		dev_warn(&dev->dev, "Trying to update VF BAR\n");
+		return;
+	}
+
 	/*
 	 * Ignore resources for unimplemented BARs and unused resource slots
 	 * for 64 bit BARs.
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux