Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] usb: musb: jz4740: Prevent lockup when CONFIG_SMP is set
@ 2020-05-20 15:01 Paul Cercueil
  2020-05-21 20:34 ` Bin Liu
  2020-05-21 21:28 ` Bin Liu
  0 siblings, 2 replies; 6+ messages in thread
From: Paul Cercueil @ 2020-05-20 15:01 UTC (permalink / raw)
  To: Bin Liu; +Cc: od, linux-usb, linux-kernel, Paul Cercueil

The function dma_controller_irq() locks up the exact same spinlock we
locked before calling it, which obviously resulted in a deadlock when
CONFIG_SMP was enabled. This flew under the radar as none of the boards
supported by this driver needs SMP.

Fixes: 57aadb46bd63 ("usb: musb: jz4740: Add support for DMA")
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/usb/musb/jz4740.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c
index 54e7b30acc69..42c1e8bfc4be 100644
--- a/drivers/usb/musb/jz4740.c
+++ b/drivers/usb/musb/jz4740.c
@@ -69,11 +69,11 @@ static irqreturn_t jz4740_musb_interrupt(int irq, void *__hci)
 	irqreturn_t	retval = IRQ_NONE, retval_dma = IRQ_NONE;
 	struct musb	*musb = __hci;
 
-	spin_lock_irqsave(&musb->lock, flags);
-
 	if (IS_ENABLED(CONFIG_USB_INVENTRA_DMA) && musb->dma_controller)
 		retval_dma = dma_controller_irq(irq, musb->dma_controller);
 
+	spin_lock_irqsave(&musb->lock, flags);
+
 	musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB);
 	musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX);
 	musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX);
-- 
2.26.2


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

* Re: [PATCH] usb: musb: jz4740: Prevent lockup when CONFIG_SMP is set
  2020-05-20 15:01 [PATCH] usb: musb: jz4740: Prevent lockup when CONFIG_SMP is set Paul Cercueil
@ 2020-05-21 20:34 ` Bin Liu
  2020-05-21 20:39   ` Paul Cercueil
  2020-05-21 21:28 ` Bin Liu
  1 sibling, 1 reply; 6+ messages in thread
From: Bin Liu @ 2020-05-21 20:34 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: od, linux-usb, linux-kernel

On Wed, May 20, 2020 at 05:01:11PM +0200, Paul Cercueil wrote:
> The function dma_controller_irq() locks up the exact same spinlock we
> locked before calling it, which obviously resulted in a deadlock when
> CONFIG_SMP was enabled. This flew under the radar as none of the boards
> supported by this driver needs SMP.
> 
> Fixes: 57aadb46bd63 ("usb: musb: jz4740: Add support for DMA")
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

Queued for v5.8. Thanks.
-Bin.

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

* Re: [PATCH] usb: musb: jz4740: Prevent lockup when CONFIG_SMP is set
  2020-05-21 20:34 ` Bin Liu
@ 2020-05-21 20:39   ` Paul Cercueil
  2020-05-21 21:30     ` Bin Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Cercueil @ 2020-05-21 20:39 UTC (permalink / raw)
  To: Bin Liu; +Cc: od, linux-usb, linux-kernel

Hi Bin,

The patch it fixes was introduced in 5.7-rc1, is it possible to queue 
it for the next -rc? Otherwise I'll need to Cc it to linux-stable.

-Paul

Le jeu. 21 mai 2020 à 15:34, Bin Liu <b-liu@ti.com> a écrit :
> On Wed, May 20, 2020 at 05:01:11PM +0200, Paul Cercueil wrote:
>>  The function dma_controller_irq() locks up the exact same spinlock 
>> we
>>  locked before calling it, which obviously resulted in a deadlock 
>> when
>>  CONFIG_SMP was enabled. This flew under the radar as none of the 
>> boards
>>  supported by this driver needs SMP.
>> 
>>  Fixes: 57aadb46bd63 ("usb: musb: jz4740: Add support for DMA")
>>  Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> 
> Queued for v5.8. Thanks.
> -Bin.



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

* Re: [PATCH] usb: musb: jz4740: Prevent lockup when CONFIG_SMP is set
  2020-05-20 15:01 [PATCH] usb: musb: jz4740: Prevent lockup when CONFIG_SMP is set Paul Cercueil
  2020-05-21 20:34 ` Bin Liu
@ 2020-05-21 21:28 ` Bin Liu
  1 sibling, 0 replies; 6+ messages in thread
From: Bin Liu @ 2020-05-21 21:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: od, linux-usb, linux-kernel, Paul Cercueil

Hi Greg,

On Wed, May 20, 2020 at 05:01:11PM +0200, Paul Cercueil wrote:
> The function dma_controller_irq() locks up the exact same spinlock we
> locked before calling it, which obviously resulted in a deadlock when
> CONFIG_SMP was enabled. This flew under the radar as none of the boards
> supported by this driver needs SMP.
> 
> Fixes: 57aadb46bd63 ("usb: musb: jz4740: Add support for DMA")
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

Is it too late if you directly take this patch for v5.7-rc7? The bug is
introduced in v5.7-rc1. If so, here is my Acked-by:

Acked-by: Bin Liu <b-liu@ti.com>

Thanks,
-Bin.

> ---
>  drivers/usb/musb/jz4740.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c
> index 54e7b30acc69..42c1e8bfc4be 100644
> --- a/drivers/usb/musb/jz4740.c
> +++ b/drivers/usb/musb/jz4740.c
> @@ -69,11 +69,11 @@ static irqreturn_t jz4740_musb_interrupt(int irq, void *__hci)
>  	irqreturn_t	retval = IRQ_NONE, retval_dma = IRQ_NONE;
>  	struct musb	*musb = __hci;
>  
> -	spin_lock_irqsave(&musb->lock, flags);
> -
>  	if (IS_ENABLED(CONFIG_USB_INVENTRA_DMA) && musb->dma_controller)
>  		retval_dma = dma_controller_irq(irq, musb->dma_controller);
>  
> +	spin_lock_irqsave(&musb->lock, flags);
> +
>  	musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB);
>  	musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX);
>  	musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX);
> -- 
> 2.26.2
> 

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

* Re: [PATCH] usb: musb: jz4740: Prevent lockup when CONFIG_SMP is set
  2020-05-21 20:39   ` Paul Cercueil
@ 2020-05-21 21:30     ` Bin Liu
  2020-05-21 21:35       ` Bin Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Bin Liu @ 2020-05-21 21:30 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: od, linux-usb, linux-kernel

On Thu, May 21, 2020 at 10:39:25PM +0200, Paul Cercueil wrote:
> Hi Bin,
> 
> The patch it fixes was introduced in 5.7-rc1, is it possible to queue it for
> the next -rc? Otherwise I'll need to Cc it to linux-stable.

I pinged Grag if he can directly take it for -rc7.

-Bin.

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

* Re: [PATCH] usb: musb: jz4740: Prevent lockup when CONFIG_SMP is set
  2020-05-21 21:30     ` Bin Liu
@ 2020-05-21 21:35       ` Bin Liu
  0 siblings, 0 replies; 6+ messages in thread
From: Bin Liu @ 2020-05-21 21:35 UTC (permalink / raw)
  To: Paul Cercueil, od, linux-usb, linux-kernel

Paul,

On Thu, May 21, 2020 at 04:30:28PM -0500, Bin Liu wrote:
> On Thu, May 21, 2020 at 10:39:25PM +0200, Paul Cercueil wrote:
> > Hi Bin,
> > 
> > The patch it fixes was introduced in 5.7-rc1, is it possible to queue it for
> > the next -rc? Otherwise I'll need to Cc it to linux-stable.
> 
> I pinged Grag if he can directly take it for -rc7.

BTY, it is not an issue if it is too late for -rc7, I've already added
Cc stable@ when queueing it.

-Bin.

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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20 15:01 [PATCH] usb: musb: jz4740: Prevent lockup when CONFIG_SMP is set Paul Cercueil
2020-05-21 20:34 ` Bin Liu
2020-05-21 20:39   ` Paul Cercueil
2020-05-21 21:30     ` Bin Liu
2020-05-21 21:35       ` Bin Liu
2020-05-21 21:28 ` Bin Liu

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git