-
Notifications
You must be signed in to change notification settings - Fork 724
[nrf fromtree] drivers: udc_dwc2: Rework control endpoint feeding #2474
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
tmon-nordic
merged 7 commits into
nrfconnect:main
from
tmon-nordic:cherry-pick-dwc2-control-transfers
Feb 10, 2025
Merged
[nrf fromtree] drivers: udc_dwc2: Rework control endpoint feeding #2474
tmon-nordic
merged 7 commits into
nrfconnect:main
from
tmon-nordic:cherry-pick-dwc2-control-transfers
Feb 10, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The DOEPTSIZ0 XferSize field is 7 bits long, meaning that maximum single transfer can be 127 bytes long. Configure the control write (OUT) transfers considering the XferSize field size to support transfers with data stage larger than 127 bytes. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit 18be1d0)
Prepare buffer to receive SETUP data on OUT endpoint 0 after endpoint halt. This solves the issue where the device would no longer process any control transfers after the first failed transfer with too large OUT Data Stage (when processing failed due to data stage buffer allocation failure). Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit 883b77f)
DMA transfers are supposed to write to buffer tail. Use the proper pointer to make multipart DMA transfers actually write the data to the intended location. The issue was observed on control write transfers where the OUT Data Stage was at least 128 bytes (because endpoint 0 transfer width is limited to 7 bits). The issue is unlikely to happen on non-control transfers because the transfer size width is at least 11 bits (at most 19 bits) and packet size counter is at least 4 bits (at most: 10 bits) which means that at least 2048 byte transfer spanning at least 15 packets (or at least 524288 byte spanning 1023 packets for 19 bits transfer size counter and 10 bits packet counter) is required to necessitate multipart DMA. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit 45ee2a0)
Use helper functions to check whether device is operating in Buffer DMA or Completer mode. This allows compile time optimizations to remove DMA handling code when DMA is disabled via KConfig symbol UDC_DWC2_DMA. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit d4cc8de)
Control OUT buffers must be multiple of bMaxPacketSize0 in Buffer DMA mode. While the transfer can be configured to smaller values, DMA will write data past the buffer (and transfer size counter will underflow) if the packet on the bus is larger or if there are multiple back-to-back SETUP packets. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit a61afc8)
The transfer is finished after ZLP is transmitted. Do not re-enable the endpoint waiting for more data. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit ea72b27)
In Completer mode SETUP data can always be received and therefore endpoint 0 should only be enabled for OUT Data Stage and OUT Status Stage. In Buffer DMA mode, SETUP can only be received when endpoint is enabled and therefore the software has to make sure that there is a buffer available to receive SETUP data. Rework the EP0 buffer feeding to adhere to DWC2 Programming Guide. Synchronize the accesses with driver mutex to avoid interrupt related race conditions. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit 8348d9a)
jfischer-no
approved these changes
Feb 10, 2025
nordicjm
approved these changes
Feb 10, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry pick control transfer related fixes.