Skip to content

Commit 9e209fc

Browse files
tstrukherbertx
authored andcommitted
crypto: qat - fix invalid pf2vf_resp_wq logic
The pf2vf_resp_wq is a global so it has to be created at init and destroyed at exit, instead of per device. Cc: <stable@vger.kernel.org> Tested-by: Suresh Marikkannu <sureshx.marikkannu@intel.com> Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 340ff60 commit 9e209fc

3 files changed

Lines changed: 24 additions & 10 deletions

File tree

‎drivers/crypto/qat/qat_common/adf_common_drv.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ void adf_disable_aer(struct adf_accel_dev *accel_dev);
144144
void adf_dev_restore(struct adf_accel_dev *accel_dev);
145145
int adf_init_aer(void);
146146
void adf_exit_aer(void);
147+
int adf_init_pf_wq(void);
148+
void adf_exit_pf_wq(void);
147149
int adf_init_admin_comms(struct adf_accel_dev *accel_dev);
148150
void adf_exit_admin_comms(struct adf_accel_dev *accel_dev);
149151
int adf_send_admin_init(struct adf_accel_dev *accel_dev);

‎drivers/crypto/qat/qat_common/adf_ctl_drv.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,17 @@ static int __init adf_register_ctl_device_driver(void)
462462
if (adf_init_aer())
463463
goto err_aer;
464464

465+
if (adf_init_pf_wq())
466+
goto err_pf_wq;
467+
465468
if (qat_crypto_register())
466469
goto err_crypto_register;
467470

468471
return 0;
469472

470473
err_crypto_register:
474+
adf_exit_pf_wq();
475+
err_pf_wq:
471476
adf_exit_aer();
472477
err_aer:
473478
adf_chr_drv_destroy();
@@ -480,6 +485,7 @@ static void __exit adf_unregister_ctl_device_driver(void)
480485
{
481486
adf_chr_drv_destroy();
482487
adf_exit_aer();
488+
adf_exit_pf_wq();
483489
qat_crypto_unregister();
484490
adf_clean_vf_map(false);
485491
mutex_destroy(&adf_ctl_lock);

‎drivers/crypto/qat/qat_common/adf_sriov.c‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,6 @@ static int adf_enable_sriov(struct adf_accel_dev *accel_dev)
119119
int i;
120120
u32 reg;
121121

122-
/* Workqueue for PF2VF responses */
123-
pf2vf_resp_wq = create_workqueue("qat_pf2vf_resp_wq");
124-
if (!pf2vf_resp_wq)
125-
return -ENOMEM;
126-
127122
for (i = 0, vf_info = accel_dev->pf.vf_info; i < totalvfs;
128123
i++, vf_info++) {
129124
/* This ptr will be populated when VFs will be created */
@@ -216,11 +211,6 @@ void adf_disable_sriov(struct adf_accel_dev *accel_dev)
216211

217212
kfree(accel_dev->pf.vf_info);
218213
accel_dev->pf.vf_info = NULL;
219-
220-
if (pf2vf_resp_wq) {
221-
destroy_workqueue(pf2vf_resp_wq);
222-
pf2vf_resp_wq = NULL;
223-
}
224214
}
225215
EXPORT_SYMBOL_GPL(adf_disable_sriov);
226216

@@ -304,3 +294,19 @@ int adf_sriov_configure(struct pci_dev *pdev, int numvfs)
304294
return numvfs;
305295
}
306296
EXPORT_SYMBOL_GPL(adf_sriov_configure);
297+
298+
int __init adf_init_pf_wq(void)
299+
{
300+
/* Workqueue for PF2VF responses */
301+
pf2vf_resp_wq = create_workqueue("qat_pf2vf_resp_wq");
302+
303+
return !pf2vf_resp_wq ? -ENOMEM : 0;
304+
}
305+
306+
void adf_exit_pf_wq(void)
307+
{
308+
if (pf2vf_resp_wq) {
309+
destroy_workqueue(pf2vf_resp_wq);
310+
pf2vf_resp_wq = NULL;
311+
}
312+
}

0 commit comments

Comments
 (0)