• Linus Walleij's avatar
    mmc: sdhci: Implement an SDHCI-specific bounce buffer · bd9b9027
    Linus Walleij authored
    The bounce buffer is gone from the MMC core, and now we found out
    that there are some (crippled) i.MX boards out there that have broken
    ADMA (cannot do scatter-gather), and also broken PIO so they must
    use SDMA. Closer examination shows a less significant slowdown
    also on SDMA-only capable Laptop hosts.
    
    SDMA sets down the number of segments to one, so that each segment
    gets turned into a singular request that ping-pongs to the block
    layer before the next request/segment is issued.
    
    Apparently it happens a lot that the block layer send requests
    that include a lot of physically discontiguous segments. My guess
    is that this phenomenon is coming from the file system.
    
    These devices that cannot handle scatterlists in hardware can see
    major benefits from a DMA-contiguous bounce buffer.
    
    This patch accumulates those fragmented scatterlists in a physically
    contiguous bounce buffer so that we can issue bigger DMA data chunks
    to/from the card.
    
    When tested with a PCI-integrated host (1217:8221) that
    only supports SDMA:
    0b:00.0 SD Host controller: O2 Micro, Inc. OZ600FJ0/OZ900FJ0/OZ600FJS
            SD/MMC Card Reader Controller (rev 05)
    This patch gave ~1Mbyte/s improved throughput on large reads and
    writes when testing using iozone than without the patch.
    
    dmesg:
    sdhci-pci 0000:0b:00.0: SDHCI controller found [1217:8221] (rev 5)
    mmc0 bounce up to 128 segments into one, max segment size 65536 bytes
    mmc0: SDHCI controller on PCI [0000:0b:00.0] using DMA
    
    On the i.MX SDHCI controllers on the crippled i.MX 25 and i.MX 35
    the patch restores the performance to what it was before we removed
    the bounce buffers.
    
    Cc: Pierre Ossman <pierre@ossman.eu>
    Cc: Benoît Thébaudeau <benoit@wsystem.com>
    Cc: Fabio Estevam <fabio.estevam@nxp.com>
    Cc: Benjamin Beckmeyer <beckmeyer.b@rittal.de>
    Cc: stable@vger.kernel.org # v4.14+
    Fixes: de3ee99b ("mmc: Delete bounce buffer handling")
    Tested-by: default avatarBenjamin Beckmeyer <beckmeyer.b@rittal.de>
    Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
    Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
    Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
    bd9b9027
sdhci.c 105 KB