From 6050649f1bb2183a693f242ca5c765d9ea0af1bc Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Tue, 27 Mar 2018 12:34:28 +0000 Subject: Tentative fix for QSPI race condition. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11858 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- os/hal/ports/STM32/LLD/QUADSPIv1/hal_qspi_lld.c | 9 ++++++--- testhal/STM32/multi/QSPI-MFS/.project | 12 +++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/os/hal/ports/STM32/LLD/QUADSPIv1/hal_qspi_lld.c b/os/hal/ports/STM32/LLD/QUADSPIv1/hal_qspi_lld.c index 523a6471e..7e42b6ffb 100644 --- a/os/hal/ports/STM32/LLD/QUADSPIv1/hal_qspi_lld.c +++ b/os/hal/ports/STM32/LLD/QUADSPIv1/hal_qspi_lld.c @@ -77,12 +77,15 @@ static void qspi_lld_serve_dma_interrupt(QSPIDriver *qspip, uint32_t flags) { */ static void qspi_lld_serve_interrupt(QSPIDriver *qspip) { - /* Stop everything.*/ - dmaStreamDisable(qspip->dma); - /* Portable QSPI ISR code defined in the high level driver, note, it is a macro.*/ _qspi_isr_code(qspip); + + /* Stop everything, we need to give DMA enough time to complete the ongoing + operation. Race condition hidden here.*/ + while (dmaStreamGetTransactionSize(qspip->dma) > 0U) + ; + dmaStreamDisable(qspip->dma); } /*===========================================================================*/ diff --git a/testhal/STM32/multi/QSPI-MFS/.project b/testhal/STM32/multi/QSPI-MFS/.project index f3561b950..fd02d3c02 100644 --- a/testhal/STM32/multi/QSPI-MFS/.project +++ b/testhal/STM32/multi/QSPI-MFS/.project @@ -84,7 +84,17 @@ test 2 - CHIBIOS/test + virtual:/virtual + + + test/lib + 2 + CHIBIOS/test/lib + + + test/mfs + 2 + CHIBIOS/test/mfs -- cgit v1.2.3