All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] crypto: qat - misc fixes
@ 2021-05-27 19:12 Marco Chiappero
  2021-05-27 19:12 ` [PATCH 01/10] crypto: qat - use proper type for vf_mask Marco Chiappero
                   ` (9 more replies)
  0 siblings, 10 replies; 15+ messages in thread
From: Marco Chiappero @ 2021-05-27 19:12 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto, qat-linux, Marco Chiappero

This set is a collection of various fixes, mostly related to the PF/VF
protocol.

Giovanni Cabiddu (4):
  crypto: qat - use proper type for vf_mask
  crypto: qat - do not ignore errors from enable_vf2pf_comms()
  crypto: qat - handle both source of interrupt in VF ISR
  crypto: qat - prevent spurious MSI interrupt in VF

Marco Chiappero (5):
  crypto: qat - remove empty sriov_configure()
  crypto: qat - enable interrupts only after ISR allocation
  crypto: qat - prevent spurious MSI interrupt in PF
  crypto: qat - rename compatibility version definition
  crypto: qat - fix reuse of completion variable

Svyatoslav Pankratov (1):
  crypto: qat - remove intermediate tasklet for vf2pf

 .../crypto/qat/qat_4xxx/adf_4xxx_hw_data.c    |  2 +-
 drivers/crypto/qat/qat_4xxx/adf_drv.c         |  2 +
 .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c  |  2 +-
 drivers/crypto/qat/qat_c3xxx/adf_drv.c        |  2 +
 .../qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c     |  2 +-
 .../crypto/qat/qat_c62x/adf_c62x_hw_data.c    |  2 +-
 drivers/crypto/qat/qat_c62x/adf_drv.c         |  2 +
 .../qat/qat_c62xvf/adf_c62xvf_hw_data.c       |  2 +-
 .../crypto/qat/qat_common/adf_accel_devices.h |  3 --
 .../crypto/qat/qat_common/adf_common_drv.h    |  6 +--
 drivers/crypto/qat/qat_common/adf_init.c      |  9 ++--
 drivers/crypto/qat/qat_common/adf_isr.c       | 42 +++++++++++++------
 drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 20 +++++----
 drivers/crypto/qat/qat_common/adf_pf2vf_msg.h |  2 +-
 drivers/crypto/qat/qat_common/adf_sriov.c     |  8 +---
 drivers/crypto/qat/qat_common/adf_vf_isr.c    | 16 +++++--
 .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c   |  2 +-
 drivers/crypto/qat/qat_dh895xcc/adf_drv.c     |  2 +
 .../qat_dh895xccvf/adf_dh895xccvf_hw_data.c   |  2 +-
 19 files changed, 75 insertions(+), 53 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 01/10] crypto: qat - use proper type for vf_mask
  2021-05-27 19:12 [PATCH 00/10] crypto: qat - misc fixes Marco Chiappero
@ 2021-05-27 19:12 ` Marco Chiappero
  2021-06-03 12:15   ` Herbert Xu
  2021-05-27 19:12 ` [PATCH 02/10] crypto: qat - remove empty sriov_configure() Marco Chiappero
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: Marco Chiappero @ 2021-05-27 19:12 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto, qat-linux, Giovanni Cabiddu, Marco Chiappero

From: Giovanni Cabiddu <giovanni.cabiddu@intel.com>

Replace vf_mask type with unsigned long to avoid a stack-out-of-bound.

This is to fix the following warning reported by KASAN the first time
adf_msix_isr_ae() gets called.

    [  692.091987] BUG: KASAN: stack-out-of-bounds in find_first_bit+0x28/0x50
    [  692.092017] Read of size 8 at addr ffff88afdf789e60 by task swapper/32/0
    [  692.092076] Call Trace:
    [  692.092089]  <IRQ>
    [  692.092101]  dump_stack+0x9c/0xcf
    [  692.092132]  print_address_description.constprop.0+0x18/0x130
    [  692.092164]  ? find_first_bit+0x28/0x50
    [  692.092185]  kasan_report.cold+0x7f/0x111
    [  692.092213]  ? static_obj+0x10/0x80
    [  692.092234]  ? find_first_bit+0x28/0x50
    [  692.092262]  find_first_bit+0x28/0x50
    [  692.092288]  adf_msix_isr_ae+0x16e/0x230 [intel_qat]

Fixes: ed8ccaef52fa ("crypto: qat - Add support for SRIOV")
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Marco Chiappero <marco.chiappero@intel.com>
---
 drivers/crypto/qat/qat_common/adf_isr.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/adf_isr.c b/drivers/crypto/qat/qat_common/adf_isr.c
index e3ad5587be49..22f8ef5bfbc5 100644
--- a/drivers/crypto/qat/qat_common/adf_isr.c
+++ b/drivers/crypto/qat/qat_common/adf_isr.c
@@ -15,6 +15,10 @@
 #include "adf_transport_access_macros.h"
 #include "adf_transport_internal.h"
 
+#ifdef CONFIG_PCI_IOV
+#define ADF_MAX_NUM_VFS	32
+#endif
+
 static int adf_enable_msix(struct adf_accel_dev *accel_dev)
 {
 	struct adf_accel_pci *pci_dev_info = &accel_dev->accel_pci_dev;
@@ -72,7 +76,7 @@ static irqreturn_t adf_msix_isr_ae(int irq, void *dev_ptr)
 		struct adf_bar *pmisc =
 			&GET_BARS(accel_dev)[hw_data->get_misc_bar_id(hw_data)];
 		void __iomem *pmisc_bar_addr = pmisc->virt_addr;
-		u32 vf_mask;
+		unsigned long vf_mask;
 
 		/* Get the interrupt sources triggered by VFs */
 		vf_mask = ((ADF_CSR_RD(pmisc_bar_addr, ADF_ERRSOU5) &
@@ -93,8 +97,7 @@ static irqreturn_t adf_msix_isr_ae(int irq, void *dev_ptr)
 			 * unless the VF is malicious and is attempting to
 			 * flood the host OS with VF2PF interrupts.
 			 */
-			for_each_set_bit(i, (const unsigned long *)&vf_mask,
-					 (sizeof(vf_mask) * BITS_PER_BYTE)) {
+			for_each_set_bit(i, &vf_mask, ADF_MAX_NUM_VFS) {
 				vf_info = accel_dev->pf.vf_info + i;
 
 				if (!__ratelimit(&vf_info->vf2pf_ratelimit)) {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 02/10] crypto: qat - remove empty sriov_configure()
  2021-05-27 19:12 [PATCH 00/10] crypto: qat - misc fixes Marco Chiappero
  2021-05-27 19:12 ` [PATCH 01/10] crypto: qat - use proper type for vf_mask Marco Chiappero
@ 2021-05-27 19:12 ` Marco Chiappero
  2021-06-03 12:15   ` Herbert Xu
  2021-05-27 19:12 ` [PATCH 03/10] crypto: qat - enable interrupts only after ISR allocation Marco Chiappero
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: Marco Chiappero @ 2021-05-27 19:12 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto, qat-linux, Marco Chiappero, Giovanni Cabiddu

Remove the empty implementation of sriov_configure() and set the
sriov_configure member of the pci_driver structure to NULL.
This way, if a user tries to enable VFs on a device, when kernel and
driver are built with CONFIG_PCI_IOV=n, the kernel reports an error
message saying that the driver does not support SRIOV configuration via
sysfs.

Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
Co-developed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
---
 drivers/crypto/qat/qat_4xxx/adf_drv.c          | 2 ++
 drivers/crypto/qat/qat_c3xxx/adf_drv.c         | 2 ++
 drivers/crypto/qat/qat_c62x/adf_drv.c          | 2 ++
 drivers/crypto/qat/qat_common/adf_common_drv.h | 5 -----
 drivers/crypto/qat/qat_dh895xcc/adf_drv.c      | 2 ++
 5 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/qat/qat_4xxx/adf_drv.c b/drivers/crypto/qat/qat_4xxx/adf_drv.c
index a8805c815d16..b77290d3da10 100644
--- a/drivers/crypto/qat/qat_4xxx/adf_drv.c
+++ b/drivers/crypto/qat/qat_4xxx/adf_drv.c
@@ -309,7 +309,9 @@ static struct pci_driver adf_driver = {
 	.name = ADF_4XXX_DEVICE_NAME,
 	.probe = adf_probe,
 	.remove = adf_remove,
+#ifdef CONFIG_PCI_IOV
 	.sriov_configure = adf_sriov_configure,
+#endif
 };
 
 module_pci_driver(adf_driver);
diff --git a/drivers/crypto/qat/qat_c3xxx/adf_drv.c b/drivers/crypto/qat/qat_c3xxx/adf_drv.c
index 7fb3343ae8b0..70be2383dce2 100644
--- a/drivers/crypto/qat/qat_c3xxx/adf_drv.c
+++ b/drivers/crypto/qat/qat_c3xxx/adf_drv.c
@@ -32,7 +32,9 @@ static struct pci_driver adf_driver = {
 	.name = ADF_C3XXX_DEVICE_NAME,
 	.probe = adf_probe,
 	.remove = adf_remove,
+#ifdef CONFIG_PCI_IOV
 	.sriov_configure = adf_sriov_configure,
+#endif
 };
 
 static void adf_cleanup_pci_dev(struct adf_accel_dev *accel_dev)
diff --git a/drivers/crypto/qat/qat_c62x/adf_drv.c b/drivers/crypto/qat/qat_c62x/adf_drv.c
index 1f5de442e1e6..ab03acb06365 100644
--- a/drivers/crypto/qat/qat_c62x/adf_drv.c
+++ b/drivers/crypto/qat/qat_c62x/adf_drv.c
@@ -32,7 +32,9 @@ static struct pci_driver adf_driver = {
 	.name = ADF_C62X_DEVICE_NAME,
 	.probe = adf_probe,
 	.remove = adf_remove,
+#ifdef CONFIG_PCI_IOV
 	.sriov_configure = adf_sriov_configure,
+#endif
 };
 
 static void adf_cleanup_pci_dev(struct adf_accel_dev *accel_dev)
diff --git a/drivers/crypto/qat/qat_common/adf_common_drv.h b/drivers/crypto/qat/qat_common/adf_common_drv.h
index c61476553728..0150fce09600 100644
--- a/drivers/crypto/qat/qat_common/adf_common_drv.h
+++ b/drivers/crypto/qat/qat_common/adf_common_drv.h
@@ -205,11 +205,6 @@ void adf_exit_pf_wq(void);
 int adf_init_vf_wq(void);
 void adf_exit_vf_wq(void);
 #else
-static inline int adf_sriov_configure(struct pci_dev *pdev, int numvfs)
-{
-	return 0;
-}
-
 static inline void adf_disable_sriov(struct adf_accel_dev *accel_dev)
 {
 }
diff --git a/drivers/crypto/qat/qat_dh895xcc/adf_drv.c b/drivers/crypto/qat/qat_dh895xcc/adf_drv.c
index a9ec4357144c..31dd2a8e32b0 100644
--- a/drivers/crypto/qat/qat_dh895xcc/adf_drv.c
+++ b/drivers/crypto/qat/qat_dh895xcc/adf_drv.c
@@ -32,7 +32,9 @@ static struct pci_driver adf_driver = {
 	.name = ADF_DH895XCC_DEVICE_NAME,
 	.probe = adf_probe,
 	.remove = adf_remove,
+#ifdef CONFIG_PCI_IOV
 	.sriov_configure = adf_sriov_configure,
+#endif
 };
 
 static void adf_cleanup_pci_dev(struct adf_accel_dev *accel_dev)
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 03/10] crypto: qat - enable interrupts only after ISR allocation
  2021-05-27 19:12 [PATCH 00/10] crypto: qat - misc fixes Marco Chiappero
  2021-05-27 19:12 ` [PATCH 01/10] crypto: qat - use proper type for vf_mask Marco Chiappero
  2021-05-27 19:12 ` [PATCH 02/10] crypto: qat - remove empty sriov_configure() Marco Chiappero
@ 2021-05-27 19:12 ` Marco Chiappero
  2021-05-27 19:12 ` [PATCH 04/10] crypto: qat - do not ignore errors from enable_vf2pf_comms() Marco Chiappero
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Marco Chiappero @ 2021-05-27 19:12 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto, qat-linux, Marco Chiappero, Giovanni Cabiddu

Enable device interrupts after the setup of the interrupt handlers.

Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
---
 drivers/crypto/qat/qat_common/adf_init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/adf_init.c b/drivers/crypto/qat/qat_common/adf_init.c
index 744c40351428..14e9f3b22c60 100644
--- a/drivers/crypto/qat/qat_common/adf_init.c
+++ b/drivers/crypto/qat/qat_common/adf_init.c
@@ -88,8 +88,6 @@ int adf_dev_init(struct adf_accel_dev *accel_dev)
 		return -EFAULT;
 	}
 
-	hw_data->enable_ints(accel_dev);
-
 	if (adf_ae_init(accel_dev)) {
 		dev_err(&GET_DEV(accel_dev),
 			"Failed to initialise Acceleration Engine\n");
@@ -110,6 +108,8 @@ int adf_dev_init(struct adf_accel_dev *accel_dev)
 	}
 	set_bit(ADF_STATUS_IRQ_ALLOCATED, &accel_dev->status);
 
+	hw_data->enable_ints(accel_dev);
+
 	/*
 	 * Subservice initialisation is divided into two stages: init and start.
 	 * This is to facilitate any ordering dependencies between services
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 04/10] crypto: qat - do not ignore errors from enable_vf2pf_comms()
  2021-05-27 19:12 [PATCH 00/10] crypto: qat - misc fixes Marco Chiappero
                   ` (2 preceding siblings ...)
  2021-05-27 19:12 ` [PATCH 03/10] crypto: qat - enable interrupts only after ISR allocation Marco Chiappero
@ 2021-05-27 19:12 ` Marco Chiappero
  2021-05-27 19:12 ` [PATCH 05/10] crypto: qat - handle both source of interrupt in VF ISR Marco Chiappero
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Marco Chiappero @ 2021-05-27 19:12 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto, qat-linux, Giovanni Cabiddu, Marco Chiappero

From: Giovanni Cabiddu <giovanni.cabiddu@intel.com>

The function adf_dev_init() ignores the error code reported by
enable_vf2pf_comms(). If the latter fails, e.g. the VF is not compatible
with the pf, then the load of the VF driver progresses.
This patch changes adf_dev_init() so that the error code from
enable_vf2pf_comms() is returned to the caller.

Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Marco Chiappero <marco.chiappero@intel.com>
---
 drivers/crypto/qat/qat_common/adf_init.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/adf_init.c b/drivers/crypto/qat/qat_common/adf_init.c
index 14e9f3b22c60..346dcb8bcca5 100644
--- a/drivers/crypto/qat/qat_common/adf_init.c
+++ b/drivers/crypto/qat/qat_common/adf_init.c
@@ -61,6 +61,7 @@ int adf_dev_init(struct adf_accel_dev *accel_dev)
 	struct service_hndl *service;
 	struct list_head *list_itr;
 	struct adf_hw_device_data *hw_data = accel_dev->hw_device;
+	int ret;
 
 	if (!hw_data) {
 		dev_err(&GET_DEV(accel_dev),
@@ -127,9 +128,9 @@ int adf_dev_init(struct adf_accel_dev *accel_dev)
 	}
 
 	hw_data->enable_error_correction(accel_dev);
-	hw_data->enable_vf2pf_comms(accel_dev);
+	ret = hw_data->enable_vf2pf_comms(accel_dev);
 
-	return 0;
+	return ret;
 }
 EXPORT_SYMBOL_GPL(adf_dev_init);
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 05/10] crypto: qat - handle both source of interrupt in VF ISR
  2021-05-27 19:12 [PATCH 00/10] crypto: qat - misc fixes Marco Chiappero
                   ` (3 preceding siblings ...)
  2021-05-27 19:12 ` [PATCH 04/10] crypto: qat - do not ignore errors from enable_vf2pf_comms() Marco Chiappero
@ 2021-05-27 19:12 ` Marco Chiappero
  2021-05-27 19:12 ` [PATCH 06/10] crypto: qat - prevent spurious MSI interrupt in VF Marco Chiappero
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Marco Chiappero @ 2021-05-27 19:12 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto, qat-linux, Giovanni Cabiddu, Marco Chiappero

From: Giovanni Cabiddu <giovanni.cabiddu@intel.com>

The top half of the VF drivers handled only a source at the time.
If an interrupt for PF2VF and bundle occurred at the same time, the ISR
scheduled only the bottom half for PF2VF.
This patch fixes the VF top half so that if both sources of interrupt
trigger at the same time, both bottom halves are scheduled.

This patch is based on earlier work done by Conor McLoughlin.

Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Marco Chiappero <marco.chiappero@intel.com>
---
 drivers/crypto/qat/qat_common/adf_vf_isr.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/adf_vf_isr.c b/drivers/crypto/qat/qat_common/adf_vf_isr.c
index 888388acb6bd..3e4f64d248f9 100644
--- a/drivers/crypto/qat/qat_common/adf_vf_isr.c
+++ b/drivers/crypto/qat/qat_common/adf_vf_isr.c
@@ -160,6 +160,7 @@ static irqreturn_t adf_isr(int irq, void *privdata)
 	struct adf_bar *pmisc =
 			&GET_BARS(accel_dev)[hw_data->get_misc_bar_id(hw_data)];
 	void __iomem *pmisc_bar_addr = pmisc->virt_addr;
+	bool handled = false;
 	u32 v_int;
 
 	/* Read VF INT source CSR to determine the source of VF interrupt */
@@ -172,7 +173,7 @@ static irqreturn_t adf_isr(int irq, void *privdata)
 
 		/* Schedule tasklet to handle interrupt BH */
 		tasklet_hi_schedule(&accel_dev->vf.pf2vf_bh_tasklet);
-		return IRQ_HANDLED;
+		handled = true;
 	}
 
 	/* Check bundle interrupt */
@@ -184,10 +185,10 @@ static irqreturn_t adf_isr(int irq, void *privdata)
 		csr_ops->write_csr_int_flag_and_col(bank->csr_addr,
 						    bank->bank_number, 0);
 		tasklet_hi_schedule(&bank->resp_handler);
-		return IRQ_HANDLED;
+		handled = true;
 	}
 
-	return IRQ_NONE;
+	return handled ? IRQ_HANDLED : IRQ_NONE;
 }
 
 static int adf_request_msi_irq(struct adf_accel_dev *accel_dev)
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 06/10] crypto: qat - prevent spurious MSI interrupt in VF
  2021-05-27 19:12 [PATCH 00/10] crypto: qat - misc fixes Marco Chiappero
                   ` (4 preceding siblings ...)
  2021-05-27 19:12 ` [PATCH 05/10] crypto: qat - handle both source of interrupt in VF ISR Marco Chiappero
@ 2021-05-27 19:12 ` Marco Chiappero
  2021-05-27 19:12 ` [PATCH 07/10] crypto: qat - prevent spurious MSI interrupt in PF Marco Chiappero
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Marco Chiappero @ 2021-05-27 19:12 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto, qat-linux, Giovanni Cabiddu, Marco Chiappero

From: Giovanni Cabiddu <giovanni.cabiddu@intel.com>

QAT GEN2 devices suffer from a defect where the MSI interrupt can be
sent multiple times.

If the second (spurious) interrupt is handled before the bottom half
handler runs, then the extra interrupt is effectively ignored because
the bottom half is only scheduled once.
However, if the top half runs again after the bottom half runs, this
will appear as a spurious PF to VF interrupt.

This can be avoided by checking the interrupt mask register in addition
to the interrupt source register in the interrupt handler.

This patch is based on earlier work done by Conor McLoughlin.

Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Co-developed-by: Marco Chiappero <marco.chiappero@intel.com>
Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
---
 drivers/crypto/qat/qat_common/adf_vf_isr.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/qat/qat_common/adf_vf_isr.c b/drivers/crypto/qat/qat_common/adf_vf_isr.c
index 3e4f64d248f9..c603979e4a4c 100644
--- a/drivers/crypto/qat/qat_common/adf_vf_isr.c
+++ b/drivers/crypto/qat/qat_common/adf_vf_isr.c
@@ -18,6 +18,7 @@
 #include "adf_pf2vf_msg.h"
 
 #define ADF_VINTSOU_OFFSET	0x204
+#define ADF_VINTMSK_OFFSET	0x208
 #define ADF_VINTSOU_BUN		BIT(0)
 #define ADF_VINTSOU_PF2VF	BIT(1)
 
@@ -161,11 +162,17 @@ static irqreturn_t adf_isr(int irq, void *privdata)
 			&GET_BARS(accel_dev)[hw_data->get_misc_bar_id(hw_data)];
 	void __iomem *pmisc_bar_addr = pmisc->virt_addr;
 	bool handled = false;
-	u32 v_int;
+	u32 v_int, v_mask;
 
 	/* Read VF INT source CSR to determine the source of VF interrupt */
 	v_int = ADF_CSR_RD(pmisc_bar_addr, ADF_VINTSOU_OFFSET);
 
+	/* Read VF INT mask CSR to determine which sources are masked */
+	v_mask = ADF_CSR_RD(pmisc_bar_addr, ADF_VINTMSK_OFFSET);
+
+	/* Recompute v_int ignoring sources that are masked */
+	v_int &= ~v_mask;
+
 	/* Check for PF2VF interrupt */
 	if (v_int & ADF_VINTSOU_PF2VF) {
 		/* Disable PF to VF interrupt */
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 07/10] crypto: qat - prevent spurious MSI interrupt in PF
  2021-05-27 19:12 [PATCH 00/10] crypto: qat - misc fixes Marco Chiappero
                   ` (5 preceding siblings ...)
  2021-05-27 19:12 ` [PATCH 06/10] crypto: qat - prevent spurious MSI interrupt in VF Marco Chiappero
@ 2021-05-27 19:12 ` Marco Chiappero
  2021-05-27 19:12 ` [PATCH 08/10] crypto: qat - rename compatibility version definition Marco Chiappero
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Marco Chiappero @ 2021-05-27 19:12 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto, qat-linux, Marco Chiappero, Giovanni Cabiddu

There is a chance of getting a "spurious interrupt" warning from the
adf_vf2pf_bh_handler() bottom half when multiple interrupts come
simultaneously from different VFs.
Since the source VF is identified by a positional bit set in the ERRSOU
registers and that it is not cleared until the bottom half completes,
new top halves from other VFs may reschedule a second bottom half
for previous interrupts.

This patch solves the problem in the ISR handler by not considering
sources with already disabled interrupts (and processing pending), as
set in the ERRMSK registers.

Also, move some definitions where actually needed.

Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
---
 .../crypto/qat/qat_common/adf_accel_devices.h |  2 --
 drivers/crypto/qat/qat_common/adf_isr.c       | 25 +++++++++++++++----
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/adf_accel_devices.h b/drivers/crypto/qat/qat_common/adf_accel_devices.h
index ac435b44f1d2..2ee11b4763cd 100644
--- a/drivers/crypto/qat/qat_common/adf_accel_devices.h
+++ b/drivers/crypto/qat/qat_common/adf_accel_devices.h
@@ -18,8 +18,6 @@
 #define ADF_4XXX_DEVICE_NAME "4xxx"
 #define ADF_4XXX_PCI_DEVICE_ID 0x4940
 #define ADF_4XXXIOV_PCI_DEVICE_ID 0x4941
-#define ADF_ERRSOU3 (0x3A000 + 0x0C)
-#define ADF_ERRSOU5 (0x3A000 + 0xD8)
 #define ADF_DEVICE_FUSECTL_OFFSET 0x40
 #define ADF_DEVICE_LEGFUSE_OFFSET 0x4C
 #define ADF_DEVICE_FUSECTL_MASK 0x80000000
diff --git a/drivers/crypto/qat/qat_common/adf_isr.c b/drivers/crypto/qat/qat_common/adf_isr.c
index 22f8ef5bfbc5..403d2fc00a7d 100644
--- a/drivers/crypto/qat/qat_common/adf_isr.c
+++ b/drivers/crypto/qat/qat_common/adf_isr.c
@@ -17,6 +17,12 @@
 
 #ifdef CONFIG_PCI_IOV
 #define ADF_MAX_NUM_VFS	32
+#define ADF_ERRSOU3 (0x3A000 + 0x0C)
+#define ADF_ERRSOU5 (0x3A000 + 0xD8)
+#define ADF_ERRMSK3 (0x3A000 + 0x1C)
+#define ADF_ERRMSK5 (0x3A000 + 0xDC)
+#define ADF_ERR_REG_VF2PF_L(vf_src)	(((vf_src) & 0x01FFFE00) >> 9)
+#define ADF_ERR_REG_VF2PF_U(vf_src)	(((vf_src) & 0x0000FFFF) << 16)
 #endif
 
 static int adf_enable_msix(struct adf_accel_dev *accel_dev)
@@ -75,14 +81,23 @@ static irqreturn_t adf_msix_isr_ae(int irq, void *dev_ptr)
 		struct adf_hw_device_data *hw_data = accel_dev->hw_device;
 		struct adf_bar *pmisc =
 			&GET_BARS(accel_dev)[hw_data->get_misc_bar_id(hw_data)];
-		void __iomem *pmisc_bar_addr = pmisc->virt_addr;
+		void __iomem *pmisc_addr = pmisc->virt_addr;
+		u32 errsou3, errsou5, errmsk3, errmsk5;
 		unsigned long vf_mask;
 
 		/* Get the interrupt sources triggered by VFs */
-		vf_mask = ((ADF_CSR_RD(pmisc_bar_addr, ADF_ERRSOU5) &
-			    0x0000FFFF) << 16) |
-			  ((ADF_CSR_RD(pmisc_bar_addr, ADF_ERRSOU3) &
-			    0x01FFFE00) >> 9);
+		errsou3 = ADF_CSR_RD(pmisc_addr, ADF_ERRSOU3);
+		errsou5 = ADF_CSR_RD(pmisc_addr, ADF_ERRSOU5);
+		vf_mask = ADF_ERR_REG_VF2PF_L(errsou3);
+		vf_mask |= ADF_ERR_REG_VF2PF_U(errsou5);
+
+		/* To avoid adding duplicate entries to work queue, clear
+		 * vf_int_mask_sets bits that are already masked in ERRMSK register.
+		 */
+		errmsk3 = ADF_CSR_RD(pmisc_addr, ADF_ERRMSK3);
+		errmsk5 = ADF_CSR_RD(pmisc_addr, ADF_ERRMSK5);
+		vf_mask &= ~ADF_ERR_REG_VF2PF_L(errmsk3);
+		vf_mask &= ~ADF_ERR_REG_VF2PF_U(errmsk5);
 
 		if (vf_mask) {
 			struct adf_accel_vf_info *vf_info;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 08/10] crypto: qat - rename compatibility version definition
  2021-05-27 19:12 [PATCH 00/10] crypto: qat - misc fixes Marco Chiappero
                   ` (6 preceding siblings ...)
  2021-05-27 19:12 ` [PATCH 07/10] crypto: qat - prevent spurious MSI interrupt in PF Marco Chiappero
@ 2021-05-27 19:12 ` Marco Chiappero
  2021-05-27 19:12 ` [PATCH 09/10] crypto: qat - remove intermediate tasklet for vf2pf Marco Chiappero
  2021-05-27 19:12 ` [PATCH 10/10] crypto: qat - fix reuse of completion variable Marco Chiappero
  9 siblings, 0 replies; 15+ messages in thread
From: Marco Chiappero @ 2021-05-27 19:12 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto, qat-linux, Marco Chiappero, Giovanni Cabiddu

Rename ADF_PFVF_COMPATIBILITY_VERSION in ADF_PFVF_COMPAT_THIS_VERSION
since it is used to indicate the current version of the PFVF protocol.

Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
---
 drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c |  2 +-
 .../crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c   |  2 +-
 .../qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c      |  2 +-
 drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c |  2 +-
 .../crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c |  2 +-
 drivers/crypto/qat/qat_common/adf_pf2vf_msg.c  | 18 +++++++++---------
 drivers/crypto/qat/qat_common/adf_pf2vf_msg.h  |  2 +-
 .../qat/qat_dh895xcc/adf_dh895xcc_hw_data.c    |  2 +-
 .../qat_dh895xccvf/adf_dh895xccvf_hw_data.c    |  2 +-
 9 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c b/drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c
index 3524ddd48930..a72142413caa 100644
--- a/drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c
+++ b/drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c
@@ -218,7 +218,7 @@ void adf_init_hw_data_4xxx(struct adf_hw_device_data *hw_data)
 	hw_data->enable_ints = adf_enable_ints;
 	hw_data->enable_vf2pf_comms = adf_pf_enable_vf2pf_comms;
 	hw_data->reset_device = adf_reset_flr;
-	hw_data->min_iov_compat_ver = ADF_PFVF_COMPATIBILITY_VERSION;
+	hw_data->min_iov_compat_ver = ADF_PFVF_COMPAT_THIS_VERSION;
 	hw_data->admin_ae_mask = ADF_4XXX_ADMIN_AE_MASK;
 	hw_data->uof_get_num_objs = uof_get_num_objs;
 	hw_data->uof_get_name = uof_get_name;
diff --git a/drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c b/drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c
index 1dd64af22bea..1c7f6a6f6f2d 100644
--- a/drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c
+++ b/drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c
@@ -211,7 +211,7 @@ void adf_init_hw_data_c3xxx(struct adf_hw_device_data *hw_data)
 	hw_data->enable_ints = adf_enable_ints;
 	hw_data->enable_vf2pf_comms = adf_pf_enable_vf2pf_comms;
 	hw_data->reset_device = adf_reset_flr;
-	hw_data->min_iov_compat_ver = ADF_PFVF_COMPATIBILITY_VERSION;
+	hw_data->min_iov_compat_ver = ADF_PFVF_COMPAT_THIS_VERSION;
 	hw_data->set_ssm_wdtimer = adf_gen2_set_ssm_wdtimer;
 	adf_gen2_init_hw_csr_ops(&hw_data->csr_ops);
 }
diff --git a/drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c b/drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c
index 15f6b9bdfb22..476a4bf3de56 100644
--- a/drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c
+++ b/drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c
@@ -96,7 +96,7 @@ void adf_init_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data)
 	hw_data->get_sku = get_sku;
 	hw_data->enable_ints = adf_vf_void_noop;
 	hw_data->enable_vf2pf_comms = adf_enable_vf2pf_comms;
-	hw_data->min_iov_compat_ver = ADF_PFVF_COMPATIBILITY_VERSION;
+	hw_data->min_iov_compat_ver = ADF_PFVF_COMPAT_THIS_VERSION;
 	hw_data->dev_class->instances++;
 	adf_devmgr_update_class_index(hw_data);
 	adf_gen2_init_hw_csr_ops(&hw_data->csr_ops);
diff --git a/drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c b/drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c
index 30337390513c..a202f912820c 100644
--- a/drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c
+++ b/drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c
@@ -213,7 +213,7 @@ void adf_init_hw_data_c62x(struct adf_hw_device_data *hw_data)
 	hw_data->enable_ints = adf_enable_ints;
 	hw_data->enable_vf2pf_comms = adf_pf_enable_vf2pf_comms;
 	hw_data->reset_device = adf_reset_flr;
-	hw_data->min_iov_compat_ver = ADF_PFVF_COMPATIBILITY_VERSION;
+	hw_data->min_iov_compat_ver = ADF_PFVF_COMPAT_THIS_VERSION;
 	hw_data->set_ssm_wdtimer = adf_gen2_set_ssm_wdtimer;
 	adf_gen2_init_hw_csr_ops(&hw_data->csr_ops);
 }
diff --git a/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c b/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c
index d231583428c9..0c867208eb90 100644
--- a/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c
+++ b/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c
@@ -96,7 +96,7 @@ void adf_init_hw_data_c62xiov(struct adf_hw_device_data *hw_data)
 	hw_data->get_sku = get_sku;
 	hw_data->enable_ints = adf_vf_void_noop;
 	hw_data->enable_vf2pf_comms = adf_enable_vf2pf_comms;
-	hw_data->min_iov_compat_ver = ADF_PFVF_COMPATIBILITY_VERSION;
+	hw_data->min_iov_compat_ver = ADF_PFVF_COMPAT_THIS_VERSION;
 	hw_data->dev_class->instances++;
 	adf_devmgr_update_class_index(hw_data);
 	adf_gen2_init_hw_csr_ops(&hw_data->csr_ops);
diff --git a/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c b/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
index a1b77bd7a894..e29f5f1dc806 100644
--- a/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
+++ b/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
@@ -216,7 +216,7 @@ void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info)
 		resp = (ADF_PF2VF_MSGORIGIN_SYSTEM |
 			 (ADF_PF2VF_MSGTYPE_VERSION_RESP <<
 			  ADF_PF2VF_MSGTYPE_SHIFT) |
-			 (ADF_PFVF_COMPATIBILITY_VERSION <<
+			 (ADF_PFVF_COMPAT_THIS_VERSION <<
 			  ADF_PF2VF_VERSION_RESP_VERS_SHIFT));
 
 		dev_dbg(&GET_DEV(accel_dev),
@@ -226,19 +226,19 @@ void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info)
 		if (vf_compat_ver < hw_data->min_iov_compat_ver) {
 			dev_err(&GET_DEV(accel_dev),
 				"VF (vers %d) incompatible with PF (vers %d)\n",
-				vf_compat_ver, ADF_PFVF_COMPATIBILITY_VERSION);
+				vf_compat_ver, ADF_PFVF_COMPAT_THIS_VERSION);
 			resp |= ADF_PF2VF_VF_INCOMPATIBLE <<
 				ADF_PF2VF_VERSION_RESP_RESULT_SHIFT;
-		} else if (vf_compat_ver > ADF_PFVF_COMPATIBILITY_VERSION) {
+		} else if (vf_compat_ver > ADF_PFVF_COMPAT_THIS_VERSION) {
 			dev_err(&GET_DEV(accel_dev),
 				"VF (vers %d) compat with PF (vers %d) unkn.\n",
-				vf_compat_ver, ADF_PFVF_COMPATIBILITY_VERSION);
+				vf_compat_ver, ADF_PFVF_COMPAT_THIS_VERSION);
 			resp |= ADF_PF2VF_VF_COMPAT_UNKNOWN <<
 				ADF_PF2VF_VERSION_RESP_RESULT_SHIFT;
 		} else {
 			dev_dbg(&GET_DEV(accel_dev),
 				"VF (vers %d) compatible with PF (vers %d)\n",
-				vf_compat_ver, ADF_PFVF_COMPATIBILITY_VERSION);
+				vf_compat_ver, ADF_PFVF_COMPAT_THIS_VERSION);
 			resp |= ADF_PF2VF_VF_COMPATIBLE <<
 				ADF_PF2VF_VERSION_RESP_RESULT_SHIFT;
 		}
@@ -251,7 +251,7 @@ void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info)
 		resp = (ADF_PF2VF_MSGORIGIN_SYSTEM |
 			 (ADF_PF2VF_MSGTYPE_VERSION_RESP <<
 			  ADF_PF2VF_MSGTYPE_SHIFT) |
-			 (ADF_PFVF_COMPATIBILITY_VERSION <<
+			 (ADF_PFVF_COMPAT_THIS_VERSION <<
 			  ADF_PF2VF_VERSION_RESP_VERS_SHIFT));
 		resp |= ADF_PF2VF_VF_COMPATIBLE <<
 			ADF_PF2VF_VERSION_RESP_RESULT_SHIFT;
@@ -313,8 +313,8 @@ static int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev)
 
 	msg = ADF_VF2PF_MSGORIGIN_SYSTEM;
 	msg |= ADF_VF2PF_MSGTYPE_COMPAT_VER_REQ << ADF_VF2PF_MSGTYPE_SHIFT;
-	msg |= ADF_PFVF_COMPATIBILITY_VERSION << ADF_VF2PF_COMPAT_VER_REQ_SHIFT;
-	BUILD_BUG_ON(ADF_PFVF_COMPATIBILITY_VERSION > 255);
+	msg |= ADF_PFVF_COMPAT_THIS_VERSION << ADF_VF2PF_COMPAT_VER_REQ_SHIFT;
+	BUILD_BUG_ON(ADF_PFVF_COMPAT_THIS_VERSION > 255);
 
 	/* Send request from VF to PF */
 	ret = adf_iov_putmsg(accel_dev, msg, 0);
@@ -345,7 +345,7 @@ static int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev)
 		dev_err(&GET_DEV(accel_dev),
 			"PF (vers %d) and VF (vers %d) are not compatible\n",
 			accel_dev->vf.pf_version,
-			ADF_PFVF_COMPATIBILITY_VERSION);
+			ADF_PFVF_COMPAT_THIS_VERSION);
 		return -EINVAL;
 	default:
 		dev_err(&GET_DEV(accel_dev),
diff --git a/drivers/crypto/qat/qat_common/adf_pf2vf_msg.h b/drivers/crypto/qat/qat_common/adf_pf2vf_msg.h
index 0690c031bfce..ffd43aa50b57 100644
--- a/drivers/crypto/qat/qat_common/adf_pf2vf_msg.h
+++ b/drivers/crypto/qat/qat_common/adf_pf2vf_msg.h
@@ -52,7 +52,7 @@
  * IN_USE_BY pattern as part of a collision control scheme (see adf_iov_putmsg).
  */
 
-#define ADF_PFVF_COMPATIBILITY_VERSION		0x1	/* PF<->VF compat */
+#define ADF_PFVF_COMPAT_THIS_VERSION		0x1	/* PF<->VF compat */
 
 /* PF->VF messages */
 #define ADF_PF2VF_INT				BIT(0)
diff --git a/drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c b/drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c
index 7dd7cd6c3ef8..dced2426edc1 100644
--- a/drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c
+++ b/drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c
@@ -232,7 +232,7 @@ void adf_init_hw_data_dh895xcc(struct adf_hw_device_data *hw_data)
 	hw_data->enable_ints = adf_enable_ints;
 	hw_data->enable_vf2pf_comms = adf_pf_enable_vf2pf_comms;
 	hw_data->reset_device = adf_reset_sbr;
-	hw_data->min_iov_compat_ver = ADF_PFVF_COMPATIBILITY_VERSION;
+	hw_data->min_iov_compat_ver = ADF_PFVF_COMPAT_THIS_VERSION;
 	adf_gen2_init_hw_csr_ops(&hw_data->csr_ops);
 }
 
diff --git a/drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c b/drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c
index f14fb82ed6df..ac233a39a530 100644
--- a/drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c
+++ b/drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c
@@ -96,7 +96,7 @@ void adf_init_hw_data_dh895xcciov(struct adf_hw_device_data *hw_data)
 	hw_data->get_sku = get_sku;
 	hw_data->enable_ints = adf_vf_void_noop;
 	hw_data->enable_vf2pf_comms = adf_enable_vf2pf_comms;
-	hw_data->min_iov_compat_ver = ADF_PFVF_COMPATIBILITY_VERSION;
+	hw_data->min_iov_compat_ver = ADF_PFVF_COMPAT_THIS_VERSION;
 	hw_data->dev_class->instances++;
 	adf_devmgr_update_class_index(hw_data);
 	adf_gen2_init_hw_csr_ops(&hw_data->csr_ops);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 09/10] crypto: qat - remove intermediate tasklet for vf2pf
  2021-05-27 19:12 [PATCH 00/10] crypto: qat - misc fixes Marco Chiappero
                   ` (7 preceding siblings ...)
  2021-05-27 19:12 ` [PATCH 08/10] crypto: qat - rename compatibility version definition Marco Chiappero
@ 2021-05-27 19:12 ` Marco Chiappero
  2021-05-27 19:12 ` [PATCH 10/10] crypto: qat - fix reuse of completion variable Marco Chiappero
  9 siblings, 0 replies; 15+ messages in thread
From: Marco Chiappero @ 2021-05-27 19:12 UTC (permalink / raw)
  To: herbert
  Cc: linux-crypto, qat-linux, Svyatoslav Pankratov, Giovanni Cabiddu,
	Marco Chiappero

From: Svyatoslav Pankratov <svyatoslav.pankratov@intel.com>

The PF driver uses the tasklet vf2pf_bh_tasklet to schedule a workqueue
to handle the vf2vf protocol (pf2vf_resp_wq).
Since the tasklet is only used to schedule the workqueue, this patch
removes it and schedules the pf2vf_resp_wq workqueue directly for the
top half.

Signed-off-by: Svyatoslav Pankratov <svyatoslav.pankratov@intel.com>
Co-developed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Marco Chiappero <marco.chiappero@intel.com>
---
 drivers/crypto/qat/qat_common/adf_accel_devices.h | 1 -
 drivers/crypto/qat/qat_common/adf_common_drv.h    | 1 +
 drivers/crypto/qat/qat_common/adf_isr.c           | 8 +++-----
 drivers/crypto/qat/qat_common/adf_sriov.c         | 8 +-------
 4 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/adf_accel_devices.h b/drivers/crypto/qat/qat_common/adf_accel_devices.h
index 2ee11b4763cd..180c7dba3ff2 100644
--- a/drivers/crypto/qat/qat_common/adf_accel_devices.h
+++ b/drivers/crypto/qat/qat_common/adf_accel_devices.h
@@ -225,7 +225,6 @@ struct adf_fw_loader_data {
 
 struct adf_accel_vf_info {
 	struct adf_accel_dev *accel_dev;
-	struct tasklet_struct vf2pf_bh_tasklet;
 	struct mutex pf2vf_lock; /* protect CSR access for PF2VF messages */
 	struct ratelimit_state vf2pf_ratelimit;
 	u32 vf_nr;
diff --git a/drivers/crypto/qat/qat_common/adf_common_drv.h b/drivers/crypto/qat/qat_common/adf_common_drv.h
index 0150fce09600..62f25a307000 100644
--- a/drivers/crypto/qat/qat_common/adf_common_drv.h
+++ b/drivers/crypto/qat/qat_common/adf_common_drv.h
@@ -197,6 +197,7 @@ void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,
 				 u32 vf_mask);
 void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
 void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
+void adf_schedule_vf2pf_handler(struct adf_accel_vf_info *vf_info);
 
 int adf_vf2pf_init(struct adf_accel_dev *accel_dev);
 void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev);
diff --git a/drivers/crypto/qat/qat_common/adf_isr.c b/drivers/crypto/qat/qat_common/adf_isr.c
index 403d2fc00a7d..fdd65771248b 100644
--- a/drivers/crypto/qat/qat_common/adf_isr.c
+++ b/drivers/crypto/qat/qat_common/adf_isr.c
@@ -108,9 +108,8 @@ static irqreturn_t adf_msix_isr_ae(int irq, void *dev_ptr)
 			adf_disable_vf2pf_interrupts(accel_dev, vf_mask);
 
 			/*
-			 * Schedule tasklets to handle VF2PF interrupt BHs
-			 * unless the VF is malicious and is attempting to
-			 * flood the host OS with VF2PF interrupts.
+			 * Handle VF2PF interrupt unless the VF is malicious and
+			 * is attempting to flood the host OS with VF2PF interrupts.
 			 */
 			for_each_set_bit(i, &vf_mask, ADF_MAX_NUM_VFS) {
 				vf_info = accel_dev->pf.vf_info + i;
@@ -122,8 +121,7 @@ static irqreturn_t adf_msix_isr_ae(int irq, void *dev_ptr)
 					continue;
 				}
 
-				/* Tasklet will re-enable ints from this VF */
-				tasklet_hi_schedule(&vf_info->vf2pf_bh_tasklet);
+				adf_schedule_vf2pf_handler(vf_info);
 				irq_handled = true;
 			}
 
diff --git a/drivers/crypto/qat/qat_common/adf_sriov.c b/drivers/crypto/qat/qat_common/adf_sriov.c
index 8c822c2861c2..90ec057f9183 100644
--- a/drivers/crypto/qat/qat_common/adf_sriov.c
+++ b/drivers/crypto/qat/qat_common/adf_sriov.c
@@ -24,9 +24,8 @@ static void adf_iov_send_resp(struct work_struct *work)
 	kfree(pf2vf_resp);
 }
 
-static void adf_vf2pf_bh_handler(void *data)
+void adf_schedule_vf2pf_handler(struct adf_accel_vf_info *vf_info)
 {
-	struct adf_accel_vf_info *vf_info = (struct adf_accel_vf_info *)data;
 	struct adf_pf2vf_resp *pf2vf_resp;
 
 	pf2vf_resp = kzalloc(sizeof(*pf2vf_resp), GFP_ATOMIC);
@@ -52,9 +51,6 @@ static int adf_enable_sriov(struct adf_accel_dev *accel_dev)
 		vf_info->accel_dev = accel_dev;
 		vf_info->vf_nr = i;
 
-		tasklet_init(&vf_info->vf2pf_bh_tasklet,
-			     (void *)adf_vf2pf_bh_handler,
-			     (unsigned long)vf_info);
 		mutex_init(&vf_info->pf2vf_lock);
 		ratelimit_state_init(&vf_info->vf2pf_ratelimit,
 				     DEFAULT_RATELIMIT_INTERVAL,
@@ -110,8 +106,6 @@ void adf_disable_sriov(struct adf_accel_dev *accel_dev)
 		hw_data->configure_iov_threads(accel_dev, false);
 
 	for (i = 0, vf = accel_dev->pf.vf_info; i < totalvfs; i++, vf++) {
-		tasklet_disable(&vf->vf2pf_bh_tasklet);
-		tasklet_kill(&vf->vf2pf_bh_tasklet);
 		mutex_destroy(&vf->pf2vf_lock);
 	}
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 10/10] crypto: qat - fix reuse of completion variable
  2021-05-27 19:12 [PATCH 00/10] crypto: qat - misc fixes Marco Chiappero
                   ` (8 preceding siblings ...)
  2021-05-27 19:12 ` [PATCH 09/10] crypto: qat - remove intermediate tasklet for vf2pf Marco Chiappero
@ 2021-05-27 19:12 ` Marco Chiappero
  9 siblings, 0 replies; 15+ messages in thread
From: Marco Chiappero @ 2021-05-27 19:12 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto, qat-linux, Marco Chiappero, Giovanni Cabiddu

Use reinit_completion() to set to a clean state a completion variable,
used to coordinate the VF to PF request-response flow, before every
new VF request.

Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
---
 drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c b/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
index e29f5f1dc806..d42461cb611f 100644
--- a/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
+++ b/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
@@ -316,6 +316,8 @@ static int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev)
 	msg |= ADF_PFVF_COMPAT_THIS_VERSION << ADF_VF2PF_COMPAT_VER_REQ_SHIFT;
 	BUILD_BUG_ON(ADF_PFVF_COMPAT_THIS_VERSION > 255);
 
+	reinit_completion(&accel_dev->vf.iov_msg_completion);
+
 	/* Send request from VF to PF */
 	ret = adf_iov_putmsg(accel_dev, msg, 0);
 	if (ret) {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 02/10] crypto: qat - remove empty sriov_configure()
  2021-05-27 19:12 ` [PATCH 02/10] crypto: qat - remove empty sriov_configure() Marco Chiappero
@ 2021-06-03 12:15   ` Herbert Xu
  2021-06-04  9:23     ` Chiappero, Marco
  0 siblings, 1 reply; 15+ messages in thread
From: Herbert Xu @ 2021-06-03 12:15 UTC (permalink / raw)
  To: Marco Chiappero; +Cc: linux-crypto, qat-linux, Giovanni Cabiddu

On Thu, May 27, 2021 at 08:12:43PM +0100, Marco Chiappero wrote:
> Remove the empty implementation of sriov_configure() and set the
> sriov_configure member of the pci_driver structure to NULL.
> This way, if a user tries to enable VFs on a device, when kernel and
> driver are built with CONFIG_PCI_IOV=n, the kernel reports an error
> message saying that the driver does not support SRIOV configuration via
> sysfs.
> 
> Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
> Co-developed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
> Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
> ---
>  drivers/crypto/qat/qat_4xxx/adf_drv.c          | 2 ++
>  drivers/crypto/qat/qat_c3xxx/adf_drv.c         | 2 ++
>  drivers/crypto/qat/qat_c62x/adf_drv.c          | 2 ++
>  drivers/crypto/qat/qat_common/adf_common_drv.h | 5 -----
>  drivers/crypto/qat/qat_dh895xcc/adf_drv.c      | 2 ++
>  5 files changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/crypto/qat/qat_4xxx/adf_drv.c b/drivers/crypto/qat/qat_4xxx/adf_drv.c
> index a8805c815d16..b77290d3da10 100644
> --- a/drivers/crypto/qat/qat_4xxx/adf_drv.c
> +++ b/drivers/crypto/qat/qat_4xxx/adf_drv.c
> @@ -309,7 +309,9 @@ static struct pci_driver adf_driver = {
>  	.name = ADF_4XXX_DEVICE_NAME,
>  	.probe = adf_probe,
>  	.remove = adf_remove,
> +#ifdef CONFIG_PCI_IOV
>  	.sriov_configure = adf_sriov_configure,
> +#endif

How about #defining adf_sriov_configure to NULL?

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 01/10] crypto: qat - use proper type for vf_mask
  2021-05-27 19:12 ` [PATCH 01/10] crypto: qat - use proper type for vf_mask Marco Chiappero
@ 2021-06-03 12:15   ` Herbert Xu
  2021-06-04  9:25     ` Chiappero, Marco
  0 siblings, 1 reply; 15+ messages in thread
From: Herbert Xu @ 2021-06-03 12:15 UTC (permalink / raw)
  To: Marco Chiappero; +Cc: linux-crypto, qat-linux, Giovanni Cabiddu

On Thu, May 27, 2021 at 08:12:42PM +0100, Marco Chiappero wrote:
>
> diff --git a/drivers/crypto/qat/qat_common/adf_isr.c b/drivers/crypto/qat/qat_common/adf_isr.c
> index e3ad5587be49..22f8ef5bfbc5 100644
> --- a/drivers/crypto/qat/qat_common/adf_isr.c
> +++ b/drivers/crypto/qat/qat_common/adf_isr.c
> @@ -15,6 +15,10 @@
>  #include "adf_transport_access_macros.h"
>  #include "adf_transport_internal.h"
>  
> +#ifdef CONFIG_PCI_IOV
> +#define ADF_MAX_NUM_VFS	32
> +#endif

The #ifdef is not necessary.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: [PATCH 02/10] crypto: qat - remove empty sriov_configure()
  2021-06-03 12:15   ` Herbert Xu
@ 2021-06-04  9:23     ` Chiappero, Marco
  0 siblings, 0 replies; 15+ messages in thread
From: Chiappero, Marco @ 2021-06-04  9:23 UTC (permalink / raw)
  To: Herbert Xu; +Cc: linux-crypto, qat-linux, Cabiddu, Giovanni

> -----Original Message-----
> From: Herbert Xu <herbert@gondor.apana.org.au>
> Sent: Thursday, June 3, 2021 1:16 PM
> To: Chiappero, Marco <marco.chiappero@intel.com>
> Cc: linux-crypto@vger.kernel.org; qat-linux <qat-linux@intel.com>; Cabiddu,
> Giovanni <giovanni.cabiddu@intel.com>
> Subject: Re: [PATCH 02/10] crypto: qat - remove empty sriov_configure()
> 
> On Thu, May 27, 2021 at 08:12:43PM +0100, Marco Chiappero wrote:
> > Remove the empty implementation of sriov_configure() and set the
> > sriov_configure member of the pci_driver structure to NULL.
> > This way, if a user tries to enable VFs on a device, when kernel and
> > driver are built with CONFIG_PCI_IOV=n, the kernel reports an error
> > message saying that the driver does not support SRIOV configuration
> > via sysfs.
> >
> > Signed-off-by: Marco Chiappero <marco.chiappero@intel.com>
> > Co-developed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
> > Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
> > ---
> >  drivers/crypto/qat/qat_4xxx/adf_drv.c          | 2 ++
> >  drivers/crypto/qat/qat_c3xxx/adf_drv.c         | 2 ++
> >  drivers/crypto/qat/qat_c62x/adf_drv.c          | 2 ++
> >  drivers/crypto/qat/qat_common/adf_common_drv.h | 5 -----
> >  drivers/crypto/qat/qat_dh895xcc/adf_drv.c      | 2 ++
> >  5 files changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/crypto/qat/qat_4xxx/adf_drv.c
> > b/drivers/crypto/qat/qat_4xxx/adf_drv.c
> > index a8805c815d16..b77290d3da10 100644
> > --- a/drivers/crypto/qat/qat_4xxx/adf_drv.c
> > +++ b/drivers/crypto/qat/qat_4xxx/adf_drv.c
> > @@ -309,7 +309,9 @@ static struct pci_driver adf_driver = {
> >  	.name = ADF_4XXX_DEVICE_NAME,
> >  	.probe = adf_probe,
> >  	.remove = adf_remove,
> > +#ifdef CONFIG_PCI_IOV
> >  	.sriov_configure = adf_sriov_configure,
> > +#endif
> 
> How about #defining adf_sriov_configure to NULL?
 
OK, looks good to me.

Best regards,
Marco

^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: [PATCH 01/10] crypto: qat - use proper type for vf_mask
  2021-06-03 12:15   ` Herbert Xu
@ 2021-06-04  9:25     ` Chiappero, Marco
  0 siblings, 0 replies; 15+ messages in thread
From: Chiappero, Marco @ 2021-06-04  9:25 UTC (permalink / raw)
  To: Herbert Xu; +Cc: linux-crypto, qat-linux, Cabiddu, Giovanni

> -----Original Message-----
> From: Herbert Xu <herbert@gondor.apana.org.au>
> Sent: Thursday, June 3, 2021 1:16 PM
> To: Chiappero, Marco <marco.chiappero@intel.com>
> Cc: linux-crypto@vger.kernel.org; qat-linux <qat-linux@intel.com>; Cabiddu,
> Giovanni <giovanni.cabiddu@intel.com>
> Subject: Re: [PATCH 01/10] crypto: qat - use proper type for vf_mask
> 
> On Thu, May 27, 2021 at 08:12:42PM +0100, Marco Chiappero wrote:
> >
> > diff --git a/drivers/crypto/qat/qat_common/adf_isr.c
> > b/drivers/crypto/qat/qat_common/adf_isr.c
> > index e3ad5587be49..22f8ef5bfbc5 100644
> > --- a/drivers/crypto/qat/qat_common/adf_isr.c
> > +++ b/drivers/crypto/qat/qat_common/adf_isr.c
> > @@ -15,6 +15,10 @@
> >  #include "adf_transport_access_macros.h"
> >  #include "adf_transport_internal.h"
> >
> > +#ifdef CONFIG_PCI_IOV
> > +#define ADF_MAX_NUM_VFS	32
> > +#endif
> 
> The #ifdef is not necessary.

Right, will resubmit soon.

Thank you,
Marco

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-06-04  9:25 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27 19:12 [PATCH 00/10] crypto: qat - misc fixes Marco Chiappero
2021-05-27 19:12 ` [PATCH 01/10] crypto: qat - use proper type for vf_mask Marco Chiappero
2021-06-03 12:15   ` Herbert Xu
2021-06-04  9:25     ` Chiappero, Marco
2021-05-27 19:12 ` [PATCH 02/10] crypto: qat - remove empty sriov_configure() Marco Chiappero
2021-06-03 12:15   ` Herbert Xu
2021-06-04  9:23     ` Chiappero, Marco
2021-05-27 19:12 ` [PATCH 03/10] crypto: qat - enable interrupts only after ISR allocation Marco Chiappero
2021-05-27 19:12 ` [PATCH 04/10] crypto: qat - do not ignore errors from enable_vf2pf_comms() Marco Chiappero
2021-05-27 19:12 ` [PATCH 05/10] crypto: qat - handle both source of interrupt in VF ISR Marco Chiappero
2021-05-27 19:12 ` [PATCH 06/10] crypto: qat - prevent spurious MSI interrupt in VF Marco Chiappero
2021-05-27 19:12 ` [PATCH 07/10] crypto: qat - prevent spurious MSI interrupt in PF Marco Chiappero
2021-05-27 19:12 ` [PATCH 08/10] crypto: qat - rename compatibility version definition Marco Chiappero
2021-05-27 19:12 ` [PATCH 09/10] crypto: qat - remove intermediate tasklet for vf2pf Marco Chiappero
2021-05-27 19:12 ` [PATCH 10/10] crypto: qat - fix reuse of completion variable Marco Chiappero

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.