Skip to contentSkip to conversation

crypto: qat - misc fixes

PATCH In review Marco Chiappero 2 participants 18 messages Apr 7, 2022 – Apr 15, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover crypto: qat - misc fixes

This set contains a collection of fixes for DH895XCC (the first two patches), PFVF (most of the set) and a few more.

Patches one and two correct the lack of necessary flags to indicate the presence of specific HW capabilities, which could result in VFs unable to work correctly.

The third patch fixes some ring interrupts silently enabled even when VFs are active, while the fourth one is just a style fix.

Patches from five to eleven are minor PFVF fixes, while patch twelve addresses a bigger problem which caused lost PFVF messages due to unhandled interrupts during bursts of PFVF messages from multiple VFs. This was usually noticeable when restarting many VMs/VFs at the same time. The remainder of the set is a refactoring resulting from the previous fix, but split into multiple commits to ease the review.

Changes from v1:

- Addition of patches #3, #4, #6, #7, #8, #9, #10 and #11.

Giovanni Cabiddu (3):
crypto: qat - set CIPHER capability for DH895XCC
crypto: qat - set COMPRESSION capability for DH895XCC
crypto: qat - remove unused PFVF stubs

Marco Chiappero (12):
crypto: qat - fix ETR sources enabled by default on GEN2 devices
crypto: qat - remove unneeded braces
crypto: qat - remove unnecessary tests to detect PFVF support
crypto: qat - add missing restarting event notification in VFs
crypto: qat - test PFVF registers for spurious interrupts on GEN4
crypto: qat - fix wording and formatting in code comment
crypto: qat - fix off-by-one error in PFVF debug print
crypto: qat - rework the VF2PF interrupt handling logic
crypto: qat - leverage the GEN2 VF mask definiton
crypto: qat - replace disable_vf2pf_interrupts()
crypto: qat - use u32 variables in all GEN4 pfvf_ops
crypto: qat - remove line wrapping for pfvf_ops functions

Wojciech Ziemba (1):
crypto: qat - add check for invalid PFVF protocol version 0

 .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c  |  15 +--
 .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.h  |   4 -
 .../crypto/qat/qat_c62x/adf_c62x_hw_data.c    |  15 +--
 .../crypto/qat/qat_c62x/adf_c62x_hw_data.h    |   4 -
 .../crypto/qat/qat_common/adf_accel_devices.h |   4 +-
 .../crypto/qat/qat_common/adf_common_drv.h    |  18 +--
 .../crypto/qat/qat_common/adf_gen2_hw_data.c  |  13 ++
 .../crypto/qat/qat_common/adf_gen2_hw_data.h  |   6 +
 drivers/crypto/qat/qat_common/adf_gen2_pfvf.c |  78 ++++++-----
 drivers/crypto/qat/qat_common/adf_gen4_pfvf.c |  61 ++++++---
 drivers/crypto/qat/qat_common/adf_isr.c       |  21 ++-
 drivers/crypto/qat/qat_common/adf_pfvf_msg.h  |   4 +-
 .../crypto/qat/qat_common/adf_pfvf_pf_proto.c |   6 +-
 drivers/crypto/qat/qat_common/adf_sriov.c     |  13 +-
 drivers/crypto/qat/qat_common/adf_vf_isr.c    |   1 +
 .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c   | 126 ++++++++++--------
 .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.h   |   4 -
 17 files changed, 206 insertions(+), 187 deletions(-)

base-commit: 25d8a743a4810228f9b391f6face4777b28bae7b

Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/16 crypto: qat - set CIPHER capability for DH895XCC

From: Giovanni Cabiddu <[email protected]>

Set the CIPHER capability for QAT DH895XCC devices if the hardware supports it. This is done if both the CIPHER and the AUTHENTICATION engines are available on the device.

Fixes ad1332aa67ec ("crypto: qat - add support for capability detection")
---
 .../crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c   | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +9 -3
index 09599fe4d2f3..ff13047772e3 100644
@@ -58,17 +58,23 @@ static u32 get_accel_cap(struct adf_accel_dev *accel_dev)
 
 	capabilities = ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC |
 		       ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC |
-		       ICP_ACCEL_CAPABILITIES_AUTHENTICATION;
+		       ICP_ACCEL_CAPABILITIES_AUTHENTICATION |
+		       ICP_ACCEL_CAPABILITIES_CIPHER;
 
 	/* Read accelerator capabilities mask */
 	pci_read_config_dword(pdev, ADF_DEVICE_LEGFUSE_OFFSET, &legfuses);
 
-	if (legfuses & ICP_ACCEL_MASK_CIPHER_SLICE)
+	/* A set bit in legfuses means the feature is OFF in this SKU */
+	if (legfuses & ICP_ACCEL_MASK_CIPHER_SLICE) {
 		capabilities &= ~ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC;
+		capabilities &= ~ICP_ACCEL_CAPABILITIES_CIPHER;
+	}
 	if (legfuses & ICP_ACCEL_MASK_PKE_SLICE)
 		capabilities &= ~ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC;
-	if (legfuses & ICP_ACCEL_MASK_AUTH_SLICE)
+	if (legfuses & ICP_ACCEL_MASK_AUTH_SLICE) {
 		capabilities &= ~ICP_ACCEL_CAPABILITIES_AUTHENTICATION;
+		capabilities &= ~ICP_ACCEL_CAPABILITIES_CIPHER;
+	}
 	if (legfuses & ICP_ACCEL_MASK_COMPRESS_SLICE)
 		capabilities &= ~ICP_ACCEL_CAPABILITIES_COMPRESSION;
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/16 crypto: qat - set COMPRESSION capability for DH895XCC

In reply to Marco Chiappero

From: Giovanni Cabiddu <[email protected]>

The capability detection logic clears bits for the features that are disabled in a certain SKU. For example, if the bit associate to compression is not present in the LEGFUSE register, the correspondent bit is cleared in the capability mask.
This change adds the compression capability to the mask as this was missing in the commit that enhanced the capability detection logic.

Fixes cfe4894eccdc ("crypto: qat - set COMPRESSION capability for QAT GEN2")
---
 drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +2 -1
index ff13047772e3..61d5467e0d92 100644
@@ -59,7 +59,8 @@ static u32 get_accel_cap(struct adf_accel_dev *accel_dev)
 	capabilities = ICP_ACCEL_CAPABILITIES_CRYPTO_SYMMETRIC |
 		       ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC |
 		       ICP_ACCEL_CAPABILITIES_AUTHENTICATION |
-		       ICP_ACCEL_CAPABILITIES_CIPHER;
+		       ICP_ACCEL_CAPABILITIES_CIPHER |
+		       ICP_ACCEL_CAPABILITIES_COMPRESSION;
 
 	/* Read accelerator capabilities mask */
 	pci_read_config_dword(pdev, ADF_DEVICE_LEGFUSE_OFFSET, &legfuses);
Signature · 1 line
2.34.1
#3 lore raw

PATCH v2 3/16 crypto: qat - fix ETR sources enabled by default on GEN2 devices

In reply to Marco Chiappero

When the driver starts the device, it enables all the necessary interrupts. However interrupts associated to host rings are enabled by default on all GEN2 devices (except for dh895x) even when SR-IOV is active. Fix this behaviour by checking if data structures associated to VFs have been allocated to determine whether to enable such interrupts or not.

Since the logic for the fix is the same across GEN2 devices, replace the function to be fixed (adf_enable_ints()) with a single one (adf_gen2_enable_ints()) in the common GEN2 code in adf_gen2_hw_data.c. Likewise, remove the unnecessary duplication of defines too.

---
 drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c | 15 +--------------
 drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.h |  4 ----
 drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c   | 15 +--------------
 drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.h   |  4 ----
 drivers/crypto/qat/qat_common/adf_gen2_hw_data.c | 13 +++++++++++++
 drivers/crypto/qat/qat_common/adf_gen2_hw_data.h |  6 ++++++
 .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c      | 16 +---------------
 .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.h      |  4 ----
 8 files changed, 22 insertions(+), 55 deletions(-)
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c +1 -14
index b941fe3713ff..50d5afa26a9b 100644
@@ -78,19 +78,6 @@ static const u32 *adf_get_arbiter_mapping(void)
 	return thrd_to_arb_map;
 }
 
-static void adf_enable_ints(struct adf_accel_dev *accel_dev)
-{
-	void __iomem *addr;
-
-	addr = (&GET_BARS(accel_dev)[ADF_C3XXX_PMISC_BAR])->virt_addr;
-
-	/* Enable bundle and misc interrupts */
-	ADF_CSR_WR(addr, ADF_C3XXX_SMIAPF0_MASK_OFFSET,
-		   ADF_C3XXX_SMIA0_MASK);
-	ADF_CSR_WR(addr, ADF_C3XXX_SMIAPF1_MASK_OFFSET,
-		   ADF_C3XXX_SMIA1_MASK);
-}
-
 static void configure_iov_threads(struct adf_accel_dev *accel_dev, bool enable)
 {
 	adf_gen2_cfg_iov_thds(accel_dev, enable,
@@ -133,7 +120,7 @@ void adf_init_hw_data_c3xxx(struct adf_hw_device_data *hw_data)
 	hw_data->init_arb = adf_init_arb;
 	hw_data->exit_arb = adf_exit_arb;
 	hw_data->get_arb_mapping = adf_get_arbiter_mapping;
-	hw_data->enable_ints = adf_enable_ints;
+	hw_data->enable_ints = adf_gen2_enable_ints;
 	hw_data->reset_device = adf_reset_flr;
 	hw_data->set_ssm_wdtimer = adf_gen2_set_ssm_wdtimer;
 	hw_data->disable_iov = adf_disable_sriov;
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.h +0 -4
index 1b86f828725c..336a06f11dbd 100644
@@ -13,10 +13,6 @@
 #define ADF_C3XXX_ACCELERATORS_MASK 0x7
 #define ADF_C3XXX_ACCELENGINES_MASK 0x3F
 #define ADF_C3XXX_ETR_MAX_BANKS 16
-#define ADF_C3XXX_SMIAPF0_MASK_OFFSET (0x3A000 + 0x28)
-#define ADF_C3XXX_SMIAPF1_MASK_OFFSET (0x3A000 + 0x30)
-#define ADF_C3XXX_SMIA0_MASK 0xFFFF
-#define ADF_C3XXX_SMIA1_MASK 0x1
 #define ADF_C3XXX_SOFTSTRAP_CSR_OFFSET 0x2EC
 
 /* AE to function mapping */
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c +1 -14
index b1eac2f81faa..c00386fe6587 100644
@@ -80,19 +80,6 @@ static const u32 *adf_get_arbiter_mapping(void)
 	return thrd_to_arb_map;
 }
 
-static void adf_enable_ints(struct adf_accel_dev *accel_dev)
-{
-	void __iomem *addr;
-
-	addr = (&GET_BARS(accel_dev)[ADF_C62X_PMISC_BAR])->virt_addr;
-
-	/* Enable bundle and misc interrupts */
-	ADF_CSR_WR(addr, ADF_C62X_SMIAPF0_MASK_OFFSET,
-		   ADF_C62X_SMIA0_MASK);
-	ADF_CSR_WR(addr, ADF_C62X_SMIAPF1_MASK_OFFSET,
-		   ADF_C62X_SMIA1_MASK);
-}
-
 static void configure_iov_threads(struct adf_accel_dev *accel_dev, bool enable)
 {
 	adf_gen2_cfg_iov_thds(accel_dev, enable,
@@ -135,7 +122,7 @@ void adf_init_hw_data_c62x(struct adf_hw_device_data *hw_data)
 	hw_data->init_arb = adf_init_arb;
 	hw_data->exit_arb = adf_exit_arb;
 	hw_data->get_arb_mapping = adf_get_arbiter_mapping;
-	hw_data->enable_ints = adf_enable_ints;
+	hw_data->enable_ints = adf_gen2_enable_ints;
 	hw_data->reset_device = adf_reset_flr;
 	hw_data->set_ssm_wdtimer = adf_gen2_set_ssm_wdtimer;
 	hw_data->disable_iov = adf_disable_sriov;
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.h +0 -4
index 68c3436bd3aa..008c0a3a9769 100644
@@ -13,10 +13,6 @@
 #define ADF_C62X_ACCELERATORS_MASK 0x1F
 #define ADF_C62X_ACCELENGINES_MASK 0x3FF
 #define ADF_C62X_ETR_MAX_BANKS 16
-#define ADF_C62X_SMIAPF0_MASK_OFFSET (0x3A000 + 0x28)
-#define ADF_C62X_SMIAPF1_MASK_OFFSET (0x3A000 + 0x30)
-#define ADF_C62X_SMIA0_MASK 0xFFFF
-#define ADF_C62X_SMIA1_MASK 0x1
 #define ADF_C62X_SOFTSTRAP_CSR_OFFSET 0x2EC
 
 /* AE to function mapping */
drivers/crypto/qat/qat_common/adf_gen2_hw_data.c +13 -0
index 57035b7dd4b2..d1884547b5a1 100644
@@ -98,6 +98,19 @@ void adf_gen2_get_arb_info(struct arb_info *arb_info)
 }
 EXPORT_SYMBOL_GPL(adf_gen2_get_arb_info);
 
+void adf_gen2_enable_ints(struct adf_accel_dev *accel_dev)
+{
+	void __iomem *addr = adf_get_pmisc_base(accel_dev);
+	u32 val;
+
+	val = accel_dev->pf.vf_info ? 0 : BIT_ULL(GET_MAX_BANKS(accel_dev)) - 1;
+
+	/* Enable bundle and misc interrupts */
+	ADF_CSR_WR(addr, ADF_GEN2_SMIAPF0_MASK_OFFSET, val);
+	ADF_CSR_WR(addr, ADF_GEN2_SMIAPF1_MASK_OFFSET, ADF_GEN2_SMIA1_MASK);
+}
+EXPORT_SYMBOL_GPL(adf_gen2_enable_ints);
+
 static u64 build_csr_ring_base_addr(dma_addr_t addr, u32 size)
 {
 	return BUILD_RING_BASE_ADDR(addr, size);
drivers/crypto/qat/qat_common/adf_gen2_hw_data.h +6 -0
index f2e0451b11c0..e4bc07529be4 100644
@@ -145,6 +145,11 @@ do { \
 #define ADF_GEN2_CERRSSMSH(i)		((i) * 0x4000 + 0x10)
 #define ADF_GEN2_ERRSSMSH_EN		BIT(3)
 
+/* Interrupts */
+#define ADF_GEN2_SMIAPF0_MASK_OFFSET    (0x3A000 + 0x28)
+#define ADF_GEN2_SMIAPF1_MASK_OFFSET    (0x3A000 + 0x30)
+#define ADF_GEN2_SMIA1_MASK             0x1
+
 u32 adf_gen2_get_num_accels(struct adf_hw_device_data *self);
 u32 adf_gen2_get_num_aes(struct adf_hw_device_data *self);
 void adf_gen2_enable_error_correction(struct adf_accel_dev *accel_dev);
@@ -153,6 +158,7 @@ void adf_gen2_cfg_iov_thds(struct adf_accel_dev *accel_dev, bool enable,
 void adf_gen2_init_hw_csr_ops(struct adf_hw_csr_ops *csr_ops);
 void adf_gen2_get_admin_info(struct admin_info *admin_csrs_info);
 void adf_gen2_get_arb_info(struct arb_info *arb_info);
+void adf_gen2_enable_ints(struct adf_accel_dev *accel_dev);
 u32 adf_gen2_get_accel_cap(struct adf_accel_dev *accel_dev);
 void adf_gen2_set_ssm_wdtimer(struct adf_accel_dev *accel_dev);
 
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +1 -15
index 61d5467e0d92..7375436ac1b8 100644
@@ -107,20 +107,6 @@ static const u32 *adf_get_arbiter_mapping(void)
 	return thrd_to_arb_map;
 }
 
-static void adf_enable_ints(struct adf_accel_dev *accel_dev)
-{
-	void __iomem *addr;
-
-	addr = (&GET_BARS(accel_dev)[ADF_DH895XCC_PMISC_BAR])->virt_addr;
-
-	/* Enable bundle and misc interrupts */
-	ADF_CSR_WR(addr, ADF_DH895XCC_SMIAPF0_MASK_OFFSET,
-		   accel_dev->pf.vf_info ? 0 :
-			BIT_ULL(GET_MAX_BANKS(accel_dev)) - 1);
-	ADF_CSR_WR(addr, ADF_DH895XCC_SMIAPF1_MASK_OFFSET,
-		   ADF_DH895XCC_SMIA1_MASK);
-}
-
 static u32 get_vf2pf_sources(void __iomem *pmisc_bar)
 {
 	u32 errsou3, errmsk3, errsou5, errmsk5, vf_int_mask;
@@ -222,7 +208,7 @@ void adf_init_hw_data_dh895xcc(struct adf_hw_device_data *hw_data)
 	hw_data->init_arb = adf_init_arb;
 	hw_data->exit_arb = adf_exit_arb;
 	hw_data->get_arb_mapping = adf_get_arbiter_mapping;
-	hw_data->enable_ints = adf_enable_ints;
+	hw_data->enable_ints = adf_gen2_enable_ints;
 	hw_data->reset_device = adf_reset_sbr;
 	hw_data->disable_iov = adf_disable_sriov;
 
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.h +0 -4
index aa17272a1507..7b674bbe4192 100644
@@ -19,10 +19,6 @@
 #define ADF_DH895XCC_ACCELERATORS_MASK 0x3F
 #define ADF_DH895XCC_ACCELENGINES_MASK 0xFFF
 #define ADF_DH895XCC_ETR_MAX_BANKS 32
-#define ADF_DH895XCC_SMIAPF0_MASK_OFFSET (0x3A000 + 0x28)
-#define ADF_DH895XCC_SMIAPF1_MASK_OFFSET (0x3A000 + 0x30)
-#define ADF_DH895XCC_SMIA0_MASK 0xFFFFFFFF
-#define ADF_DH895XCC_SMIA1_MASK 0x1
 
 /* Masks for VF2PF interrupts */
 #define ADF_DH895XCC_ERR_REG_VF2PF_L(vf_src)	(((vf_src) & 0x01FFFE00) >> 9)
Signature · 1 line
2.34.1
#4 lore raw

PATCH v2 4/16 crypto: qat - remove unneeded braces

In reply to Marco Chiappero

Remove unnecessary braces around a single statement in a for loop.

---
 drivers/crypto/qat/qat_common/adf_sriov.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/crypto/qat/qat_common/adf_sriov.c +1 -2
index b960bca1f9d2..81f484cbad3d 100644
@@ -117,9 +117,8 @@ void adf_disable_sriov(struct adf_accel_dev *accel_dev)
 	if (hw_data->configure_iov_threads)
 		hw_data->configure_iov_threads(accel_dev, false);
 
-	for (i = 0, vf = accel_dev->pf.vf_info; i < totalvfs; i++, vf++) {
+	for (i = 0, vf = accel_dev->pf.vf_info; i < totalvfs; i++, vf++)
 		mutex_destroy(&vf->pf2vf_lock);
-	}
 
 	kfree(accel_dev->pf.vf_info);
 	accel_dev->pf.vf_info = NULL;
Signature · 1 line
2.34.1
#5 lore raw

PATCH v2 5/16 crypto: qat - remove unused PFVF stubs

In reply to Marco Chiappero

From: Giovanni Cabiddu <[email protected]>

The functions adf_enable_pf2vf_interrupts(), adf_flush_vf_wq() and adf_disable_pf2vf_interrupts() are not referenced when the driver is compiled with CONFIG_PCI_IOV=n. This patch removes these unused stubs.

---
 drivers/crypto/qat/qat_common/adf_common_drv.h | 12 ------------
 1 file changed, 12 deletions(-)
drivers/crypto/qat/qat_common/adf_common_drv.h +0 -12
index e8c9b77c0d66..feecf1035a90 100644
@@ -217,14 +217,6 @@ static inline void adf_disable_sriov(struct adf_accel_dev *accel_dev)
 {
 }
 
-static inline void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev)
-{
-}
-
-static inline void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev)
-{
-}
-
 static inline int adf_init_pf_wq(void)
 {
 	return 0;
@@ -243,10 +235,6 @@ static inline void adf_exit_vf_wq(void)
 {
 }
 
-static inline void adf_flush_vf_wq(struct adf_accel_dev *accel_dev)
-{
-}
-
 #endif
 
 static inline void __iomem *adf_get_pmisc_base(struct adf_accel_dev *accel_dev)
Signature · 1 line
2.34.1
#6 lore raw

PATCH v2 6/16 crypto: qat - remove unnecessary tests to detect PFVF support

In reply to Marco Chiappero

Previously, the GEN4 host driver supported SR-IOV but had no working implementation of the PFVF protocol to communicate with VF drivers. Since all the host drivers for QAT devices now support both SR-IOV and PFVF, remove the old and unnecessary checks to test PFVF support.

---
 drivers/crypto/qat/qat_common/adf_sriov.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/crypto/qat/qat_common/adf_sriov.c +3 -7
index 81f484cbad3d..71d75f65b504 100644
@@ -74,8 +74,7 @@ static int adf_enable_sriov(struct adf_accel_dev *accel_dev)
 		hw_data->configure_iov_threads(accel_dev, true);
 
 	/* Enable VF to PF interrupts for all VFs */
-	if (hw_data->pfvf_ops.get_pf2vf_offset)
-		adf_enable_vf2pf_interrupts(accel_dev, BIT_ULL(totalvfs) - 1);
+	adf_enable_vf2pf_interrupts(accel_dev, BIT_ULL(totalvfs) - 1);
 
 	/*
 	 * Due to the hardware design, when SR-IOV and the ring arbiter
@@ -104,14 +103,11 @@ void adf_disable_sriov(struct adf_accel_dev *accel_dev)
 	if (!accel_dev->pf.vf_info)
 		return;
 
-	if (hw_data->pfvf_ops.get_pf2vf_offset)
-		adf_pf2vf_notify_restarting(accel_dev);
-
+	adf_pf2vf_notify_restarting(accel_dev);
 	pci_disable_sriov(accel_to_pci_dev(accel_dev));
 
 	/* Disable VF to PF interrupts */
-	if (hw_data->pfvf_ops.get_pf2vf_offset)
-		adf_disable_vf2pf_interrupts(accel_dev, GENMASK(31, 0));
+	adf_disable_vf2pf_interrupts(accel_dev, GENMASK(31, 0));
 
 	/* Clear Valid bits in AE Thread to PCIe Function Mapping */
 	if (hw_data->configure_iov_threads)
Signature · 1 line
2.34.1
#7 lore raw

PATCH v2 7/16 crypto: qat - add missing restarting event notification in VFs

In reply to Marco Chiappero

VF drivers are notified via PFVF of the VFs being disabled, but such notification was not propagated within the VF driver. Dispatch the ADF_EVENT_RESTARTING event by adding a missing call to adf_dev_restarting_notify().

---
 drivers/crypto/qat/qat_common/adf_vf_isr.c | 1 +
 1 file changed, 1 insertion(+)
drivers/crypto/qat/qat_common/adf_vf_isr.c +1 -0
index 86c3bd0c9c2b..8c95fcd8e64b 100644
@@ -70,6 +70,7 @@ static void adf_dev_stop_async(struct work_struct *work)
 		container_of(work, struct adf_vf_stop_data, work);
 	struct adf_accel_dev *accel_dev = stop_data->accel_dev;
 
+	adf_dev_restarting_notify(accel_dev);
 	adf_dev_stop(accel_dev);
 	adf_dev_shutdown(accel_dev);
 
Signature · 1 line
2.34.1
#8 lore raw

PATCH v2 8/16 crypto: qat - add check for invalid PFVF protocol version 0

In reply to Marco Chiappero

From: Wojciech Ziemba <[email protected]>

PFVF protocol version 0 is not a valid version, but PF drivers currently would report any such version from VFs as compatible. This patch adds an extra check for the invalid PFVF protocol version 0.

---
 drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c +3 -1
index 588352de1ef0..c059b98836aa 100644
@@ -242,7 +242,9 @@ static int adf_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u8 vf_nr,
 			"VersionRequest received from VF%d (vers %d) to PF (vers %d)\n",
 			vf_nr, vf_compat_ver, ADF_PFVF_COMPAT_THIS_VERSION);
 
-		if (vf_compat_ver <= ADF_PFVF_COMPAT_THIS_VERSION)
+		if (vf_compat_ver == 0)
+			compat = ADF_PF2VF_VF_INCOMPATIBLE;
+		else if (vf_compat_ver <= ADF_PFVF_COMPAT_THIS_VERSION)
 			compat = ADF_PF2VF_VF_COMPATIBLE;
 		else
 			compat = ADF_PF2VF_VF_COMPAT_UNKNOWN;
Signature · 1 line
2.34.1
#9 lore raw

PATCH v2 9/16 crypto: qat - test PFVF registers for spurious interrupts on GEN4

In reply to Marco Chiappero

Spurious PFVF interrupts can happen when either the ISR is invoked without a valid source being set or, otherwise, when no interrupt bit is set in the PFVF register containing the message.

The latter test was present for GEN2 devices but missing for GEN4, this patch fills the gap.

---
 drivers/crypto/qat/qat_common/adf_gen4_pfvf.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/crypto/qat/qat_common/adf_gen4_pfvf.c +6 -0
index d80d493a7756..f7860bf612da 100644
@@ -96,10 +96,16 @@ static struct pfvf_message adf_gen4_pfvf_recv(struct adf_accel_dev *accel_dev,
 					      u32 pfvf_offset, u8 compat_ver)
 {
 	void __iomem *pmisc_addr = adf_get_pmisc_base(accel_dev);
+	struct pfvf_message msg = { 0 };
 	u32 csr_val;
 
 	/* Read message from the CSR */
 	csr_val = ADF_CSR_RD(pmisc_addr, pfvf_offset);
+	if (!(csr_val & ADF_PFVF_INT)) {
+		dev_info(&GET_DEV(accel_dev),
+			 "Spurious PFVF interrupt, msg 0x%.8x. Ignored\n", csr_val);
+		return msg;
+	}
 
 	/* We can now acknowledge the message reception by clearing the
 	 * interrupt bit
Signature · 1 line
2.34.1
#10 lore raw

PATCH v2 10/16 crypto: qat - fix wording and formatting in code comment

In reply to Marco Chiappero

Remove an unintentional extra space and improve the readability of a PFVF related code comment.

---
 drivers/crypto/qat/qat_common/adf_pfvf_msg.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/qat/qat_common/adf_pfvf_msg.h +2 -2
index 9c37a2661392..204a42438992 100644
@@ -8,8 +8,8 @@
 /*
  * PF<->VF Gen2 Messaging format
  *
- * The PF has an array of 32-bit PF2VF registers, one for each VF.  The
- * PF can access all these registers; each VF can access only the one
+ * The PF has an array of 32-bit PF2VF registers, one for each VF. The
+ * PF can access all these registers while each VF can access only the one
  * register associated with that particular VF.
  *
  * The register functionally is split into two parts:
Signature · 1 line
2.34.1
#11 lore raw

PATCH v2 11/16 crypto: qat - fix off-by-one error in PFVF debug print

In reply to Marco Chiappero

PFVF Block Message requests for CRC use 0-based values to indicate amounts, which have to be remapped to 1-based values on the receiving side.

This patch fixes one debug print which was however using the wire value.

---
 drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/qat/qat_common/adf_pfvf_pf_proto.c +1 -1
index c059b98836aa..388e58bcbcaf 100644
@@ -154,7 +154,7 @@ static struct pfvf_message handle_blkmsg_req(struct adf_accel_vf_info *vf_info,
 	if (FIELD_GET(ADF_VF2PF_BLOCK_CRC_REQ_MASK, req.data)) {
 		dev_dbg(&GET_DEV(vf_info->accel_dev),
 			"BlockMsg of type %d for CRC over %d bytes received from VF%d\n",
-			blk_type, blk_byte, vf_info->vf_nr);
+			blk_type, blk_byte + 1, vf_info->vf_nr);
 
 		if (!adf_pf2vf_blkmsg_get_data(vf_info, blk_type, blk_byte,
 					       byte_max, &resp_data,
Signature · 1 line
2.34.1
#12 lore raw

PATCH v2 12/16 crypto: qat - rework the VF2PF interrupt handling logic

In reply to Marco Chiappero

Change the VF2PF interrupt handler in the PF ISR and the definition of the internal PFVF API to correct the current implementation, which can result in missed interrupts.

More specifically, current HW generations consider a write to the mask register, regardless of the value, as an acknowledge of any pending VF2PF interrupt. Therefore, if there is an interrupt between the source register read and the mask register write, such interrupt will not be delivered and silently acknowledged, resulting in a lost VF2PF message.

To work around the problem, rather than disabling specific interrupts, disable all the interrupts and re-enable only the ones that we are not serving (excluding the already disabled ones too). This will force any other pending interrupt to be triggered and be serviced by a subsequent ISR.

This new approach requires, however, changes to the interrupt related pfvf_ops functions. In particular, get_vf2pf_sources() has now been removed in favor of disable_pending_vf2pf_interrupts(), which not only retrieves and returns the pending (and enabled) sources, but also disables them.
As a consequence, introduce the adf_disable_pending_vf2pf_interrupts() utility in place of adf_disable_vf2pf_interrupts_irq(), which is no longer needed.

Fixes 993161d ("crypto: qat - fix handling of VF to PF interrupts")
---
 .../crypto/qat/qat_common/adf_accel_devices.h |  2 +-
 drivers/crypto/qat/qat_common/adf_gen2_pfvf.c | 58 +++++++++-----
 drivers/crypto/qat/qat_common/adf_gen4_pfvf.c | 44 ++++++++---
 drivers/crypto/qat/qat_common/adf_isr.c       | 17 ++---
 .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c   | 76 +++++++++++++------
 5 files changed, 132 insertions(+), 65 deletions(-)
drivers/crypto/qat/qat_common/adf_accel_devices.h +1 -1
index a03c6cf72331..dfa7ee41c5e9 100644
@@ -152,9 +152,9 @@ struct adf_pfvf_ops {
 	int (*enable_comms)(struct adf_accel_dev *accel_dev);
 	u32 (*get_pf2vf_offset)(u32 i);
 	u32 (*get_vf2pf_offset)(u32 i);
-	u32 (*get_vf2pf_sources)(void __iomem *pmisc_addr);
 	void (*enable_vf2pf_interrupts)(void __iomem *pmisc_addr, u32 vf_mask);
 	void (*disable_vf2pf_interrupts)(void __iomem *pmisc_addr, u32 vf_mask);
+	u32 (*disable_pending_vf2pf_interrupts)(void __iomem *pmisc_addr);
 	int (*send_msg)(struct adf_accel_dev *accel_dev, struct pfvf_message msg,
 			u32 pfvf_offset, struct mutex *csr_lock);
 	struct pfvf_message (*recv_msg)(struct adf_accel_dev *accel_dev,
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c +40 -18

84 lines not on this page · raw message

drivers/crypto/qat/qat_common/adf_gen4_pfvf.c +33 -11

70 lines not on this page · raw message

drivers/crypto/qat/qat_common/adf_isr.c +7 -10
index a35149f8bf1e..23f7fff32c64 100644
@@ -76,32 +76,29 @@ void adf_disable_vf2pf_interrupts(struct adf_accel_dev *accel_dev, u32 vf_mask)
 	spin_unlock_irqrestore(&accel_dev->pf.vf2pf_ints_lock, flags);
 }
 
-static void adf_disable_vf2pf_interrupts_irq(struct adf_accel_dev *accel_dev,
-					     u32 vf_mask)
+static u32 adf_disable_pending_vf2pf_interrupts(struct adf_accel_dev *accel_dev)
 {
 	void __iomem *pmisc_addr = adf_get_pmisc_base(accel_dev);
+	u32 pending;
 
 	spin_lock(&accel_dev->pf.vf2pf_ints_lock);
-	GET_PFVF_OPS(accel_dev)->disable_vf2pf_interrupts(pmisc_addr, vf_mask);
+	pending = GET_PFVF_OPS(accel_dev)->disable_pending_vf2pf_interrupts(pmisc_addr);
 	spin_unlock(&accel_dev->pf.vf2pf_ints_lock);
+
+	return pending;
 }
 
 static bool adf_handle_vf2pf_int(struct adf_accel_dev *accel_dev)
 {
-	void __iomem *pmisc_addr = adf_get_pmisc_base(accel_dev);
 	bool irq_handled = false;
 	unsigned long vf_mask;
 
-	/* Get the interrupt sources triggered by VFs */
-	vf_mask = GET_PFVF_OPS(accel_dev)->get_vf2pf_sources(pmisc_addr);
-
+	/* Get the interrupt sources triggered by VFs, except for those already disabled */
+	vf_mask = adf_disable_pending_vf2pf_interrupts(accel_dev);
 	if (vf_mask) {
 		struct adf_accel_vf_info *vf_info;
 		int i;
 
-		/* Disable VF2PF interrupts for VFs with pending ints */
-		adf_disable_vf2pf_interrupts_irq(accel_dev, vf_mask);
-
 		/*
 		 * Handle VF2PF interrupt unless the VF is malicious and
 		 * is attempting to flood the host OS with VF2PF interrupts.
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +51 -25

108 lines not on this page · raw message

Signature · 1 line
2.34.1
#13 lore raw

PATCH v2 13/16 crypto: qat - leverage the GEN2 VF mask definiton

In reply to Marco Chiappero

Replace hard coded VF masks in adf_gen2_pfvf.c with the recently introduced ADF_GEN2_VF_MSK.

---
 drivers/crypto/qat/qat_common/adf_gen2_pfvf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c +3 -3
index def4cc8e1039..8df952df18ef 100644
@@ -15,7 +15,7 @@
  /* VF2PF interrupts */
 #define ADF_GEN2_VF_MSK			0xFFFF
 #define ADF_GEN2_ERR_REG_VF2PF(vf_src)	(((vf_src) & 0x01FFFE00) >> 9)
-#define ADF_GEN2_ERR_MSK_VF2PF(vf_mask)	(((vf_mask) & 0xFFFF) << 9)
+#define ADF_GEN2_ERR_MSK_VF2PF(vf_mask)	(((vf_mask) & ADF_GEN2_VF_MSK) << 9)
 
 #define ADF_GEN2_PF_PF2VF_OFFSET(i)	(0x3A000 + 0x280 + ((i) * 0x04))
 #define ADF_GEN2_VF_PF2VF_OFFSET	0x200
@@ -55,7 +55,7 @@ static void adf_gen2_enable_vf2pf_interrupts(void __iomem *pmisc_addr,
 					     u32 vf_mask)
 {
 	/* Enable VF2PF Messaging Ints - VFs 0 through 15 per vf_mask[15:0] */
-	if (vf_mask & 0xFFFF) {
+	if (vf_mask & ADF_GEN2_VF_MSK) {
 		u32 val = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRMSK3)
 			  & ~ADF_GEN2_ERR_MSK_VF2PF(vf_mask);
 		ADF_CSR_WR(pmisc_addr, ADF_GEN2_ERRMSK3, val);
@@ -66,7 +66,7 @@ static void adf_gen2_disable_vf2pf_interrupts(void __iomem *pmisc_addr,
 					      u32 vf_mask)
 {
 	/* Disable VF2PF interrupts for VFs 0 through 15 per vf_mask[15:0] */
-	if (vf_mask & 0xFFFF) {
+	if (vf_mask & ADF_GEN2_VF_MSK) {
 		u32 val = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRMSK3)
 			  | ADF_GEN2_ERR_MSK_VF2PF(vf_mask);
 		ADF_CSR_WR(pmisc_addr, ADF_GEN2_ERRMSK3, val);
Signature · 1 line
2.34.1
#14 lore raw

PATCH v2 14/16 crypto: qat - replace disable_vf2pf_interrupts()

In reply to Marco Chiappero

As a consequence of the refactored VF2PF interrupt handling logic, a function that disables specific VF2PF interrupts is no longer needed. Instead, a simpler function that disables all the interrupts, also hiding the device specific amount of VFs to be disabled from the pfvf_ops users, would be sufficient.

This patch replaces disable_vf2pf_interrupts() with the new disable_all_vf2pf_interrupts(), which doesn't need any argument and disables all the VF2PF interrupts.

---
 .../crypto/qat/qat_common/adf_accel_devices.h |  2 +-
 .../crypto/qat/qat_common/adf_common_drv.h    |  3 +--
 drivers/crypto/qat/qat_common/adf_gen2_pfvf.c | 13 ++++-------
 drivers/crypto/qat/qat_common/adf_gen4_pfvf.c | 10 +++-----
 drivers/crypto/qat/qat_common/adf_isr.c       |  4 ++--
 drivers/crypto/qat/qat_common/adf_sriov.c     |  2 +-
 .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c   | 23 ++++++++-----------
 7 files changed, 23 insertions(+), 34 deletions(-)
drivers/crypto/qat/qat_common/adf_accel_devices.h +1 -1
index dfa7ee41c5e9..e927799a8e6c 100644
@@ -153,7 +153,7 @@ struct adf_pfvf_ops {
 	u32 (*get_pf2vf_offset)(u32 i);
 	u32 (*get_vf2pf_offset)(u32 i);
 	void (*enable_vf2pf_interrupts)(void __iomem *pmisc_addr, u32 vf_mask);
-	void (*disable_vf2pf_interrupts)(void __iomem *pmisc_addr, u32 vf_mask);
+	void (*disable_all_vf2pf_interrupts)(void __iomem *pmisc_addr);
 	u32 (*disable_pending_vf2pf_interrupts)(void __iomem *pmisc_addr);
 	int (*send_msg)(struct adf_accel_dev *accel_dev, struct pfvf_message msg,
 			u32 pfvf_offset, struct mutex *csr_lock);
drivers/crypto/qat/qat_common/adf_common_drv.h +1 -2
index feecf1035a90..da9d765834f0 100644
@@ -195,10 +195,9 @@ bool adf_misc_wq_queue_work(struct work_struct *work);
 #if defined(CONFIG_PCI_IOV)
 int adf_sriov_configure(struct pci_dev *pdev, int numvfs);
 void adf_disable_sriov(struct adf_accel_dev *accel_dev);
-void adf_disable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,
-				  u32 vf_mask);
 void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,
 				 u32 vf_mask);
+void adf_disable_all_vf2pf_interrupts(struct adf_accel_dev *accel_dev);
 bool adf_recv_and_handle_pf2vf_msg(struct adf_accel_dev *accel_dev);
 bool adf_recv_and_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr);
 int adf_pf2vf_handle_pf_restarting(struct adf_accel_dev *accel_dev);
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c +5 -8
index 8df952df18ef..606409533409 100644
@@ -62,15 +62,12 @@ static void adf_gen2_enable_vf2pf_interrupts(void __iomem *pmisc_addr,
 	}
 }
 
-static void adf_gen2_disable_vf2pf_interrupts(void __iomem *pmisc_addr,
-					      u32 vf_mask)
+static void adf_gen2_disable_all_vf2pf_interrupts(void __iomem *pmisc_addr)
 {
 	/* Disable VF2PF interrupts for VFs 0 through 15 per vf_mask[15:0] */
-	if (vf_mask & ADF_GEN2_VF_MSK) {
-		u32 val = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRMSK3)
-			  | ADF_GEN2_ERR_MSK_VF2PF(vf_mask);
-		ADF_CSR_WR(pmisc_addr, ADF_GEN2_ERRMSK3, val);
-	}
+	u32 val = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRMSK3)
+		  | ADF_GEN2_ERR_MSK_VF2PF(ADF_GEN2_VF_MSK);
+	ADF_CSR_WR(pmisc_addr, ADF_GEN2_ERRMSK3, val);
 }
 
 static u32 adf_gen2_disable_pending_vf2pf_interrupts(void __iomem *pmisc_addr)
@@ -385,7 +382,7 @@ void adf_gen2_init_pf_pfvf_ops(struct adf_pfvf_ops *pfvf_ops)
 	pfvf_ops->get_pf2vf_offset = adf_gen2_pf_get_pfvf_offset;
 	pfvf_ops->get_vf2pf_offset = adf_gen2_pf_get_pfvf_offset;
 	pfvf_ops->enable_vf2pf_interrupts = adf_gen2_enable_vf2pf_interrupts;
-	pfvf_ops->disable_vf2pf_interrupts = adf_gen2_disable_vf2pf_interrupts;
+	pfvf_ops->disable_all_vf2pf_interrupts = adf_gen2_disable_all_vf2pf_interrupts;
 	pfvf_ops->disable_pending_vf2pf_interrupts = adf_gen2_disable_pending_vf2pf_interrupts;
 	pfvf_ops->send_msg = adf_gen2_pf2vf_send;
 	pfvf_ops->recv_msg = adf_gen2_vf2pf_recv;
drivers/crypto/qat/qat_common/adf_gen4_pfvf.c +3 -7
index 4061725b926d..8091fc52e13a 100644
@@ -46,13 +46,9 @@ static void adf_gen4_enable_vf2pf_interrupts(void __iomem *pmisc_addr,
 	ADF_CSR_WR(pmisc_addr, ADF_4XXX_VM2PF_MSK, val);
 }
 
-static void adf_gen4_disable_vf2pf_interrupts(void __iomem *pmisc_addr,
-					      u32 vf_mask)
+static void adf_gen4_disable_all_vf2pf_interrupts(void __iomem *pmisc_addr)
 {
-	unsigned int val;
-
-	val = ADF_CSR_RD(pmisc_addr, ADF_4XXX_VM2PF_MSK) | vf_mask;
-	ADF_CSR_WR(pmisc_addr, ADF_4XXX_VM2PF_MSK, val);
+	ADF_CSR_WR(pmisc_addr, ADF_4XXX_VM2PF_MSK, ADF_GEN4_VF_MSK);
 }
 
 static u32 adf_gen4_disable_pending_vf2pf_interrupts(void __iomem *pmisc_addr)
@@ -144,7 +140,7 @@ void adf_gen4_init_pf_pfvf_ops(struct adf_pfvf_ops *pfvf_ops)
 	pfvf_ops->get_pf2vf_offset = adf_gen4_pf_get_pf2vf_offset;
 	pfvf_ops->get_vf2pf_offset = adf_gen4_pf_get_vf2pf_offset;
 	pfvf_ops->enable_vf2pf_interrupts = adf_gen4_enable_vf2pf_interrupts;
-	pfvf_ops->disable_vf2pf_interrupts = adf_gen4_disable_vf2pf_interrupts;
+	pfvf_ops->disable_all_vf2pf_interrupts = adf_gen4_disable_all_vf2pf_interrupts;
 	pfvf_ops->disable_pending_vf2pf_interrupts = adf_gen4_disable_pending_vf2pf_interrupts;
 	pfvf_ops->send_msg = adf_gen4_pfvf_send;
 	pfvf_ops->recv_msg = adf_gen4_pfvf_recv;
drivers/crypto/qat/qat_common/adf_isr.c +2 -2
index 23f7fff32c64..ad9e135b8560 100644
@@ -66,13 +66,13 @@ void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev, u32 vf_mask)
 	spin_unlock_irqrestore(&accel_dev->pf.vf2pf_ints_lock, flags);
 }
 
-void adf_disable_vf2pf_interrupts(struct adf_accel_dev *accel_dev, u32 vf_mask)
+void adf_disable_all_vf2pf_interrupts(struct adf_accel_dev *accel_dev)
 {
 	void __iomem *pmisc_addr = adf_get_pmisc_base(accel_dev);
 	unsigned long flags;
 
 	spin_lock_irqsave(&accel_dev->pf.vf2pf_ints_lock, flags);
-	GET_PFVF_OPS(accel_dev)->disable_vf2pf_interrupts(pmisc_addr, vf_mask);
+	GET_PFVF_OPS(accel_dev)->disable_all_vf2pf_interrupts(pmisc_addr);
 	spin_unlock_irqrestore(&accel_dev->pf.vf2pf_ints_lock, flags);
 }
 
drivers/crypto/qat/qat_common/adf_sriov.c +1 -1
index 71d75f65b504..d4e7d002a6e4 100644
@@ -107,7 +107,7 @@ void adf_disable_sriov(struct adf_accel_dev *accel_dev)
 	pci_disable_sriov(accel_to_pci_dev(accel_dev));
 
 	/* Disable VF to PF interrupts */
-	adf_disable_vf2pf_interrupts(accel_dev, GENMASK(31, 0));
+	adf_disable_all_vf2pf_interrupts(accel_dev);
 
 	/* Clear Valid bits in AE Thread to PCIe Function Mapping */
 	if (hw_data->configure_iov_threads)
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +10 -13
index 86187671893c..cb3bdd3618fb 100644
@@ -126,22 +126,19 @@ static void enable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mask)
 	}
 }
 
-static void disable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mask)
+static void disable_all_vf2pf_interrupts(void __iomem *pmisc_addr)
 {
+	u32 val;
+
 	/* Disable VF2PF interrupts for VFs 0 through 15 per vf_mask[15:0] */
-	if (vf_mask & 0xFFFF) {
-		u32 val = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRMSK3)
-			  | ADF_DH895XCC_ERR_MSK_VF2PF_L(vf_mask);
-		ADF_CSR_WR(pmisc_addr, ADF_GEN2_ERRMSK3, val);
-	}
+	val = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRMSK3)
+	      | ADF_DH895XCC_ERR_MSK_VF2PF_L(ADF_DH895XCC_VF_MSK);
+	ADF_CSR_WR(pmisc_addr, ADF_GEN2_ERRMSK3, val);
 
 	/* Disable VF2PF interrupts for VFs 16 through 31 per vf_mask[31:16] */
-	if (vf_mask >> 16) {
-		u32 val = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRMSK5)
-			  | ADF_DH895XCC_ERR_MSK_VF2PF_U(vf_mask);
-
-		ADF_CSR_WR(pmisc_addr, ADF_GEN2_ERRMSK5, val);
-	}
+	val = ADF_CSR_RD(pmisc_addr, ADF_GEN2_ERRMSK5)
+	      | ADF_DH895XCC_ERR_MSK_VF2PF_U(ADF_DH895XCC_VF_MSK);
+	ADF_CSR_WR(pmisc_addr, ADF_GEN2_ERRMSK5, val);
 }
 
 static u32 disable_pending_vf2pf_interrupts(void __iomem *pmisc_addr)
@@ -240,7 +237,7 @@ void adf_init_hw_data_dh895xcc(struct adf_hw_device_data *hw_data)
 
 	adf_gen2_init_pf_pfvf_ops(&hw_data->pfvf_ops);
 	hw_data->pfvf_ops.enable_vf2pf_interrupts = enable_vf2pf_interrupts;
-	hw_data->pfvf_ops.disable_vf2pf_interrupts = disable_vf2pf_interrupts;
+	hw_data->pfvf_ops.disable_all_vf2pf_interrupts = disable_all_vf2pf_interrupts;
 	hw_data->pfvf_ops.disable_pending_vf2pf_interrupts = disable_pending_vf2pf_interrupts;
 	adf_gen2_init_hw_csr_ops(&hw_data->csr_ops);
 }
Signature · 1 line
2.34.1
#15 lore raw

PATCH v2 15/16 crypto: qat - use u32 variables in all GEN4 pfvf_ops

In reply to Marco Chiappero

Change adf_gen4_enable_vf2pf_interrupts() to use a u32 variable, consistently with both other GEN4 pfvf_ops and pfvf_ops of other generations.

---
 drivers/crypto/qat/qat_common/adf_gen4_pfvf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/qat/qat_common/adf_gen4_pfvf.c +1 -1
index 8091fc52e13a..73ec8defb2d3 100644
@@ -40,7 +40,7 @@ static u32 adf_gen4_pf_get_vf2pf_offset(u32 i)
 static void adf_gen4_enable_vf2pf_interrupts(void __iomem *pmisc_addr,
 					     u32 vf_mask)
 {
-	unsigned int val;
+	u32 val;
 
 	val = ADF_CSR_RD(pmisc_addr, ADF_4XXX_VM2PF_MSK) & ~vf_mask;
 	ADF_CSR_WR(pmisc_addr, ADF_4XXX_VM2PF_MSK, val);
Signature · 1 line
2.34.1
#16 lore raw

PATCH v2 16/16 crypto: qat - remove line wrapping for pfvf_ops functions

In reply to Marco Chiappero

Remove unnecessary line wrapping for the adf_enable_vf2pf_interrupts() function, and harmonize pfvf_ops text.

---
 drivers/crypto/qat/qat_common/adf_common_drv.h | 3 +--
 drivers/crypto/qat/qat_common/adf_gen2_pfvf.c  | 3 +--
 drivers/crypto/qat/qat_common/adf_gen4_pfvf.c  | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)
drivers/crypto/qat/qat_common/adf_common_drv.h +1 -2
index da9d765834f0..0464fa257929 100644
@@ -195,8 +195,7 @@ bool adf_misc_wq_queue_work(struct work_struct *work);
 #if defined(CONFIG_PCI_IOV)
 int adf_sriov_configure(struct pci_dev *pdev, int numvfs);
 void adf_disable_sriov(struct adf_accel_dev *accel_dev);
-void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,
-				 u32 vf_mask);
+void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev, u32 vf_mask);
 void adf_disable_all_vf2pf_interrupts(struct adf_accel_dev *accel_dev);
 bool adf_recv_and_handle_pf2vf_msg(struct adf_accel_dev *accel_dev);
 bool adf_recv_and_handle_vf2pf_msg(struct adf_accel_dev *accel_dev, u32 vf_nr);
drivers/crypto/qat/qat_common/adf_gen2_pfvf.c +1 -2
index 606409533409..70ef11963938 100644
@@ -51,8 +51,7 @@ static u32 adf_gen2_vf_get_pfvf_offset(u32 i)
 	return ADF_GEN2_VF_PF2VF_OFFSET;
 }
 
-static void adf_gen2_enable_vf2pf_interrupts(void __iomem *pmisc_addr,
-					     u32 vf_mask)
+static void adf_gen2_enable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mask)
 {
 	/* Enable VF2PF Messaging Ints - VFs 0 through 15 per vf_mask[15:0] */
 	if (vf_mask & ADF_GEN2_VF_MSK) {
drivers/crypto/qat/qat_common/adf_gen4_pfvf.c +1 -2
index 73ec8defb2d3..8e8efe93f3ee 100644
@@ -37,8 +37,7 @@ static u32 adf_gen4_pf_get_vf2pf_offset(u32 i)
 	return ADF_4XXX_VM2PF_OFFSET(i);
 }
 
-static void adf_gen4_enable_vf2pf_interrupts(void __iomem *pmisc_addr,
-					     u32 vf_mask)
+static void adf_gen4_enable_vf2pf_interrupts(void __iomem *pmisc_addr, u32 vf_mask)
 {
 	u32 val;
 
Signature · 1 line
2.34.1
maintainer
#17 lore raw
In reply to Marco Chiappero
Quoted 63 lines · Marco Chiappero

This set contains a collection of fixes for DH895XCC (the first two patches), PFVF (most of the set) and a few more.

Patches one and two correct the lack of necessary flags to indicate the presence of specific HW capabilities, which could result in VFs unable to work correctly.

The third patch fixes some ring interrupts silently enabled even when VFs are active, while the fourth one is just a style fix.

Patches from five to eleven are minor PFVF fixes, while patch twelve addresses a bigger problem which caused lost PFVF messages due to unhandled interrupts during bursts of PFVF messages from multiple VFs. This was usually noticeable when restarting many VMs/VFs at the same time. The remainder of the set is a refactoring resulting from the previous fix, but split into multiple commits to ease the review.

Changes from v1:

- Addition of patches #3, #4, #6, #7, #8, #9, #10 and #11.

Giovanni Cabiddu (3):
crypto: qat - set CIPHER capability for DH895XCC
crypto: qat - set COMPRESSION capability for DH895XCC
crypto: qat - remove unused PFVF stubs

Marco Chiappero (12):
crypto: qat - fix ETR sources enabled by default on GEN2 devices
crypto: qat - remove unneeded braces
crypto: qat - remove unnecessary tests to detect PFVF support
crypto: qat - add missing restarting event notification in VFs
crypto: qat - test PFVF registers for spurious interrupts on GEN4
crypto: qat - fix wording and formatting in code comment
crypto: qat - fix off-by-one error in PFVF debug print
crypto: qat - rework the VF2PF interrupt handling logic
crypto: qat - leverage the GEN2 VF mask definiton
crypto: qat - replace disable_vf2pf_interrupts()
crypto: qat - use u32 variables in all GEN4 pfvf_ops
crypto: qat - remove line wrapping for pfvf_ops functions

Wojciech Ziemba (1):
crypto: qat - add check for invalid PFVF protocol version 0

 .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c  |  15 +--
 .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.h  |   4 -
 .../crypto/qat/qat_c62x/adf_c62x_hw_data.c    |  15 +--
 .../crypto/qat/qat_c62x/adf_c62x_hw_data.h    |   4 -
 .../crypto/qat/qat_common/adf_accel_devices.h |   4 +-
 .../crypto/qat/qat_common/adf_common_drv.h    |  18 +--
 .../crypto/qat/qat_common/adf_gen2_hw_data.c  |  13 ++
 .../crypto/qat/qat_common/adf_gen2_hw_data.h  |   6 +
 drivers/crypto/qat/qat_common/adf_gen2_pfvf.c |  78 ++++++-----
 drivers/crypto/qat/qat_common/adf_gen4_pfvf.c |  61 ++++++---
 drivers/crypto/qat/qat_common/adf_isr.c       |  21 ++-
 drivers/crypto/qat/qat_common/adf_pfvf_msg.h  |   4 +-
 .../crypto/qat/qat_common/adf_pfvf_pf_proto.c |   6 +-
 drivers/crypto/qat/qat_common/adf_sriov.c     |  13 +-
 drivers/crypto/qat/qat_common/adf_vf_isr.c    |   1 +
 .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c   | 126 ++++++++++--------
 .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.h   |   4 -
 17 files changed, 206 insertions(+), 187 deletions(-)
Quoted 3 lines

base-commit: 25d8a743a4810228f9b391f6face4777b28bae7b

Signature · 1 line
2.34.1

All applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt