cxl: Enable CAPP recovery
authorRyan Grimm <grimm@linux.vnet.ibm.com>
Mon, 19 Jan 2015 17:52:50 +0000 (11:52 -0600)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 22 Jan 2015 06:31:52 +0000 (17:31 +1100)
Turning snoops on is the last step in CAPP recovery. Sapphire is expected to
have reinitialized the PHB and done the previous recovery steps.

Add mode argument to opal call to do this. Driver can turn snoops off although
it does not currently.

Signed-off-by: Ryan Grimm <grimm@linux.vnet.ibm.com>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/opal.h
arch/powerpc/include/asm/pnv-pci.h
arch/powerpc/platforms/powernv/pci-ioda.c
drivers/misc/cxl/pci.c

index eb95b675109b64c47b58a29673c0fc5bc4cfaa46..2baf8a5925ca964067e7f3dbaa798835bd39135c 100644 (file)
@@ -595,6 +595,14 @@ enum {
        OPAL_PHB3_NUM_PEST_REGS = 256
 };
 
+/* CAPI modes for PHB */
+enum {
+       OPAL_PHB_CAPI_MODE_PCIE         = 0,
+       OPAL_PHB_CAPI_MODE_CAPI         = 1,
+       OPAL_PHB_CAPI_MODE_SNOOP_OFF    = 2,
+       OPAL_PHB_CAPI_MODE_SNOOP_ON     = 3,
+};
+
 struct OpalIoPhbErrorCommon {
        __be32 version;
        __be32 ioType;
index f09a22fa1bd79438eef538176693a2952e76e2eb..3c00d648336d781fbb434766fd903281fee29d35 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/pci.h>
 #include <misc/cxl.h>
 
-int pnv_phb_to_cxl(struct pci_dev *dev);
+int pnv_phb_to_cxl_mode(struct pci_dev *dev, uint64_t mode);
 int pnv_cxl_ioda_msi_setup(struct pci_dev *dev, unsigned int hwirq,
                           unsigned int virq);
 int pnv_cxl_alloc_hwirqs(struct pci_dev *dev, int num);
index fac88ed8a915eb782e750b6749df1bff0a9b5790..5d52d6f274f81d4d8ac6499243769a08234af80c 100644 (file)
@@ -1468,7 +1468,7 @@ struct device_node *pnv_pci_to_phb_node(struct pci_dev *dev)
 }
 EXPORT_SYMBOL(pnv_pci_to_phb_node);
 
-int pnv_phb_to_cxl(struct pci_dev *dev)
+int pnv_phb_to_cxl_mode(struct pci_dev *dev, uint64_t mode)
 {
        struct pci_controller *hose = pci_bus_to_host(dev->bus);
        struct pnv_phb *phb = hose->private_data;
@@ -1481,13 +1481,13 @@ int pnv_phb_to_cxl(struct pci_dev *dev)
 
        pe_info(pe, "Switching PHB to CXL\n");
 
-       rc = opal_pci_set_phb_cxl_mode(phb->opal_id, 1, pe->pe_number);
+       rc = opal_pci_set_phb_cxl_mode(phb->opal_id, mode, pe->pe_number);
        if (rc)
                dev_err(&dev->dev, "opal_pci_set_phb_cxl_mode failed: %i\n", rc);
 
        return rc;
 }
-EXPORT_SYMBOL(pnv_phb_to_cxl);
+EXPORT_SYMBOL(pnv_phb_to_cxl_mode);
 
 /* Find PHB for cxl dev and allocate MSI hwirqs?
  * Returns the absolute hardware IRQ number
index 014f4c928e4c5c81187f321d9930fb27d5d58ebf..a4a4e0217eed20465341e4232a541ada82d60670 100644 (file)
@@ -926,9 +926,15 @@ static struct cxl *cxl_init_adapter(struct pci_dev *dev)
        if ((rc = init_implementation_adapter_regs(adapter, dev)))
                goto err3;
 
-       if ((rc = pnv_phb_to_cxl(dev)))
+       if ((rc = pnv_phb_to_cxl_mode(dev, OPAL_PHB_CAPI_MODE_CAPI)))
                goto err3;
 
+       /* If recovery happened, the last step is to turn on snooping.
+        * In the non-recovery case this has no effect */
+       if ((rc = pnv_phb_to_cxl_mode(dev, OPAL_PHB_CAPI_MODE_SNOOP_ON))) {
+               goto err3;
+       }
+
        if ((rc = cxl_register_psl_err_irq(adapter)))
                goto err3;