aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/cxl/pci.c
diff options
context:
space:
mode:
authorIan Munsie <imunsie@au1.ibm.com>2015-05-27 02:07:04 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2015-06-02 23:27:17 -0400
commitbee30c7045847524be1b4b6b23a303c6763a96f9 (patch)
tree0b79ec6dca53f8123302bb467008c0d23530f335 /drivers/misc/cxl/pci.c
parent69c3a73c81a648daeac08225ff08b168472ff27e (diff)
cxl: Re-order card init to check the VSEC earlier
When we expose AFUs as virtual PCI devices, they may look like the physical CAPI PCI card. ie they may have the same vendor/device IDs. We want to avoid these AFUs binding to this driver and any init this driver may do. Re-order card init to check the VSEC earlier before assigning BARs or activating CXL. Also change the dev used in early prints as the adapter struct may not be inited at this earlier stage. Signed-off-by: Ian Munsie <imunsie@au1.ibm.com> Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/misc/cxl/pci.c')
-rw-r--r--drivers/misc/cxl/pci.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index ef24e21a93a1..787f966f4088 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -917,13 +917,13 @@ static int cxl_read_vsec(struct cxl *adapter, struct pci_dev *dev)
917 u8 image_state; 917 u8 image_state;
918 918
919 if (!(vsec = find_cxl_vsec(dev))) { 919 if (!(vsec = find_cxl_vsec(dev))) {
920 dev_err(&adapter->dev, "ABORTING: CXL VSEC not found!\n"); 920 dev_err(&dev->dev, "ABORTING: CXL VSEC not found!\n");
921 return -ENODEV; 921 return -ENODEV;
922 } 922 }
923 923
924 CXL_READ_VSEC_LENGTH(dev, vsec, &vseclen); 924 CXL_READ_VSEC_LENGTH(dev, vsec, &vseclen);
925 if (vseclen < CXL_VSEC_MIN_SIZE) { 925 if (vseclen < CXL_VSEC_MIN_SIZE) {
926 pr_err("ABORTING: CXL VSEC too short\n"); 926 dev_err(&dev->dev, "ABORTING: CXL VSEC too short\n");
927 return -EINVAL; 927 return -EINVAL;
928 } 928 }
929 929
@@ -962,24 +962,24 @@ static int cxl_vsec_looks_ok(struct cxl *adapter, struct pci_dev *dev)
962 return -EBUSY; 962 return -EBUSY;
963 963
964 if (adapter->vsec_status & CXL_UNSUPPORTED_FEATURES) { 964 if (adapter->vsec_status & CXL_UNSUPPORTED_FEATURES) {
965 dev_err(&adapter->dev, "ABORTING: CXL requires unsupported features\n"); 965 dev_err(&dev->dev, "ABORTING: CXL requires unsupported features\n");
966 return -EINVAL; 966 return -EINVAL;
967 } 967 }
968 968
969 if (!adapter->slices) { 969 if (!adapter->slices) {
970 /* Once we support dynamic reprogramming we can use the card if 970 /* Once we support dynamic reprogramming we can use the card if
971 * it supports loadable AFUs */ 971 * it supports loadable AFUs */
972 dev_err(&adapter->dev, "ABORTING: Device has no AFUs\n"); 972 dev_err(&dev->dev, "ABORTING: Device has no AFUs\n");
973 return -EINVAL; 973 return -EINVAL;
974 } 974 }
975 975
976 if (!adapter->afu_desc_off || !adapter->afu_desc_size) { 976 if (!adapter->afu_desc_off || !adapter->afu_desc_size) {
977 dev_err(&adapter->dev, "ABORTING: VSEC shows no AFU descriptors\n"); 977 dev_err(&dev->dev, "ABORTING: VSEC shows no AFU descriptors\n");
978 return -EINVAL; 978 return -EINVAL;
979 } 979 }
980 980
981 if (adapter->ps_size > p2_size(dev) - adapter->ps_off) { 981 if (adapter->ps_size > p2_size(dev) - adapter->ps_off) {
982 dev_err(&adapter->dev, "ABORTING: Problem state size larger than " 982 dev_err(&dev->dev, "ABORTING: Problem state size larger than "
983 "available in BAR2: 0x%llx > 0x%llx\n", 983 "available in BAR2: 0x%llx > 0x%llx\n",
984 adapter->ps_size, p2_size(dev) - adapter->ps_off); 984 adapter->ps_size, p2_size(dev) - adapter->ps_off);
985 return -EINVAL; 985 return -EINVAL;
@@ -1028,6 +1028,15 @@ static struct cxl *cxl_init_adapter(struct pci_dev *dev)
1028 if (!(adapter = cxl_alloc_adapter(dev))) 1028 if (!(adapter = cxl_alloc_adapter(dev)))
1029 return ERR_PTR(-ENOMEM); 1029 return ERR_PTR(-ENOMEM);
1030 1030
1031 if ((rc = cxl_read_vsec(adapter, dev)))
1032 goto err1;
1033
1034 if ((rc = cxl_vsec_looks_ok(adapter, dev)))
1035 goto err1;
1036
1037 if ((rc = setup_cxl_bars(dev)))
1038 goto err1;
1039
1031 if ((rc = switch_card_to_cxl(dev))) 1040 if ((rc = switch_card_to_cxl(dev)))
1032 goto err1; 1041 goto err1;
1033 1042
@@ -1037,12 +1046,6 @@ static struct cxl *cxl_init_adapter(struct pci_dev *dev)
1037 if ((rc = dev_set_name(&adapter->dev, "card%i", adapter->adapter_num))) 1046 if ((rc = dev_set_name(&adapter->dev, "card%i", adapter->adapter_num)))
1038 goto err2; 1047 goto err2;
1039 1048
1040 if ((rc = cxl_read_vsec(adapter, dev)))
1041 goto err2;
1042
1043 if ((rc = cxl_vsec_looks_ok(adapter, dev)))
1044 goto err2;
1045
1046 if ((rc = cxl_update_image_control(adapter))) 1049 if ((rc = cxl_update_image_control(adapter)))
1047 goto err2; 1050 goto err2;
1048 1051
@@ -1127,9 +1130,6 @@ static int cxl_probe(struct pci_dev *dev, const struct pci_device_id *id)
1127 if (cxl_verbose) 1130 if (cxl_verbose)
1128 dump_cxl_config_space(dev); 1131 dump_cxl_config_space(dev);
1129 1132
1130 if ((rc = setup_cxl_bars(dev)))
1131 return rc;
1132
1133 if ((rc = pci_enable_device(dev))) { 1133 if ((rc = pci_enable_device(dev))) {
1134 dev_err(&dev->dev, "pci_enable_device failed: %i\n", rc); 1134 dev_err(&dev->dev, "pci_enable_device failed: %i\n", rc);
1135 return rc; 1135 return rc;