Skip to content

Commit 1212aa1

Browse files
Ryan Grimmmpe
authored andcommitted
cxl: Enable CAPP recovery
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 <[email protected]> Acked-by: Ian Munsie <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 95bc11b commit 1212aa1

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

arch/powerpc/include/asm/opal.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,14 @@ enum {
595595
OPAL_PHB3_NUM_PEST_REGS = 256
596596
};
597597

598+
/* CAPI modes for PHB */
599+
enum {
600+
OPAL_PHB_CAPI_MODE_PCIE = 0,
601+
OPAL_PHB_CAPI_MODE_CAPI = 1,
602+
OPAL_PHB_CAPI_MODE_SNOOP_OFF = 2,
603+
OPAL_PHB_CAPI_MODE_SNOOP_ON = 3,
604+
};
605+
598606
struct OpalIoPhbErrorCommon {
599607
__be32 version;
600608
__be32 ioType;

arch/powerpc/include/asm/pnv-pci.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <linux/pci.h>
1414
#include <misc/cxl.h>
1515

16-
int pnv_phb_to_cxl(struct pci_dev *dev);
16+
int pnv_phb_to_cxl_mode(struct pci_dev *dev, uint64_t mode);
1717
int pnv_cxl_ioda_msi_setup(struct pci_dev *dev, unsigned int hwirq,
1818
unsigned int virq);
1919
int pnv_cxl_alloc_hwirqs(struct pci_dev *dev, int num);

arch/powerpc/platforms/powernv/pci-ioda.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ struct device_node *pnv_pci_to_phb_node(struct pci_dev *dev)
14681468
}
14691469
EXPORT_SYMBOL(pnv_pci_to_phb_node);
14701470

1471-
int pnv_phb_to_cxl(struct pci_dev *dev)
1471+
int pnv_phb_to_cxl_mode(struct pci_dev *dev, uint64_t mode)
14721472
{
14731473
struct pci_controller *hose = pci_bus_to_host(dev->bus);
14741474
struct pnv_phb *phb = hose->private_data;
@@ -1481,13 +1481,13 @@ int pnv_phb_to_cxl(struct pci_dev *dev)
14811481

14821482
pe_info(pe, "Switching PHB to CXL\n");
14831483

1484-
rc = opal_pci_set_phb_cxl_mode(phb->opal_id, 1, pe->pe_number);
1484+
rc = opal_pci_set_phb_cxl_mode(phb->opal_id, mode, pe->pe_number);
14851485
if (rc)
14861486
dev_err(&dev->dev, "opal_pci_set_phb_cxl_mode failed: %i\n", rc);
14871487

14881488
return rc;
14891489
}
1490-
EXPORT_SYMBOL(pnv_phb_to_cxl);
1490+
EXPORT_SYMBOL(pnv_phb_to_cxl_mode);
14911491

14921492
/* Find PHB for cxl dev and allocate MSI hwirqs?
14931493
* Returns the absolute hardware IRQ number

drivers/misc/cxl/pci.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,9 +926,15 @@ static struct cxl *cxl_init_adapter(struct pci_dev *dev)
926926
if ((rc = init_implementation_adapter_regs(adapter, dev)))
927927
goto err3;
928928

929-
if ((rc = pnv_phb_to_cxl(dev)))
929+
if ((rc = pnv_phb_to_cxl_mode(dev, OPAL_PHB_CAPI_MODE_CAPI)))
930930
goto err3;
931931

932+
/* If recovery happened, the last step is to turn on snooping.
933+
* In the non-recovery case this has no effect */
934+
if ((rc = pnv_phb_to_cxl_mode(dev, OPAL_PHB_CAPI_MODE_SNOOP_ON))) {
935+
goto err3;
936+
}
937+
932938
if ((rc = cxl_register_psl_err_irq(adapter)))
933939
goto err3;
934940

0 commit comments

Comments
 (0)