]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
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>
Thu, 28 Aug 2025 14:26:12 +0000 (16:26 +0200)
commit a238487f7965d102794ed9f8aff0b667cd2ae886 upstream.

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>
[Giovanni: backport to 6.1.y, conflict resolved simplifying the logic
in the function get_ring_to_svc_map() as the QAT driver in v6.1 supports
only limited configurations (crypto only and compression).  Differs from
upstream as the ring to service mapping is hardcoded rather than being
dynamically computed.]
Reviewed-by: Ahsan Atta <ahsan.atta@intel.com>
Tested-by: Ahsan Atta <ahsan.atta@intel.com>
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c
drivers/crypto/qat/qat_common/adf_accel_devices.h
drivers/crypto/qat/qat_common/adf_gen4_hw_data.h
drivers/crypto/qat/qat_common/adf_init.c

index fda5f699ff57514362f2ced23f2afdde3a8d7474..65b52c692add081b93707ee05238dfbffe9b8ed4 100644 (file)
@@ -297,6 +297,18 @@ static char *uof_get_name(struct adf_accel_dev *accel_dev, u32 obj_num)
        return NULL;
 }
 
+static u16 get_ring_to_svc_map(struct adf_accel_dev *accel_dev)
+{
+       switch (get_service_enabled(accel_dev)) {
+       case SVC_CY:
+               return ADF_GEN4_DEFAULT_RING_TO_SRV_MAP;
+       case SVC_DC:
+               return ADF_GEN4_DEFAULT_RING_TO_SRV_MAP_DC;
+       }
+
+       return 0;
+}
+
 static u32 uof_get_ae_mask(struct adf_accel_dev *accel_dev, u32 obj_num)
 {
        switch (get_service_enabled(accel_dev)) {
@@ -353,6 +365,7 @@ void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data)
        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 ad01d99e6e2ba7b036f49f94bb0f81a84a26c898..7993d0f82dea65e88bef7e5f1618319286e89bec 100644 (file)
@@ -176,6 +176,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 4fb4b3df5a1885ac11c16a3bf3e9a2af999caf03..5e653ec755e6ff35ccb08f6c574d0bdf20d25294 100644 (file)
@@ -95,6 +95,12 @@ do { \
                   ADF_RING_BUNDLE_SIZE * (bank) + \
                   ADF_RING_CSR_RING_SRV_ARB_EN, (value))
 
+#define ADF_GEN4_DEFAULT_RING_TO_SRV_MAP_DC \
+       (COMP << ADF_CFG_SERV_RING_PAIR_0_SHIFT | \
+        COMP << ADF_CFG_SERV_RING_PAIR_1_SHIFT | \
+        COMP << ADF_CFG_SERV_RING_PAIR_2_SHIFT | \
+        COMP << ADF_CFG_SERV_RING_PAIR_3_SHIFT)
+
 /* Default ring mapping */
 #define ADF_GEN4_DEFAULT_RING_TO_SRV_MAP \
        (ASYM << ADF_CFG_SERV_RING_PAIR_0_SHIFT | \
index 2e3481270c4baeb0fc2c1214b45b20c5f1c37cf6..49f07584f8c9f38ce8e11f7d75628d5f9ddb8ac6 100644 (file)
@@ -95,6 +95,9 @@ 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");