aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorIan Munsie <imunsie@au1.ibm.com>2015-02-04 03:09:02 -0500
committerMichael Ellerman <mpe@ellerman.id.au>2015-02-05 19:16:58 -0500
commit3d5be0392f52489b7572903d83f1f267f26e6b69 (patch)
tree6a8ac7ae7fbc02ad1851bd1e02d26d84d8dad66d /drivers/misc
parentb087e6190ddcd9ae4e8ff2c788d2b32f193e946b (diff)
cxl: Fail AFU initialisation if an invalid configuration record is found
If an AFU claims to have a configuration record but doesn't actually contain a vendor and device ID, fail the AFU initialisation. Right now this is just a way of politely letting AFU developers know that they need to fix their config space, but later on we may expose the AFUs as actual PCI devices in their own right and don't want to inadvertendly expose an AFU with a bad config space. Signed-off-by: Ian Munsie <imunsie@au1.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/cxl/pci.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index 2b2e1b80d759..1ef01647265f 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -598,6 +598,8 @@ static int cxl_read_afu_descriptor(struct cxl_afu *afu)
598 598
599static int cxl_afu_descriptor_looks_ok(struct cxl_afu *afu) 599static int cxl_afu_descriptor_looks_ok(struct cxl_afu *afu)
600{ 600{
601 int i;
602
601 if (afu->psa && afu->adapter->ps_size < 603 if (afu->psa && afu->adapter->ps_size <
602 (afu->pp_offset + afu->pp_size*afu->max_procs_virtualised)) { 604 (afu->pp_offset + afu->pp_size*afu->max_procs_virtualised)) {
603 dev_err(&afu->dev, "per-process PSA can't fit inside the PSA!\n"); 605 dev_err(&afu->dev, "per-process PSA can't fit inside the PSA!\n");
@@ -607,6 +609,13 @@ static int cxl_afu_descriptor_looks_ok(struct cxl_afu *afu)
607 if (afu->pp_psa && (afu->pp_size < PAGE_SIZE)) 609 if (afu->pp_psa && (afu->pp_size < PAGE_SIZE))
608 dev_warn(&afu->dev, "AFU uses < PAGE_SIZE per-process PSA!"); 610 dev_warn(&afu->dev, "AFU uses < PAGE_SIZE per-process PSA!");
609 611
612 for (i = 0; i < afu->crs_num; i++) {
613 if ((cxl_afu_cr_read32(afu, i, 0) == 0)) {
614 dev_err(&afu->dev, "ABORTING: AFU configuration record %i is invalid\n", i);
615 return -EINVAL;
616 }
617 }
618
610 return 0; 619 return 0;
611} 620}
612 621