• Wolfram Sang's avatar
    mmc: tmio: ensure end of DMA and SD access are in sync · 52ad9a8e
    Wolfram Sang authored
    The current code assumes that DMA is finished before SD access end is
    flagged. Thus, it schedules the 'dma_complete' tasklet in the SD card
    interrupt routine when DATAEND is set. The assumption is not safe,
    though. Even by mounting an SD card, it can be seen that sometimes DMA
    complete is first, sometimes DATAEND. It seems they are usually close
    enough timewise to not cause problems. However, a customer reported that
    with CMD53 sometimes things really break apart. As a result, the BSP has
    a patch which introduces flags for both events and makes sure both flags
    are set before scheduling the tasklet. The customer accepted the patch,
    yet it doesn't seem a proper upstream solution to me.
    
    This patch refactors the code to replace the tasklet with already
    existing and more lightweight mechanisms. First of all, we set the
    callback in a DMA descriptor to automatically get notified when DMA is
    done. In the callback, we then use a completion to make sure the SD
    access has already ended. Then, we proceed as before.
    Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
    Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
    52ad9a8e
tmio_mmc_dma.c 8.31 KB