Skip to contentSkip to conversation

New: dwc2 gadget mode read call blocks

Bug 212045 [email protected] 1 participant 4 messages Mar 4, 2021 – Mar 10, 2021 USB

lore
Share & tools
lore
#0 lore raw

https://bugzilla.kernel.org/show_bug.cgi?id=212045

Bug ID: 212045
Summary: dwc2 gadget mode read call blocks
Product: Drivers
Version: 2.5
Kernel Version: 5.9
Hardware: All
OS: Linux
Tree: Mainline
Status: NEW
Severity: normal
Priority: P1
Component: USB
Assignee: [email protected]
Reporter: [email protected]
Regression: No

When implementing USB gadget on Odroid N2 I write descriptors for two endpoints so I get ep0, ep1 and ep2 files. I open those files and try to read from ep0 and ep2. While ep0 more or less works, for ep2 I get weird behaviour: the select() call returns 1 indicating that there is data to read and then read() call blocks. It happens even if I set the file descriptor to O_NONBLOCK. Here is the kernel log: https://pastebin.pl/view/aaa2d7f0

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
#1 lore raw

[Bug 212045] dwc2 gadget mode read call blocks

https://bugzilla.kernel.org/show_bug.cgi?id=212045

Minas Harutyunyan ([email protected]) changed:

What |Removed |Added
----------------------------------------------------------------------------

                 CC|                            |Minas.Harutyunyan@synopsys.
                   |                            |com

--- Comment #4 from Minas Harutyunyan ([email protected]) --- According to dmesg, you use follow EP's: ep0in, ep0out, ep1in and ep1out. Why you refer to not used ep2?

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
#2 lore raw

[Bug 212045] dwc2 gadget mode read call blocks

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=212045

--- Comment #5 from Tomasz Grobelny ([email protected]) ---
The files that functionfs exposes are ep0 (for reading, events), ep1 (for writing, direction: to host) and ep2 (for reading, direction: to gadget). Not sure how and why they are named in dmesg. You can find the gadget configuration here:
https://github.com/tomasz-grobelny/AACS/blob/master/AAServer/src/descriptors.cpp
- line 75 and 84:
.bEndpointAddress = 1 | USB_DIR_IN, .bEndpointAddress = 2 | USB_DIR_OUT,

The code that fails/hangs is readWraper function here:
https://github.com/tomasz-grobelny/AACS/blob/master/AAServer/src/AaCommunicator.cpp:493

select succeeds for ep2 and the read blocks. Exactly same function works ok for ep0 for all 3 hosts that I tested on and the code works fully ok for 2 out of 3 hosts that I tested on. I also know that in principle the 3rd host also should work because it works with other devices.

Maybe lack of ep2 in the logs is something interesting?

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
#3 lore raw

[Bug 212045] dwc2 gadget mode read call blocks

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=212045

--- Comment #7 from Tomasz Grobelny ([email protected]) --- What do you mean by "function driver"? The userspace code that actually opens the ep0/ep1/ep2 files exposed by functionfs? It works correctly for other hosts.

I don't have any more data to argue it is dwc2, but still seems like an issue in kernel USB subsystem.

Another question that might help debugging it: is it the host that should open the ep2 endpoint? In other words: is it the host that is directly responsible for lack of any mention of ep2 in dmesg output after the device was reinitialized?

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.