Skip to content

host/dwc2: cleanup transfer on device close #3076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

HiFiPhile
Copy link
Collaborator

@HiFiPhile HiFiPhile commented Apr 11, 2025

Describe the PR
Fix queued xfer of previous failed enumeration mess with next enumeration.

[1:1] Get Descriptor: 80 06 03 03 09 04 00 01 
on EP 00 with 8 bytes: OK
on EP 80 with 40 bytes: OK
[1:1] Control data:
  0000:  28 03 4D 00 61 00 73 00 73 00 20 00 53 00 74 00  |(.M.a.s.s. .S.t.|
  0010:  6F 00 72 00 61 00 67 00 65 00 20 00 44 00 65 00  |o.r.a.g.e. .D.e.|
  0020:  76 00 69 00 63 00 65 00                          |v.i.c.e.|
[1:0:0] USBH DEVICE REMOVED
[1:0:0] unplugged address = 1
Device removed, address = 1
[1:] USBH Device Attach
High Speed
[1:0] Open EP0 with Size = 8
Get 8 byte of Device Descriptor
[1:0] Get Descriptor: 80 06 00 01 00 00 08 00 
on EP 00 with 8 bytes: OK                                  <------- Missed by one
on EP 00 with 8 bytes: OK
[1:0] Control data:
  0000:  12 01 00 02 00 00 00 40                          |.......@|
on EP 80 with 8 bytes: OK

Set Address = 1
[1:0] Set Address: 00 05 01 00 00 00 00 00 
on EP 00 with 0 bytes: OK
on EP 00 with 8 bytes: OK

[1:1] Open EP0 with Size = 64
Get Device Descriptor
[1:1] Get Descriptor: 80 06 00 01 00 00 12 00 
on EP 80 with 8 bytes: OK
hcd_edpt_xfer 655: ASSERT FAILED

@maximevince
Copy link
Contributor

maximevince commented Apr 14, 2025

While I can see the issue described here on my side as well, it seems to me this is not the proper fix, but rather a workaround - with its own side-effects.
Why wasn't this xfer cleared? And what if is currently ongoing?

There seem to be some race conditions between handling some stuff in the interrupt handler, and deferring some stuff to the tuh_task(). This is probably the root of (some of) these problems...

@HiFiPhile
Copy link
Collaborator Author

it seems to me this is not the proper fix, but rather a workaround - with its own side-effects.

Could you detail more, what you mean sie-effects ?

@hathach
Copy link
Owner

hathach commented Apr 18, 2025

my bad, I think we cannot simply clear data here. We should mark endpoint for removal then disable channel first, within the halted interrupt check the flag and clear the endpoint.

@HiFiPhile
Copy link
Collaborator Author

Ah yes we should close the channel properly, especially when a hub is used.

Signed-off-by: HiFiPhile <[email protected]>
@HiFiPhile
Copy link
Collaborator Author

I've changed it use channel_disable(), I think there is no need to wait until the channel is disabled ?

@hathach
Copy link
Owner

hathach commented Apr 29, 2025

I've changed it use channel_disable(), I think there is no need to wait until the channel is disabled ?

I am on vacation, will try to check this out afterwards (next week or so).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants