Skip to content

Commit c3dccb7

Browse files
linuswstorulf
authored andcommitted
mmc: core: Delete bounce buffer Kconfig option
This option is activated by all multiplatform configs and what not so we almost always have it turned on, and the memory it saves is negligible, even more so moving forward. The actual bounce buffer only gets allocated only when used, the only thing the ifdefs are saving is a little bit of code. It is highly improper to have this as a Kconfig option that get turned on by Kconfig, make this a pure runtime-thing and let the host decide whether we use bounce buffers. We add a new property "disable_bounce" to the host struct. Notice that mmc_queue_calc_bouncesz() already disables the bounce buffers if host->max_segs != 1, so any arch that has a maximum number of segments higher than 1 will have bounce buffers disabled. The option CONFIG_MMC_BLOCK_BOUNCE is default y so the majority of platforms in the kernel already have it on, and it then gets turned off at runtime since most of these have a host->max_segs > 1. The few exceptions that have host->max_segs == 1 and still turn off the bounce buffering are those that disable it in their defconfig. Those are the following: arch/arm/configs/colibri_pxa300_defconfig arch/arm/configs/zeus_defconfig - Uses MMC_PXA, drivers/mmc/host/pxamci.c - Sets host->max_segs = NR_SG, which is 1 - This needs its bounce buffer deactivated so we set host->disable_bounce to true in the host driver arch/arm/configs/davinci_all_defconfig - Uses MMC_DAVINCI, drivers/mmc/host/davinci_mmc.c - This driver sets host->max_segs to MAX_NR_SG, which is 16 - That means this driver anyways disabled bounce buffers - No special action needed for this platform arch/arm/configs/lpc32xx_defconfig arch/arm/configs/nhk8815_defconfig arch/arm/configs/u300_defconfig - Uses MMC_ARMMMCI, drivers/mmc/host/mmci.[c|h] - This driver by default sets host->max_segs to NR_SG, which is 128, unless a DMA engine is used, and in that case the number of segments are also > 1 - That means this driver already disables bounce buffers - No special action needed for these platforms arch/arm/configs/sama5_defconfig - Uses MMC_SDHCI, MMC_SDHCI_PLTFM, MMC_SDHCI_OF_AT91, MMC_ATMELMCI - Uses drivers/mmc/host/sdhci.c - Normally sets host->max_segs to SDHCI_MAX_SEGS which is 128 and thus disables bounce buffers - Sets host->max_segs to 1 if SDHCI_USE_SDMA is set - SDHCI_USE_SDMA is only set by SDHCI on PCI adapers - That means that for this platform bounce buffers are already disabled at runtime - No special action needed for this platform arch/blackfin/configs/CM-BF533_defconfig arch/blackfin/configs/CM-BF537E_defconfig - Uses MMC_SPI (a simple MMC card connected on SPI pins) - Uses drivers/mmc/host/mmc_spi.c - Sets host->max_segs to MMC_SPI_BLOCKSATONCE which is 128 - That means this platform already disables bounce buffers at runtime - No special action needed for these platforms arch/mips/configs/cavium_octeon_defconfig - Uses MMC_CAVIUM_OCTEON, drivers/mmc/host/cavium.c - Sets host->max_segs to 16 or 1 - Setting host->disable_bounce to be sure for the 1 case arch/mips/configs/qi_lb60_defconfig - Uses MMC_JZ4740, drivers/mmc/host/jz4740_mmc.c - This sets host->max_segs to 128 so bounce buffers are already runtime disabled - No action needed for this platform It would be interesting to come up with a list of the platforms that actually end up using bounce buffers. I have not been able to infer such a list, but it occurs when host->max_segs == 1 and the bounce buffering is not explicitly disabled. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 9d08428 commit c3dccb7

File tree

5 files changed

+10
-34
lines changed

5 files changed

+10
-34
lines changed

drivers/mmc/core/Kconfig

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,6 @@ config MMC_BLOCK_MINORS
6161

6262
If unsure, say 8 here.
6363

64-
config MMC_BLOCK_BOUNCE
65-
bool "Use bounce buffer for simple hosts"
66-
depends on MMC_BLOCK
67-
default y
68-
help
69-
SD/MMC is a high latency protocol where it is crucial to
70-
send large requests in order to get high performance. Many
71-
controllers, however, are restricted to continuous memory
72-
(i.e. they can't do scatter-gather), something the kernel
73-
rarely can provide.
74-
75-
Say Y here to help these restricted hosts by bouncing
76-
requests back and forth from a large buffer. You will get
77-
a big performance gain at the cost of up to 64 KiB of
78-
physical memory.
79-
80-
If unsure, say Y here.
81-
8264
config SDIO_UART
8365
tristate "SDIO UART/GPS class support"
8466
depends on TTY

drivers/mmc/core/queue.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ static struct mmc_queue_req *mmc_queue_alloc_mqrqs(int qdepth)
219219
return mqrq;
220220
}
221221

222-
#ifdef CONFIG_MMC_BLOCK_BOUNCE
223222
static int mmc_queue_alloc_bounce_bufs(struct mmc_queue_req *mqrq, int qdepth,
224223
unsigned int bouncesz)
225224
{
@@ -258,7 +257,7 @@ static unsigned int mmc_queue_calc_bouncesz(struct mmc_host *host)
258257
{
259258
unsigned int bouncesz = MMC_QUEUE_BOUNCESZ;
260259

261-
if (host->max_segs != 1)
260+
if (host->max_segs != 1 || (host->caps & MMC_CAP_NO_BOUNCE_BUFF))
262261
return 0;
263262

264263
if (bouncesz > host->max_req_size)
@@ -273,18 +272,6 @@ static unsigned int mmc_queue_calc_bouncesz(struct mmc_host *host)
273272

274273
return bouncesz;
275274
}
276-
#else
277-
static inline bool mmc_queue_alloc_bounce(struct mmc_queue_req *mqrq,
278-
int qdepth, unsigned int bouncesz)
279-
{
280-
return false;
281-
}
282-
283-
static unsigned int mmc_queue_calc_bouncesz(struct mmc_host *host)
284-
{
285-
return 0;
286-
}
287-
#endif
288275

289276
static int mmc_queue_alloc_sgs(struct mmc_queue_req *mqrq, int qdepth,
290277
int max_segs)

drivers/mmc/host/cavium.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,10 +1035,12 @@ int cvm_mmc_of_slot_probe(struct device *dev, struct cvm_mmc_host *host)
10351035
* We only have a 3.3v supply, we cannot support any
10361036
* of the UHS modes. We do support the high speed DDR
10371037
* modes up to 52MHz.
1038+
*
1039+
* Disable bounce buffers for max_segs = 1
10381040
*/
10391041
mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
10401042
MMC_CAP_ERASE | MMC_CAP_CMD23 | MMC_CAP_POWER_OFF_CARD |
1041-
MMC_CAP_3_3V_DDR;
1043+
MMC_CAP_3_3V_DDR | MMC_CAP_NO_BOUNCE_BUFF;
10421044

10431045
if (host->use_sg)
10441046
mmc->max_segs = 16;

drivers/mmc/host/pxamci.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,11 @@ static int pxamci_probe(struct platform_device *pdev)
702702

703703
pxamci_init_ocr(host);
704704

705-
mmc->caps = 0;
705+
/*
706+
* This architecture used to disable bounce buffers through its
707+
* defconfig, now it is done at runtime as a host property.
708+
*/
709+
mmc->caps = MMC_CAP_NO_BOUNCE_BUFF;
706710
host->cmdat = 0;
707711
if (!cpu_is_pxa25x()) {
708712
mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ;

include/linux/mmc/host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ struct mmc_host {
271271
#define MMC_CAP_UHS_SDR50 (1 << 18) /* Host supports UHS SDR50 mode */
272272
#define MMC_CAP_UHS_SDR104 (1 << 19) /* Host supports UHS SDR104 mode */
273273
#define MMC_CAP_UHS_DDR50 (1 << 20) /* Host supports UHS DDR50 mode */
274+
#define MMC_CAP_NO_BOUNCE_BUFF (1 << 21) /* Disable bounce buffers on host */
274275
#define MMC_CAP_DRIVER_TYPE_A (1 << 23) /* Host supports Driver Type A */
275276
#define MMC_CAP_DRIVER_TYPE_C (1 << 24) /* Host supports Driver Type C */
276277
#define MMC_CAP_DRIVER_TYPE_D (1 << 25) /* Host supports Driver Type D */

0 commit comments

Comments
 (0)