Skip to content

dwc2/host: immediately retry IN token for bInterval=1 #3072

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

Merged
merged 3 commits into from
Apr 18, 2025

Conversation

maximevince
Copy link
Contributor

@maximevince maximevince commented Apr 10, 2025

Describe the PR

When connecting a HS device with an interrupt endpoint with bInterval = 1 (1 microframe, 125us), it was being polled only at 2 microframe interval (250us), in case of a NAK. This is because the retry was deferred to the next SOF, basically wasting a full microframe.

The fix is to re-send the IN token as soon as we get the NAK, in base bInterval = 1. In other cases, we still rely on the existing polling interval calculations in the SOF IRQ handler.

Additional context

Pre-fix situation:
image

Post-fix situation:
(the SOF IRQ is fired, but is not used to schedule the retry, hence no xfer_kickoff from there)
image

@HiFiPhile @roma-jam

@HiFiPhile
Copy link
Collaborator

Just did some tests and confirmed my guess, all intervals are polled one frame longer.
Please try https://github.com/HiFiPhile/tinyusb/tree/retry

@maximevince maximevince force-pushed the dwc2-retry-in-token-immediately branch from 1b37f2e to 46ec89e Compare April 14, 2025 07:26
@maximevince
Copy link
Contributor Author

@HiFiPhile thanks, that makes sense!

However, if I try your branch, I get a data toggle error. (Cannot just issue a channel_xfer_start(dwc2, ch_id); on the tests I did on my side)

However, I have integrated your idea into this PR and update it. Can you check?

@HiFiPhile
Copy link
Collaborator

However, if I try your branch, I get a data toggle error

I didn't met it in my side, what's the error message ? channel_send_in_token() doesn't work when DMA is enabled, need some investigation.

@maximevince
Copy link
Contributor Author

I get a HCINT_DATATOGGLE_ERR when using channel_xfer_start(), since it updates edpt->next_pid, which it shouldn't for a retry.

@maximevince maximevince force-pushed the dwc2-retry-in-token-immediately branch from 46ec89e to 62d06e7 Compare April 15, 2025 07:08
@maximevince
Copy link
Contributor Author

I have also rebased on master, and should have properly merged the bitfields change.

@HiFiPhile
Copy link
Collaborator

I get a HCINT_DATATOGGLE_ERR when using channel_xfer_start(), since it updates edpt->next_pid, which it shouldn't for a retry.

Ah that's make sense

Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for your PR. I also clean up and remove the halted_sof_schedule flags (obsolete code). since channel_xfer_in_retry() is only called when halted. Please check if the changes make sense to you

@hathach hathach merged commit e44f556 into hathach:master Apr 18, 2025
110 checks passed
@HiFiPhile
Copy link
Collaborator

A small fix added in #3088

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

Successfully merging this pull request may close these issues.

3 participants