Torsten Duwe a2fb7a
From cfe4894eccdc7fa5cd35bf34e918614d06ecce38 Mon Sep 17 00:00:00 2001
Torsten Duwe a2fb7a
From: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Torsten Duwe a2fb7a
Date: Thu, 16 Dec 2021 09:13:13 +0000
Torsten Duwe a2fb7a
Subject: [PATCH] crypto: qat - set COMPRESSION capability for QAT GEN2
Torsten Duwe a2fb7a
Git-commit: cfe4894eccdc7fa5cd35bf34e918614d06ecce38
Torsten Duwe a2fb7a
Patch-mainline: v5.17-rc1
Torsten Duwe a2fb7a
References: jsc#PED-1073
Torsten Duwe a2fb7a
Torsten Duwe a2fb7a
Enhance the device capability detection for QAT GEN2 devices to detect if
Torsten Duwe a2fb7a
a device supports the compression service.
Torsten Duwe a2fb7a
Torsten Duwe a2fb7a
This is done by checking both the fuse and the strap registers for c62x
Torsten Duwe a2fb7a
and c3xxx and only the fuse register for dh895xcc.
Torsten Duwe a2fb7a
Torsten Duwe a2fb7a
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Torsten Duwe a2fb7a
Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
Torsten Duwe a2fb7a
Reviewed-by: Fiona Trahe <fiona.trahe@intel.com>
Torsten Duwe a2fb7a
Reviewed-by: Marco Chiappero <marco.chiappero@intel.com>
Torsten Duwe a2fb7a
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Torsten Duwe a2fb7a
Signed-off-by: Torsten Duwe <duwe@suse.de>
Torsten Duwe a2fb7a
Torsten Duwe a2fb7a
---
Torsten Duwe a2fb7a
 drivers/crypto/qat/qat_common/adf_gen2_hw_data.c       | 8 +++++++-
Torsten Duwe a2fb7a
 drivers/crypto/qat/qat_common/adf_gen2_hw_data.h       | 1 +
Torsten Duwe a2fb7a
 drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 2 ++
Torsten Duwe a2fb7a
 3 files changed, 10 insertions(+), 1 deletion(-)
Torsten Duwe a2fb7a
Torsten Duwe a2fb7a
diff --git a/drivers/crypto/qat/qat_common/adf_gen2_hw_data.c b/drivers/crypto/qat/qat_common/adf_gen2_hw_data.c
Torsten Duwe a2fb7a
index 3ea26f2f4a226..688dd6f53b0bd 100644
Torsten Duwe a2fb7a
--- a/drivers/crypto/qat/qat_common/adf_gen2_hw_data.c
Torsten Duwe a2fb7a
+++ b/drivers/crypto/qat/qat_common/adf_gen2_hw_data.c
Torsten Duwe a2fb7a
@@ -212,7 +212,8 @@ u32 adf_gen2_get_accel_cap(struct adf_accel_dev *accel_dev)
Torsten Duwe a2fb7a
 	u32 capabilities = ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC |
Torsten Duwe a2fb7a
 			   ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC |
Torsten Duwe a2fb7a
 			   ICP_ACCEL_CAPABILITIES_AUTHENTICATION |
Torsten Duwe a2fb7a
-			   ICP_ACCEL_CAPABILITIES_CIPHER;
Torsten Duwe a2fb7a
+			   ICP_ACCEL_CAPABILITIES_CIPHER |
Torsten Duwe a2fb7a
+			   ICP_ACCEL_CAPABILITIES_COMPRESSION;
Torsten Duwe a2fb7a
 
Torsten Duwe a2fb7a
 	/* Read accelerator capabilities mask */
Torsten Duwe a2fb7a
 	pci_read_config_dword(pdev, ADF_DEVICE_LEGFUSE_OFFSET, &legfuses);
Torsten Duwe a2fb7a
@@ -228,10 +229,15 @@ u32 adf_gen2_get_accel_cap(struct adf_accel_dev *accel_dev)
Torsten Duwe a2fb7a
 		capabilities &= ~ICP_ACCEL_CAPABILITIES_AUTHENTICATION;
Torsten Duwe a2fb7a
 		capabilities &= ~ICP_ACCEL_CAPABILITIES_CIPHER;
Torsten Duwe a2fb7a
 	}
Torsten Duwe a2fb7a
+	if (legfuses & ICP_ACCEL_MASK_COMPRESS_SLICE)
Torsten Duwe a2fb7a
+		capabilities &= ~ICP_ACCEL_CAPABILITIES_COMPRESSION;
Torsten Duwe a2fb7a
 
Torsten Duwe a2fb7a
 	if ((straps | fuses) & ADF_POWERGATE_PKE)
Torsten Duwe a2fb7a
 		capabilities &= ~ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC;
Torsten Duwe a2fb7a
 
Torsten Duwe a2fb7a
+	if ((straps | fuses) & ADF_POWERGATE_DC)
Torsten Duwe a2fb7a
+		capabilities &= ~ICP_ACCEL_CAPABILITIES_COMPRESSION;
Torsten Duwe a2fb7a
+
Torsten Duwe a2fb7a
 	return capabilities;
Torsten Duwe a2fb7a
 }
Torsten Duwe a2fb7a
 EXPORT_SYMBOL_GPL(adf_gen2_get_accel_cap);
Torsten Duwe a2fb7a
diff --git a/drivers/crypto/qat/qat_common/adf_gen2_hw_data.h b/drivers/crypto/qat/qat_common/adf_gen2_hw_data.h
Torsten Duwe a2fb7a
index 448c97f740e7c..7c2c173664609 100644
Torsten Duwe a2fb7a
--- a/drivers/crypto/qat/qat_common/adf_gen2_hw_data.h
Torsten Duwe a2fb7a
+++ b/drivers/crypto/qat/qat_common/adf_gen2_hw_data.h
Torsten Duwe a2fb7a
@@ -113,6 +113,7 @@ do { \
Torsten Duwe a2fb7a
 	(ADF_ARB_REG_SLOT * (index)), value)
Torsten Duwe a2fb7a
 
Torsten Duwe a2fb7a
 /* Power gating */
Torsten Duwe a2fb7a
+#define ADF_POWERGATE_DC		BIT(23)
Torsten Duwe a2fb7a
 #define ADF_POWERGATE_PKE		BIT(24)
Torsten Duwe a2fb7a
 
Torsten Duwe a2fb7a
 /* WDT timers
Torsten Duwe a2fb7a
diff --git a/drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c b/drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c
Torsten Duwe a2fb7a
index 27d4cab65dd88..2d18279191d7e 100644
Torsten Duwe a2fb7a
--- a/drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c
Torsten Duwe a2fb7a
+++ b/drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c
Torsten Duwe a2fb7a
@@ -69,6 +69,8 @@ static u32 get_accel_cap(struct adf_accel_dev *accel_dev)
Torsten Duwe a2fb7a
 		capabilities &= ~ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC;
Torsten Duwe a2fb7a
 	if (legfuses & ICP_ACCEL_MASK_AUTH_SLICE)
Torsten Duwe a2fb7a
 		capabilities &= ~ICP_ACCEL_CAPABILITIES_AUTHENTICATION;
Torsten Duwe a2fb7a
+	if (legfuses & ICP_ACCEL_MASK_COMPRESS_SLICE)
Torsten Duwe a2fb7a
+		capabilities &= ~ICP_ACCEL_CAPABILITIES_COMPRESSION;
Torsten Duwe a2fb7a
 
Torsten Duwe a2fb7a
 	return capabilities;
Torsten Duwe a2fb7a
 }
Torsten Duwe a2fb7a
-- 
Torsten Duwe a2fb7a
2.35.3
Torsten Duwe a2fb7a