Skip to content

Commit 60781d6

Browse files
P33Mpopcornmix
authored andcommitted
mmc: bcm2835-sdhost: use Host Software Queueing mechanism
See commit 511ce37 ("mmc: Add MMC host software queue support") Introduced in 5.8, this feature lets the block layer issue up to 2 pending requests to the MMC layer which in certain cases can improve throughput, but in the case of this driver can significantly reduce context switching when performing random reads. On bcm2837 with a performant class A1 card, context switches under FIO random 4k reads go from ~8800 per second to ~5800, with a reduction in hardIRQs per second from ~5800 to ~4000. There is no appreciable difference in throughput. For bcm2835, and for workloads other than random read, HSQ is a wash in terms of throughput and CPU load. So, use it by default. Signed-off-by: Jonathan Bell <[email protected]>
1 parent 82db5ba commit 60781d6

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

drivers/mmc/host/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ config MMC_BCM2835_PIO_DMA_BARRIER
3737
config MMC_BCM2835_SDHOST
3838
tristate "Support for the SDHost controller on BCM2708/9"
3939
depends on ARCH_BCM2835
40+
select MMC_HSQ
4041
help
4142
This selects the SDHost controller on BCM2835/6.
4243

drivers/mmc/host/bcm2835-sdhost.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757

5858
/* For mmc_card_blockaddr */
5959
#include "../core/card.h"
60+
#include "mmc_hsq.h"
6061

6162
#define DRIVER_NAME "sdhost-bcm2835"
6263

@@ -1891,13 +1892,16 @@ static void bcm2835_sdhost_tasklet_finish(unsigned long param)
18911892
mmc_hostname(host->mmc));
18921893
}
18931894

1894-
mmc_request_done(host->mmc, mrq);
1895+
if (!mmc_hsq_finalize_request(host->mmc, mrq))
1896+
mmc_request_done(host->mmc, mrq);
18951897
log_event("TSK>", mrq, 0);
18961898
}
18971899

1898-
int bcm2835_sdhost_add_host(struct bcm2835_host *host)
1900+
int bcm2835_sdhost_add_host(struct platform_device *pdev)
18991901
{
1902+
struct bcm2835_host *host = platform_get_drvdata(pdev);
19001903
struct mmc_host *mmc;
1904+
struct mmc_hsq *hsq;
19011905
struct dma_slave_config cfg;
19021906
char pio_limit_string[20];
19031907
int ret;
@@ -1992,6 +1996,16 @@ int bcm2835_sdhost_add_host(struct bcm2835_host *host)
19921996
goto untasklet;
19931997
}
19941998

1999+
hsq = devm_kzalloc(&pdev->dev, sizeof(*hsq), GFP_KERNEL);
2000+
if (!hsq) {
2001+
ret = -ENOMEM;
2002+
goto free_irq;
2003+
}
2004+
2005+
ret = mmc_hsq_init(hsq, host->mmc);
2006+
if (ret)
2007+
goto free_irq;
2008+
19952009
mmc_add_host(mmc);
19962010

19972011
pio_limit_string[0] = '\0';
@@ -2004,6 +2018,9 @@ int bcm2835_sdhost_add_host(struct bcm2835_host *host)
20042018

20052019
return 0;
20062020

2021+
free_irq:
2022+
free_irq(host->irq, host);
2023+
20072024
untasklet:
20082025
tasklet_kill(&host->finish_tasklet);
20092026

@@ -2134,12 +2151,12 @@ static int bcm2835_sdhost_probe(struct platform_device *pdev)
21342151

21352152
host->firmware_sets_cdiv = (msg[1] != ~0);
21362153

2137-
ret = bcm2835_sdhost_add_host(host);
2154+
platform_set_drvdata(pdev, host);
2155+
2156+
ret = bcm2835_sdhost_add_host(pdev);
21382157
if (ret)
21392158
goto err;
21402159

2141-
platform_set_drvdata(pdev, host);
2142-
21432160
pr_debug("bcm2835_sdhost_probe -> OK\n");
21442161

21452162
return 0;

0 commit comments

Comments
 (0)