]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.0.5/mmc-alcor-fix-dma-reads.patch
Linux 5.0.5
[thirdparty/kernel/stable-queue.git] / releases / 5.0.5 / mmc-alcor-fix-dma-reads.patch
1 From 5ea47691bd99e1100707ec63364aff72324e2af4 Mon Sep 17 00:00:00 2001
2 From: Daniel Drake <drake@endlessm.com>
3 Date: Wed, 20 Mar 2019 14:36:53 +0800
4 Subject: mmc: alcor: fix DMA reads
5
6 From: Daniel Drake <drake@endlessm.com>
7
8 commit 5ea47691bd99e1100707ec63364aff72324e2af4 upstream.
9
10 Setting max_blk_count to 1 here was causing the mmc block layer
11 to always use the MMC_READ_SINGLE_BLOCK command here, which the
12 driver does not DMA-accelerate.
13
14 Drop the max_blk_ settings here. The mmc host defaults suffice,
15 along with the max_segs and max_seg_size settings, which I have
16 now documented in more detail.
17
18 Now each MMC command reads 4 512-byte blocks, using DMA instead of
19 PIO. On my SD card, this increases read performance (measured with dd)
20 from 167kb/sec to 4.6mb/sec.
21
22 Link: http://lkml.kernel.org/r/CAD8Lp47L5T3jnAjBiPs1cQ+yFA3L6LJtgFvMETnBrY63-Zdi2g@mail.gmail.com
23 Signed-off-by: Daniel Drake <drake@endlessm.com>
24 Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
25 Fixes: c5413ad815a6 ("mmc: add new Alcor Micro Cardreader SD/MMC driver")
26 Cc: stable@vger.kernel.org
27 Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
28 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
29
30 ---
31 drivers/mmc/host/alcor.c | 25 +++++++++++++++++++------
32 1 file changed, 19 insertions(+), 6 deletions(-)
33
34 --- a/drivers/mmc/host/alcor.c
35 +++ b/drivers/mmc/host/alcor.c
36 @@ -1044,14 +1044,27 @@ static void alcor_init_mmc(struct alcor_
37 mmc->caps2 = MMC_CAP2_NO_SDIO;
38 mmc->ops = &alcor_sdc_ops;
39
40 - /* Hardware cannot do scatter lists */
41 + /* The hardware does DMA data transfer of 4096 bytes to/from a single
42 + * buffer address. Scatterlists are not supported, but upon DMA
43 + * completion (signalled via IRQ), the original vendor driver does
44 + * then immediately set up another DMA transfer of the next 4096
45 + * bytes.
46 + *
47 + * This means that we need to handle the I/O in 4096 byte chunks.
48 + * Lacking a way to limit the sglist entries to 4096 bytes, we instead
49 + * impose that only one segment is provided, with maximum size 4096,
50 + * which also happens to be the minimum size. This means that the
51 + * single-entry sglist handled by this driver can be handed directly
52 + * to the hardware, nice and simple.
53 + *
54 + * Unfortunately though, that means we only do 4096 bytes I/O per
55 + * MMC command. A future improvement would be to make the driver
56 + * accept sg lists and entries of any size, and simply iterate
57 + * through them 4096 bytes at a time.
58 + */
59 mmc->max_segs = AU6601_MAX_DMA_SEGMENTS;
60 mmc->max_seg_size = AU6601_MAX_DMA_BLOCK_SIZE;
61 -
62 - mmc->max_blk_size = mmc->max_seg_size;
63 - mmc->max_blk_count = mmc->max_segs;
64 -
65 - mmc->max_req_size = mmc->max_seg_size * mmc->max_segs;
66 + mmc->max_req_size = mmc->max_seg_size;
67 }
68
69 static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)