linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: Remove redundant 'flush_workqueue()' calls
@ 2021-11-12 16:30 Christophe JAILLET
  2021-11-12 17:59 ` Shuah Khan
  2021-11-13 12:25 ` Peter Chen
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2021-11-12 16:30 UTC (permalink / raw)
  To: peter.chen, gregkh, balbi, valentina.manea.m, shuah, johan,
	zhengyongjun3, colin.king, trix
  Cc: linux-usb, linux-kernel, kernel-janitors, Christophe JAILLET

'destroy_workqueue()' already drains the queue before destroying it, so
there is no need to flush it explicitly.

Remove the redundant 'flush_workqueue()' calls.

This was generated with coccinelle:

@@
expression E;
@@
- 	flush_workqueue(E);
	destroy_workqueue(E);

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/usb/chipidea/otg.c           | 5 ++---
 drivers/usb/gadget/udc/mv_udc_core.c | 4 +---
 drivers/usb/host/u132-hcd.c          | 1 -
 drivers/usb/phy/phy-mv-usb.c         | 5 +----
 drivers/usb/usbip/usbip_event.c      | 1 -
 5 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 8dd59282827b..7b53274ef966 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -255,10 +255,9 @@ int ci_hdrc_otg_init(struct ci_hdrc *ci)
  */
 void ci_hdrc_otg_destroy(struct ci_hdrc *ci)
 {
-	if (ci->wq) {
-		flush_workqueue(ci->wq);
+	if (ci->wq)
 		destroy_workqueue(ci->wq);
-	}
+
 	/* Disable all OTG irq and clear status */
 	hw_write_otgsc(ci, OTGSC_INT_EN_BITS | OTGSC_INT_STATUS_BITS,
 						OTGSC_INT_STATUS_BITS);
diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c
index 7f24ce400b59..b6d34dda028b 100644
--- a/drivers/usb/gadget/udc/mv_udc_core.c
+++ b/drivers/usb/gadget/udc/mv_udc_core.c
@@ -2084,10 +2084,8 @@ static int mv_udc_remove(struct platform_device *pdev)
 
 	usb_del_gadget_udc(&udc->gadget);
 
-	if (udc->qwork) {
-		flush_workqueue(udc->qwork);
+	if (udc->qwork)
 		destroy_workqueue(udc->qwork);
-	}
 
 	/* free memory allocated in probe */
 	dma_pool_destroy(udc->dtd_pool);
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index ae882d76612b..d879d6af5710 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -3211,7 +3211,6 @@ static void __exit u132_hcd_exit(void)
 	platform_driver_unregister(&u132_platform_driver);
 	printk(KERN_INFO "u132-hcd driver deregistered\n");
 	wait_event(u132_hcd_wait, u132_instances == 0);
-	flush_workqueue(workqueue);
 	destroy_workqueue(workqueue);
 }
 
diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index 576d925af77c..86503b7d695c 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -648,10 +648,8 @@ static int mv_otg_remove(struct platform_device *pdev)
 {
 	struct mv_otg *mvotg = platform_get_drvdata(pdev);
 
-	if (mvotg->qwork) {
-		flush_workqueue(mvotg->qwork);
+	if (mvotg->qwork)
 		destroy_workqueue(mvotg->qwork);
-	}
 
 	mv_otg_disable(mvotg);
 
@@ -825,7 +823,6 @@ static int mv_otg_probe(struct platform_device *pdev)
 err_disable_clk:
 	mv_otg_disable_internal(mvotg);
 err_destroy_workqueue:
-	flush_workqueue(mvotg->qwork);
 	destroy_workqueue(mvotg->qwork);
 
 	return retval;
diff --git a/drivers/usb/usbip/usbip_event.c b/drivers/usb/usbip/usbip_event.c
index 086ca76dd053..26513540bcdb 100644
--- a/drivers/usb/usbip/usbip_event.c
+++ b/drivers/usb/usbip/usbip_event.c
@@ -137,7 +137,6 @@ int usbip_init_eh(void)
 
 void usbip_finish_eh(void)
 {
-	flush_workqueue(usbip_queue);
 	destroy_workqueue(usbip_queue);
 	usbip_queue = NULL;
 }
-- 
2.30.2


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

* Re: [PATCH] usb: Remove redundant 'flush_workqueue()' calls
  2021-11-12 16:30 [PATCH] usb: Remove redundant 'flush_workqueue()' calls Christophe JAILLET
@ 2021-11-12 17:59 ` Shuah Khan
  2021-11-13 12:25 ` Peter Chen
  1 sibling, 0 replies; 3+ messages in thread
From: Shuah Khan @ 2021-11-12 17:59 UTC (permalink / raw)
  To: Christophe JAILLET, peter.chen, gregkh, balbi, valentina.manea.m,
	shuah, johan, zhengyongjun3, colin.king, trix, Shuah Khan
  Cc: linux-usb, linux-kernel, kernel-janitors

On 11/12/21 9:30 AM, Christophe JAILLET wrote:
> 'destroy_workqueue()' already drains the queue before destroying it, so
> there is no need to flush it explicitly.
> 
> Remove the redundant 'flush_workqueue()' calls.
> 
> This was generated with coccinelle:
> 
> @@
> expression E;
> @@
> - 	flush_workqueue(E);
> 	destroy_workqueue(E);
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>   drivers/usb/chipidea/otg.c           | 5 ++---
>   drivers/usb/gadget/udc/mv_udc_core.c | 4 +---
>   drivers/usb/host/u132-hcd.c          | 1 -
>   drivers/usb/phy/phy-mv-usb.c         | 5 +----
>   drivers/usb/usbip/usbip_event.c      | 1 -
>   5 files changed, 4 insertions(+), 12 deletions(-)
> 

> diff --git a/drivers/usb/usbip/usbip_event.c b/drivers/usb/usbip/usbip_event.c
> index 086ca76dd053..26513540bcdb 100644
> --- a/drivers/usb/usbip/usbip_event.c
> +++ b/drivers/usb/usbip/usbip_event.c
> @@ -137,7 +137,6 @@ int usbip_init_eh(void)
>   
>   void usbip_finish_eh(void)
>   {
> -	flush_workqueue(usbip_queue);
>   	destroy_workqueue(usbip_queue);
>   	usbip_queue = NULL;
>   }
> 

Might be better to generate per driver patches.

Looks good to me. For the usbip change in this patch:

Acked-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah

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

* Re: [PATCH] usb: Remove redundant 'flush_workqueue()' calls
  2021-11-12 16:30 [PATCH] usb: Remove redundant 'flush_workqueue()' calls Christophe JAILLET
  2021-11-12 17:59 ` Shuah Khan
@ 2021-11-13 12:25 ` Peter Chen
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Chen @ 2021-11-13 12:25 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: gregkh, balbi, valentina.manea.m, shuah, johan, zhengyongjun3,
	colin.king, trix, linux-usb, linux-kernel, kernel-janitors

On 21-11-12 17:30:16, Christophe JAILLET wrote:
> 'destroy_workqueue()' already drains the queue before destroying it, so
> there is no need to flush it explicitly.
> 
> Remove the redundant 'flush_workqueue()' calls.
> 
> This was generated with coccinelle:
> 
> @@
> expression E;
> @@
> - 	flush_workqueue(E);
> 	destroy_workqueue(E);
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/usb/chipidea/otg.c           | 5 ++---

Acked-by: Peter Chen <peter.chen@kernel.or> # for chipidea part
>  drivers/usb/gadget/udc/mv_udc_core.c | 4 +---
>  drivers/usb/host/u132-hcd.c          | 1 -
>  drivers/usb/phy/phy-mv-usb.c         | 5 +----
>  drivers/usb/usbip/usbip_event.c      | 1 -
>  5 files changed, 4 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
> index 8dd59282827b..7b53274ef966 100644
> --- a/drivers/usb/chipidea/otg.c
> +++ b/drivers/usb/chipidea/otg.c
> @@ -255,10 +255,9 @@ int ci_hdrc_otg_init(struct ci_hdrc *ci)
>   */
>  void ci_hdrc_otg_destroy(struct ci_hdrc *ci)
>  {
> -	if (ci->wq) {
> -		flush_workqueue(ci->wq);
> +	if (ci->wq)
>  		destroy_workqueue(ci->wq);
> -	}
> +
>  	/* Disable all OTG irq and clear status */
>  	hw_write_otgsc(ci, OTGSC_INT_EN_BITS | OTGSC_INT_STATUS_BITS,
>  						OTGSC_INT_STATUS_BITS);
> diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c
> index 7f24ce400b59..b6d34dda028b 100644
> --- a/drivers/usb/gadget/udc/mv_udc_core.c
> +++ b/drivers/usb/gadget/udc/mv_udc_core.c
> @@ -2084,10 +2084,8 @@ static int mv_udc_remove(struct platform_device *pdev)
>  
>  	usb_del_gadget_udc(&udc->gadget);
>  
> -	if (udc->qwork) {
> -		flush_workqueue(udc->qwork);
> +	if (udc->qwork)
>  		destroy_workqueue(udc->qwork);
> -	}
>  
>  	/* free memory allocated in probe */
>  	dma_pool_destroy(udc->dtd_pool);
> diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
> index ae882d76612b..d879d6af5710 100644
> --- a/drivers/usb/host/u132-hcd.c
> +++ b/drivers/usb/host/u132-hcd.c
> @@ -3211,7 +3211,6 @@ static void __exit u132_hcd_exit(void)
>  	platform_driver_unregister(&u132_platform_driver);
>  	printk(KERN_INFO "u132-hcd driver deregistered\n");
>  	wait_event(u132_hcd_wait, u132_instances == 0);
> -	flush_workqueue(workqueue);
>  	destroy_workqueue(workqueue);
>  }
>  
> diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
> index 576d925af77c..86503b7d695c 100644
> --- a/drivers/usb/phy/phy-mv-usb.c
> +++ b/drivers/usb/phy/phy-mv-usb.c
> @@ -648,10 +648,8 @@ static int mv_otg_remove(struct platform_device *pdev)
>  {
>  	struct mv_otg *mvotg = platform_get_drvdata(pdev);
>  
> -	if (mvotg->qwork) {
> -		flush_workqueue(mvotg->qwork);
> +	if (mvotg->qwork)
>  		destroy_workqueue(mvotg->qwork);
> -	}
>  
>  	mv_otg_disable(mvotg);
>  
> @@ -825,7 +823,6 @@ static int mv_otg_probe(struct platform_device *pdev)
>  err_disable_clk:
>  	mv_otg_disable_internal(mvotg);
>  err_destroy_workqueue:
> -	flush_workqueue(mvotg->qwork);
>  	destroy_workqueue(mvotg->qwork);
>  
>  	return retval;
> diff --git a/drivers/usb/usbip/usbip_event.c b/drivers/usb/usbip/usbip_event.c
> index 086ca76dd053..26513540bcdb 100644
> --- a/drivers/usb/usbip/usbip_event.c
> +++ b/drivers/usb/usbip/usbip_event.c
> @@ -137,7 +137,6 @@ int usbip_init_eh(void)
>  
>  void usbip_finish_eh(void)
>  {
> -	flush_workqueue(usbip_queue);
>  	destroy_workqueue(usbip_queue);
>  	usbip_queue = NULL;
>  }
> -- 
> 2.30.2
> 

-- 

Thanks,
Peter Chen


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

end of thread, other threads:[~2021-11-13 12:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-12 16:30 [PATCH] usb: Remove redundant 'flush_workqueue()' calls Christophe JAILLET
2021-11-12 17:59 ` Shuah Khan
2021-11-13 12:25 ` Peter Chen

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).