Skip to content
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

overwrite grstctl on edpt_disable #1454

Merged
merged 2 commits into from Jun 1, 2022
Merged

Conversation

Iktek
Copy link
Contributor

@Iktek Iktek commented May 3, 2022

Solves #1453

@cr1901
Copy link
Collaborator

cr1901 commented May 3, 2022

From #1453

For my opinion it's completely ok to clear the whole grstctl because all bits (except the TXFNUM) are self-cleared.

This looks reasonable/fine to me in light of that (unless it's somehow possible to get to this code before all the bits self-clear).

If you look at my comments on PRs/Issues over the years, you'll find that I had a number of bugs where I do |= instead of doing =. This appears to be no exception. Also, epnum - 1 in the linked line is also wrong, but that was fixed some time ago :P.

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.

Sorry for late response, and thank for your PR. This somehow falls off my radar. The code is spot-on, though I think we can actually set the fifo number, and flush it at the same time. Let me know if you have time to test that out, otherwise, I will merge this as it is and test the combined code later on.

@@ -796,7 +796,7 @@ static void dcd_edpt_disable (uint8_t rhport, uint8_t ep_addr, bool stall)
}

// Flush the FIFO, and wait until we have confirmed it cleared.
dwc2->grstctl |= (epnum << GRSTCTL_TXFNUM_Pos);
dwc2->grstctl = (epnum << GRSTCTL_TXFNUM_Pos);
Copy link
Owner

@hathach hathach May 26, 2022

Choose a reason for hiding this comment

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

I think we can actually merge them into 1 line as

dwc2->grstctl = (epnum << GRSTCTL_TXFNUM_Pos) | GRSTCTL_TXFFLSH;

from linux dwc2

https://github.com/torvalds/linux/blob/babf0bb978e3c9fce6c4eba6b744c8754fd43d8e/drivers/usb/dwc2/core.c#L823-L825

@Iktek
Copy link
Contributor Author

Iktek commented May 27, 2022 via email

@hathach
Copy link
Owner

hathach commented May 30, 2022

Hi, @hathach, unfortunately I currently don't have the test-equipment on desk any more currently, so no further possibility to test. I'll do further tests with this software in the 2nd half of the year and also might test that change then, but I'd propose to first merge the current solution. Regards Pascal Am 26.05.22 um 16:34 schrieb Ha Thach:

No problems, I think it is safe to do so when observing code from linux driver. I will make the change to pr and merge asap.

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.

None yet

4 participants