All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hw/phb3: improve handling of PHB init failure
@ 2016-10-21  5:51 Andrew Donnellan
  2016-10-21  5:56 ` [Skiboot] " Andrew Donnellan
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Donnellan @ 2016-10-21  5:51 UTC (permalink / raw)
  To: skiboot, gwshan; +Cc: stable

PHB initialisation in phb3_init_hw() can fail for a number of reasons, such
as DLP reset timeout, root complex config space init failure, etc. When
this occurs, an error message is printed to the console and the PHB's state
is set to PHB3_STATE_BROKEN.

However, currently both phb3_create() and phb3_creset() will continue on
trying to set up the PHB or reset it respectively. This doesn't seem like a
particularly good idea.

Make phb3_init_hw() return OPAL_HARDWARE on failure, and make phb3_creset()
and phb3_create() abort appropriately on failure.

Cc: stable
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

---

Gavin: in phb3_create() is returning before the platform.pci_setup_phb()
call the right thing to do in this case?
---
 hw/phb3.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/hw/phb3.c b/hw/phb3.c
index 1c09ffe..cdfc38a 100644
--- a/hw/phb3.c
+++ b/hw/phb3.c
@@ -38,7 +38,7 @@
 /* Enable this to disable error interrupts for debug purposes */
 #undef DISABLE_ERR_INTS
 
-static void phb3_init_hw(struct phb3 *p, bool first_init);
+static int64_t phb3_init_hw(struct phb3 *p, bool first_init);
 
 #define PHBDBG(p, fmt, a...)	prlog(PR_DEBUG, "PHB#%04x: " fmt, \
 				      (p)->phb.opal_id, ## a)
@@ -2481,6 +2481,7 @@ static int64_t phb3_creset(struct pci_slot *slot)
 {
 	struct phb3 *p = phb_to_phb3(slot->phb);
 	uint64_t cqsts, val;
+	int64_t rc;
 
 	switch (slot->state) {
 	case PHB3_SLOT_NORMAL:
@@ -2545,7 +2546,9 @@ static int64_t phb3_creset(struct pci_slot *slot)
 		 */
 		p->flags &= ~PHB3_AIB_FENCED;
 		p->flags &= ~PHB3_CAPP_RECOVERY;
-		phb3_init_hw(p, false);
+		rc = phb3_init_hw(p, false);
+		if (rc)
+			goto error;
 
 		pci_slot_set_state(slot, PHB3_SLOT_CRESET_FRESET);
 		return pci_slot_set_sm_timeout(slot, msecs_to_tb(100));
@@ -4023,7 +4026,7 @@ static int64_t phb3_fixup_pec_inits(struct phb3 *p)
 	return 0;
 }
 
-static void phb3_init_hw(struct phb3 *p, bool first_init)
+static int64_t phb3_init_hw(struct phb3 *p, bool first_init)
 {
 	uint64_t val;
 
@@ -4221,11 +4224,12 @@ static void phb3_init_hw(struct phb3 *p, bool first_init)
 
 	PHBDBG(p, "Initialization complete\n");
 
-	return;
+	return OPAL_SUCCESS;
 
  failed:
 	PHBERR(p, "Initialization failed\n");
 	p->state = PHB3_STATE_BROKEN;
+	return OPAL_HARDWARE;
 }
 
 static void phb3_allocate_tables(struct phb3 *p)
@@ -4413,6 +4417,7 @@ static void phb3_create(struct dt_node *np)
 	struct proc_chip *chip;
 	int opal_id;
 	char *path;
+	int64_t rc;
 
 	assert(p);
 
@@ -4531,7 +4536,9 @@ static void phb3_create(struct dt_node *np)
 	register_irq_source(&phb3_lsi_irq_ops, p, p->base_lsi, 8);
 
 	/* Get the HW up and running */
-	phb3_init_hw(p, true);
+	rc = phb3_init_hw(p, true);
+	if (rc)
+		return;
 
 	/* Load capp microcode into capp unit */
 	capp_load_ucode(p);
-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com  IBM Australia Limited


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Skiboot] [PATCH] hw/phb3: improve handling of PHB init failure
  2016-10-21  5:51 [PATCH] hw/phb3: improve handling of PHB init failure Andrew Donnellan
@ 2016-10-21  5:56 ` Andrew Donnellan
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Donnellan @ 2016-10-21  5:56 UTC (permalink / raw)
  To: skiboot, gwshan; +Cc: stable

On 21/10/16 16:51, Andrew Donnellan wrote:
> PHB initialisation in phb3_init_hw() can fail for a number of reasons, such
> as DLP reset timeout, root complex config space init failure, etc. When
> this occurs, an error message is printed to the console and the PHB's state
> is set to PHB3_STATE_BROKEN.
>
> However, currently both phb3_create() and phb3_creset() will continue on
> trying to set up the PHB or reset it respectively. This doesn't seem like a
> particularly good idea.
>
> Make phb3_init_hw() return OPAL_HARDWARE on failure, and make phb3_creset()
> and phb3_create() abort appropriately on failure.
>
> Cc: stable

Argh, git-send-email interpreted this as a Cc to stable@vger.kernel.org 
and I didn't notice...

Please disregard, stable kernel people! skiboot people should probably 
drop their Cc on replies...

-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com  IBM Australia Limited


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-10-21  5:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-21  5:51 [PATCH] hw/phb3: improve handling of PHB init failure Andrew Donnellan
2016-10-21  5:56 ` [Skiboot] " Andrew Donnellan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.