summaryrefslogtreecommitdiffstats
path: root/hw/phb4.c
diff options
context:
space:
mode:
authorVaibhav Jain <vaibhav@linux.ibm.com>2019-01-13 11:07:11 +0530
committerStewart Smith <stewart@linux.ibm.com>2019-01-16 00:46:49 -0600
commit1a87f8f971751702665edcc8800f30438cc8eb19 (patch)
tree39b8423b11fa3fff94e7d4f96ed914a2f5f1f270 /hw/phb4.c
parent763f397d5be7580e3ecf525ca5939f3ab9f6ff5d (diff)
downloadblackbird-skiboot-1a87f8f971751702665edcc8800f30438cc8eb19.tar.gz
blackbird-skiboot-1a87f8f971751702665edcc8800f30438cc8eb19.zip
phb4/capp: Update and re-factor phb4_set_capi_mode()
Presently phb4_set_capi_mode() performs certain CAPP checks like, checking of CAPP ucode loaded or checks if CAPP is still in recovery, even when the requested mode is to switch to PCI mode. Hence this patch updates and re-factors phb4_set_capi_mode() to make sure CAPP related checks are only performed when request to enable CAPP is made by mode==OPAL_PHB_CAPI_MODE_CAPI/DMA_TVT1. We also update other possible modes requests to return a more appropriate status code based on if CAPP is activated or not. Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Reviewed-by: Christophe Lombard <clombard@linux.vnet.ibm.com> Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com> Reviewed-by: Frederic Barrat <fbarrat@linux.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Diffstat (limited to 'hw/phb4.c')
-rw-r--r--hw/phb4.c88
1 files changed, 53 insertions, 35 deletions
diff --git a/hw/phb4.c b/hw/phb4.c
index a0431d4f..e712b230 100644
--- a/hw/phb4.c
+++ b/hw/phb4.c
@@ -4441,54 +4441,72 @@ static int64_t phb4_set_capi_mode(struct phb *phb, uint64_t mode,
struct proc_chip *chip = get_chip(p->chip_id);
struct capp *capp = p->capp;
uint64_t reg, ret;
- uint32_t offset;
-
- if (capp == NULL)
- return OPAL_UNSUPPORTED;
- if (!capp_ucode_loaded(chip, p->index)) {
- PHBERR(p, "CAPP: ucode not loaded\n");
- return OPAL_RESOURCE;
- }
-
- /* mark the capp attached to the phb */
- capp->phb = phb;
- capp->attached_pe = pe_number;
+ /* cant do a mode switch when capp is in recovery mode */
+ ret = capp_xscom_read(capp, CAPP_ERR_STATUS_CTRL, &reg);
+ if (ret != OPAL_SUCCESS)
+ return ret;
- offset = PHB4_CAPP_REG_OFFSET(p);
- xscom_read(p->chip_id, CAPP_ERR_STATUS_CTRL + offset, &reg);
- if ((reg & PPC_BIT(5))) {
- PHBERR(p, "CAPP: recovery failed (%016llx)\n", reg);
- return OPAL_HARDWARE;
- } else if ((reg & PPC_BIT(0)) && (!(reg & PPC_BIT(1)))) {
+ if ((reg & PPC_BIT(0)) && (!(reg & PPC_BIT(1)))) {
PHBDBG(p, "CAPP: recovery in progress\n");
return OPAL_BUSY;
}
+
switch (mode) {
- case OPAL_PHB_CAPI_MODE_CAPI:
- ret = enable_capi_mode(p, pe_number,
- CAPP_MAX_STQ_ENGINES |
- CAPP_MIN_DMA_READ_ENGINES);
- disable_fast_reboot("CAPP being enabled");
+
+ case OPAL_PHB_CAPI_MODE_DMA: /* Enabled by default on p9 */
+ case OPAL_PHB_CAPI_MODE_SNOOP_ON:
+ /* nothing to do on P9 if CAPP is already enabled */
+ ret = p->capp->phb ? OPAL_SUCCESS : OPAL_UNSUPPORTED;
break;
- case OPAL_PHB_CAPI_MODE_DMA_TVT1:
- ret = enable_capi_mode(p, pe_number,
- CAPP_MIN_STQ_ENGINES |
- CAPP_MAX_DMA_READ_ENGINES);
- disable_fast_reboot("CAPP being enabled");
+
+ case OPAL_PHB_CAPI_MODE_SNOOP_OFF:
+ case OPAL_PHB_CAPI_MODE_PCIE: /* Not supported at the moment */
+ ret = p->capp->phb ? OPAL_UNSUPPORTED : OPAL_SUCCESS;
break;
- case OPAL_PHB_CAPI_MODE_SNOOP_ON:
- /* nothing to do P9 if CAPP is alreay enabled */
- ret = OPAL_SUCCESS;
+
+ case OPAL_PHB_CAPI_MODE_CAPI: /* Fall Through */
+ case OPAL_PHB_CAPI_MODE_DMA_TVT1:
+ /* Check if ucode is available */
+ if (!capp_ucode_loaded(chip, p->index)) {
+ PHBERR(p, "CAPP: ucode not loaded\n");
+ ret = OPAL_RESOURCE;
+ break;
+ }
+
+ /*
+ * Mark the CAPP attached to the PHB right away so that
+ * if a MCE happens during CAPP init we can handle it.
+ * In case of an error in CAPP init we remove the PHB
+ * from the attached_mask later.
+ */
+ capp->phb = phb;
+ capp->attached_pe = pe_number;
+
+ if (mode == OPAL_PHB_CAPI_MODE_DMA_TVT1)
+ ret = enable_capi_mode(p, pe_number,
+ CAPP_MIN_STQ_ENGINES |
+ CAPP_MAX_DMA_READ_ENGINES);
+
+ else
+ ret = enable_capi_mode(p, pe_number,
+ CAPP_MAX_STQ_ENGINES |
+ CAPP_MIN_DMA_READ_ENGINES);
+ if (ret == OPAL_SUCCESS) {
+ /* Disable fast reboot for CAPP */
+ disable_fast_reboot("CAPP being enabled");
+ } else {
+ /* In case of an error mark the PHB detached */
+ capp->phb = NULL;
+ capp->attached_pe = phb4_get_reserved_pe_number(phb);
+ }
break;
- case OPAL_PHB_CAPI_MODE_PCIE: /* shouldn't be called on p9*/
- case OPAL_PHB_CAPI_MODE_DMA: /* Enabled by default on p9 */
- case OPAL_PHB_CAPI_MODE_SNOOP_OFF: /* shouldn't be called on p9*/
default:
ret = OPAL_UNSUPPORTED;
- }
+ break;
+ };
return ret;
}
OpenPOWER on IntegriCloud