1 From c0b9523ee9a6c3f2cc42529f18b33b0606413abc Mon Sep 17 00:00:00 2001
2 From: Jonathan Bell <jonathan@raspberrypi.com>
3 Date: Tue, 4 Jun 2024 13:45:37 +0100
4 Subject: [PATCH] mmc: sdhci: extend maximum ADMA transfer length to 4MiB
6 This gains about 8-12% sequential write speed with the fastest SD/eMMC
7 cards, and Class A1/A2 card sequential performance is only assured with
10 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
12 drivers/mmc/host/sdhci.c | 15 ++++++++++-----
13 1 file changed, 10 insertions(+), 5 deletions(-)
15 --- a/drivers/mmc/host/sdhci.c
16 +++ b/drivers/mmc/host/sdhci.c
17 @@ -1081,7 +1081,7 @@ static void sdhci_initialize_data(struct
21 - BUG_ON(data->blksz * data->blocks > 524288);
22 + BUG_ON(data->blksz * data->blocks > host->mmc->max_req_size);
23 BUG_ON(data->blksz > host->mmc->max_blk_size);
24 BUG_ON(data->blocks > 65535);
26 @@ -4714,11 +4714,16 @@ int sdhci_setup_host(struct sdhci_host *
27 spin_lock_init(&host->lock);
30 - * Maximum number of sectors in one transfer. Limited by SDMA boundary
31 - * size (512KiB). Note some tuning modes impose a 4MiB limit, but this
33 + * Maximum number of sectors in one transfer.
34 + * 4MiB is preferred for multi-descriptor DMA as a) card sequential
35 + * write speeds are only guaranteed with a 4MiB write length and
36 + * b) most tuning modes require a 4MiB limit.
37 + * SDMA has a 512KiB boundary size.
39 - mmc->max_req_size = 524288;
40 + if (host->flags & SDHCI_USE_ADMA)
41 + mmc->max_req_size = SZ_4M;
43 + mmc->max_req_size = SZ_512K;
46 * Maximum number of segments. Depends on if the hardware