1 From a6f14ebd60346418df6cb750c9e36563bd887720 Mon Sep 17 00:00:00 2001
2 From: Jonathan Bell <jonathan@raspberrypi.com>
3 Date: Thu, 18 Jan 2024 14:32:16 +0000
4 Subject: [PATCH 0843/1085] mmc: bcm2835-sdhost: use Host Software Queueing
7 See commit 511ce378e16f ("mmc: Add MMC host software queue support")
9 Introduced in 5.8, this feature lets the block layer issue up to 2
10 pending requests to the MMC layer which in certain cases can improve
11 throughput, but in the case of this driver can significantly reduce
12 context switching when performing random reads.
14 On bcm2837 with a performant class A1 card, context switches under FIO
15 random 4k reads go from ~8800 per second to ~5800, with a reduction in
16 hardIRQs per second from ~5800 to ~4000. There is no appreciable
17 difference in throughput.
19 For bcm2835, and for workloads other than random read, HSQ is a wash in
20 terms of throughput and CPU load.
22 So, use it by default.
24 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
26 drivers/mmc/host/Kconfig | 1 +
27 drivers/mmc/host/bcm2835-sdhost.c | 27 ++++++++++++++++++++++-----
28 2 files changed, 23 insertions(+), 5 deletions(-)
30 --- a/drivers/mmc/host/Kconfig
31 +++ b/drivers/mmc/host/Kconfig
32 @@ -37,6 +37,7 @@ config MMC_BCM2835_PIO_DMA_BARRIER
33 config MMC_BCM2835_SDHOST
34 tristate "Support for the SDHost controller on BCM2708/9"
35 depends on ARCH_BCM2835
38 This selects the SDHost controller on BCM2835/6.
40 --- a/drivers/mmc/host/bcm2835-sdhost.c
41 +++ b/drivers/mmc/host/bcm2835-sdhost.c
44 /* For mmc_card_blockaddr */
45 #include "../core/card.h"
48 #define DRIVER_NAME "sdhost-bcm2835"
50 @@ -1891,13 +1892,16 @@ static void bcm2835_sdhost_tasklet_finis
51 mmc_hostname(host->mmc));
54 - mmc_request_done(host->mmc, mrq);
55 + if (!mmc_hsq_finalize_request(host->mmc, mrq))
56 + mmc_request_done(host->mmc, mrq);
57 log_event("TSK>", mrq, 0);
60 -int bcm2835_sdhost_add_host(struct bcm2835_host *host)
61 +int bcm2835_sdhost_add_host(struct platform_device *pdev)
63 + struct bcm2835_host *host = platform_get_drvdata(pdev);
65 + struct mmc_hsq *hsq;
66 struct dma_slave_config cfg;
67 char pio_limit_string[20];
69 @@ -1992,6 +1996,16 @@ int bcm2835_sdhost_add_host(struct bcm28
73 + hsq = devm_kzalloc(&pdev->dev, sizeof(*hsq), GFP_KERNEL);
79 + ret = mmc_hsq_init(hsq, host->mmc);
85 pio_limit_string[0] = '\0';
86 @@ -2004,6 +2018,9 @@ int bcm2835_sdhost_add_host(struct bcm28
91 + free_irq(host->irq, host);
94 tasklet_kill(&host->finish_tasklet);
96 @@ -2134,12 +2151,12 @@ static int bcm2835_sdhost_probe(struct p
98 host->firmware_sets_cdiv = (msg[1] != ~0);
100 - ret = bcm2835_sdhost_add_host(host);
101 + platform_set_drvdata(pdev, host);
103 + ret = bcm2835_sdhost_add_host(pdev);
107 - platform_set_drvdata(pdev, host);
109 pr_debug("bcm2835_sdhost_probe -> OK\n");