crypto: qat - fix ring to service map for QAT GEN4
authorGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Fri, 20 Oct 2023 13:49:23 +0000 (15:49 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:59:23 +0000 (11:59 +0100)
[ Upstream commit a238487f7965d102794ed9f8aff0b667cd2ae886 ]

The 4xxx drivers hardcode the ring to service mapping. However, when
additional configurations where added to the driver, the mappings were
not updated. This implies that an incorrect mapping might be reported
through pfvf for certain configurations.

Add an algorithm that computes the correct ring to service mapping based
on the firmware loaded on the device.

Fixes: 0cec19c761e5 ("crypto: qat - add support for compression for 4xxx")
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Damian Muszynski <damian.muszynski@intel.com>
Reviewed-by: Tero Kristo <tero.kristo@linux.intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/intel/qat/qat_4xxx/adf_4xxx_hw_data.c
drivers/crypto/intel/qat/qat_common/adf_accel_devices.h
drivers/crypto/intel/qat/qat_common/adf_init.c

index 44b732f..a5691ba 100644 (file)
@@ -423,6 +423,59 @@ static const struct adf_fw_config *get_fw_config(struct adf_accel_dev *accel_dev
        }
 }
 
+enum adf_rp_groups {
+       RP_GROUP_0 = 0,
+       RP_GROUP_1,
+       RP_GROUP_COUNT
+};
+
+static u16 get_ring_to_svc_map(struct adf_accel_dev *accel_dev)
+{
+       enum adf_cfg_service_type rps[RP_GROUP_COUNT];
+       const struct adf_fw_config *fw_config;
+       u16 ring_to_svc_map;
+       int i, j;
+
+       fw_config = get_fw_config(accel_dev);
+       if (!fw_config)
+               return 0;
+
+       for (i = 0; i < RP_GROUP_COUNT; i++) {
+               switch (fw_config[i].ae_mask) {
+               case ADF_AE_GROUP_0:
+                       j = RP_GROUP_0;
+                       break;
+               case ADF_AE_GROUP_1:
+                       j = RP_GROUP_1;
+                       break;
+               default:
+                       return 0;
+               }
+
+               switch (fw_config[i].obj) {
+               case ADF_FW_SYM_OBJ:
+                       rps[j] = SYM;
+                       break;
+               case ADF_FW_ASYM_OBJ:
+                       rps[j] = ASYM;
+                       break;
+               case ADF_FW_DC_OBJ:
+                       rps[j] = COMP;
+                       break;
+               default:
+                       rps[j] = 0;
+                       break;
+               }
+       }
+
+       ring_to_svc_map = rps[RP_GROUP_0] << ADF_CFG_SERV_RING_PAIR_0_SHIFT |
+                         rps[RP_GROUP_1] << ADF_CFG_SERV_RING_PAIR_1_SHIFT |
+                         rps[RP_GROUP_0] << ADF_CFG_SERV_RING_PAIR_2_SHIFT |
+                         rps[RP_GROUP_1] << ADF_CFG_SERV_RING_PAIR_3_SHIFT;
+
+       return ring_to_svc_map;
+}
+
 static const char *uof_get_name(struct adf_accel_dev *accel_dev, u32 obj_num,
                                const char * const fw_objs[], int num_objs)
 {
@@ -519,6 +572,7 @@ void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data, u32 dev_id)
        hw_data->uof_get_ae_mask = uof_get_ae_mask;
        hw_data->set_msix_rttable = set_msix_default_rttable;
        hw_data->set_ssm_wdtimer = adf_gen4_set_ssm_wdtimer;
+       hw_data->get_ring_to_svc_map = get_ring_to_svc_map;
        hw_data->disable_iov = adf_disable_sriov;
        hw_data->ring_pair_reset = adf_gen4_ring_pair_reset;
        hw_data->enable_pm = adf_gen4_enable_pm;
index 1e84ff3..79d5a15 100644 (file)
@@ -182,6 +182,7 @@ struct adf_hw_device_data {
        void (*get_arb_info)(struct arb_info *arb_csrs_info);
        void (*get_admin_info)(struct admin_info *admin_csrs_info);
        enum dev_sku_info (*get_sku)(struct adf_hw_device_data *self);
+       u16 (*get_ring_to_svc_map)(struct adf_accel_dev *accel_dev);
        int (*alloc_irq)(struct adf_accel_dev *accel_dev);
        void (*free_irq)(struct adf_accel_dev *accel_dev);
        void (*enable_error_correction)(struct adf_accel_dev *accel_dev);
index 7323a9f..0f9e2d5 100644 (file)
@@ -97,6 +97,9 @@ static int adf_dev_init(struct adf_accel_dev *accel_dev)
                return -EFAULT;
        }
 
+       if (hw_data->get_ring_to_svc_map)
+               hw_data->ring_to_svc_map = hw_data->get_ring_to_svc_map(accel_dev);
+
        if (adf_ae_init(accel_dev)) {
                dev_err(&GET_DEV(accel_dev),
                        "Failed to initialise Acceleration Engine\n");