Skip to content

Conversation

fcooperti
Copy link

For a single packet read and write operations must pick either 32-bit, 16-bit or 8-bit read or write operations. Mixing and matching can cause corruption of data.

This becomes a bigger issue when using TinyUSB fifo that has to deal with wrapping since read/write operations may be split between multiple transfers of different sizes.

Therefore, create a function that will determine which operation can be used for transfer the entire buffer of data. Then read and write operations can use a parameter to determine what should be used.

fixes #3010

For a single packet read and write operations must pick either 32-bit, 16-bit or
8-bit read or write operations. Mixing and matching can cause corruption of
data.

This becomes a bigger issue when using TinyUSB fifo that has to deal with
wrapping since read/write operations may be split between multiple transfers
of different sizes.

Therefore, create a function that will determine which operation can be used
for transfer the entire buffer of data. Then read and write operations can
use a parameter to determine what should be used.

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

Thank you for the fix, but the logic can be better.

For example non-fifo based 11 bytes transfer can be 5*16b loops + 1*8b loop.

  • even length -> 32b + 16b transfers
  • odd length -> 16b + 8b transfers

@HiFiPhile
Copy link
Collaborator

@fcooperti, please test my last commit.

After checking kernel source code, the access width change is not limited to the latest operation, for example 32b+16b+8b is allowed for 7 bytes I/O (not limited to 3*16b+8b).

https://github.com/torvalds/linux/blob/19272b37aa4f83ca52bdf9c16d5d81bdd1354494/drivers/usb/musb/musb_core.c#L329

I've updated the logic to make access width limit only applied to wrapped fifo part while keeping normal transfer and linear fifo part untouched.

@HiFiPhile
Copy link
Collaborator

@fcooperti Hello, are you still on this ?

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.

audio_test - Noisy generated to generated saw tooth tone
2 participants