]> git.ipfire.org Git - thirdparty/openwrt.git/blob
fab83b2d71fb20a3dee75fbd7125fcd85e03661b
[thirdparty/openwrt.git] /
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
5 mechanism
6
7 See commit 511ce378e16f ("mmc: Add MMC host software queue support")
8
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.
13
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.
18
19 For bcm2835, and for workloads other than random read, HSQ is a wash in
20 terms of throughput and CPU load.
21
22 So, use it by default.
23
24 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
25 ---
26 drivers/mmc/host/Kconfig | 1 +
27 drivers/mmc/host/bcm2835-sdhost.c | 27 ++++++++++++++++++++++-----
28 2 files changed, 23 insertions(+), 5 deletions(-)
29
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
36 + select MMC_HSQ
37 help
38 This selects the SDHost controller on BCM2835/6.
39
40 --- a/drivers/mmc/host/bcm2835-sdhost.c
41 +++ b/drivers/mmc/host/bcm2835-sdhost.c
42 @@ -57,6 +57,7 @@
43
44 /* For mmc_card_blockaddr */
45 #include "../core/card.h"
46 +#include "mmc_hsq.h"
47
48 #define DRIVER_NAME "sdhost-bcm2835"
49
50 @@ -1891,13 +1892,16 @@ static void bcm2835_sdhost_tasklet_finis
51 mmc_hostname(host->mmc));
52 }
53
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);
58 }
59
60 -int bcm2835_sdhost_add_host(struct bcm2835_host *host)
61 +int bcm2835_sdhost_add_host(struct platform_device *pdev)
62 {
63 + struct bcm2835_host *host = platform_get_drvdata(pdev);
64 struct mmc_host *mmc;
65 + struct mmc_hsq *hsq;
66 struct dma_slave_config cfg;
67 char pio_limit_string[20];
68 int ret;
69 @@ -1992,6 +1996,16 @@ int bcm2835_sdhost_add_host(struct bcm28
70 goto untasklet;
71 }
72
73 + hsq = devm_kzalloc(&pdev->dev, sizeof(*hsq), GFP_KERNEL);
74 + if (!hsq) {
75 + ret = -ENOMEM;
76 + goto free_irq;
77 + }
78 +
79 + ret = mmc_hsq_init(hsq, host->mmc);
80 + if (ret)
81 + goto free_irq;
82 +
83 mmc_add_host(mmc);
84
85 pio_limit_string[0] = '\0';
86 @@ -2004,6 +2018,9 @@ int bcm2835_sdhost_add_host(struct bcm28
87
88 return 0;
89
90 +free_irq:
91 + free_irq(host->irq, host);
92 +
93 untasklet:
94 tasklet_kill(&host->finish_tasklet);
95
96 @@ -2134,12 +2151,12 @@ static int bcm2835_sdhost_probe(struct p
97
98 host->firmware_sets_cdiv = (msg[1] != ~0);
99
100 - ret = bcm2835_sdhost_add_host(host);
101 + platform_set_drvdata(pdev, host);
102 +
103 + ret = bcm2835_sdhost_add_host(pdev);
104 if (ret)
105 goto err;
106
107 - platform_set_drvdata(pdev, host);
108 -
109 pr_debug("bcm2835_sdhost_probe -> OK\n");
110
111 return 0;