From: Albert Yang <yangzh0906@thundersoft.com>
To: Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Ge Gordon <gordon.ge@bst.ai>,
BST Linux Kernel Upstream Group <bst-upstream@bstai.top>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Ulf Hansson <ulf.hansson@linaro.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Arnd Bergmann <arnd@arndb.de>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-mmc@vger.kernel.org,
soc@lists.linux.dev, Albert Yang <yangzh0906@thundersoft.com>
Subject: [PATCH 6/9] mmc: sdhci: allow drivers to pre-allocate bounce buffer
Date: Tue, 23 Sep 2025 14:10:12 +0800 [thread overview]
Message-ID: <20250923-v4-patch-final-v1-6-2283ad7cbf88@thundersoft.com> (raw)
In-Reply-To: <20250923-v4-patch-final-v1-0-2283ad7cbf88@thundersoft.com>
In sdhci_allocate_bounce_buffer(), add an early path that respects a
driver-provided pre-allocated bounce buffer (host->bounce_buffer).
If the buffer is already allocated by the driver (e.g. coherent/SRAM
buffer needed for platforms with 32-bit DMA constraints), just compute
max_blocks from host->bounce_buffer_size and jump to the common "out"
path to set mmc->max_*.
This enables platform drivers to allocate the bounce buffer before
sdhci_add_host(), avoiding starting the host without the buffer ready
and aligning with the guidance from review.
No functional change for drivers that do not pre-allocate the buffer.
drivers/mmc/host/sdhci.c (sdhci_allocate_bounce_buffer): Handle
pre-allocated bounce buffer and fall through to set mmc->max_*.
Suggested-by: Adrian Hunter <adrian.hunter@intel.com>
Link: https://lore.kernel.org/lkml/2b23bcb9-abc7-4667-b939-a19ecae935a2@intel.com/
Signed-off-by: Albert Yang <yangzh0906@thundersoft.com>
---
Changes for v4:
- Add new patch by 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 3a17821efa5ca92c6c29141d8fcb9ebf58355cc7..03fbe30cb205e16b924481caa44f0979d230f380 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
next prev parent reply other threads:[~2025-09-23 6:46 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 6:10 [PATCH 0/9] arm64: introduce Black Sesame Technologies C1200 SoC and CDCU1.0 board Albert Yang
2025-09-23 6:10 ` [PATCH 1/9] dt-bindings: vendor-prefixes: Add Black Sesame Technologies Co., Ltd Albert Yang
2025-09-23 6:10 ` [PATCH 2/9] dt-bindings: arm: add Black Sesame Technologies (bst) SoC Albert Yang
2025-09-23 6:10 ` [PATCH 3/9] arm64: Kconfig: add ARCH_BST for Black Sesame Technologies SoCs Albert Yang
2025-09-23 6:10 ` [PATCH 4/9] dt-bindings: mmc: add binding for BST DWCMSHC SDHCI controller Albert Yang
2025-09-23 10:13 ` Rob Herring (Arm)
2025-10-15 9:31 ` Albert Yang
2025-09-23 13:56 ` Rob Herring
2025-09-26 3:06 ` [PATCH v4 4/9] dt-bindings: mmc: Add Black Sesame Technologies DWCMSHC SDHCI Albert Yang
2025-10-15 9:09 ` [PATCH 4/9] dt-bindings: mmc: add binding for BST DWCMSHC SDHCI controller Albert Yang
2025-09-23 6:10 ` [PATCH 5/9] mmc: sdhci: add Black Sesame Technologies BST C1200 controller driver Albert Yang
2025-09-29 13:25 ` Adrian Hunter
2025-09-23 6:10 ` Albert Yang [this message]
2025-09-29 13:26 ` [PATCH 6/9] mmc: sdhci: allow drivers to pre-allocate bounce buffer Adrian Hunter
2025-09-23 6:10 ` [PATCH 7/9] arm64: dts: bst: add support for Black Sesame Technologies C1200 CDCU1.0 board Albert Yang
2025-09-23 6:10 ` [PATCH 8/9] arm64: defconfig: enable BST platform and SDHCI controller support Albert Yang
2025-09-23 6:10 ` [PATCH 9/9] MAINTAINERS: add Black Sesame Technologies (BST) ARM SoC support Albert Yang
2025-09-29 13:29 ` Adrian Hunter
2025-10-15 7:30 ` Albert Yang
2025-09-25 7:06 ` [PATCH 0/9] arm64: introduce Black Sesame Technologies C1200 SoC and CDCU1.0 board Arnd Bergmann
2025-09-25 9:03 ` Albert Yang
2025-09-25 12:11 ` Albert Yang
2025-09-25 13:34 ` Ulf Hansson
2025-09-25 13:38 ` Arnd Bergmann
2025-09-26 1:48 ` Albert Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250923-v4-patch-final-v1-6-2283ad7cbf88@thundersoft.com \
--to=yangzh0906@thundersoft.com \
--cc=adrian.hunter@intel.com \
--cc=arnd@arndb.de \
--cc=bst-upstream@bstai.top \
--cc=catalin.marinas@arm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gordon.ge@bst.ai \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=robh@kernel.org \
--cc=soc@lists.linux.dev \
--cc=ulf.hansson@linaro.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).