From 055c8f405b1d133b5ad005ff190ceabb8820d6b5 Mon Sep 17 00:00:00 2001 From: Lephe Date: Sat, 20 Nov 2021 16:39:46 +0100 Subject: [PATCH] r61524: fix a tight freeze window due to a CPU/DMA race --- src/r61524/r61524.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/r61524/r61524.c b/src/r61524/r61524.c index 5e72f6f..b1416c3 100644 --- a/src/r61524/r61524.c +++ b/src/r61524/r61524.c @@ -149,6 +149,10 @@ void r61524_start_frame(int start, int height) void r61524_display(uint16_t *vram, int start, int height, int method) { + /* Wait for any transfer to finish before using the screen, otherwise + the DMA might write data *while* we're sending commands! */ + dma_transfer_wait(0); + r61524_start_frame(start, height); if(method == R61524_CPU) @@ -167,9 +171,6 @@ void r61524_display(uint16_t *vram, int start, int height, int method) int blocks = 99 * (height >> 2); if(method == R61524_DMA) { - /* If the previous transfer is still running, wait for it; then - start sending asynchronously and return. */ - dma_transfer_wait(0); dma_transfer_async(0, DMA_32B, blocks, src, DMA_INC, dst, DMA_FIXED, GINT_CALL_NULL); }