[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260123095342.272505-3-yangzh0906@thundersoft.com>
Date: Fri, 23 Jan 2026 17:53:38 +0800
From: Albert Yang <yangzh0906@...ndersoft.com>
To: Ulf Hansson <ulf.hansson@...aro.org>,
Adrian Hunter <adrian.hunter@...el.com>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Ge Gordon <gordon.ge@....ai>,
Arnd Bergmann <arnd@...db.de>
Cc: BST Linux Kernel Upstream Group <bst-upstream@...ai.top>,
linux-mmc@...r.kernel.org,
devicetree@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
Albert Yang <yangzh0906@...ndersoft.com>
Subject: [PATCH v5 2/6] 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@...el.com>
Signed-off-by: Albert Yang <yangzh0906@...ndersoft.com>
Acked-by: Adrian Hunter <adrian.hunter@...el.com>
---
Changes for v5:
- Split from platform series per Arnd's feedback
Changes for v4:
- New patch suggested by Adrian Hunter
---
drivers/mmc/host/sdhci.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index ac7e11f37af7..dc5960e72a38 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;
--
2.43.0
Powered by blists - more mailing lists