summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Yang <yangzh0906@thundersoft.com>2026-01-23 12:53:38 +0300
committerUlf Hansson <ulf.hansson@linaro.org>2026-02-23 14:06:55 +0300
commitef7eb1a7094dbb5042ea1bed34193c1415fb9844 (patch)
treeef009fd28581f63ea1032ad5ba968ea494eb1ef4
parentd5159623162cc3d462ba1e661f8362c181756d65 (diff)
downloadlinux-ef7eb1a7094dbb5042ea1bed34193c1415fb9844.tar.xz
mmc: sdhci: allow drivers to pre-allocate bounce buffer
Allow platform drivers to pre-allocate bounce buffer by checking if host->bounce_buffer is already set before attempting allocation. This enables platforms with specific DMA constraints (such as 32-bit DMA on controllers that cannot access high memory) to use their own reserved memory regions for the bounce buffer. Suggested-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Albert Yang <yangzh0906@thundersoft.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/host/sdhci.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 1ff15fa9b042..b1a3cd574c84 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -4193,6 +4193,12 @@ static void sdhci_allocate_bounce_buffer(struct sdhci_host *host)
unsigned int bounce_size;
int ret;
+ /* Drivers may have already allocated the buffer */
+ if (host->bounce_buffer) {
+ bounce_size = host->bounce_buffer_size;
+ max_blocks = bounce_size / 512;
+ goto out;
+ }
/*
* Cap the bounce buffer at 64KB. Using a bigger bounce buffer
* has diminishing returns, this is probably because SD/MMC
@@ -4241,6 +4247,7 @@ static void sdhci_allocate_bounce_buffer(struct sdhci_host *host)
host->bounce_buffer_size = bounce_size;
+out:
/* Lie about this since we're bouncing */
mmc->max_segs = max_blocks;
mmc->max_seg_size = bounce_size;