Thread (6 messages) read the whole thread 6 messages, 2 authors, 2021-07-01

Re: USB Gadget Filesystem HID stuck on write when using mass storage at the same time

From: Benjamin Marty <hidden>
Date: 2021-06-30 10:25:24

Am Mi., 30. Juni 2021 um 11:28 Uhr schrieb Greg KH [off-list ref]:
On Wed, Jun 30, 2021 at 10:55:04AM +0200, Benjamin Marty wrote:
quoted
On the iMX8 device `Linux imx8mm-var-dart 5.4.3-g050b21f4b394 #1 SMP
PREEMPT Fri Oct 9 11:36:53 PDT 2020 aarch64 GNU/Linux` and on the
Raspberry Pi device `Linux raspberry 5.10.17-v7l+ #1403 SMP Mon Feb 22
11:33:35 GMT 2021 armv7l GNU/Linux`.
I do not understand, which is the host and which is the gadget here?
I use both as Gadget, two different HW platforms to rule out a
Hardware related issue.
As Host, I've tried multiple normal Intel computers.
I was able to reproduce this issue with all HW Combinations
quoted
File write to `/dev/hidg0` starts to hang when there was high mass
storage traffic. It also doesn't recover itself. There is no `complete
kernel lockup`.
File write on the host or gadget?
File write on the gadget to the gadget HID device `/dev/hidg0`
If things are not locked up, what is stalled?
The File write to the gadget HID device is stalled.
quoted
I haven't used usbmon yet but if I don't have high traffic scenarios
on the mass storage then the mass storage and HID device works as
expected. So I'm confident that I send the correct data.
That's fine, but it is good to use usbmon to see what the errors are as
well when things go wrong.
Unfortunately both Kernel Versions don't have the usbmon module, need
to recompile the Kernel first.
quoted
Also saw that I'm getting this error in dmesg on both devices:
[ 1895.677053] configfs-gadget gadget: End Point Request ERROR: -108
Ah, is your userspace code on the gadget not handling this properly?
What userspace code is running on the gadget for your USB device
emulation?
Yes, my userspace code is on the gadget. It runs after I've setup the
gadget HID + gadget Mass Storage. But it starts to fail after High
Traffic scenarios to the gadget Mass Storage.

To replicate the issue, I wrote a simple Bash script which just
wiggles the gadget HID (Mouse) every 50ms:

while true; do
if [ -e "/dev/hidg0" ]; then
echo write0
echo \\x00\\xff\\xff\\x00\\xff\\xff > /dev/hidg0
sleep 0.05
echo write1
echo \\x00\\xff\\xff\\x00\\xff\\x00 > /dev/hidg0
sleep 0.05
fi
done

Do I need to check something before writing to the gadget HID device?
Or should this usage of the gadget HID device be fine?

Thanks

Benjamin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help