Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ringbuffer hardware race condition bug.
When attempting to get a snapshot of the completion count and position, the current ringbuffer implementation uses a critical section. This does indeed prevent the completion_count from updating but does not prevent the position from updating since that is fetched directly from the DMA register. When the code is called right at the end of the DMA cycle, the position that is read may be that of the next cycle, while the completion_count is still that of the previous cycle. As a result it looks to the code as if we went backwards and an overrun error is emitted. In order to fix this we remove the critical section and get two readings, comparing the two in order to deduce that a wrap-around occured.
- Loading branch information