-
Notifications
You must be signed in to change notification settings - Fork 16
samd51: Work around DMA hang #29
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
Conversation
@tannewt I can't request review in here, but it would be great if you could take a look at this or send it on to the right person! |
I can't say I see any issues with the current code, but there's a lot of confusing dead code and comments. I think Lines 113 to 114 in 28ad937
Not sure what is going on below with the commented-out stuff: Lines 155 to 160 in 28ad937
The comments below seem completely outdated and, like above, not sure what is going on with the Lines 171 to 184 in 28ad937
The
If CHSTATUS.PEND is set, then the DMA won't be triggered, it sounds like. In your debugging, did you look for this. Is that something to busy-wait on? |
Fwiw the change is intended to fix adafruit/circuitpython#2005 rather than generally address problems like @dhalbert mentions. |
@jepler Sorry for introducing general code cleanup, but I was trying to see if some previous code change introduced a problem, and the current state of the code is confusing. I do wonder about the CHSTATUS.PEND thing which I mentioned last. Also , is there any timing issue between enabling the channels and doing the SWTRIG? If you inserted a delay there of 10 or 100 usecs, does the problem go away? That is not necessarily a fix: maybe instead there's a status bit that could be checked before triggering. |
.. this involves inverting one condition, since the branch that needed to be preserved was the 'else' branch
In a fresh commit, I updated the comments based on @dhalbert 's comments and my own understanding of the code, and removed dead code. I don't think |
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.
Looks good to me! Sorry for the dead code.
@dhalbert Feel free to merge if you are happy. |
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.
Thank you for the cleanup! This is OK by me now.
There's a hang when using multiple DMA channels on SAMD51 that has affected several projects based on CircuitPython and on Arduino (nofrendo_arcada).
This patch attempts to address the DMA hang for Circuitpython, in the specific case where audio hangs while doing DMA for display. It should also help if there are DMA hangs while doing other SPI or QSPI activity, but I never personally observed a hang other than from display-during-audio.
There's no particular reason I chose 10 iterations for the loop; in CircuitPython, we know that there are at least 16 bytes of transfer to do, so probably checking 10 times in a row wouldn't lengthen a short transaction.
Testing performed: On a pygamer, with an additional local patch that tracked the number of times the (!is_okay) branch was entered, I found that it was entered around 2-3 times per hour during my audio playback with display test, and zero hangs were observed.
Because I was not in the room when it was playing, I didn't hear whether audible glitches occur.