aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Munsie <imunsie@au1.ibm.com>2016-07-13 17:17:01 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2016-07-14 06:26:33 -0400
commit4e56f858bdde5cbfb70f61baddfaa56a8ed851bf (patch)
tree37455bf364dd67f734b1f2a61290ae2367d051f2
parentf456834a6c1db36c290fdfe8ab53107adaf334e7 (diff)
cxl: Add cxl_slot_is_supported API
This extends the check that the adapter is in a CAPI capable slot so that it may be called by external users in the kernel API. This will be used by the upcoming Mellanox CX4 support, which needs to know ahead of time if the card can be switched to cxl mode so that it can leave it in PCI mode if it is not. This API takes a parameter to check if CAPP DMA mode is supported, which it currently only allows on P8NVL systems, since that mode currently has issues accessing memory < 4GB on P8, and we cannot realistically avoid that. This API does not currently check if a CAPP unit is available (i.e. not already assigned to another PHB) on P8. Doing so would be racy since it is assigned on a first come first serve basis, and so long as CAPP DMA mode is not supported on P8 we don't need this, since the only anticipated user of this API requires CAPP DMA mode. Cc: Philippe Bergheaud <felix@linux.vnet.ibm.com> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r--drivers/misc/cxl/pci.c37
-rw-r--r--include/misc/cxl.h15
2 files changed, 52 insertions, 0 deletions
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index 3a5f9801640d..6ac6b05f41a4 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -1426,6 +1426,43 @@ static int cxl_slot_is_switched(struct pci_dev *dev)
1426 return (depth > CXL_MAX_PCIEX_PARENT); 1426 return (depth > CXL_MAX_PCIEX_PARENT);
1427} 1427}
1428 1428
1429bool cxl_slot_is_supported(struct pci_dev *dev, int flags)
1430{
1431 if (!cpu_has_feature(CPU_FTR_HVMODE))
1432 return false;
1433
1434 if ((flags & CXL_SLOT_FLAG_DMA) && (!pvr_version_is(PVR_POWER8NVL))) {
1435 /*
1436 * CAPP DMA mode is technically supported on regular P8, but
1437 * will EEH if the card attempts to access memory < 4GB, which
1438 * we cannot realistically avoid. We might be able to work
1439 * around the issue, but until then return unsupported:
1440 */
1441 return false;
1442 }
1443
1444 if (cxl_slot_is_switched(dev))
1445 return false;
1446
1447 /*
1448 * XXX: This gets a little tricky on regular P8 (not POWER8NVL) since
1449 * the CAPP can be connected to PHB 0, 1 or 2 on a first come first
1450 * served basis, which is racy to check from here. If we need to
1451 * support this in future we might need to consider having this
1452 * function effectively reserve it ahead of time.
1453 *
1454 * Currently, the only user of this API is the Mellanox CX4, which is
1455 * only supported on P8NVL due to the above mentioned limitation of
1456 * CAPP DMA mode and therefore does not need to worry about this. If the
1457 * issue with CAPP DMA mode is later worked around on P8 we might need
1458 * to revisit this.
1459 */
1460
1461 return true;
1462}
1463EXPORT_SYMBOL_GPL(cxl_slot_is_supported);
1464
1465
1429static int cxl_probe(struct pci_dev *dev, const struct pci_device_id *id) 1466static int cxl_probe(struct pci_dev *dev, const struct pci_device_id *id)
1430{ 1467{
1431 struct cxl *adapter; 1468 struct cxl *adapter;
diff --git a/include/misc/cxl.h b/include/misc/cxl.h
index b6d040f31f76..dd9eebba3bb6 100644
--- a/include/misc/cxl.h
+++ b/include/misc/cxl.h
@@ -24,6 +24,21 @@
24 * generic PCI API. This API is agnostic to the actual AFU. 24 * generic PCI API. This API is agnostic to the actual AFU.
25 */ 25 */
26 26
27#define CXL_SLOT_FLAG_DMA 0x1
28
29/*
30 * Checks if the given card is in a cxl capable slot. Pass CXL_SLOT_FLAG_DMA if
31 * the card requires CAPP DMA mode to also check if the system supports it.
32 * This is intended to be used by bi-modal devices to determine if they can use
33 * cxl mode or if they should continue running in PCI mode.
34 *
35 * Note that this only checks if the slot is cxl capable - it does not
36 * currently check if the CAPP is currently available for chips where it can be
37 * assigned to different PHBs on a first come first serve basis (i.e. P8)
38 */
39bool cxl_slot_is_supported(struct pci_dev *dev, int flags);
40
41
27/* Get the AFU associated with a pci_dev */ 42/* Get the AFU associated with a pci_dev */
28struct cxl_afu *cxl_pci_to_afu(struct pci_dev *dev); 43struct cxl_afu *cxl_pci_to_afu(struct pci_dev *dev);
29 44