-
Notifications
You must be signed in to change notification settings - Fork 58
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
sw: Fix snrt_dma_wait
implementation
#153
Conversation
The previous implementation of `snrt_dma_wait` was incorrect as it had an infinite loop in the case that `tid` was the last completed transaction. Looking at the documentation, the snippet in custom_instructions.md shows the correct way of implementing the transaction check (get last completed tid and loop if it's less than the one we are waiting for) except it had its register operands swapped. This PR uses that implementation instead, fixes the small bug in the documentation and changes one of the waits in `dma_simple.c` to make sure we don't regress either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the fix!
Thank you! Would you mind merging this for me as well? I do not have commit writes :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution @zero9178 :)
Looking at the PR, it looks like this breaks the way zero-sized transfers are handled (return a transaction ID of -1).
I'm adding a test for these transfers and correcting the condition. Will merge as soon as I get this fixed :)
Thanks good catch I did not consider these. Could these use 0 instead or does the DMA engine return 0 for the very first transaction? Otherwise I'd just change the |
Zero seems to work. But actually the new DMA should support zero-sized transfers, so removing the if condition on the size altogether should work. There seems to be a bug however which I'm currently investigating. |
A fix to the DMA bug is provided in pulp-platform/iDMA#50. Till that is merged and a new release of the iDMA is created, we can merge this PR with the zero ID as suggested. |
The previous implementation of
snrt_dma_wait
was incorrect as it had an infinite loop in the case thattid
was the last completed transaction. Looking at the documentation, the snippet in custom_instructions.md shows the correct way of implementing the transaction check (get last completed tid and loop if it's less than the one we are waiting for) except it had its register operands swapped. This PR uses that implementation instead, fixes the small bug in the documentation and changes one of the waits indma_simple.c
to make sure we don't regress either.