[Skiboot] [PATCH v2 1/4] core/pci: Use cached VDID when populating device node

Gavin Shan gwshan at linux.vnet.ibm.com
Mon Jun 19 16:46:46 AEST 2017


No need to read the VDID from HW when populating the PCI device
node, as it has been cached in pd->vdid.

Signed-off-by: Gavin Shan <gwshan at linux.vnet.ibm.com>
---
 core/pci.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/core/pci.c b/core/pci.c
index 63d9d24..7cd29fd 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -1435,12 +1435,9 @@ static void pci_print_summary_line(struct phb *phb, struct pci_device *pd,
 				   const char *cname)
 {
 	const char *label, *dtype, *s;
-	u32 vdid;
 #define MAX_SLOTSTR 32
 	char slotstr[MAX_SLOTSTR  + 1] = { 0, };
 
-	pci_cfg_read32(phb, pd->bdfn, 0, &vdid);
-
 	/* If it's a slot, it has a slot-label */
 	label = dt_prop_get_def(np, "ibm,slot-label", NULL);
 	if (label) {
@@ -1479,13 +1476,15 @@ static void pci_print_summary_line(struct phb *phb, struct pci_device *pd,
 	if (pd->is_bridge)
 		PCINOTICE(phb, pd->bdfn,
 			  "[%s] %04x %04x R:%02x C:%06x B:%02x..%02x %s\n",
-			  dtype, vdid & 0xffff, vdid >> 16,
+			  dtype, PCI_VENDOR_ID(pd->vdid),
+			  PCI_DEVICE_ID(pd->vdid),
 			  rev_class & 0xff, rev_class >> 8, pd->secondary_bus,
 			  pd->subordinate_bus, slotstr);
 	else
 		PCINOTICE(phb, pd->bdfn,
 			  "[%s] %04x %04x R:%02x C:%06x (%14s) %s\n",
-			  dtype, vdid & 0xffff, vdid >> 16,
+			  dtype, PCI_VENDOR_ID(pd->vdid),
+			  PCI_DEVICE_ID(pd->vdid),
 			  rev_class & 0xff, rev_class >> 8, cname, slotstr);
 }
 
@@ -1500,7 +1499,7 @@ static void pci_add_one_device_node(struct phb *phb,
 #define MAX_NAME 256
 	char name[MAX_NAME];
 	char compat[MAX_NAME];
-	uint32_t rev_class, vdid;
+	uint32_t rev_class;
 	uint32_t reg[5];
 	uint8_t intpin;
 	const uint32_t ranges_direct[] = {
@@ -1511,7 +1510,6 @@ static void pci_add_one_device_node(struct phb *phb,
 				0x02000000, 0x0, 0x0,
 				0xf0000000, 0x0};
 
-	pci_cfg_read32(phb, pd->bdfn, 0, &vdid);
 	pci_cfg_read32(phb, pd->bdfn, PCI_CFG_REV_ID, &rev_class);
 	pci_cfg_read8(phb, pd->bdfn, PCI_CFG_INT_PIN, &intpin);
 
@@ -1536,17 +1534,17 @@ static void pci_add_one_device_node(struct phb *phb,
 	/* XXX FIXME: make proper "compatible" properties */
 	if (pci_has_cap(pd, PCI_CFG_CAP_ID_EXP, false)) {
 		snprintf(compat, MAX_NAME, "pciex%x,%x",
-			 vdid & 0xffff, vdid >> 16);
+			 PCI_VENDOR_ID(pd->vdid), PCI_DEVICE_ID(pd->vdid));
 		dt_add_property_cells(np, "ibm,pci-config-space-type", 1);
 	} else {
 		snprintf(compat, MAX_NAME, "pci%x,%x",
-			 vdid & 0xffff, vdid >> 16);
+			 PCI_VENDOR_ID(pd->vdid), PCI_DEVICE_ID(pd->vdid));
 		dt_add_property_cells(np, "ibm,pci-config-space-type", 0);
 	}
 	dt_add_property_cells(np, "class-code", rev_class >> 8);
 	dt_add_property_cells(np, "revision-id", rev_class & 0xff);
-	dt_add_property_cells(np, "vendor-id", vdid & 0xffff);
-	dt_add_property_cells(np, "device-id", vdid >> 16);
+	dt_add_property_cells(np, "vendor-id", PCI_VENDOR_ID(pd->vdid));
+	dt_add_property_cells(np, "device-id", PCI_DEVICE_ID(pd->vdid));
 	if (intpin)
 		dt_add_property_cells(np, "interrupts", intpin);
 
-- 
2.7.4



More information about the Skiboot mailing list