2021-05-27 19:16:20

by Chiappero, Marco

[permalink] [raw]
Subject: [PATCH 00/10] 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(-)

--
2.26.2


2021-05-27 19:16:26

by Chiappero, Marco

[permalink] [raw]
Subject: [PATCH 09/10] crypto: qat - remove intermediate tasklet for vf2pf

From: 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.

Signed-off-by: Svyatoslav Pankratov <[email protected]>
Co-developed-by: Giovanni Cabiddu <[email protected]>
Signed-off-by: Giovanni Cabiddu <[email protected]>
Reviewed-by: Marco Chiappero <[email protected]>
---
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

2021-05-27 19:16:50

by Chiappero, Marco

[permalink] [raw]
Subject: [PATCH 02/10] crypto: qat - remove empty sriov_configure()

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 <[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(-)

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

2021-06-03 12:16:24

by Herbert Xu

[permalink] [raw]
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 <[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(-)
>
> 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 <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2021-06-04 09:24:31

by Chiappero, Marco

[permalink] [raw]
Subject: RE: [PATCH 02/10] crypto: qat - remove empty sriov_configure()

> -----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 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 <[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(-)
> >
> > 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