Skip to content
  • André Przywara's avatar
    mmc: sunxi: Increase MMIO FIFO read performance · 9faae545
    André Przywara authored
    
    
    To avoid the complexity of DMA operations (with chained descriptors), we
    use repeated MMIO reads and writes to the SD_FIFO_REG, which allows us
    to drain or fill the MMC data buffer FIFO very easily.
    
    However those MMIO accesses are somewhat costly, so this limits our MMC
    performance, to between 17 and 22 MB/s, but down to 9.5 MB/s on the H6
    (partly due to the lower AHB1 frequency).
    
    As it turns out we read the FIFO status register after *every* word we
    read or write, which effectively doubles the number of MMIO accesses,
    thus effectively more than halving our performance.
    
    To avoid this overhead, we can make use of the FIFO level bits, which are
    in the very same FIFO status registers.
    So for a read request, we now can collect as many words as the FIFO
    level originally indicated, and only then need to update the status
    register.
    
    We don't know for sure the size of the FIFO (and it seems to differ
    across SoCs anyway), so writing is more fragile, which is why we still
    use the old method for that. If we find a minimum FIFO size available on
    all SoCs, we could use that, in a later optimisation.
    
    This patch increases the eMMC read speed on a Pine64-LTS from about
    22MB/s to 44 MB/s. SD card reads don't gain that much, but with 23 MB/s
    we now reach the practical limit for 3.3V SD cards.
    On the H6 we double our transfer speed, from 9.5 MB/s to 19.7 MB/s.
    
    Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
    9faae545