aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin Shan <gwshan@linux.vnet.ibm.com>2017-05-24 12:30:23 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-06-19 14:49:29 +1000
commitd065caf3b3101400744d4afb915edf57755a0c95 (patch)
tree942551ef104847c84d6689ea9c299e6847b12863
parent92d7ccf00bdd6c994341feb013390c28993652bf (diff)
downloadskiboot-d065caf3b3101400744d4afb915edf57755a0c95.zip
skiboot-d065caf3b3101400744d4afb915edf57755a0c95.tar.gz
skiboot-d065caf3b3101400744d4afb915edf57755a0c95.tar.bz2
hw/phb4: Rework phb4_get_presence_state()
There are two issues in current implementation: It should return errcode visibile to Linux, which has prefix OPAL_*. The code isn't very obvious. This returns OPAL_HARDWARE when the PHB is broken. Otherwise, OPAL_SUCCESS is always returned. In the mean while, It refactors the code to make it obvious: OPAL_PCI_SLOT_PRESENT is returned when the presence signal (low active) or PCIe link is active. Otherwise, OPAL_PCI_SLOT_EMPTY is returned. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--hw/phb4.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/hw/phb4.c b/hw/phb4.c
index fdc843a..a06d38c 100644
--- a/hw/phb4.c
+++ b/hw/phb4.c
@@ -1845,36 +1845,26 @@ static int64_t phb4_get_presence_state(struct pci_slot *slot, uint8_t *val)
if (p->state == PHB4_STATE_BROKEN)
return OPAL_HARDWARE;
- /* Read hotplug status */
+ /* Check hotplug status */
hps = in_be64(p->regs + PHB_PCIE_HOTPLUG_STATUS);
-
- /* Read link status */
- dtctl = in_be64(p->regs + PHB_PCIE_DLP_TRAIN_CTL);
-
- PHBDBG(p, "hp_status=0x%016llx, dlp_train_ctl=0x%016llx\n",
- hps, dtctl);
-
- *val = OPAL_PCI_SLOT_PRESENT;
- /* Check presence detect */
- if (hps & PHB_PCIE_HPSTAT_PRESENCE) {
- /* If it says not present but link is up, then we assume
+ if (!(hps & PHB_PCIE_HPSTAT_PRESENCE)) {
+ *val = OPAL_PCI_SLOT_PRESENT;
+ } else {
+ /*
+ * If it says not present but link is up, then we assume
* we are on a broken simulation environment and still
* return a valid presence. Otherwise, not present.
*/
+ dtctl = in_be64(p->regs + PHB_PCIE_DLP_TRAIN_CTL);
if (dtctl & PHB_PCIE_DLP_TL_LINKACT) {
PHBERR(p, "Presence detect 0 but link set !\n");
- return OPAL_SHPC_DEV_PRESENT;
+ *val = OPAL_PCI_SLOT_PRESENT;
+ } else {
+ *val = OPAL_PCI_SLOT_EMPTY;
}
- *val = OPAL_PCI_SLOT_EMPTY;
- return OPAL_SHPC_DEV_NOT_PRESENT;
}
- /*
- * Anything else, we assume device present, the link state
- * machine will perform an early bail out if no electrical
- * signaling is established after a second.
- */
- return OPAL_SHPC_DEV_PRESENT;
+ return OPAL_SUCCESS;
}
static int64_t phb4_get_link_state(struct pci_slot *slot, uint8_t *val)