[Skiboot] [PATCH v11 22/23] core/opal: Extend opal_pci_set_power_state()

Gavin Shan gwshan at linux.vnet.ibm.com
Fri May 20 16:32:24 AEST 2016


The API opal_pci_set_power_state() applied PCI hotplug on target
slot. The power supply to the slot is changed accordingly. It's
not the expected behaviour for CAPI developers. They want one
specific slot offline or online without affecting the power supply.

This extends opal_pci_set_power_state() to meet the requirement.

Signed-off-by: Gavin Shan <gwshan at linux.vnet.ibm.com>
---
 core/pci-opal.c                               | 17 +++++++++++++++++
 doc/opal-api/opal-pci-set-power-state-121.txt |  5 +++++
 include/opal-api.h                            |  4 +++-
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/core/pci-opal.c b/core/pci-opal.c
index 460e39f..c0f399c 100644
--- a/core/pci-opal.c
+++ b/core/pci-opal.c
@@ -711,6 +711,7 @@ static int64_t opal_pci_set_power_state(uint64_t async_token,
 {
 	struct pci_slot *slot = pci_slot_find(id);
 	struct phb *phb = slot ? slot->phb : NULL;
+	struct pci_device *pd = slot ? slot->pd : NULL;
 	uint8_t *state = (uint8_t *)data;
 	int64_t rc;
 
@@ -736,6 +737,22 @@ static int64_t opal_pci_set_power_state(uint64_t async_token,
 		slot->async_token = async_token;
 		rc = slot->ops.set_power_state(slot, PCI_SLOT_POWER_ON);
 		break;
+	case OPAL_PCI_SLOT_OFFLINE:
+		if (!pd)
+			return OPAL_PARAMETER;
+
+		pci_remove_bus(phb, &pd->children);
+		rc = OPAL_SUCCESS;
+		break;
+	case OPAL_PCI_SLOT_ONLINE:
+		if (!pd)
+			return OPAL_PARAMETER;
+		pci_scan_bus(phb, pd->secondary_bus, pd->subordinate_bus,
+			     &pd->children, pd, true);
+		pci_add_device_nodes(phb, &pd->children, pd->dn,
+				     &phb->lstate, 0);
+		rc = OPAL_SUCCESS;
+		break;
 	default:
 		rc = OPAL_PARAMETER;
 	}
diff --git a/doc/opal-api/opal-pci-set-power-state-121.txt b/doc/opal-api/opal-pci-set-power-state-121.txt
index ef19aff..8bc6595 100644
--- a/doc/opal-api/opal-pci-set-power-state-121.txt
+++ b/doc/opal-api/opal-pci-set-power-state-121.txt
@@ -18,6 +18,11 @@ contains the API completion status: event (Power off or on), device node's
 phandle identifying the PCI slot, errcode (e.g. OPAL_SUCCESS). The API returns
 OPAL_ASYNC_COMPLETION for the case.
 
+User (e.g. CAPI developers) might make a specified slot offline or online
+without affecting its power state. User should use OPAL_PCI_SLOT_OFFLINE
+or OPAL_PCI_SLOT_ONLINE in the parameter. The API should returns OPAL_SUCCESS
+immediately without further asynchronous message sent.
+
 Return Codes:
 
 OPAL_SUCCESS - PCI hotplug on the slot is completed successfully
diff --git a/include/opal-api.h b/include/opal-api.h
index f06613e..4203f66 100644
--- a/include/opal-api.h
+++ b/include/opal-api.h
@@ -386,7 +386,9 @@ enum OpalPciSlotPresentenceState {
 
 enum OpalPciSlotPowerState {
 	OPAL_PCI_SLOT_POWER_OFF	= 0,
-	OPAL_PCI_SLOT_POWER_ON	= 1
+	OPAL_PCI_SLOT_POWER_ON	= 1,
+	OPAL_PCI_SLOT_OFFLINE	= 2,
+	OPAL_PCI_SLOT_ONLINE	= 3
 };
 
 enum OpalSlotLedType {
-- 
2.1.0



More information about the Skiboot mailing list