Skip to content

Commit

Permalink
phb4: Rework retries so we can do more than one
Browse files Browse the repository at this point in the history
This reworks the pci link training retry code so that we can do more
than one retry.

This will now also print an error if a link fails to train.

Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
mikey authored and stewartsmith committed Jul 13, 2017
1 parent 17b6f2b commit 652340a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
14 changes: 7 additions & 7 deletions hw/phb4.c
Expand Up @@ -2166,13 +2166,12 @@ static int64_t phb4_retry_state(struct pci_slot *slot)
{
struct phb4 *p = phb_to_phb4(slot->phb);

if (slot->retry_state == PCI_SLOT_STATE_NORMAL)
return OPAL_WRONG_STATE;
if (!slot->link_retries--) {
PHBERR(p, "Link detected but won't train\n");
return OPAL_HARDWARE;
}

PHBDBG(p, "Retry state %08x\n", slot->retry_state);
slot->delay_tgt_tb = 0;
pci_slot_set_state(slot, slot->retry_state);
slot->retry_state = PCI_SLOT_STATE_NORMAL;
pci_slot_set_state(slot, PHB4_SLOT_CRESET_START);
return pci_slot_set_sm_timeout(slot, msecs_to_tb(1));
}

Expand Down Expand Up @@ -2325,7 +2324,7 @@ static int64_t phb4_freset(struct pci_slot *slot)
}

PHBDBG(p, "FRESET: Prepare for link down\n");
slot->retry_state = PHB4_SLOT_CRESET_START;

if (slot->ops.prepare_link_change)
slot->ops.prepare_link_change(slot, false);
/* fall through */
Expand Down Expand Up @@ -2513,6 +2512,7 @@ static struct pci_slot *phb4_slot_create(struct phb *phb)
slot->ops.hreset = phb4_hreset;
slot->ops.freset = phb4_freset;
slot->ops.creset = phb4_creset;
slot->link_retries = 1;

return slot;
}
Expand Down
1 change: 1 addition & 0 deletions include/pci-slot.h
Expand Up @@ -184,6 +184,7 @@ struct pci_slot {
uint32_t slot_cap;
uint64_t delay_tgt_tb;
uint64_t retries;
uint64_t link_retries;
struct pci_slot_ops ops;
void *data;
};
Expand Down

0 comments on commit 652340a

Please sign in to comment.