All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* dwc3 38100000.usb: No resource for ep1in
@ 2022-12-07 14:27 Dan Scally
  2022-12-07 16:15 ` Greg KH
  2022-12-08  6:11 ` Felipe Balbi
  0 siblings, 2 replies; 7+ messages in thread
From: Dan Scally @ 2022-12-07 14:27 UTC (permalink / raw
  To: Felipe Balbi; +Cc: Laurent Pinchart, Kieran Bingham, linux-usb

[-- Attachment #1: Type: text/plain, Size: 4120 bytes --]

Hello Felipe


I'm having an issue with DWC3 which I'm hoping you might be able to shed 
light on. I'm using the UVC gadget function to stream video from an 
imx8mp platform, which works just fine. Once I have stopped streaming 
however and after some time has passed (the exact duration seems to vary 
quite a lot from 1-2 minutes to 15+ mins) I get a kernel warning like so:


[  737.996842] configfs-gadget gadget.0: uvc: uvc_function_disable()
[  738.519582] configfs-gadget gadget.0: uvc: uvc_function_set_alt(0, 0)
[  738.526060] configfs-gadget gadget.0: uvc: reset UVC interrupt endpoint
[  738.532713] ------------[ cut here ]------------
[  738.537683] dwc3 38100000.usb: No resource for ep1in
[  738.542712] WARNING: CPU: 0 PID: 645 at drivers/usb/dwc3/gadget.c:384 
dwc3_send_gadget_ep_cmd+0x478/0x580
[  738.552314] Modules linked in:
[  738.555402] CPU: 0 PID: 645 Comm: irq/208-dwc3 Not tainted 
5.19.0-00034-gf017ce943b32 #82
[  738.563601] Hardware name: Polyhex Debix Model A i.MX8MPlus board (DT)
[  738.570145] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS 
BTYPE=--)
[  738.577128] pc : dwc3_send_gadget_ep_cmd+0x478/0x580
[  738.582116] lr : dwc3_send_gadget_ep_cmd+0x478/0x580
[  738.587102] sp : ffffffc00c3c39e0
[  738.590433] x29: ffffffc00c3c39e0 x28: 0000000000031006 x27: 
00000000ffffffea
[  738.597618] x26: 0000000000000006 x25: ffffff8004f32880 x24: 
ffffffc00c3c3abc
[  738.604801] x23: 0000000000000406 x22: ffffffffffff3f00 x21: 
ffffffffffff3f0c
[  738.611984] x20: ffffff8003872600 x19: 0000000000000001 x18: 
ffffffffffffffff
[  738.619166] x17: 000000000000001c x16: 00000000c99c42a5 x15: 
ffffffc08c3c36b7
[  738.626347] x14: 0000000000000000 x13: 6e6931706520726f x12: 
6620656372756f73
[  738.633528] x11: 00000000000c02a7 x10: ffffffc009af1ac0 x9 : 
ffffffc0080c42bc
[  738.640710] x8 : 00000000ffffefff x7 : ffffffc009af1ac0 x6 : 
0000000000000000
[  738.647891] x5 : ffffff807fb2eb08 x4 : 0000000000000000 x3 : 
0000000000000027
[  738.655072] x2 : 0000000000000000 x1 : 0000000000000000 x0 : 
ffffff80158a8000
[  738.662255] Call trace:
[  738.664721]  dwc3_send_gadget_ep_cmd+0x478/0x580
[  738.669362]  __dwc3_gadget_ep_enable+0x4f4/0x714
[  738.674004]  dwc3_gadget_ep_enable+0x6c/0x15c
[  738.678382]  usb_ep_enable+0x4c/0x1bc
[  738.682067]  uvc_function_set_alt+0xcc/0x264
[  738.686362]  composite_setup+0x7ec/0x195c
[  738.690395]  configfs_composite_setup+0x90/0xc0
[  738.694950]  dwc3_ep0_interrupt+0x834/0x9e0
[  738.699156]  dwc3_thread_interrupt+0x994/0xd70
[  738.703624]  irq_thread_fn+0x38/0xa4
[  738.707221]  irq_thread+0x184/0x230
[  738.710733]  kthread+0x118/0x120
[  738.713981]  ret_from_fork+0x10/0x20
[  738.717582] irq event stamp: 41021
[  738.720998] hardirqs last  enabled at (41019): [<ffffffc008082858>] 
finish_task_switch.isra.0+0xe8/0x264
[  738.730501] hardirqs last disabled at (41021): [<ffffffc008f15058>] 
_raw_spin_lock_irqsave+0xc4/0x170
[  738.739747] softirqs last  enabled at (41014): [<ffffffc008a25b90>] 
dwc3_thread_interrupt+0x1c0/0xd70
[  738.748988] softirqs last disabled at (41020): [<ffffffc008a259dc>] 
dwc3_thread_interrupt+0xc/0xd70


ep1in in this instance refers to a Status Interrupt Endpoint under the 
UVC specification, which is being "reset" by uvc_function_set_alt() 
against the VideoControl interface (meaning a call to usb_ep_disable() 
followed by usb_ep_enable(), see [1]). The isochronous endpoint that 
data is streamed across is treated similarly in the same function (when 
called for the VideoStreaming interface) and never seems to show the 
same warning and as far as I can tell the operation ought to be safe, so 
I'm struggling to see anything in the f_uvc code that's misbehaving to 
cause the problem. I wondered if you might be able to take a look at the 
trace and regdump of the dwc3 (which was taken immediately after the 
warning is thrown) and see if that sheds any light on what might be 
going on?


Thanks in advance

Dan


[1] 
https://elixir.bootlin.com/linux/latest/source/drivers/usb/gadget/function/f_uvc.c#L293


[-- Attachment #2: dwc3.tar.gz --]
[-- Type: application/gzip, Size: 156574 bytes --]

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

* Re: dwc3 38100000.usb: No resource for ep1in
  2022-12-07 14:27 dwc3 38100000.usb: No resource for ep1in Dan Scally
@ 2022-12-07 16:15 ` Greg KH
  2022-12-08  6:11 ` Felipe Balbi
  1 sibling, 0 replies; 7+ messages in thread
From: Greg KH @ 2022-12-07 16:15 UTC (permalink / raw
  To: Dan Scally; +Cc: Felipe Balbi, Laurent Pinchart, Kieran Bingham, linux-usb

On Wed, Dec 07, 2022 at 02:27:32PM +0000, Dan Scally wrote:
> Hello Felipe
> 
> 
> I'm having an issue with DWC3 which I'm hoping you might be able to shed
> light on.

Why not ask the _current_ dwc3 maintainer?

(hint, check the latest MAINTAINERS file...)

thanks,

greg k-h

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

* Re: dwc3 38100000.usb: No resource for ep1in
  2022-12-07 14:27 dwc3 38100000.usb: No resource for ep1in Dan Scally
  2022-12-07 16:15 ` Greg KH
@ 2022-12-08  6:11 ` Felipe Balbi
  2022-12-08  7:46   ` Dan Scally
  1 sibling, 1 reply; 7+ messages in thread
From: Felipe Balbi @ 2022-12-08  6:11 UTC (permalink / raw
  To: Dan Scally; +Cc: Laurent Pinchart, Kieran Bingham, linux-usb, Thinh Nguyen

[-- Attachment #1: Type: text/plain, Size: 4556 bytes --]


Hi,

Dan Scally <dan.scally@ideasonboard.com> writes:
> I'm having an issue with DWC3 which I'm hoping you might be able to shed 
> light on. I'm using the UVC gadget function to stream video from an 
> imx8mp platform, which works just fine. Once I have stopped streaming 
> however and after some time has passed (the exact duration seems to vary 
> quite a lot from 1-2 minutes to 15+ mins) I get a kernel warning like so:

As Greg mentioned, please add Thinh, the new maintainer, to the loop.

> [  737.996842] configfs-gadget gadget.0: uvc: uvc_function_disable()
> [  738.519582] configfs-gadget gadget.0: uvc: uvc_function_set_alt(0, 0)
> [  738.526060] configfs-gadget gadget.0: uvc: reset UVC interrupt endpoint
> [  738.532713] ------------[ cut here ]------------
> [  738.537683] dwc3 38100000.usb: No resource for ep1in
> [  738.542712] WARNING: CPU: 0 PID: 645 at drivers/usb/dwc3/gadget.c:384 
> dwc3_send_gadget_ep_cmd+0x478/0x580
> [  738.552314] Modules linked in:
> [  738.555402] CPU: 0 PID: 645 Comm: irq/208-dwc3 Not tainted 
> 5.19.0-00034-gf017ce943b32 #82
> [  738.563601] Hardware name: Polyhex Debix Model A i.MX8MPlus board (DT)
> [  738.570145] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS 
> BTYPE=--)
> [  738.577128] pc : dwc3_send_gadget_ep_cmd+0x478/0x580
> [  738.582116] lr : dwc3_send_gadget_ep_cmd+0x478/0x580
> [  738.587102] sp : ffffffc00c3c39e0
> [  738.590433] x29: ffffffc00c3c39e0 x28: 0000000000031006 x27: 
> 00000000ffffffea
> [  738.597618] x26: 0000000000000006 x25: ffffff8004f32880 x24: 
> ffffffc00c3c3abc
> [  738.604801] x23: 0000000000000406 x22: ffffffffffff3f00 x21: 
> ffffffffffff3f0c
> [  738.611984] x20: ffffff8003872600 x19: 0000000000000001 x18: 
> ffffffffffffffff
> [  738.619166] x17: 000000000000001c x16: 00000000c99c42a5 x15: 
> ffffffc08c3c36b7
> [  738.626347] x14: 0000000000000000 x13: 6e6931706520726f x12: 
> 6620656372756f73
> [  738.633528] x11: 00000000000c02a7 x10: ffffffc009af1ac0 x9 : 
> ffffffc0080c42bc
> [  738.640710] x8 : 00000000ffffefff x7 : ffffffc009af1ac0 x6 : 
> 0000000000000000
> [  738.647891] x5 : ffffff807fb2eb08 x4 : 0000000000000000 x3 : 
> 0000000000000027
> [  738.655072] x2 : 0000000000000000 x1 : 0000000000000000 x0 : 
> ffffff80158a8000
> [  738.662255] Call trace:
> [  738.664721]  dwc3_send_gadget_ep_cmd+0x478/0x580
> [  738.669362]  __dwc3_gadget_ep_enable+0x4f4/0x714
> [  738.674004]  dwc3_gadget_ep_enable+0x6c/0x15c
> [  738.678382]  usb_ep_enable+0x4c/0x1bc
> [  738.682067]  uvc_function_set_alt+0xcc/0x264
> [  738.686362]  composite_setup+0x7ec/0x195c
> [  738.690395]  configfs_composite_setup+0x90/0xc0
> [  738.694950]  dwc3_ep0_interrupt+0x834/0x9e0
> [  738.699156]  dwc3_thread_interrupt+0x994/0xd70
> [  738.703624]  irq_thread_fn+0x38/0xa4
> [  738.707221]  irq_thread+0x184/0x230
> [  738.710733]  kthread+0x118/0x120
> [  738.713981]  ret_from_fork+0x10/0x20
> [  738.717582] irq event stamp: 41021
> [  738.720998] hardirqs last  enabled at (41019): [<ffffffc008082858>] 
> finish_task_switch.isra.0+0xe8/0x264
> [  738.730501] hardirqs last disabled at (41021): [<ffffffc008f15058>] 
> _raw_spin_lock_irqsave+0xc4/0x170
> [  738.739747] softirqs last  enabled at (41014): [<ffffffc008a25b90>] 
> dwc3_thread_interrupt+0x1c0/0xd70
> [  738.748988] softirqs last disabled at (41020): [<ffffffc008a259dc>] 
> dwc3_thread_interrupt+0xc/0xd70
>
>
> ep1in in this instance refers to a Status Interrupt Endpoint under the 
> UVC specification, which is being "reset" by uvc_function_set_alt() 
> against the VideoControl interface (meaning a call to usb_ep_disable() 
> followed by usb_ep_enable(), see [1]). The isochronous endpoint that 
> data is streamed across is treated similarly in the same function (when 
> called for the VideoStreaming interface) and never seems to show the 
> same warning and as far as I can tell the operation ought to be safe, so 
> I'm struggling to see anything in the f_uvc code that's misbehaving to 
> cause the problem. I wondered if you might be able to take a look at the 
> trace and regdump of the dwc3 (which was taken immediately after the 
> warning is thrown) and see if that sheds any light on what might be 
> going on?

Best way forward is to collect dwc3 trace points, so we can see what the
HW is doing. For details, see [1].

[1] https://kernel.org/doc/html/latest/driver-api/usb/dwc3.html#reporting-bugs

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 857 bytes --]

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

* Re: dwc3 38100000.usb: No resource for ep1in
  2022-12-08  6:11 ` Felipe Balbi
@ 2022-12-08  7:46   ` Dan Scally
  2022-12-08 23:18     ` Thinh Nguyen
  2022-12-11 15:36     ` Felipe Balbi
  0 siblings, 2 replies; 7+ messages in thread
From: Dan Scally @ 2022-12-08  7:46 UTC (permalink / raw
  To: Felipe Balbi
  Cc: Laurent Pinchart, Kieran Bingham, linux-usb, Thinh Nguyen,
	Greg Kroah-Hartman

[-- Attachment #1: Type: text/plain, Size: 4780 bytes --]

Good morning

On 08/12/2022 06:11, Felipe Balbi wrote:
> Hi,
>
> Dan Scally <dan.scally@ideasonboard.com> writes:
>> I'm having an issue with DWC3 which I'm hoping you might be able to shed
>> light on. I'm using the UVC gadget function to stream video from an
>> imx8mp platform, which works just fine. Once I have stopped streaming
>> however and after some time has passed (the exact duration seems to vary
>> quite a lot from 1-2 minutes to 15+ mins) I get a kernel warning like so:
> As Greg mentioned, please add Thinh, the new maintainer, to the loop.


Apologies to both of you; for some reason I thought you had taken over 
from Thinh rather than the other way around. Thanks for the heads up Greg.

>
>> [  737.996842] configfs-gadget gadget.0: uvc: uvc_function_disable()
>> [  738.519582] configfs-gadget gadget.0: uvc: uvc_function_set_alt(0, 0)
>> [  738.526060] configfs-gadget gadget.0: uvc: reset UVC interrupt endpoint
>> [  738.532713] ------------[ cut here ]------------
>> [  738.537683] dwc3 38100000.usb: No resource for ep1in
>> [  738.542712] WARNING: CPU: 0 PID: 645 at drivers/usb/dwc3/gadget.c:384
>> dwc3_send_gadget_ep_cmd+0x478/0x580
>> [  738.552314] Modules linked in:
>> [  738.555402] CPU: 0 PID: 645 Comm: irq/208-dwc3 Not tainted
>> 5.19.0-00034-gf017ce943b32 #82
>> [  738.563601] Hardware name: Polyhex Debix Model A i.MX8MPlus board (DT)
>> [  738.570145] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS
>> BTYPE=--)
>> [  738.577128] pc : dwc3_send_gadget_ep_cmd+0x478/0x580
>> [  738.582116] lr : dwc3_send_gadget_ep_cmd+0x478/0x580
>> [  738.587102] sp : ffffffc00c3c39e0
>> [  738.590433] x29: ffffffc00c3c39e0 x28: 0000000000031006 x27:
>> 00000000ffffffea
>> [  738.597618] x26: 0000000000000006 x25: ffffff8004f32880 x24:
>> ffffffc00c3c3abc
>> [  738.604801] x23: 0000000000000406 x22: ffffffffffff3f00 x21:
>> ffffffffffff3f0c
>> [  738.611984] x20: ffffff8003872600 x19: 0000000000000001 x18:
>> ffffffffffffffff
>> [  738.619166] x17: 000000000000001c x16: 00000000c99c42a5 x15:
>> ffffffc08c3c36b7
>> [  738.626347] x14: 0000000000000000 x13: 6e6931706520726f x12:
>> 6620656372756f73
>> [  738.633528] x11: 00000000000c02a7 x10: ffffffc009af1ac0 x9 :
>> ffffffc0080c42bc
>> [  738.640710] x8 : 00000000ffffefff x7 : ffffffc009af1ac0 x6 :
>> 0000000000000000
>> [  738.647891] x5 : ffffff807fb2eb08 x4 : 0000000000000000 x3 :
>> 0000000000000027
>> [  738.655072] x2 : 0000000000000000 x1 : 0000000000000000 x0 :
>> ffffff80158a8000
>> [  738.662255] Call trace:
>> [  738.664721]  dwc3_send_gadget_ep_cmd+0x478/0x580
>> [  738.669362]  __dwc3_gadget_ep_enable+0x4f4/0x714
>> [  738.674004]  dwc3_gadget_ep_enable+0x6c/0x15c
>> [  738.678382]  usb_ep_enable+0x4c/0x1bc
>> [  738.682067]  uvc_function_set_alt+0xcc/0x264
>> [  738.686362]  composite_setup+0x7ec/0x195c
>> [  738.690395]  configfs_composite_setup+0x90/0xc0
>> [  738.694950]  dwc3_ep0_interrupt+0x834/0x9e0
>> [  738.699156]  dwc3_thread_interrupt+0x994/0xd70
>> [  738.703624]  irq_thread_fn+0x38/0xa4
>> [  738.707221]  irq_thread+0x184/0x230
>> [  738.710733]  kthread+0x118/0x120
>> [  738.713981]  ret_from_fork+0x10/0x20
>> [  738.717582] irq event stamp: 41021
>> [  738.720998] hardirqs last  enabled at (41019): [<ffffffc008082858>]
>> finish_task_switch.isra.0+0xe8/0x264
>> [  738.730501] hardirqs last disabled at (41021): [<ffffffc008f15058>]
>> _raw_spin_lock_irqsave+0xc4/0x170
>> [  738.739747] softirqs last  enabled at (41014): [<ffffffc008a25b90>]
>> dwc3_thread_interrupt+0x1c0/0xd70
>> [  738.748988] softirqs last disabled at (41020): [<ffffffc008a259dc>]
>> dwc3_thread_interrupt+0xc/0xd70
>>
>>
>> ep1in in this instance refers to a Status Interrupt Endpoint under the
>> UVC specification, which is being "reset" by uvc_function_set_alt()
>> against the VideoControl interface (meaning a call to usb_ep_disable()
>> followed by usb_ep_enable(), see [1]). The isochronous endpoint that
>> data is streamed across is treated similarly in the same function (when
>> called for the VideoStreaming interface) and never seems to show the
>> same warning and as far as I can tell the operation ought to be safe, so
>> I'm struggling to see anything in the f_uvc code that's misbehaving to
>> cause the problem. I wondered if you might be able to take a look at the
>> trace and regdump of the dwc3 (which was taken immediately after the
>> warning is thrown) and see if that sheds any light on what might be
>> going on?
> Best way forward is to collect dwc3 trace points, so we can see what the
> HW is doing. For details, see [1].
>
> [1] https://kernel.org/doc/html/latest/driver-api/usb/dwc3.html#reporting-bugs


Both the trace and regdump should be in the attached .tar.gz

>

[-- Attachment #2: dwc3.tar.gz --]
[-- Type: application/gzip, Size: 156574 bytes --]

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

* Re: dwc3 38100000.usb: No resource for ep1in
  2022-12-08  7:46   ` Dan Scally
@ 2022-12-08 23:18     ` Thinh Nguyen
  2022-12-11 15:36     ` Felipe Balbi
  1 sibling, 0 replies; 7+ messages in thread
From: Thinh Nguyen @ 2022-12-08 23:18 UTC (permalink / raw
  To: Dan Scally
  Cc: Felipe Balbi, Laurent Pinchart, Kieran Bingham,
	linux-usb@vger.kernel.org, Thinh Nguyen, Greg Kroah-Hartman

Hi Dan,

On Thu, Dec 08, 2022, Dan Scally wrote:
> Good morning
> 
> On 08/12/2022 06:11, Felipe Balbi wrote:
> > Hi,
> > 
> > Dan Scally <dan.scally@ideasonboard.com> writes:
> > > I'm having an issue with DWC3 which I'm hoping you might be able to shed
> > > light on. I'm using the UVC gadget function to stream video from an
> > > imx8mp platform, which works just fine. Once I have stopped streaming
> > > however and after some time has passed (the exact duration seems to vary
> > > quite a lot from 1-2 minutes to 15+ mins) I get a kernel warning like so:
> > As Greg mentioned, please add Thinh, the new maintainer, to the loop.
> 
> 
> Apologies to both of you; for some reason I thought you had taken over from
> Thinh rather than the other way around. Thanks for the heads up Greg.
> 
> > 
> > > [  737.996842] configfs-gadget gadget.0: uvc: uvc_function_disable()
> > > [  738.519582] configfs-gadget gadget.0: uvc: uvc_function_set_alt(0, 0)
> > > [  738.526060] configfs-gadget gadget.0: uvc: reset UVC interrupt endpoint
> > > [  738.532713] ------------[ cut here ]------------
> > > [  738.537683] dwc3 38100000.usb: No resource for ep1in
> > > [  738.542712] WARNING: CPU: 0 PID: 645 at drivers/usb/dwc3/gadget.c:384
> > > dwc3_send_gadget_ep_cmd+0x478/0x580
> > > [  738.552314] Modules linked in:
> > > [  738.555402] CPU: 0 PID: 645 Comm: irq/208-dwc3 Not tainted
> > > 5.19.0-00034-gf017ce943b32 #82
> > > [  738.563601] Hardware name: Polyhex Debix Model A i.MX8MPlus board (DT)
> > > [  738.570145] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS
> > > BTYPE=--)
> > > [  738.577128] pc : dwc3_send_gadget_ep_cmd+0x478/0x580
> > > [  738.582116] lr : dwc3_send_gadget_ep_cmd+0x478/0x580
> > > [  738.587102] sp : ffffffc00c3c39e0
> > > [  738.590433] x29: ffffffc00c3c39e0 x28: 0000000000031006 x27:
> > > 00000000ffffffea
> > > [  738.597618] x26: 0000000000000006 x25: ffffff8004f32880 x24:
> > > ffffffc00c3c3abc
> > > [  738.604801] x23: 0000000000000406 x22: ffffffffffff3f00 x21:
> > > ffffffffffff3f0c
> > > [  738.611984] x20: ffffff8003872600 x19: 0000000000000001 x18:
> > > ffffffffffffffff
> > > [  738.619166] x17: 000000000000001c x16: 00000000c99c42a5 x15:
> > > ffffffc08c3c36b7
> > > [  738.626347] x14: 0000000000000000 x13: 6e6931706520726f x12:
> > > 6620656372756f73
> > > [  738.633528] x11: 00000000000c02a7 x10: ffffffc009af1ac0 x9 :
> > > ffffffc0080c42bc
> > > [  738.640710] x8 : 00000000ffffefff x7 : ffffffc009af1ac0 x6 :
> > > 0000000000000000
> > > [  738.647891] x5 : ffffff807fb2eb08 x4 : 0000000000000000 x3 :
> > > 0000000000000027
> > > [  738.655072] x2 : 0000000000000000 x1 : 0000000000000000 x0 :
> > > ffffff80158a8000
> > > [  738.662255] Call trace:
> > > [  738.664721]  dwc3_send_gadget_ep_cmd+0x478/0x580
> > > [  738.669362]  __dwc3_gadget_ep_enable+0x4f4/0x714
> > > [  738.674004]  dwc3_gadget_ep_enable+0x6c/0x15c
> > > [  738.678382]  usb_ep_enable+0x4c/0x1bc
> > > [  738.682067]  uvc_function_set_alt+0xcc/0x264
> > > [  738.686362]  composite_setup+0x7ec/0x195c
> > > [  738.690395]  configfs_composite_setup+0x90/0xc0
> > > [  738.694950]  dwc3_ep0_interrupt+0x834/0x9e0
> > > [  738.699156]  dwc3_thread_interrupt+0x994/0xd70
> > > [  738.703624]  irq_thread_fn+0x38/0xa4
> > > [  738.707221]  irq_thread+0x184/0x230
> > > [  738.710733]  kthread+0x118/0x120
> > > [  738.713981]  ret_from_fork+0x10/0x20
> > > [  738.717582] irq event stamp: 41021
> > > [  738.720998] hardirqs last  enabled at (41019): [<ffffffc008082858>]
> > > finish_task_switch.isra.0+0xe8/0x264
> > > [  738.730501] hardirqs last disabled at (41021): [<ffffffc008f15058>]
> > > _raw_spin_lock_irqsave+0xc4/0x170
> > > [  738.739747] softirqs last  enabled at (41014): [<ffffffc008a25b90>]
> > > dwc3_thread_interrupt+0x1c0/0xd70
> > > [  738.748988] softirqs last disabled at (41020): [<ffffffc008a259dc>]
> > > dwc3_thread_interrupt+0xc/0xd70
> > > 
> > > 
> > > ep1in in this instance refers to a Status Interrupt Endpoint under the
> > > UVC specification, which is being "reset" by uvc_function_set_alt()
> > > against the VideoControl interface (meaning a call to usb_ep_disable()
> > > followed by usb_ep_enable(), see [1]). The isochronous endpoint that
> > > data is streamed across is treated similarly in the same function (when
> > > called for the VideoStreaming interface) and never seems to show the
> > > same warning and as far as I can tell the operation ought to be safe, so
> > > I'm struggling to see anything in the f_uvc code that's misbehaving to
> > > cause the problem. I wondered if you might be able to take a look at the
> > > trace and regdump of the dwc3 (which was taken immediately after the
> > > warning is thrown) and see if that sheds any light on what might be
> > > going on?
> > Best way forward is to collect dwc3 trace points, so we can see what the
> > HW is doing. For details, see [1].
> > 
> > [1] https://urldefense.com/v3/__https://kernel.org/doc/html/latest/driver-api/usb/dwc3.html*reporting-bugs__;Iw!!A4F2R9G_pg!Zb5Cx7r3McJ2FCbH_oK14MqINrzor9SihvyA9qFxrlmzU-d_VcBhZYs2jTpWMNE8oxhIH8PMIdk0Nhqj8xBEmkEwe9H6$
> 
> 
> Both the trace and regdump should be in the attached .tar.gz
> 
> > 

Looks like we're missing the check to ignore delay End Transfer.

Can you try this to see if it fixes your issue?

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index ebc0e147cc71..65500246323b 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2008,6 +2008,7 @@ static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool int
 	else if (!ret)
 		dep->flags |= DWC3_EP_END_TRANSFER_PENDING;
 
+	dep->flags &= ~DWC3_EP_DELAY_STOP;
 	return ret;
 }
 
@@ -4279,8 +4280,10 @@ void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force,
 	    dwc->hiber_state != DWC3_HIBER_ENTERING_DISCONNECTED)
 		return;
 
+	if (interrupt && (dep->flags & DWC3_EP_DELAY_STOP))
+		return;
+
 	if (!(dep->flags & DWC3_EP_TRANSFER_STARTED) ||
-	    (dep->flags & DWC3_EP_DELAY_STOP) ||
 	    (dep->flags & DWC3_EP_END_TRANSFER_PENDING))
 		return;
 

Thanks,
Thinh

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

* Re: dwc3 38100000.usb: No resource for ep1in
  2022-12-08  7:46   ` Dan Scally
  2022-12-08 23:18     ` Thinh Nguyen
@ 2022-12-11 15:36     ` Felipe Balbi
  2022-12-12 17:51       ` Thinh Nguyen
  1 sibling, 1 reply; 7+ messages in thread
From: Felipe Balbi @ 2022-12-11 15:36 UTC (permalink / raw
  To: Dan Scally, Thinh Nguyen
  Cc: Laurent Pinchart, Kieran Bingham, linux-usb, Greg Kroah-Hartman


Hi,

Dan Scally <dan.scally@ideasonboard.com> writes:
> Good morning
>
> On 08/12/2022 06:11, Felipe Balbi wrote:
>> Hi,
>>
>> Dan Scally <dan.scally@ideasonboard.com> writes:
>>> I'm having an issue with DWC3 which I'm hoping you might be able to shed
>>> light on. I'm using the UVC gadget function to stream video from an
>>> imx8mp platform, which works just fine. Once I have stopped streaming
>>> however and after some time has passed (the exact duration seems to vary
>>> quite a lot from 1-2 minutes to 15+ mins) I get a kernel warning like so:
>> As Greg mentioned, please add Thinh, the new maintainer, to the loop.
>
>
> Apologies to both of you; for some reason I thought you had taken over 
> from Thinh rather than the other way around. Thanks for the heads up Greg.

no worries, it happens.

>> [1] https://kernel.org/doc/html/latest/driver-api/usb/dwc3.html#reporting-bugs
>
>
> Both the trace and regdump should be in the attached .tar.gz

Can you confirm which kernel version you're using?

It looks like there's a missing End Transfer on ep1in:

>   uvc-gadget-696 [000] .....  2646.761444: dwc3_gadget_ep_cmd: ep1in: cmd 'Set Endpoint Transfer Resource' [402] params 00000001 00000000 00000000 --> status: Successful
> irq/208-dwc3-689 [000] D..3.  2647.237436: dwc3_gadget_ep_cmd: ep1in: cmd 'Set Endpoint Configuration' [401] params 00020086 06070200 00000000 --> status: Successful
> irq/208-dwc3-689 [000] D..3.  2647.237457: dwc3_gadget_ep_cmd: ep1in: cmd 'Start Transfer' [406] params 00000000 45751000 00000000 --> status: Successful
> irq/208-dwc3-689 [000] D..3.  2647.237467: dwc3_gadget_ep_enable: ep1in: mps 16/1024 streams 16 burst 0 ring 0/0 flags E:swBp:<
>   uvc-gadget-696 [003] d..1.  2648.484042: dwc3_gadget_ep_cmd: ep1in: cmd 'End Transfer' [30c08] params 00000000 00000000 00000000 --> status: Successful
>   uvc-gadget-696 [003] d..3.  2648.490356: dwc3_gadget_ep_disable: ep1in: mps 16/1024 streams 16 burst 0 ring 0/0 flags E:swbp:<
>   uvc-gadget-698 [001] .....  2650.645667: dwc3_gadget_ep_cmd: ep1in: cmd 'Set Endpoint Transfer Resource' [402] params 00000001 00000000 00000000 --> status: Successful
> irq/208-dwc3-689 [000] D..3.  2651.141040: dwc3_gadget_ep_cmd: ep1in: cmd 'Set Endpoint Configuration' [401] params 00020086 06070200 00000000 --> status: Successful
> irq/208-dwc3-689 [000] D..3.  2651.141061: dwc3_gadget_ep_cmd: ep1in: cmd 'Start Transfer' [406] params 00000000 45751000 00000000 --> status: Successful
> irq/208-dwc3-689 [000] D..3.  2651.141070: dwc3_gadget_ep_enable: ep1in: mps 16/1024 streams 16 burst 0 ring 0/0 flags E:swBp:<
> irq/208-dwc3-689 [000] D..3.  3201.415410: dwc3_gadget_ep_disable: ep1in: mps 16/1024 streams 16 burst 0 ring 0/0 flags E:swBp:<

Right here we don't know if DWC3_EP_DELAY_STOP flag is set. In fact,
there are many flags which are not decoded to the trace points, which
makes this trace point "pointless" as it's not helping with debug
activities anymore.

In any case, I suspect DELAY_STOP is set at this point, which is causing
dwc3_stop_active_transfer() to bail out without issuing the End Transfer
command, see lines 3725 - 3728 in gadget.c (quoted below):

	if (!(dep->flags & DWC3_EP_TRANSFER_STARTED) ||
	    (dep->flags & DWC3_EP_DELAY_STOP) ||
	    (dep->flags & DWC3_EP_END_TRANSFER_PENDING))
		return;

This, in turn, will cause a subsequent ep_enable to fail with No
Resource, as the resource is still occupied by the same endpoint due to
lack of End Transfer.

@Thinh, looks like something you should patch up. Also, you should
probably go through the trace points and make sure all relevant
information is being printed to trace points. We don't want to have to
guess what's going on :-)

> irq/208-dwc3-689 [000] D..3.  3201.584476: dwc3_gadget_ep_cmd: ep1in: cmd 'Set Endpoint Configuration' [401] params 00020086 06070200 00000000 --> status: Successful
> irq/208-dwc3-689 [000] D..3.  3201.584506: dwc3_send_gadget_ep_cmd: No resource for ep1in
> irq/208-dwc3-689 [000] D..3.  3201.814837: dwc3_gadget_ep_cmd: ep1in: cmd 'Start Transfer' [406] params 00000000 45751000 00000000 --> status: No Resource

-- 
balbi

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

* Re: dwc3 38100000.usb: No resource for ep1in
  2022-12-11 15:36     ` Felipe Balbi
@ 2022-12-12 17:51       ` Thinh Nguyen
  0 siblings, 0 replies; 7+ messages in thread
From: Thinh Nguyen @ 2022-12-12 17:51 UTC (permalink / raw
  To: Felipe Balbi
  Cc: Dan Scally, Thinh Nguyen, Laurent Pinchart, Kieran Bingham,
	linux-usb@vger.kernel.org, Greg Kroah-Hartman

On Sun, Dec 11, 2022, Felipe Balbi wrote:
> 
> Hi,
> 
> Dan Scally <dan.scally@ideasonboard.com> writes:
> > Good morning
> >
> > On 08/12/2022 06:11, Felipe Balbi wrote:
> >> Hi,
> >>
> >> Dan Scally <dan.scally@ideasonboard.com> writes:
> >>> I'm having an issue with DWC3 which I'm hoping you might be able to shed
> >>> light on. I'm using the UVC gadget function to stream video from an
> >>> imx8mp platform, which works just fine. Once I have stopped streaming
> >>> however and after some time has passed (the exact duration seems to vary
> >>> quite a lot from 1-2 minutes to 15+ mins) I get a kernel warning like so:
> >> As Greg mentioned, please add Thinh, the new maintainer, to the loop.
> >
> >
> > Apologies to both of you; for some reason I thought you had taken over 
> > from Thinh rather than the other way around. Thanks for the heads up Greg.
> 
> no worries, it happens.
> 

I thought Dan knew that from his email to me a while ago:
https://lore.kernel.org/linux-usb/7d402274-a7fe-1254-c662-657188db5a84@ideasonboard.com/


> 
> @Thinh, looks like something you should patch up. Also, you should

Which I did. Perhaps my response to Dan [1] and and the fix patch last
week [2] were lost in your inbox somewhere?


> probably go through the trace points and make sure all relevant
> information is being printed to trace points. We don't want to have to
> guess what's going on :-)
> 

Sure. It may not be obvious. We can patch that.

BR,
Thinh

[1] https://lore.kernel.org/linux-usb/20221208231836.jbe64o3yk4bv4tpa@synopsys.com/
[2] https://lore.kernel.org/linux-usb/f1617a323e190b9cc408fb8b65456e32b5814113.1670546756.git.Thinh.Nguyen@synopsys.com/

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

end of thread, other threads:[~2022-12-12 17:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-07 14:27 dwc3 38100000.usb: No resource for ep1in Dan Scally
2022-12-07 16:15 ` Greg KH
2022-12-08  6:11 ` Felipe Balbi
2022-12-08  7:46   ` Dan Scally
2022-12-08 23:18     ` Thinh Nguyen
2022-12-11 15:36     ` Felipe Balbi
2022-12-12 17:51       ` Thinh Nguyen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.