Fix potential display coherency problem when D-cache is enabled#455
Open
pat-rogers wants to merge 1 commit intoAdaCore:masterfrom
Open
Fix potential display coherency problem when D-cache is enabled#455pat-rogers wants to merge 1 commit intoAdaCore:masterfrom
pat-rogers wants to merge 1 commit intoAdaCore:masterfrom
Conversation
Fixes the case in which the LTDC displayed content would occasionally
slew to the left and then snap back immediately.
Affects: stm32-dma2d_bitmap, framebuffer_ltdc
DMA2D_Fill_Rect was called without Synchronous => True, allowing DMA2D
writes to the hidden framebuffer to still be in progress when
Internal_Update_Layer flushed and handed the buffer to LTDC. This
caused occasional display corruption ("slewing") as LTDC scanned out
a partially-written buffer.
Fix Fill_Rect to use Synchronous => True, consistent with Fill.
Add Clean_DCache in Internal_Update_Layer covering the hidden buffer
before Set_Frame_Buffer, ensuring CPU-written dirty cache lines are
flushed to physical memory before LTDC DMA reads them.
Author
|
Problem remains under at least one as-yet-undetermined circumstance. Investigating further... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Affects: stm32-dma2d_bitmap, framebuffer_ltdc
DMA2D_Fill_Rect was called without Synchronous => True, allowing DMA2D writes to the hidden framebuffer to still be in progress when Internal_Update_Layer flushed and handed the buffer to LTDC. We need to change the call to Fill_Rect to use Synchronous => True, consistent with Fill.
After the calls to Wait_Transfer in procedure Internal_Update_Layer , we need a call to Clean_DCache covering the hidden buffer, before the call to Set_Frame_Buffer, ensuring CPU-written dirty cache lines are flushed to physical memory before LTDC DMA reads them.
Why Wait_Transfer alone is insufficient: Wait_Transfer waits for any in-progress DMA2D transfer to complete on that buffer, and then calls Clean_Invalidate_DCache. That's correct for a buffer the CPU is about to read (invalidate stale CPU-cache lines so it re-fetches DMA2D-written data). But for a buffer LTDC is about to read, we need Clean_DCache (flush CPU-dirty lines to physical memory without discarding them). In other words, Clean_Invalidate is correct for the CPU-read case, and Clean only is correct for the LTDC-handoff case. The Clean_Invalidate_DCache inside Wait_Transfer becomes redundant given the subsequent Clean_DCache, but the synchronization barrier it provides is not. We still need to wait for DMA2D to finish before flipping.