Thread (53 messages) 53 messages, 7 authors, 2014-07-14
STALE4460d

Revision v3 of 3 in this series.

Revisions (3)
  1. v3 current
  2. v14 [diff vs current]
  3. v15 [diff vs current]

[RFC PATCH V3 13/17] powerpc/powernv: shift VF resource with an offset

From: Wei Yang <hidden>
Date: 2014-06-10 01:57:18
Also in: linux-pci
Subsystem: linux for powerpc (32-bit and 64-bit), the rest · Maintainers: Madhavan Srinivasan, Linus Torvalds

On powrnv platform, resource position in M64 implies the PE# the resource
belongs to. In some particular case, adjustment of a resource is necessary to
locate it to a correct position in M64.

This patch introduce a function to shift the 'real' VF BAR address according to
an offset.

Signed-off-by: Wei Yang <redacted>
---
 arch/powerpc/platforms/powernv/pci-ioda.c |   30 +++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index b0ac851..e46c5bf 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -13,6 +13,7 @@
 
 #include <linux/kernel.h>
 #include <linux/pci.h>
+#include <linux/pci_regs.h>
 #include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/string.h>
@@ -544,6 +545,35 @@ static unsigned int pnv_ioda_dma_weight(struct pci_dev *dev)
 	return 10;
 }
 
+#ifdef CONFIG_PCI_IOV
+static void pnv_pci_vf_resource_shift(struct pci_dev *dev, int offset)
+{
+	struct pci_dn *pdn = pci_get_pdn(dev);
+	int i;
+	struct resource *res;
+	resource_size_t size;
+
+	if (dev->is_physfn) {
+		for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) {
+			res = dev->resource + PCI_IOV_RESOURCES + i;
+			if (!res->flags || !res->parent)
+				continue;
+
+			if (!is_mem_pref_64_type(res->flags))
+				continue;
+
+			dev_info(&dev->dev, "PowerNV: Shifting VF BAR %pR to\n", res);
+			size = pci_sriov_resource_size(dev, PCI_IOV_RESOURCES + i);
+			res->start += size*offset;
+
+			dev_info(&dev->dev, "                         %pR\n", res);
+			pci_update_resource(dev, PCI_IOV_RESOURCES + i);
+		}
+		pdn->vfs -= offset;
+	}
+}
+#endif /* CONFIG_PCI_IOV */
+
 #if 0
 static struct pnv_ioda_pe *pnv_ioda_setup_dev_PE(struct pci_dev *dev)
 {
-- 
1.7.9.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help