linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: qat - Fix missing destroy_workqueue in adf_init_aer()
@ 2024-10-24 14:00 Wang Hai
  2024-10-24 15:04 ` Cabiddu, Giovanni
  0 siblings, 1 reply; 5+ messages in thread
From: Wang Hai @ 2024-10-24 14:00 UTC (permalink / raw)
  To: giovanni.cabiddu, herbert, davem, ahsan.atta, mun.chun.yep,
	markas.rapoportas, damian.muszynski, furong.zhou, adam.guerin,
	zhangxiaoxu5
  Cc: qat-linux, linux-crypto, linux-kernel, wanghai38

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")
Signed-off-by: Wang Hai <wanghai38@huawei.com>
---
 drivers/crypto/intel/qat/qat_common/adf_aer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/intel/qat/qat_common/adf_aer.c b/drivers/crypto/intel/qat/qat_common/adf_aer.c
index ec7913ab00a2..907144ec7e65 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_aer.c
+++ b/drivers/crypto/intel/qat/qat_common/adf_aer.c
@@ -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;
 }
-- 
2.17.1


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

* Re: [PATCH] crypto: qat - Fix missing destroy_workqueue in adf_init_aer()
  2024-10-24 14:00 [PATCH] crypto: qat - Fix missing destroy_workqueue in adf_init_aer() Wang Hai
@ 2024-10-24 15:04 ` Cabiddu, Giovanni
  2024-10-25  1:24   ` Wang Hai
  0 siblings, 1 reply; 5+ messages in thread
From: Cabiddu, Giovanni @ 2024-10-24 15:04 UTC (permalink / raw)
  To: Wang Hai
  Cc: herbert, davem, ahsan.atta, mun.chun.yep, markas.rapoportas,
	damian.muszynski, furong.zhou, adam.guerin, zhangxiaoxu5,
	qat-linux, linux-crypto, linux-kernel

On Thu, Oct 24, 2024 at 10:00:57PM +0800, Wang Hai wrote:
> 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")
> Signed-off-by: Wang Hai <wanghai38@huawei.com>
> ---
>  drivers/crypto/intel/qat/qat_common/adf_aer.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/intel/qat/qat_common/adf_aer.c b/drivers/crypto/intel/qat/qat_common/adf_aer.c
> index ec7913ab00a2..907144ec7e65 100644
> --- a/drivers/crypto/intel/qat/qat_common/adf_aer.c
> +++ b/drivers/crypto/intel/qat/qat_common/adf_aer.c
> @@ -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,

-- 
Giovanni

[1] https://elixir.bootlin.com/linux/v6.11.5/source/drivers/crypto/intel/qat/qat_common/adf_ctl_drv.c#L425

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

* Re: [PATCH] crypto: qat - Fix missing destroy_workqueue in adf_init_aer()
  2024-10-24 15:04 ` Cabiddu, Giovanni
@ 2024-10-25  1:24   ` Wang Hai
  2024-10-25  8:32     ` Cabiddu, Giovanni
  0 siblings, 1 reply; 5+ messages in thread
From: Wang Hai @ 2024-10-25  1:24 UTC (permalink / raw)
  To: Cabiddu, Giovanni
  Cc: herbert, davem, ahsan.atta, mun.chun.yep, markas.rapoportas,
	damian.muszynski, furong.zhou, adam.guerin, zhangxiaoxu5,
	qat-linux, linux-crypto, linux-kernel



On 2024/10/24 23:04, Cabiddu, Giovanni wrote:
> On Thu, Oct 24, 2024 at 10:00:57PM +0800, Wang Hai wrote:
>> 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")
>> Signed-off-by: Wang Hai <wanghai38@huawei.com>
>> ---
>>   drivers/crypto/intel/qat/qat_common/adf_aer.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/crypto/intel/qat/qat_common/adf_aer.c b/drivers/crypto/intel/qat/qat_common/adf_aer.c
>> index ec7913ab00a2..907144ec7e65 100644
>> --- a/drivers/crypto/intel/qat/qat_common/adf_aer.c
>> +++ b/drivers/crypto/intel/qat/qat_common/adf_aer.c
>> @@ -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].
> 
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:
...
}
> With this change, destroy_workqueue() is called twice.
> 
> Regards,
> 


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

* Re: [PATCH] crypto: qat - Fix missing destroy_workqueue in adf_init_aer()
  2024-10-25  1:24   ` Wang Hai
@ 2024-10-25  8:32     ` Cabiddu, Giovanni
  2024-10-26  1:29       ` Wang Hai
  0 siblings, 1 reply; 5+ messages in thread
From: Cabiddu, Giovanni @ 2024-10-25  8:32 UTC (permalink / raw)
  To: Wang Hai
  Cc: herbert, davem, ahsan.atta, mun.chun.yep, markas.rapoportas,
	damian.muszynski, furong.zhou, adam.guerin, zhangxiaoxu5,
	qat-linux, linux-crypto, linux-kernel

On Fri, Oct 25, 2024 at 09:24:52AM +0800, Wang Hai wrote:
> 
> 
> On 2024/10/24 23:04, Cabiddu, Giovanni wrote:
> > On Thu, Oct 24, 2024 at 10:00:57PM +0800, Wang Hai wrote:
> > > 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")
> > > Signed-off-by: Wang Hai <wanghai38@huawei.com>
> > > ---
> > >   drivers/crypto/intel/qat/qat_common/adf_aer.c | 4 +++-
> > >   1 file changed, 3 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/crypto/intel/qat/qat_common/adf_aer.c b/drivers/crypto/intel/qat/qat_common/adf_aer.c
> > > index ec7913ab00a2..907144ec7e65 100644
> > > --- a/drivers/crypto/intel/qat/qat_common/adf_aer.c
> > > +++ b/drivers/crypto/intel/qat/qat_common/adf_aer.c
> > > @@ -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].
> > 
> 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,

-- 
Giovanni

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

* Re: [PATCH] crypto: qat - Fix missing destroy_workqueue in adf_init_aer()
  2024-10-25  8:32     ` Cabiddu, Giovanni
@ 2024-10-26  1:29       ` Wang Hai
  0 siblings, 0 replies; 5+ messages in thread
From: Wang Hai @ 2024-10-26  1:29 UTC (permalink / raw)
  To: Cabiddu, Giovanni
  Cc: herbert, davem, ahsan.atta, mun.chun.yep, markas.rapoportas,
	damian.muszynski, furong.zhou, adam.guerin, zhangxiaoxu5,
	qat-linux, linux-crypto, linux-kernel



On 2024/10/25 16:32, Cabiddu, Giovanni wrote:
> On Fri, Oct 25, 2024 at 09:24:52AM +0800, Wang Hai wrote:
>>
>>
>> On 2024/10/24 23:04, Cabiddu, Giovanni wrote:
>>> On Thu, Oct 24, 2024 at 10:00:57PM +0800, Wang Hai wrote:
>>>> 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")
>>>> Signed-off-by: Wang Hai <wanghai38@huawei.com>
>>>> ---
>>>>    drivers/crypto/intel/qat/qat_common/adf_aer.c | 4 +++-
>>>>    1 file changed, 3 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/crypto/intel/qat/qat_common/adf_aer.c b/drivers/crypto/intel/qat/qat_common/adf_aer.c
>>>> index ec7913ab00a2..907144ec7e65 100644
>>>> --- a/drivers/crypto/intel/qat/qat_common/adf_aer.c
>>>> +++ b/drivers/crypto/intel/qat/qat_common/adf_aer.c
>>>> @@ -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].
>>>
>> 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;
> 	}
> 
Thanks for the suggestion, I will send a v2 patch
> Regards,
> 


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

end of thread, other threads:[~2024-10-26  1:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-24 14:00 [PATCH] crypto: qat - Fix missing destroy_workqueue in adf_init_aer() Wang Hai
2024-10-24 15:04 ` Cabiddu, Giovanni
2024-10-25  1:24   ` Wang Hai
2024-10-25  8:32     ` Cabiddu, Giovanni
2024-10-26  1:29       ` Wang Hai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).