musb patches for v5.8-rc1
Bin Liu
maintainercover musb patches for v5.8-rc1
Hi Greg,
Here are musb patches for v5.8-rc1, including some fixes which were late to get in v5.7. I cc'd stable@ in some of them but wanted the rest fixes to sit in v5.8 for a while before backport to stable.
Please let me know if any change is needed.
Thanks,
-Bin.
---
Bin Liu (2):
usb: musb: return -ESHUTDOWN in urb when three-strikes error happened
usb: musb: start session in resume for host port
Dinghao Liu (1):
usb: musb: Fix runtime PM imbalance on error
Jason Yan (1):
usb: musb: use true for 'use_dma'
Macpaul Lin (1):
usb: musb: mediatek: add reset FADDR to zero in reset interrupt handle
Paul Cercueil (1):
usb: musb: jz4740: Prevent lockup when CONFIG_SMP is set
drivers/usb/musb/jz4740.c | 4 ++-- drivers/usb/musb/mediatek.c | 6 ++++++ drivers/usb/musb/musb_core.c | 9 ++++++++- drivers/usb/musb/musb_debugfs.c | 10 +++++----- drivers/usb/musb/musb_host.c | 10 ++++++++-- 5 files changed, 29 insertions(+), 10 deletions(-)
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 1/6 usb: musb: return -ESHUTDOWN in urb when three-strikes error happened
When a USB device attached to a hub got disconnected, MUSB controller generates RXCSR_RX_ERROR interrupt for the 3-strikes-out error.
Currently the MUSB host driver returns -EPROTO in current URB, then the USB device driver could immediately resubmit the URB which causes MUSB generate RXCSR_RX_ERROR interrupt again. This circle causes interrupt storm then the hub never got a chance to report the USB device detach.
To fix the interrupt storm, change the URB return code to -ESHUTDOWN for MUSB_RXCSR_H_ERROR interrupt, so that the USB device driver will not immediately resubmit the URB.
--- drivers/usb/musb/musb_host.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/usb/musb/musb_host.c +8 -2
@@ -1774,9 +1774,15 @@ void musb_host_rx(struct musb *musb, u8 epnum) status = -EPIPE ; }else if (rx_csr &MUSB_RXCSR_H_ERROR ) { -musb_dbg (musb,"end %d RX proto error" , epnum); +dev_err (musb->controller,"ep%d RX three-strikes error" , epnum); - status = -EPROTO ; +/* +* The three-strikes error could only happen when the USB +* device is not accessible, for example detached or powered +* off. So return the fatal error -ESHUTDOWN so hopefully the +* USB device drivers won't immediately resubmit the same URB. +*/ + status = -ESHUTDOWN ;musb_writeb (epio,MUSB_RXINTERVAL ,0 ); rx_csr &= ~MUSB_RXCSR_H_ERROR ;
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 2/6 usb: musb: start session in resume for host port
In reply to Bin LiuCommit 17539f2f4f0b ("usb: musb: fix enumeration after resume") replaced musb_start() in musb_resume() to not override softconnect bit, but it doesn't restart the session for host port which was done in musb_start(). The session could be disabled in musb_suspend(), which leads the host port doesn't stay in host mode.
So let's start the session specifically for host port in musb_resume().
--- drivers/usb/musb/musb_core.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/musb/musb_core.c +7 -0
@@ -2877,6 +2877,13 @@ static int musb_resume(struct device *dev)musb_enable_interrupts (musb);musb_platform_enable (musb); +/* session might be disabled in suspend */ +if (musb->port_mode ==MUSB_HOST && + !(musb->ops->quirks &MUSB_PRESERVE_SESSION )) { + devctl |=MUSB_DEVCTL_SESSION ; +musb_writeb (musb->mregs,MUSB_DEVCTL , devctl); + } +spin_lock_irqsave (&musb->lock, flags); error =musb_run_resume_work (musb);if (error)
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 3/6 usb: musb: use true for 'use_dma'
In reply to Bin LiuFrom: Jason Yan <[email protected]>
Fix the following coccicheck warning:
drivers/usb/musb/musb_core.c:1798:12-19: WARNING: Assignment of 0/1 to bool variable
--- drivers/usb/musb/musb_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/musb/musb_core.c +1 -1
@@ -1795,7 +1795,7 @@ irqreturn_t musb_interrupt(struct musb *musb)EXPORT_SYMBOL_GPL (musb_interrupt);#ifndef CONFIG_MUSB_PIO_ONLY -static bool use_dma =1 ; +static bool use_dma = true;/* "modprobe ... use_dma=0" etc */ module_param (use_dma, bool,0644 );
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 4/6 usb: musb: mediatek: add reset FADDR to zero in reset interrupt handle
In reply to Bin LiuFrom: Macpaul Lin <[email protected]>
When receiving reset interrupt, FADDR need to be reset to zero in peripheral mode. Otherwise ep0 cannot do enumeration when re-plugging USB cable.
--- drivers/usb/musb/mediatek.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/musb/mediatek.c +6 -0
@@ -208,6 +208,12 @@ static irqreturn_t generic_interrupt(int irq, void *__hci) musb->int_rx =musb_clearw (musb->mregs,MUSB_INTRRX ); musb->int_tx =musb_clearw (musb->mregs,MUSB_INTRTX ); +if ((musb->int_usb &MUSB_INTR_RESET ) && !is_host_active (musb)) { +/* ep0 FADDR must be 0 when (re)entering peripheral mode */ +musb_ep_select (musb->mregs,0 ); +musb_writeb (musb->mregs,MUSB_FADDR ,0 ); + } +if (musb->int_usb || musb->int_tx || musb->int_rx) retval =musb_interrupt (musb);
Signature · 1 line
2.17.1
Re: [PATCH 4/6] usb: musb: mediatek: add reset FADDR to zero in reset interrupt handle
Bin Liu <[email protected]> 於 2020年5月25日 週一 上午10:53寫道:
Quoted 32 lines
From: Macpaul Lin <[email protected]>
When receiving reset interrupt, FADDR need to be reset to zero in peripheral mode. Otherwise ep0 cannot do enumeration when re-plugging USB cable.
Signed-off-by Macpaul Lin <[email protected]>Acked-by Min Guo <[email protected]>Signed-off-by Bin Liu <[email protected]>--- drivers/usb/musb/mediatek.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/usb/musb/mediatek.c +6
-1@@ -208,6 +208,12 @@ static irqreturn_t generic_interrupt(int irq, void *__hci) musb->int_rx =musb_clearw (musb->mregs,MUSB_INTRRX ); musb->int_tx =musb_clearw (musb->mregs,MUSB_INTRTX ); +if ((musb->int_usb &MUSB_INTR_RESET ) && !is_host_active (musb)) { +/* ep0 FADDR must be 0 when (re)entering peripheral mode */ +musb_ep_select (musb->mregs,0 ); +musb_writeb (musb->mregs,MUSB_FADDR ,0 ); + } +if (musb->int_usb || musb->int_tx || musb->int_rx) retval =musb_interrupt (musb); --
Quoted 2 lines
2.17.1
Could this bug fix also been applied to stable kernel? Thanks!
Best regards,
Macpaul Lin
Greg Kroah-Hartman
maintainerRe: [PATCH 4/6] usb: musb: mediatek: add reset FADDR to zero in reset interrupt handle
Quoted 32 lines · Macpaul Lin
Bin Liu <[email protected]> 於 2020年5月25日 週一 上午10:53寫道:
Quoted 31 lines
From: Macpaul Lin <[email protected]>
When receiving reset interrupt, FADDR need to be reset to zero in peripheral mode. Otherwise ep0 cannot do enumeration when re-plugging USB cable.
Signed-off-by Macpaul Lin <[email protected]>Acked-by Min Guo <[email protected]>Signed-off-by Bin Liu <[email protected]>--- drivers/usb/musb/mediatek.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/usb/musb/mediatek.c +6
-0@@ -208,6 +208,12 @@ static irqreturn_t generic_interrupt(int irq, void *__hci) musb->int_rx =musb_clearw (musb->mregs,MUSB_INTRRX ); musb->int_tx =musb_clearw (musb->mregs,MUSB_INTRTX ); +if ((musb->int_usb &MUSB_INTR_RESET ) && !is_host_active (musb)) { +/* ep0 FADDR must be 0 when (re)entering peripheral mode */ +musb_ep_select (musb->mregs,0 ); +musb_writeb (musb->mregs,MUSB_FADDR ,0 ); + } +if (musb->int_usb || musb->int_tx || musb->int_rx) retval =musb_interrupt (musb);
Quoted 4 lines
Quoted 3 lines
--
2.17.1Could this bug fix also been applied to stable kernel?
Sure, what is the git commit of it in Linus's tree?
thanks,
greg k-h
Re: [PATCH 4/6] usb: musb: mediatek: add reset FADDR to zero in reset interrupt handle
Quoted 38 lines · Greg Kroah-Hartman
Quoted 32 lines · Macpaul Lin
Bin Liu <[email protected]> 於 2020年5月25日 週一 上午10:53寫道:
Quoted 31 lines
From: Macpaul Lin <[email protected]>
When receiving reset interrupt, FADDR need to be reset to zero in peripheral mode. Otherwise ep0 cannot do enumeration when re-plugging USB cable.
Signed-off-by Macpaul Lin <[email protected]>Acked-by Min Guo <[email protected]>Signed-off-by Bin Liu <[email protected]>--- drivers/usb/musb/mediatek.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/usb/musb/mediatek.c +6
-0@@ -208,6 +208,12 @@ static irqreturn_t generic_interrupt(int irq, void *__hci) musb->int_rx =musb_clearw (musb->mregs,MUSB_INTRRX ); musb->int_tx =musb_clearw (musb->mregs,MUSB_INTRTX ); +if ((musb->int_usb &MUSB_INTR_RESET ) && !is_host_active (musb)) { +/* ep0 FADDR must be 0 when (re)entering peripheral mode */ +musb_ep_select (musb->mregs,0 ); +musb_writeb (musb->mregs,MUSB_FADDR ,0 ); + } +if (musb->int_usb || musb->int_tx || musb->int_rx) retval =musb_interrupt (musb);Quoted 4 lines
Quoted 3 lines
--
2.17.1Could this bug fix also been applied to stable kernel?
Quoted 5 lines
Sure, what is the git commit of it in Linus's tree?
thanks,
greg k-h
The commit id of this patch should be402bcac4b25b520c89ba60db85eb6316f36e797f
Thank you very much.
BR
Macpaul Lin
Greg Kroah-Hartman
maintainerRe: [PATCH 4/6] usb: musb: mediatek: add reset FADDR to zero in reset interrupt handle
Quoted 39 lines · Macpaul Lin
Quoted 38 lines · Greg Kroah-Hartman
Quoted 36 lines · Macpaul Lin
Bin Liu <[email protected]> 於 2020年5月25日 週一 上午10:53寫道:
Quoted 32 lines
From: Macpaul Lin <[email protected]>
When receiving reset interrupt, FADDR need to be reset to zero in peripheral mode. Otherwise ep0 cannot do enumeration when re-plugging USB cable.
Signed-off-by Macpaul Lin <[email protected]>Acked-by Min Guo <[email protected]>Signed-off-by Bin Liu <[email protected]>--- drivers/usb/musb/mediatek.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/usb/musb/mediatek.c +6
-1@@ -208,6 +208,12 @@ static irqreturn_t generic_interrupt(int irq, void *__hci) musb->int_rx =musb_clearw (musb->mregs,MUSB_INTRRX ); musb->int_tx =musb_clearw (musb->mregs,MUSB_INTRTX ); +if ((musb->int_usb &MUSB_INTR_RESET ) && !is_host_active (musb)) { +/* ep0 FADDR must be 0 when (re)entering peripheral mode */ +musb_ep_select (musb->mregs,0 ); +musb_writeb (musb->mregs,MUSB_FADDR ,0 ); + } +if (musb->int_usb || musb->int_tx || musb->int_rx) retval =musb_interrupt (musb); --Quoted 2 lines
2.17.1
Could this bug fix also been applied to stable kernel?
Quoted 8 lines
Quoted 5 lines
Sure, what is the git commit of it in Linus's tree?
thanks,
greg k-h
The commit id of this patch should be
402bcac4b25b520c89ba60db85eb6316f36e797f
Now queued up, thanks.
greg k-h
Bin Liu
maintainerPATCH 5/6 usb: musb: jz4740: Prevent lockup when CONFIG_SMP is set
In reply to Bin LiuFrom: Paul Cercueil <[email protected]>
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.
--- drivers/usb/musb/jz4740.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/musb/jz4740.c +2 -2
@@ -30,11 +30,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 );
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 6/6 usb: musb: Fix runtime PM imbalance on error
In reply to Bin LiuFrom: Dinghao Liu <[email protected]>
When copy_from_user() returns an error code, there is a runtime PM usage counter imbalance.
Fix this by moving copy_from_user() to the beginning of this function.
--- drivers/usb/musb/musb_debugfs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/usb/musb/musb_debugfs.c +5 -5
@@ -168,6 +168,11 @@ static ssize_t musb_test_mode_write(struct file *file,u8 test;char buf[24 ]; +memset (buf,0x00 ,sizeof (buf)); + +if (copy_from_user (buf, ubuf,min_t (size_t,sizeof (buf) -1 , count))) +return -EFAULT ; +pm_runtime_get_sync (musb->controller); test =musb_readb (musb->mregs,MUSB_TESTMODE );if (test) {
@@ -176,11 +181,6 @@ static ssize_t musb_test_mode_write(struct file *file, goto ret; } -memset (buf,0x00 ,sizeof (buf)); - -if (copy_from_user (buf, ubuf,min_t (size_t,sizeof (buf) -1 , count))) -return -EFAULT ; -if (strstarts (buf,"force host full-speed" )) test =MUSB_TEST_FORCE_HOST |MUSB_TEST_FORCE_FS ;
Signature · 1 line
2.17.1