[Skiboot] [PATCH 2/6] PCI: Trace device node from PCI device

Alistair Popple alistair at popple.id.au
Fri Oct 16 16:08:16 AEDT 2015


From: Gavin Shan <gwshan at linux.vnet.ibm.com>

When nvLink and nVida's GPU included in PCI topology, we have the
emulated PCI devices to represent nvLinks, which is associated with
the real GPU PCI device with help of device-tree. The patch introduces
one more field "dn" to "struct pci_device" to make the job easier.

The patch also adds one more PHB operations "device_node_fixup", which
is to be called when populating PCI device node so that we have chance
to link the emulated PCI device and the real GPU device through device
tree.

Signed-off-by: Gavin Shan <gwshan at linux.vnet.ibm.com>
---
 core/pci.c    |  7 +++++--
 include/pci.h | 11 +++++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/core/pci.c b/core/pci.c
index a8015cb..22d38b5 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -1342,7 +1342,7 @@ static void pci_add_one_node(struct phb *phb, struct pci_device *pd,
 	else
 		snprintf(name, MAX_NAME - 1, "%s@%x",
 			 cname, (pd->bdfn >> 3) & 0x1f);
-	np = dt_new(parent_node, name);
+	pd->dn = np = dt_new(parent_node, name);
 
 	/* XXX FIXME: make proper "compatible" properties */
 	if (pci_has_cap(pd, PCI_CFG_CAP_ID_EXP, false)) {
@@ -1386,9 +1386,12 @@ static void pci_add_one_node(struct phb *phb, struct pci_device *pd,
 	reg[1] = reg[2] = reg[3] = reg[4] = 0;
 	dt_add_property(np, "reg", reg, sizeof(reg));
 
+	/* Device node fixup */
+	if (phb->ops->device_node_fixup)
+		phb->ops->device_node_fixup(phb, pd);
+
 	/* Print summary info about the device */
 	pci_print_summary_line(phb, pd, np, rev_class, cname);
-
 	if (!pd->is_bridge)
 		return;
 
diff --git a/include/pci.h b/include/pci.h
index ca3f949..52579ad 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -149,6 +149,7 @@ struct pci_device {
 	uint32_t		pcrf_end;
 	struct list_head	pcrf;
 
+	struct dt_node		*dn;
 	struct pci_slot_info    *slot_info;
 	struct pci_device	*parent;
 	struct list_head	children;
@@ -198,14 +199,14 @@ struct pci_lsi_state {
 #define MAX_INT_SIZE	2
 	uint32_t int_size;			/* #cells */
 	uint32_t int_val[4][MAX_INT_SIZE];	/* INTA...INTD */
-	uint32_t int_parent[4];	
+	uint32_t int_parent[4];
 };
 
 /*
  * NOTE: All PCI functions return negative OPAL error codes
  *
  * In addition, some functions may return a positive timeout
- * value or some other state information, see the description	
+ * value or some other state information, see the description
  * of individual functions. If nothing is specified, it's
  * just an error code or 0 (success).
  *
@@ -266,6 +267,12 @@ struct phb_ops {
 	void (*device_init)(struct phb *phb, struct pci_device *device);
 
 	/*
+	 * Device node fixup is called when the PCI device node is being
+	 * populated
+	 */
+	void (*device_node_fixup)(struct phb *phb, struct pci_device *pd);
+
+	/*
 	 * EEH methods
 	 *
 	 * The various arguments are identical to the corresponding
-- 
2.1.4



More information about the Skiboot mailing list