Skip to contentSkip to conversation

crypto: qat - Fix missing destroy_workqueue in adf_init_aer()

PATCH Superseded Wang Hai 2 participants 5 messages Oct 24, 2024 – Oct 26, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wang Hai

author
#0 lore raw

PATCH 1/1 crypto: qat - Fix missing destroy_workqueue in adf_init_aer()

The adf_init_aer() won't destroy device_reset_wq when alloc_workqueue() for device_sriov_wq failed. Add destroy_workqueue for device_reset_wq to fix this issue.

Fixes 4469f9b23468 ("crypto: qat - re-enable sriov after pf reset")
---
 drivers/crypto/intel/qat/qat_common/adf_aer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/crypto/intel/qat/qat_common/adf_aer.c +3 -1
index ec7913ab00a2..907144ec7e65 100644
@@ -281,8 +281,10 @@ int adf_init_aer(void)
 		return -EFAULT;
 
 	device_sriov_wq = alloc_workqueue("qat_device_sriov_wq", 0, 0);
-	if (!device_sriov_wq)
+	if (!device_sriov_wq) {
+		destroy_workqueue(device_reset_wq);
 		return -EFAULT;
+	}
 
 	return 0;
 }
Signature · 1 line
2.17.1
#1 lore raw
Quoted 15 lines · Wang Hai

The adf_init_aer() won't destroy device_reset_wq when alloc_workqueue() for device_sriov_wq failed. Add destroy_workqueue for device_reset_wq to fix this issue.

Fixes 4469f9b23468 ("crypto: qat - re-enable sriov after pf reset")
---
 drivers/crypto/intel/qat/qat_common/adf_aer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/crypto/intel/qat/qat_common/adf_aer.c +0 -0
index ec7913ab00a2..907144ec7e65 100644

drivers/crypto/intel/qat/qat_common/adf_aer.c int adf_init_aer(void) · line 285

Quoted 6 lines
drivers/crypto/intel/qat/qat_common/adf_aer.c +2 -1
@@ -281,8 +281,10 @@ int adf_init_aer(void)
 		return -EFAULT;
 
 	device_sriov_wq = alloc_workqueue("qat_device_sriov_wq", 0, 0);
-	if (!device_sriov_wq)
+	if (!device_sriov_wq) {
+		destroy_workqueue(device_reset_wq);

The missing destroy_workqueue() here is intentional as the device_reset_wq is destroyed in adf_exit_aer() which is called if adf_init_aer() fails, see [1].

With this change, destroy_workqueue() is called twice.

Regards,

Signature · 3 lines
Giovanni

[1] https://elixir.bootlin.com/linux/v6.11.5/source/drivers/crypto/intel/qat/qat_common/adf_ctl_drv.c#L425
author
#2 lore raw
Quoted 18 lines · Giovanni
Quoted 17 lines · Wang Hai

The adf_init_aer() won't destroy device_reset_wq when alloc_workqueue() for device_sriov_wq failed. Add destroy_workqueue for device_reset_wq to fix this issue.

Fixes 4469f9b23468 ("crypto: qat - re-enable sriov after pf reset")
---
  drivers/crypto/intel/qat/qat_common/adf_aer.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/crypto/intel/qat/qat_common/adf_aer.c +0 -0
index ec7913ab00a2..907144ec7e65 100644
@@ -281,8 +281,10 @@ int adf_init_aer(void)
  		return -EFAULT;
 
Quoted 8 lines

drivers/crypto/intel/qat/qat_common/adf_aer.c int adf_init_aer(void) · line 285

Quoted 4 lines
drivers/crypto/intel/qat/qat_common/adf_aer.c +2 -1
  	device_sriov_wq = alloc_workqueue("qat_device_sriov_wq", 0, 0);
-	if (!device_sriov_wq)
+	if (!device_sriov_wq) {
+		destroy_workqueue(device_reset_wq);

The missing destroy_workqueue() here is intentional as the device_reset_wq is destroyed in adf_exit_aer() which is called if adf_init_aer() fails, see [1].

Hi, Giovanni.

Thanks for the review.

If adf_init_aer() fails, it will goto err_aer and then call adf_exit_misc_wq() instead of goto err_pf_wq and then call adf_exit_aer(). So this patch is needed.

static long adf_ctl_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) {
...

	if (adf_init_aer())
		goto err_aer;
...		
err_pf_wq:
	adf_exit_aer(); // will not be called when adf_init_aer() failed
err_aer:
	adf_exit_misc_wq();

err_misc_wq:
...
}

Quoted 4 lines

With this change, destroy_workqueue() is called twice.

Regards,

#3 lore raw
Quoted 28 lines · Wang Hai
Quoted 11 lines · Giovanni
Quoted 10 lines · Wang Hai

The adf_init_aer() won't destroy device_reset_wq when alloc_workqueue() for device_sriov_wq failed. Add destroy_workqueue for device_reset_wq to fix this issue.

Fixes 4469f9b23468 ("crypto: qat - re-enable sriov after pf reset")
---
  drivers/crypto/intel/qat/qat_common/adf_aer.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 14 lines

drivers/crypto/intel/qat/qat_common/adf_aer.c int adf_init_aer(void) · line 284

Quoted 10 lines
drivers/crypto/intel/qat/qat_common/adf_aer.c +2 -1
index ec7913ab00a2..907144ec7e65 100644
@@ -281,8 +281,10 @@ int adf_init_aer(void)
  		return -EFAULT;
  	device_sriov_wq = alloc_workqueue("qat_device_sriov_wq", 0, 0);
-	if (!device_sriov_wq)
+	if (!device_sriov_wq) {
+		destroy_workqueue(device_reset_wq);

The missing destroy_workqueue() here is intentional as the device_reset_wq is destroyed in adf_exit_aer() which is called if adf_init_aer() fails, see [1].

Quoted 7 lines

Hi, Giovanni.

Thanks for the review.

If adf_init_aer() fails, it will goto err_aer and then call adf_exit_misc_wq() instead of goto err_pf_wq and then call adf_exit_aer(). So this patch is needed.

Sorry, I overlooked it. You are right.
On the error path I would also set device_reset_wq to NULL.

	if (!device_sriov_wq) {
		destroy_workqueue(device_reset_wq);
		device_reset_wq = NULL;
		return -EFAULT;
	}

Regards,

Signature · 1 line
Giovanni
author
#4 lore raw
Quoted 36 lines · Giovanni
Quoted 28 lines · Wang Hai
Quoted 11 lines · Giovanni
Quoted 10 lines · Wang Hai

The adf_init_aer() won't destroy device_reset_wq when alloc_workqueue() for device_sriov_wq failed. Add destroy_workqueue for device_reset_wq to fix this issue.

Fixes 4469f9b23468 ("crypto: qat - re-enable sriov after pf reset")
---
   drivers/crypto/intel/qat/qat_common/adf_aer.c | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 14 lines

drivers/crypto/intel/qat/qat_common/adf_aer.c int adf_init_aer(void) · line 284

Quoted 10 lines
drivers/crypto/intel/qat/qat_common/adf_aer.c +2 -1
index ec7913ab00a2..907144ec7e65 100644
@@ -281,8 +281,10 @@ int adf_init_aer(void)
   		return -EFAULT;
   	device_sriov_wq = alloc_workqueue("qat_device_sriov_wq", 0, 0);
-	if (!device_sriov_wq)
+	if (!device_sriov_wq) {
+		destroy_workqueue(device_reset_wq);

The missing destroy_workqueue() here is intentional as the device_reset_wq is destroyed in adf_exit_aer() which is called if adf_init_aer() fails, see [1].

Quoted 7 lines

Hi, Giovanni.

Thanks for the review.

If adf_init_aer() fails, it will goto err_aer and then call adf_exit_misc_wq() instead of goto err_pf_wq and then call adf_exit_aer(). So this patch is needed.

Quoted 8 lines

Sorry, I overlooked it. You are right.
On the error path I would also set device_reset_wq to NULL.

	if (!device_sriov_wq) {
		destroy_workqueue(device_reset_wq);
		device_reset_wq = NULL;
		return -EFAULT;
	}

Thanks for the suggestion, I will send a v2 patch

Quoted 2 lines

Regards,