• Gerard Kam's avatar
    atmel_spi: fix hang due to missed interrupt · dc329442
    Gerard Kam authored
    For some time my at91sam9260 board with JFFS2 on serial flash (m25p80)
    would hang when accessing the serial flash and SPI bus.  Slowing the SPI
    clock down to 9 MHz reduced the occurrence of the hang from "always"
    during boot to a nuisance level that allowed other SW development to
    continue.  Finally had to address this issue when an application stresses
    the I/O to always cause a hang.
    
    Hang seems to be caused by a missed SPI interrupt, so that the task ends
    up waiting forever after calling spi_sync().  The fix has 2 parts.  First
    is to halt the DMA engine before the "current" PDC registers are loaded.
    This ensures that the "next" registers are loaded before the DMA operation
    takes off.  The second part of the fix is a kludge that adds a
    "completion" interrupt in case the ENDRX interrupt for the last segment of
    the DMA chaining operation was missed.
    
    The patch allows the SPI clock for the serial flash to be increased from 9
    MHz to 15 MHz (or more?).  No hangs or SPI overruns were encountered.
    
    Haavard: while this patch does indeed improve things, I still see overruns
    and CRC errors on my NGW100 board when running the DataFlash at 10 MHz.
    However, I think some improvement is better than nothing, so I'm passing
    this on for inclusion in 2.6.27.
    Signed-off-by: default avatarGerard Kam <gerardk5@verizon.net>
    Signed-off-by: default avatarHaavard Skinnemoen <haavard.skinnemoen@atmel.com>
    Cc: David Brownell <david-b@pacbell.net>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    dc329442
atmel_spi.c 22.2 KB