[Skiboot] [PATCH] pci: Clarify power down logic
Oliver O'Halloran
oohall at gmail.com
Tue Jul 31 18:43:22 AEST 2018
Currently pci_scan_bus() unconditionally calls pci_slot_set_power_state()
when it's finished scanning a bus. This is one of those things that
makes you go "WHAT?" when you first see it and frankly the skiboot PCI
code could do with less of that.
Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
core/pci.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/core/pci.c b/core/pci.c
index 5ec7dabd94eb..cd196b5ab26b 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -406,8 +406,10 @@ static void pci_slot_set_power_state(struct phb *phb,
if (state == PCI_SLOT_POWER_OFF) {
/* Bail if there're something connected */
- if (!list_empty(&pd->children))
+ if (!list_empty(&pd->children)) {
+ PCIERR(phb, pd->bdfn, "Attempted to power off slot with attached devices!\n");
return;
+ }
pci_slot_add_flags(slot, PCI_SLOT_FLAG_BOOTUP);
rc = slot->ops.get_power_state(slot, &cur_state);
@@ -920,7 +922,9 @@ uint8_t pci_scan_bus(struct phb *phb, uint8_t bus, uint8_t max_bus,
pci_cfg_write8(phb, pd->bdfn, PCI_CFG_SUBORDINATE_BUS, max_sub);
next_bus = max_sub + 1;
- pci_slot_set_power_state(phb, pd, PCI_SLOT_POWER_OFF);
+ /* power off the slot if there's nothing below it */
+ if (list_empty(&pd->children))
+ pci_slot_set_power_state(phb, pd, PCI_SLOT_POWER_OFF);
}
return max_sub;
--
2.9.5
More information about the Skiboot
mailing list