stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Add "usb: dwc3: Stop active transfers before halting the controller" to 5.4-stable
@ 2021-08-06 13:25 Sam Protsenko
  2021-08-09  8:53 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 8+ messages in thread
From: Sam Protsenko @ 2021-08-06 13:25 UTC (permalink / raw)
  To: stable, Greg Kroah-Hartman; +Cc: Wesley Cheng

Hi Greg,

Suggest including next patch (available in linux-mainline) to
5.4-stable branch: commit ae7e86108b12 ("usb: dwc3: Stop active
transfers before halting the controller"). It's also already present
in 5.10 stable. Some fixes exist in 5.10-stable for that patch too.

This patch fixes panic in case of using USB2.0 Dual Role Device
controller, as described below.

1. Boot in peripheral role
2. Configure RNDIS gadget, perform ping, stop ping
3. Switch to host role
4. Kernel panic occurs

Kernel panic happens because gadget->udc->driver->disconnect() (which
is configfs_composite_disconnect()) is not called from
usb_gadget_disconnect() function, due to timeout condition in
dwc3_gadget_run_stop(), which leads to not called rndis_disable(). And
although previously created endpoints are not valid anymore,
eth_start_xmit() gets called and tries to use those, which leads to
invalid memory access. This patch fixes timeout condition, so next
call chain doesn't fail anymore, and RNDIS uninitialized properly on
gadget to host role switch:

<<<<<<<<<<<<<<<<<<<< cut here >>>>>>>>>>>>>>>>>>>
    usb_role_switch_set_role()
        v
    dwc3_usb_role_switch_set()
        v
    dwc3_set_mode()
        v
    __dwc3_set_mode()
        v
    dwc3_gadget_exit()
        v
    usb_del_gadget_udc()
        v
    usb_gadget_remove_driver()
        v
    usb_gadget_disconnect()
        v
    // THIS IS NOT CALLED because gadget->ops->pullup() =
    // dwc3_gadget_pullup() returns -ETIMEDOUT (-110)
    gadget->udc->driver->disconnect()
    // = configfs_composite_disconnect()
        v
    composite_disconnect()
        v
    reset_config()
        v
    foreach (f : function) : f->disable
        v
    rndis_disable()
        v
    gether_disconnect()
        v
    usb_ep_disable(),
    dev->port_usb = NULL
<<<<<<<<<<<<<<<<<<<< cut here >>>>>>>>>>>>>>>>>>>

Thanks!

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

* Re: Add "usb: dwc3: Stop active transfers before halting the controller" to 5.4-stable
  2021-08-06 13:25 Add "usb: dwc3: Stop active transfers before halting the controller" to 5.4-stable Sam Protsenko
@ 2021-08-09  8:53 ` Greg Kroah-Hartman
  2021-08-09 16:58   ` Sam Protsenko
  0 siblings, 1 reply; 8+ messages in thread
From: Greg Kroah-Hartman @ 2021-08-09  8:53 UTC (permalink / raw)
  To: Sam Protsenko; +Cc: stable, Wesley Cheng

On Fri, Aug 06, 2021 at 04:25:17PM +0300, Sam Protsenko wrote:
> Hi Greg,
> 
> Suggest including next patch (available in linux-mainline) to
> 5.4-stable branch: commit ae7e86108b12 ("usb: dwc3: Stop active
> transfers before halting the controller"). It's also already present
> in 5.10 stable. Some fixes exist in 5.10-stable for that patch too.

Can you provide a list of the fixes that also need to be backported?  I
do not want to take one patch and not all of the relevant ones.

thanks,

greg k-h

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

* Re: Add "usb: dwc3: Stop active transfers before halting the controller" to 5.4-stable
  2021-08-09  8:53 ` Greg Kroah-Hartman
@ 2021-08-09 16:58   ` Sam Protsenko
  2021-08-10  7:27     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 8+ messages in thread
From: Sam Protsenko @ 2021-08-09 16:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: stable, Wesley Cheng

On Mon, 9 Aug 2021 at 11:53, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Fri, Aug 06, 2021 at 04:25:17PM +0300, Sam Protsenko wrote:
> > Hi Greg,
> >
> > Suggest including next patch (available in linux-mainline) to
> > 5.4-stable branch: commit ae7e86108b12 ("usb: dwc3: Stop active
> > transfers before halting the controller"). It's also already present
> > in 5.10 stable. Some fixes exist in 5.10-stable for that patch too.
>
> Can you provide a list of the fixes that also need to be backported?  I
> do not want to take one patch and not all of the relevant ones.
>

Sure. Here is the whole list:

[PATCH 01/04]
usb: dwc3: Stop active transfers before halting the controller
UPSTREAM: ae7e86108b12351028fa7e8796a59f9b2d9e1774

[PATCH 02/04]
usb: dwc3: gadget: Restart DWC3 gadget when enabling pullup
UPSTREAM: a1383b3537a7bea1c213baa7878ccc4ecf4413b5
5.10-stable: dd8363fbca508616811f8a94006b09c66c094107

[PATCH 03/04]
usb: dwc3: gadget: Prevent EP queuing while stopping transfers
UPSTREAM: f09ddcfcb8c569675066337adac2ac205113471f
5.10-stable: c7bb96a37dd2095fcd6c65a59689004e63e4b872

[PATCH 04/04]
usb: dwc3: gadget: Disable gadget IRQ during pullup disable
UPSTREAM: 8212937305f84ef73ea81036dafb80c557583d4b
5.10-stable: 9e0677c2e39052ac20efae4474bb20614d9a88c9

Just "git cherry-pick" from upstream kernel seems to work fine.

Thanks!

> thanks,
>
> greg k-h

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

* Re: Add "usb: dwc3: Stop active transfers before halting the controller" to 5.4-stable
  2021-08-09 16:58   ` Sam Protsenko
@ 2021-08-10  7:27     ` Greg Kroah-Hartman
  2021-08-10 14:52       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 8+ messages in thread
From: Greg Kroah-Hartman @ 2021-08-10  7:27 UTC (permalink / raw)
  To: Sam Protsenko; +Cc: stable, Wesley Cheng

On Mon, Aug 09, 2021 at 07:58:24PM +0300, Sam Protsenko wrote:
> On Mon, 9 Aug 2021 at 11:53, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > On Fri, Aug 06, 2021 at 04:25:17PM +0300, Sam Protsenko wrote:
> > > Hi Greg,
> > >
> > > Suggest including next patch (available in linux-mainline) to
> > > 5.4-stable branch: commit ae7e86108b12 ("usb: dwc3: Stop active
> > > transfers before halting the controller"). It's also already present
> > > in 5.10 stable. Some fixes exist in 5.10-stable for that patch too.
> >
> > Can you provide a list of the fixes that also need to be backported?  I
> > do not want to take one patch and not all of the relevant ones.
> >
> 
> Sure. Here is the whole list:
> 
> [PATCH 01/04]
> usb: dwc3: Stop active transfers before halting the controller
> UPSTREAM: ae7e86108b12351028fa7e8796a59f9b2d9e1774
> 
> [PATCH 02/04]
> usb: dwc3: gadget: Restart DWC3 gadget when enabling pullup
> UPSTREAM: a1383b3537a7bea1c213baa7878ccc4ecf4413b5
> 5.10-stable: dd8363fbca508616811f8a94006b09c66c094107
> 
> [PATCH 03/04]
> usb: dwc3: gadget: Prevent EP queuing while stopping transfers
> UPSTREAM: f09ddcfcb8c569675066337adac2ac205113471f
> 5.10-stable: c7bb96a37dd2095fcd6c65a59689004e63e4b872

This patch did not apply cleanly :(

Can you send a working set of backported patches so that I know to get
this all fixed up correctly?

thanks,

greg k-h

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

* Re: Add "usb: dwc3: Stop active transfers before halting the controller" to 5.4-stable
  2021-08-10  7:27     ` Greg Kroah-Hartman
@ 2021-08-10 14:52       ` Greg Kroah-Hartman
  2021-08-10 14:58         ` Greg Kroah-Hartman
  0 siblings, 1 reply; 8+ messages in thread
From: Greg Kroah-Hartman @ 2021-08-10 14:52 UTC (permalink / raw)
  To: Sam Protsenko; +Cc: stable, Wesley Cheng

On Tue, Aug 10, 2021 at 09:27:13AM +0200, Greg Kroah-Hartman wrote:
> On Mon, Aug 09, 2021 at 07:58:24PM +0300, Sam Protsenko wrote:
> > On Mon, 9 Aug 2021 at 11:53, Greg Kroah-Hartman
> > <gregkh@linuxfoundation.org> wrote:
> > >
> > > On Fri, Aug 06, 2021 at 04:25:17PM +0300, Sam Protsenko wrote:
> > > > Hi Greg,
> > > >
> > > > Suggest including next patch (available in linux-mainline) to
> > > > 5.4-stable branch: commit ae7e86108b12 ("usb: dwc3: Stop active
> > > > transfers before halting the controller"). It's also already present
> > > > in 5.10 stable. Some fixes exist in 5.10-stable for that patch too.
> > >
> > > Can you provide a list of the fixes that also need to be backported?  I
> > > do not want to take one patch and not all of the relevant ones.
> > >
> > 
> > Sure. Here is the whole list:
> > 
> > [PATCH 01/04]
> > usb: dwc3: Stop active transfers before halting the controller
> > UPSTREAM: ae7e86108b12351028fa7e8796a59f9b2d9e1774
> > 
> > [PATCH 02/04]
> > usb: dwc3: gadget: Restart DWC3 gadget when enabling pullup
> > UPSTREAM: a1383b3537a7bea1c213baa7878ccc4ecf4413b5
> > 5.10-stable: dd8363fbca508616811f8a94006b09c66c094107
> > 
> > [PATCH 03/04]
> > usb: dwc3: gadget: Prevent EP queuing while stopping transfers
> > UPSTREAM: f09ddcfcb8c569675066337adac2ac205113471f
> > 5.10-stable: c7bb96a37dd2095fcd6c65a59689004e63e4b872
> 
> This patch did not apply cleanly :(
> 
> Can you send a working set of backported patches so that I know to get
> this all fixed up correctly?

Ok, I think I got this myself...

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

* Re: Add "usb: dwc3: Stop active transfers before halting the controller" to 5.4-stable
  2021-08-10 14:52       ` Greg Kroah-Hartman
@ 2021-08-10 14:58         ` Greg Kroah-Hartman
  2021-08-10 17:55           ` Sam Protsenko
  0 siblings, 1 reply; 8+ messages in thread
From: Greg Kroah-Hartman @ 2021-08-10 14:58 UTC (permalink / raw)
  To: Sam Protsenko; +Cc: stable, Wesley Cheng

On Tue, Aug 10, 2021 at 04:52:43PM +0200, Greg Kroah-Hartman wrote:
> On Tue, Aug 10, 2021 at 09:27:13AM +0200, Greg Kroah-Hartman wrote:
> > On Mon, Aug 09, 2021 at 07:58:24PM +0300, Sam Protsenko wrote:
> > > On Mon, 9 Aug 2021 at 11:53, Greg Kroah-Hartman
> > > <gregkh@linuxfoundation.org> wrote:
> > > >
> > > > On Fri, Aug 06, 2021 at 04:25:17PM +0300, Sam Protsenko wrote:
> > > > > Hi Greg,
> > > > >
> > > > > Suggest including next patch (available in linux-mainline) to
> > > > > 5.4-stable branch: commit ae7e86108b12 ("usb: dwc3: Stop active
> > > > > transfers before halting the controller"). It's also already present
> > > > > in 5.10 stable. Some fixes exist in 5.10-stable for that patch too.
> > > >
> > > > Can you provide a list of the fixes that also need to be backported?  I
> > > > do not want to take one patch and not all of the relevant ones.
> > > >
> > > 
> > > Sure. Here is the whole list:
> > > 
> > > [PATCH 01/04]
> > > usb: dwc3: Stop active transfers before halting the controller
> > > UPSTREAM: ae7e86108b12351028fa7e8796a59f9b2d9e1774
> > > 
> > > [PATCH 02/04]
> > > usb: dwc3: gadget: Restart DWC3 gadget when enabling pullup
> > > UPSTREAM: a1383b3537a7bea1c213baa7878ccc4ecf4413b5
> > > 5.10-stable: dd8363fbca508616811f8a94006b09c66c094107
> > > 
> > > [PATCH 03/04]
> > > usb: dwc3: gadget: Prevent EP queuing while stopping transfers
> > > UPSTREAM: f09ddcfcb8c569675066337adac2ac205113471f
> > > 5.10-stable: c7bb96a37dd2095fcd6c65a59689004e63e4b872
> > 
> > This patch did not apply cleanly :(
> > 
> > Can you send a working set of backported patches so that I know to get
> > this all fixed up correctly?
> 
> Ok, I think I got this myself...

Ick, no, the 4th patch had problems.  I need a backported series,
thanks!

greg k-h

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

* Re: Add "usb: dwc3: Stop active transfers before halting the controller" to 5.4-stable
  2021-08-10 14:58         ` Greg Kroah-Hartman
@ 2021-08-10 17:55           ` Sam Protsenko
  2021-08-12 17:19             ` Sam Protsenko
  0 siblings, 1 reply; 8+ messages in thread
From: Sam Protsenko @ 2021-08-10 17:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: stable, Wesley Cheng

On Tue, 10 Aug 2021 at 17:58, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Tue, Aug 10, 2021 at 04:52:43PM +0200, Greg Kroah-Hartman wrote:
> > On Tue, Aug 10, 2021 at 09:27:13AM +0200, Greg Kroah-Hartman wrote:
> > > On Mon, Aug 09, 2021 at 07:58:24PM +0300, Sam Protsenko wrote:
> > > > On Mon, 9 Aug 2021 at 11:53, Greg Kroah-Hartman
> > > > <gregkh@linuxfoundation.org> wrote:
> > > > >
> > > > > On Fri, Aug 06, 2021 at 04:25:17PM +0300, Sam Protsenko wrote:
> > > > > > Hi Greg,
> > > > > >
> > > > > > Suggest including next patch (available in linux-mainline) to
> > > > > > 5.4-stable branch: commit ae7e86108b12 ("usb: dwc3: Stop active
> > > > > > transfers before halting the controller"). It's also already present
> > > > > > in 5.10 stable. Some fixes exist in 5.10-stable for that patch too.
> > > > >
> > > > > Can you provide a list of the fixes that also need to be backported?  I
> > > > > do not want to take one patch and not all of the relevant ones.
> > > > >
> > > >
> > > > Sure. Here is the whole list:
> > > >
> > > > [PATCH 01/04]
> > > > usb: dwc3: Stop active transfers before halting the controller
> > > > UPSTREAM: ae7e86108b12351028fa7e8796a59f9b2d9e1774
> > > >
> > > > [PATCH 02/04]
> > > > usb: dwc3: gadget: Restart DWC3 gadget when enabling pullup
> > > > UPSTREAM: a1383b3537a7bea1c213baa7878ccc4ecf4413b5
> > > > 5.10-stable: dd8363fbca508616811f8a94006b09c66c094107
> > > >
> > > > [PATCH 03/04]
> > > > usb: dwc3: gadget: Prevent EP queuing while stopping transfers
> > > > UPSTREAM: f09ddcfcb8c569675066337adac2ac205113471f
> > > > 5.10-stable: c7bb96a37dd2095fcd6c65a59689004e63e4b872
> > >
> > > This patch did not apply cleanly :(
> > >
> > > Can you send a working set of backported patches so that I know to get
> > > this all fixed up correctly?
> >
> > Ok, I think I got this myself...
>
> Ick, no, the 4th patch had problems.  I need a backported series,
> thanks!
>

Sure, will do shortly. As I remember, kdiff3 resolved those conflicts
automagically for me (correctly).

> greg k-h

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

* Re: Add "usb: dwc3: Stop active transfers before halting the controller" to 5.4-stable
  2021-08-10 17:55           ` Sam Protsenko
@ 2021-08-12 17:19             ` Sam Protsenko
  0 siblings, 0 replies; 8+ messages in thread
From: Sam Protsenko @ 2021-08-12 17:19 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: stable, Wesley Cheng

On Tue, 10 Aug 2021 at 20:55, Sam Protsenko <semen.protsenko@linaro.org> wrote:
>
> On Tue, 10 Aug 2021 at 17:58, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > On Tue, Aug 10, 2021 at 04:52:43PM +0200, Greg Kroah-Hartman wrote:
> > > On Tue, Aug 10, 2021 at 09:27:13AM +0200, Greg Kroah-Hartman wrote:
> > > > On Mon, Aug 09, 2021 at 07:58:24PM +0300, Sam Protsenko wrote:
> > > > > On Mon, 9 Aug 2021 at 11:53, Greg Kroah-Hartman
> > > > > <gregkh@linuxfoundation.org> wrote:
> > > > > >
> > > > > > On Fri, Aug 06, 2021 at 04:25:17PM +0300, Sam Protsenko wrote:
> > > > > > > Hi Greg,
> > > > > > >
> > > > > > > Suggest including next patch (available in linux-mainline) to
> > > > > > > 5.4-stable branch: commit ae7e86108b12 ("usb: dwc3: Stop active
> > > > > > > transfers before halting the controller"). It's also already present
> > > > > > > in 5.10 stable. Some fixes exist in 5.10-stable for that patch too.
> > > > > >
> > > > > > Can you provide a list of the fixes that also need to be backported?  I
> > > > > > do not want to take one patch and not all of the relevant ones.
> > > > > >
> > > > >
> > > > > Sure. Here is the whole list:
> > > > >
> > > > > [PATCH 01/04]
> > > > > usb: dwc3: Stop active transfers before halting the controller
> > > > > UPSTREAM: ae7e86108b12351028fa7e8796a59f9b2d9e1774
> > > > >
> > > > > [PATCH 02/04]
> > > > > usb: dwc3: gadget: Restart DWC3 gadget when enabling pullup
> > > > > UPSTREAM: a1383b3537a7bea1c213baa7878ccc4ecf4413b5
> > > > > 5.10-stable: dd8363fbca508616811f8a94006b09c66c094107
> > > > >
> > > > > [PATCH 03/04]
> > > > > usb: dwc3: gadget: Prevent EP queuing while stopping transfers
> > > > > UPSTREAM: f09ddcfcb8c569675066337adac2ac205113471f
> > > > > 5.10-stable: c7bb96a37dd2095fcd6c65a59689004e63e4b872
> > > >
> > > > This patch did not apply cleanly :(
> > > >
> > > > Can you send a working set of backported patches so that I know to get
> > > > this all fixed up correctly?
> > >
> > > Ok, I think I got this myself...
> >
> > Ick, no, the 4th patch had problems.  I need a backported series,
> > thanks!
> >
>
> Sure, will do shortly. As I remember, kdiff3 resolved those conflicts
> automagically for me (correctly).
>

Hi Greg,

Just sent those in a patch series: "[PATCH 5.4 0/7] usb: dwc3: Fix DRD
role switch". Found more fixes and dependencies, now it seems to be
complete, and applies nicely.

Thanks!

> > greg k-h

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

end of thread, other threads:[~2021-08-12 17:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-06 13:25 Add "usb: dwc3: Stop active transfers before halting the controller" to 5.4-stable Sam Protsenko
2021-08-09  8:53 ` Greg Kroah-Hartman
2021-08-09 16:58   ` Sam Protsenko
2021-08-10  7:27     ` Greg Kroah-Hartman
2021-08-10 14:52       ` Greg Kroah-Hartman
2021-08-10 14:58         ` Greg Kroah-Hartman
2021-08-10 17:55           ` Sam Protsenko
2021-08-12 17:19             ` Sam Protsenko

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