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

sw: Fix snrt_dma_wait implementation #153

Merged
merged 2 commits into from
Jul 1, 2024

Conversation

zero9178
Copy link
Contributor

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.

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.
Copy link
Contributor

@fischeti fischeti left a 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!

@zero9178
Copy link
Contributor Author

LGTM. Thanks for the fix!

Thank you! Would you mind merging this for me as well? I do not have commit writes :)

@fischeti
Copy link
Contributor

LGTM. Thanks for the fix!

Thank you! Would you mind merging this for me as well? I do not have commit writes :)

Me neither unfortunately😉 @paulsc96 and @colluca are maintainers of the repository

Copy link
Collaborator

@colluca colluca left a 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 :)

@zero9178
Copy link
Contributor Author

zero9178 commented Jul 1, 2024

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 bltu to blt

@colluca
Copy link
Collaborator

colluca commented Jul 1, 2024

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 bltu to blt

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.

@colluca
Copy link
Collaborator

colluca commented Jul 1, 2024

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.

@colluca colluca merged commit 17aa42a into pulp-platform:main Jul 1, 2024
13 checks passed
@zero9178 zero9178 deleted the dma-wait-fix branch July 16, 2024 08:34
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