[Skiboot] [PATCH v12 12/23] core/pci: Return value for struct phb_ops::device_init

Gavin Shan gwshan at linux.vnet.ibm.com
Fri Jun 10 15:03:41 AEST 2016


This adds @data argument and "int" return value for struct phb_ops::
device_init() so that it can be called in pci_walk_dev() directly to
reinitialize the PCI devices behind the specified slot in subsequent
patches.

Signed-off-by: Gavin Shan <gwshan at linux.vnet.ibm.com>
---
 core/pci.c     |  2 +-
 hw/p7ioc-phb.c | 12 ++++++++++--
 hw/phb3.c      | 12 ++++++++++--
 include/pci.h  |  3 ++-
 4 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/core/pci.c b/core/pci.c
index 8040932..b36d5a6 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -255,7 +255,7 @@ static struct pci_device *pci_scan_one(struct phb *phb, struct pci_device *paren
 	 * Call PHB hook
 	 */
 	if (phb->ops->device_init)
-		phb->ops->device_init(phb, pd);
+		phb->ops->device_init(phb, pd, NULL);
 
 	return pd;
  fail:
diff --git a/hw/p7ioc-phb.c b/hw/p7ioc-phb.c
index a50bae0..9e52d31 100644
--- a/hw/p7ioc-phb.c
+++ b/hw/p7ioc-phb.c
@@ -2180,7 +2180,9 @@ static void p7ioc_endpoint_init(struct phb *phb,
 	pci_cfg_write32(phb, bdfn, aercap + PCIECAP_AER_CAPCTL, val32);
 }
 
-static void p7ioc_device_init(struct phb *phb, struct pci_device *dev)
+static int p7ioc_device_init(struct phb *phb,
+			     struct pci_device *dev,
+			     void *data __unused)
 {
 	int ecap = 0;
 	int aercap = 0;
@@ -2209,6 +2211,8 @@ static void p7ioc_device_init(struct phb *phb, struct pci_device *dev)
 		p7ioc_switch_port_init(phb, dev, ecap, aercap);
 	else
 		p7ioc_endpoint_init(phb, dev, ecap, aercap);
+
+	return 0;
 }
 
 static int64_t p7ioc_pci_reinit(struct phb *phb,
@@ -2216,6 +2220,7 @@ static int64_t p7ioc_pci_reinit(struct phb *phb,
 {
 	struct pci_device *pd;
 	uint16_t bdfn = data;
+	int ret;
 
 	if (scope != OPAL_REINIT_PCI_DEV)
 		return OPAL_PARAMETER;
@@ -2224,7 +2229,10 @@ static int64_t p7ioc_pci_reinit(struct phb *phb,
 	if (!pd)
 		return OPAL_PARAMETER;
 
-	p7ioc_device_init(phb, pd);
+	ret = p7ioc_device_init(phb, pd, NULL);
+	if (ret)
+		return OPAL_HARDWARE;
+
 	return OPAL_SUCCESS;
 }
 
diff --git a/hw/phb3.c b/hw/phb3.c
index 9a67560..c9906c7 100644
--- a/hw/phb3.c
+++ b/hw/phb3.c
@@ -526,7 +526,9 @@ static void phb3_check_device_quirks(struct phb *phb, struct pci_device *dev)
 	}
 }
 
-static void phb3_device_init(struct phb *phb, struct pci_device *dev)
+static int phb3_device_init(struct phb *phb,
+			    struct pci_device *dev,
+			    void *data __unused)
 {
 	int ecap = 0;
 	int aercap = 0;
@@ -558,12 +560,15 @@ static void phb3_device_init(struct phb *phb, struct pci_device *dev)
 		phb3_switch_port_init(phb, dev, ecap, aercap);
 	else
 		phb3_endpoint_init(phb, dev, ecap, aercap);
+
+	return 0;
 }
 
 static int64_t phb3_pci_reinit(struct phb *phb, uint64_t scope, uint64_t data)
 {
 	struct pci_device *pd;
 	uint16_t bdfn = data;
+	int ret;
 
 	if (scope != OPAL_REINIT_PCI_DEV)
 		return OPAL_PARAMETER;
@@ -572,7 +577,10 @@ static int64_t phb3_pci_reinit(struct phb *phb, uint64_t scope, uint64_t data)
 	if (!pd)
 		return OPAL_PARAMETER;
 
-	phb3_device_init(phb, pd);
+	ret = phb3_device_init(phb, pd, NULL);
+	if (ret)
+		return OPAL_HARDWARE;
+
 	return OPAL_SUCCESS;
 }
 
diff --git a/include/pci.h b/include/pci.h
index 788f1ef..69be49e 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -261,7 +261,8 @@ struct phb_ops {
 	 * and before probing further. It can alter things like scan_map
 	 * for bridge ports etc...
 	 */
-	void (*device_init)(struct phb *phb, struct pci_device *device);
+	int (*device_init)(struct phb *phb, struct pci_device *device,
+			   void *data);
 
 	/* PHB final fixup is called after PCI probing is completed */
 	void (*phb_final_fixup)(struct phb *phb);
-- 
2.1.0



More information about the Skiboot mailing list