Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: qat - configure arbiter mapping based on engines enabled

The hardware specific function adf_get_arbiter_mapping() modifies
the static array thrd_to_arb_map to disable mappings for AEs
that are disabled. This static array is used for each device
of the same type. If the ae mask is not identical for all devices
of the same type then the arbiter mapping returned by
adf_get_arbiter_mapping() may be wrong.

This patch fixes this problem by ensuring the static arbiter
mapping is unchanged and the device arbiter mapping is re-calculated
each time based on the static mapping.

Signed-off-by: Wojciech Ziemba <wojciech.ziemba@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Wojciech Ziemba and committed by
Herbert Xu
0db0d797 d6cbf4ea

+19 -76
+3 -11
drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c
··· 19 19 }; 20 20 21 21 /* Worker thread to service arbiter mappings */ 22 - static u32 thrd_to_arb_map[] = { 22 + static const u32 thrd_to_arb_map[ADF_4XXX_MAX_ACCELENGINES] = { 23 23 0x5555555, 0x5555555, 0x5555555, 0x5555555, 24 24 0xAAAAAAA, 0xAAAAAAA, 0xAAAAAAA, 0xAAAAAAA, 25 25 0x0 ··· 119 119 return DEV_SKU_1; 120 120 } 121 121 122 - static void adf_get_arbiter_mapping(struct adf_accel_dev *accel_dev, 123 - u32 const **arb_map_config) 122 + static const u32 *adf_get_arbiter_mapping(void) 124 123 { 125 - struct adf_hw_device_data *hw_device = accel_dev->hw_device; 126 - unsigned long ae_mask = hw_device->ae_mask; 127 - int i; 128 - 129 - for_each_clear_bit(i, &ae_mask, ADF_4XXX_MAX_ACCELENGINES) 130 - thrd_to_arb_map[i] = 0; 131 - 132 - *arb_map_config = thrd_to_arb_map; 124 + return thrd_to_arb_map; 133 125 } 134 126 135 127 static void get_arb_info(struct arb_info *arb_info)
+4 -13
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c
··· 7 7 #include "adf_c3xxx_hw_data.h" 8 8 #include "icp_qat_hw.h" 9 9 10 - /* Worker thread to service arbiter mappings based on dev SKUs */ 11 - static const u32 thrd_to_arb_map_6_me_sku[] = { 10 + /* Worker thread to service arbiter mappings */ 11 + static const u32 thrd_to_arb_map[ADF_C3XXX_MAX_ACCELENGINES] = { 12 12 0x12222AAA, 0x11222AAA, 0x12222AAA, 13 13 0x11222AAA, 0x12222AAA, 0x11222AAA 14 14 }; ··· 101 101 return DEV_SKU_UNKNOWN; 102 102 } 103 103 104 - static void adf_get_arbiter_mapping(struct adf_accel_dev *accel_dev, 105 - u32 const **arb_map_config) 104 + static const u32 *adf_get_arbiter_mapping(void) 106 105 { 107 - switch (accel_dev->accel_pci_dev.sku) { 108 - case DEV_SKU_4: 109 - *arb_map_config = thrd_to_arb_map_6_me_sku; 110 - break; 111 - default: 112 - dev_err(&GET_DEV(accel_dev), 113 - "The configuration doesn't match any SKU"); 114 - *arb_map_config = NULL; 115 - } 106 + return thrd_to_arb_map; 116 107 } 117 108 118 109 static u32 get_pf2vf_offset(u32 i)
+4 -21
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c
··· 7 7 #include "adf_c62x_hw_data.h" 8 8 #include "icp_qat_hw.h" 9 9 10 - /* Worker thread to service arbiter mappings based on dev SKUs */ 11 - static const u32 thrd_to_arb_map_8_me_sku[] = { 12 - 0x12222AAA, 0x11222AAA, 0x12222AAA, 0x11222AAA, 0x12222AAA, 13 - 0x11222AAA, 0x12222AAA, 0x11222AAA, 0, 0 14 - }; 15 - 16 - static const u32 thrd_to_arb_map_10_me_sku[] = { 10 + /* Worker thread to service arbiter mappings */ 11 + static const u32 thrd_to_arb_map[ADF_C62X_MAX_ACCELENGINES] = { 17 12 0x12222AAA, 0x11222AAA, 0x12222AAA, 0x11222AAA, 0x12222AAA, 18 13 0x11222AAA, 0x12222AAA, 0x11222AAA, 0x12222AAA, 0x11222AAA 19 14 }; ··· 103 108 return DEV_SKU_UNKNOWN; 104 109 } 105 110 106 - static void adf_get_arbiter_mapping(struct adf_accel_dev *accel_dev, 107 - u32 const **arb_map_config) 111 + static const u32 *adf_get_arbiter_mapping(void) 108 112 { 109 - switch (accel_dev->accel_pci_dev.sku) { 110 - case DEV_SKU_2: 111 - *arb_map_config = thrd_to_arb_map_8_me_sku; 112 - break; 113 - case DEV_SKU_4: 114 - *arb_map_config = thrd_to_arb_map_10_me_sku; 115 - break; 116 - default: 117 - dev_err(&GET_DEV(accel_dev), 118 - "The configuration doesn't match any SKU"); 119 - *arb_map_config = NULL; 120 - } 113 + return thrd_to_arb_map; 121 114 } 122 115 123 116 static u32 get_pf2vf_offset(u32 i)
+1 -2
drivers/crypto/qat/qat_common/adf_accel_devices.h
··· 168 168 int (*send_admin_init)(struct adf_accel_dev *accel_dev); 169 169 int (*init_arb)(struct adf_accel_dev *accel_dev); 170 170 void (*exit_arb)(struct adf_accel_dev *accel_dev); 171 - void (*get_arb_mapping)(struct adf_accel_dev *accel_dev, 172 - const u32 **cfg); 171 + const u32 *(*get_arb_mapping)(void); 173 172 void (*disable_iov)(struct adf_accel_dev *accel_dev); 174 173 void (*configure_iov_threads)(struct adf_accel_dev *accel_dev, 175 174 bool enable);
+3 -5
drivers/crypto/qat/qat_common/adf_hw_arbiter.c
··· 19 19 { 20 20 struct adf_hw_device_data *hw_data = accel_dev->hw_device; 21 21 void __iomem *csr = accel_dev->transport->banks[0].csr_addr; 22 + unsigned long ae_mask = hw_data->ae_mask; 22 23 u32 arb_off, wt_off, arb_cfg; 23 24 const u32 *thd_2_arb_cfg; 24 25 struct arb_info info; ··· 36 35 WRITE_CSR_ARB_SARCONFIG(csr, arb_off, arb, arb_cfg); 37 36 38 37 /* Map worker threads to service arbiters */ 39 - hw_data->get_arb_mapping(accel_dev, &thd_2_arb_cfg); 38 + thd_2_arb_cfg = hw_data->get_arb_mapping(); 40 39 41 - if (!thd_2_arb_cfg) 42 - return -EFAULT; 43 - 44 - for (i = 0; i < hw_data->num_engines; i++) 40 + for_each_set_bit(i, &ae_mask, hw_data->num_engines) 45 41 WRITE_CSR_ARB_WT2SAM(csr, arb_off, wt_off, i, thd_2_arb_cfg[i]); 46 42 47 43 return 0;
+4 -24
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c
··· 7 7 #include "adf_dh895xcc_hw_data.h" 8 8 #include "icp_qat_hw.h" 9 9 10 - /* Worker thread to service arbiter mappings based on dev SKUs */ 11 - static const u32 thrd_to_arb_map_sku4[] = { 12 - 0x12222AAA, 0x11666666, 0x12222AAA, 0x11666666, 13 - 0x12222AAA, 0x11222222, 0x12222AAA, 0x11222222, 14 - 0x00000000, 0x00000000, 0x00000000, 0x00000000 15 - }; 16 - 17 - static const u32 thrd_to_arb_map_sku6[] = { 10 + /* Worker thread to service arbiter mappings */ 11 + static const u32 thrd_to_arb_map[ADF_DH895XCC_MAX_ACCELENGINES] = { 18 12 0x12222AAA, 0x11666666, 0x12222AAA, 0x11666666, 19 13 0x12222AAA, 0x11222222, 0x12222AAA, 0x11222222, 20 14 0x12222AAA, 0x11222222, 0x12222AAA, 0x11222222 ··· 121 127 return DEV_SKU_UNKNOWN; 122 128 } 123 129 124 - static void adf_get_arbiter_mapping(struct adf_accel_dev *accel_dev, 125 - u32 const **arb_map_config) 130 + static const u32 *adf_get_arbiter_mapping(void) 126 131 { 127 - switch (accel_dev->accel_pci_dev.sku) { 128 - case DEV_SKU_1: 129 - *arb_map_config = thrd_to_arb_map_sku4; 130 - break; 131 - 132 - case DEV_SKU_2: 133 - case DEV_SKU_4: 134 - *arb_map_config = thrd_to_arb_map_sku6; 135 - break; 136 - default: 137 - dev_err(&GET_DEV(accel_dev), 138 - "The configuration doesn't match any SKU"); 139 - *arb_map_config = NULL; 140 - } 132 + return thrd_to_arb_map; 141 133 } 142 134 143 135 static u32 get_pf2vf_offset(u32 i)