crypto: qat - misc fixes
cover crypto: qat - misc fixes
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(-)
Signature · 1 line
2.26.2
PATCH 1/10 crypto: qat - use proper type for vf_mask
From: Giovanni Cabiddu <[email protected]>
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]--- drivers/crypto/qat/qat_common/adf_isr.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/crypto/qat/qat_common/adf_isr.c +6 -3
@@ -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)) {
Signature · 1 line
2.26.2
Herbert Xu
maintainerRe: [PATCH 01/10] crypto: qat - use proper type for vf_mask
drivers/crypto/qat/qat_common/adf_isr.c line 20
Quoted 12 lines · Marco Chiappero
drivers/crypto/qat/qat_common/adf_isr.c +3
-0@@ -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,
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
RE: [PATCH 01/10] crypto: qat - use proper type for vf_mask
Quoted 19 lines
-----Original Message-----
From: Herbert Xu <[email protected]>
Sent: Thursday, June 3, 2021 1:16 PM
To: Chiappero, Marco <[email protected]>
Cc: [email protected]; qat-linux <[email protected]>; Cabiddu, Giovanni <[email protected]>
Subject: Re: [PATCH 01/10] crypto: qat - use proper type forvf_maskQuoted 10 lines · Marco Chiappero
drivers/crypto/qat/qat_common/adf_isr.c +0
-0@@ -15,6 +15,10 @@#include "adf_transport_access_macros.h" #include "adf_transport_internal.h"
Quoted 5 lines
drivers/crypto/qat/qat_common/adf_isr.c line 20
Quoted 3 lines
drivers/crypto/qat/qat_common/adf_isr.c +3
-0+#ifdef CONFIG_PCI_IOV +#define ADF_MAX_NUM_VFS 32 +#endif The #ifdef is not necessary.
Right, will resubmit soon.
Thank you,
Marco
PATCH 2/10 crypto: qat - remove empty sriov_configure()
In reply to Marco ChiapperoRemove 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.
--- 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(-)
drivers/crypto/qat/qat_4xxx/adf_drv.c +2 -0
@@ -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);
drivers/crypto/qat/qat_c3xxx/adf_drv.c +2 -0
@@ -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)
drivers/crypto/qat/qat_c62x/adf_drv.c +2 -0
@@ -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)
drivers/crypto/qat/qat_common/adf_common_drv.h +0 -5
@@ -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) { }
drivers/crypto/qat/qat_dh895xcc/adf_drv.c +2 -0
@@ -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)
Signature · 1 line
2.26.2
Herbert Xu
maintainerRe: [PATCH 02/10] crypto: qat - remove empty sriov_configure()
Quoted 23 lines · Marco Chiappero
Remove the empty implementation of
sriov_configure()and set thesriov_configuremember of thepci_driverstructure to NULL. This way, if a user tries to enable VFs on a device, when kernel and driver are built withCONFIG_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 <[email protected]>Co-developed-by Giovanni Cabiddu <[email protected]>Signed-off-by Giovanni Cabiddu <[email protected]>--- 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(-)drivers/crypto/qat/qat_4xxx/adf_drv.c +0
-0
drivers/crypto/qat/qat_4xxx/adf_drv.c static struct pci_driver adf_driver = { · line 314
Quoted 6 lines
drivers/crypto/qat/qat_4xxx/adf_drv.c +2
-0@@ -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,
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
RE: [PATCH 02/10] crypto: qat - remove empty sriov_configure()
Quoted 27 lines
-----Original Message-----
From: Herbert Xu <[email protected]>
Sent: Thursday, June 3, 2021 1:16 PM
To: Chiappero, Marco <[email protected]>
Cc: [email protected]; qat-linux <[email protected]>; Cabiddu, Giovanni <[email protected]>
Subject: Re: [PATCH 02/10] crypto: qat - remove emptysriov_configure()Quoted 18 lines · Marco Chiappero
Remove the empty implementation of
sriov_configure()and set thesriov_configuremember of thepci_driverstructure to NULL. This way, if a user tries to enable VFs on a device, when kernel and driver are built withCONFIG_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 <[email protected]>Co-developed-by Giovanni Cabiddu <[email protected]>Signed-off-by Giovanni Cabiddu <[email protected]>--- 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(-)
Quoted 14 lines
drivers/crypto/qat/qat_4xxx/adf_drv.c static struct pci_driver adf_driver = { · line 314
Quoted 12 lines
drivers/crypto/qat/qat_4xxx/adf_drv.c +2
-0@@ -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_configureto NULL?
OK, looks good to me.
Best regards,
Marco
PATCH 3/10 crypto: qat - enable interrupts only after ISR allocation
In reply to Marco ChiapperoEnable device interrupts after the setup of the interrupt handlers.
--- drivers/crypto/qat/qat_common/adf_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/qat/qat_common/adf_init.c +2 -2
@@ -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
Signature · 1 line
2.26.2
PATCH 4/10 crypto: qat - do not ignore errors from enable_vf2pf_comms()
In reply to Marco ChiapperoFrom: Giovanni Cabiddu <[email protected]>
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.
--- drivers/crypto/qat/qat_common/adf_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/crypto/qat/qat_common/adf_init.c +3 -2
@@ -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);
Signature · 1 line
2.26.2
PATCH 5/10 crypto: qat - handle both source of interrupt in VF ISR
In reply to Marco ChiapperoFrom: Giovanni Cabiddu <[email protected]>
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.
--- drivers/crypto/qat/qat_common/adf_vf_isr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/crypto/qat/qat_common/adf_vf_isr.c +4 -3
@@ -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)
Signature · 1 line
2.26.2
PATCH 6/10 crypto: qat - prevent spurious MSI interrupt in VF
In reply to Marco ChiapperoFrom: Giovanni Cabiddu <[email protected]>
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.
--- drivers/crypto/qat/qat_common/adf_vf_isr.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/crypto/qat/qat_common/adf_vf_isr.c +8 -1
@@ -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 */
Signature · 1 line
2.26.2
PATCH 7/10 crypto: qat - prevent spurious MSI interrupt in PF
In reply to Marco ChiapperoThere 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.
--- .../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(-)
drivers/crypto/qat/qat_common/adf_accel_devices.h +0 -2
@@ -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
drivers/crypto/qat/qat_common/adf_isr.c +20 -5
@@ -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;
Signature · 1 line
2.26.2
PATCH 8/10 crypto: qat - rename compatibility version definition
In reply to Marco ChiapperoRename ADF_PFVF_COMPATIBILITY_VERSION in ADF_PFVF_COMPAT_THIS_VERSION since it is used to indicate the current version of the PFVF protocol.
--- 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(-)
drivers/crypto/qat/qat_4xxx/adf_4xxx_hw_data.c +1 -1
@@ -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;
drivers/crypto/qat/qat_c3xxx/adf_c3xxx_hw_data.c +1 -1
@@ -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); }
drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c +1 -1
@@ -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);
drivers/crypto/qat/qat_c62x/adf_c62x_hw_data.c +1 -1
@@ -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); }
drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c +1 -1
@@ -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);
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c +9 -9
@@ -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),
drivers/crypto/qat/qat_common/adf_pf2vf_msg.h +1 -1
@@ -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)
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c +1 -1
@@ -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); }
drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c +1 -1
@@ -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);
Signature · 1 line
2.26.2
PATCH 9/10 crypto: qat - remove intermediate tasklet for vf2pf
In reply to Marco ChiapperoFrom: Svyatoslav Pankratov <[email protected]>
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.
--- 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(-)
drivers/crypto/qat/qat_common/adf_accel_devices.h +0 -1
@@ -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;
drivers/crypto/qat/qat_common/adf_common_drv.h +1 -0
@@ -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);
drivers/crypto/qat/qat_common/adf_isr.c +3 -5
@@ -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; }
drivers/crypto/qat/qat_common/adf_sriov.c +1 -7
@@ -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); }
Signature · 1 line
2.26.2
PATCH 10/10 crypto: qat - fix reuse of completion variable
In reply to Marco ChiapperoUse 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.
--- drivers/crypto/qat/qat_common/adf_pf2vf_msg.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c +2 -0
@@ -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) {
Signature · 1 line
2.26.2