[Skiboot] [RFC 1/2] hw/phb3: add OPAL call to get current PHB CAPI state

Andrew Donnellan andrew.donnellan at au1.ibm.com
Fri Sep 16 20:22:47 AEST 2016


Add an OPAL call, OPAL_PCI_GET_PHB_CAPI_MODE, to find out whether a PHB is
currently in CAPI mode or not.

This will be used by Linux to determine whether a PHB needs a complete
reset to disable CAPI mode post-kexec.

Signed-off-by: Andrew Donnellan <andrew.donnellan at au1.ibm.com>
---
 core/pci-opal.c                                 | 17 +++++++++++++-
 doc/opal-api/opal-pci-get-phb-capi-mode-128.rst | 24 ++++++++++++++++++-
 hw/phb3.c                                       | 14 +++++++++++-
 include/opal-api.h                              |  3 +-
 include/pci.h                                   |  2 +-
 5 files changed, 58 insertions(+), 2 deletions(-)
 create mode 100644 doc/opal-api/opal-pci-get-phb-capi-mode-128.rst

diff --git a/core/pci-opal.c b/core/pci-opal.c
index ba7a261..e877d5d 100644
--- a/core/pci-opal.c
+++ b/core/pci-opal.c
@@ -961,3 +961,20 @@ static int64_t opal_pci_set_phb_capi_mode(uint64_t phb_id, uint64_t mode, uint64
 	return rc;
 }
 opal_call(OPAL_PCI_SET_PHB_CAPI_MODE, opal_pci_set_phb_capi_mode, 3);
+
+static int64_t opal_pci_get_phb_capi_mode(uint64_t phb_id)
+{
+	struct phb *phb = pci_get_phb(phb_id);
+	int64_t rc;
+
+	if (!phb)
+		return OPAL_PARAMETER;
+	if (!phb->ops->get_capi_mode)
+		return OPAL_UNSUPPORTED;
+
+	phb_lock(phb);
+	rc = phb->ops->get_capi_mode(phb);
+	phb_unlock(phb);
+	return rc;
+}
+opal_call(OPAL_PCI_GET_PHB_CAPI_MODE, opal_pci_get_phb_capi_mode, 1);
diff --git a/doc/opal-api/opal-pci-get-phb-capi-mode-128.rst b/doc/opal-api/opal-pci-get-phb-capi-mode-128.rst
new file mode 100644
index 0000000..e5e0bc2
--- /dev/null
+++ b/doc/opal-api/opal-pci-get-phb-capi-mode-128.rst
@@ -0,0 +1,24 @@
+OPAL_PCI_GET_PHB_CAPI_MODE
+==========================
+
+Get a PHB's current CAPI mode status.
+
+Parameter
+---------
+
+``uint64_t phb_id``
+  is the value from the PHB node ibm,opal-phbid property.
+
+Return Codes
+------------
+OPAL_PARAMETER
+  The specified PHB was not found.
+
+OPAL_UNSUPPORTED
+  The specified PHB does not support this operation.
+
+OPAL_PHB_CAPI_MODE_CAPI
+  The PHB is currently in CAPI mode.
+
+OPAL_PHB_CAPI_MODE_PCIE
+  The PHB is currently in regular PCIe mode.
diff --git a/hw/phb3.c b/hw/phb3.c
index d0b5010..4425522 100644
--- a/hw/phb3.c
+++ b/hw/phb3.c
@@ -3422,6 +3422,19 @@ static int64_t enable_capi_mode(struct phb3 *p, uint64_t pe_number, bool dma_mod
 	return OPAL_SUCCESS;
 }
 
+static int64_t phb3_get_capi_mode(struct phb *phb)
+{
+	struct phb3 *p = phb_to_phb3(phb);
+	struct proc_chip *chip = get_chip(p->chip_id);
+	int64_t ret;
+	lock(&capi_lock);
+	ret = (chip->capp_phb3_attached_mask & (1 << p->index)) ?
+		OPAL_PHB_CAPI_MODE_CAPI :
+		OPAL_PHB_CAPI_MODE_PCIE;
+        unlock(&capi_lock);
+	return ret;
+}
+
 static int64_t phb3_set_capi_mode(struct phb *phb, uint64_t mode,
 				  uint64_t pe_number)
 {
@@ -3551,6 +3564,7 @@ static const struct phb_ops phb3_ops = {
 	.get_diag_data		= NULL,
 	.get_diag_data2		= phb3_get_diag_data,
 	.set_capi_mode		= phb3_set_capi_mode,
+	.get_capi_mode		= phb3_get_capi_mode,
 	.set_capp_recovery	= phb3_set_capp_recovery,
 };
 
diff --git a/include/opal-api.h b/include/opal-api.h
index f607a41..b54378e 100644
--- a/include/opal-api.h
+++ b/include/opal-api.h
@@ -181,7 +181,8 @@
 #define OPAL_INT_SET_MFRR			125
 #define OPAL_PCI_TCE_KILL			126
 #define OPAL_NMMU_SET_PTCR			127
-#define OPAL_LAST				127
+#define OPAL_PCI_GET_PHB_CAPI_MODE		128
+#define OPAL_LAST				128
 
 /* Device tree flags */
 
diff --git a/include/pci.h b/include/pci.h
index 92e3dce..7aa0bb8 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -303,7 +303,7 @@ struct phb_ops {
 	/* Put phb in capi mode or pcie mode */
 	int64_t (*set_capi_mode)(struct phb *phb, uint64_t mode,
 				 uint64_t pe_number);
-
+	int64_t (*get_capi_mode)(struct phb *phb);
 	int64_t (*set_capp_recovery)(struct phb *phb);
 };
 
-- 
git-series 0.8.10



More information about the Skiboot mailing list