[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <acd73e05-fb8d-46f4-aa8e-e475685e5a18@intel.com>
Date: Mon, 29 Sep 2025 16:26:11 +0300
From: Adrian Hunter <adrian.hunter@...el.com>
To: Albert Yang <yangzh0906@...ndersoft.com>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
Ge Gordon <gordon.ge@....ai>, BST Linux Kernel Upstream Group
<bst-upstream@...ai.top>, Catalin Marinas <catalin.marinas@....com>, "Will
Deacon" <will@...nel.org>, Ulf Hansson <ulf.hansson@...aro.org>, Arnd
Bergmann <arnd@...db.de>
CC: <devicetree@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>, <linux-mmc@...r.kernel.org>,
<soc@...ts.linux.dev>
Subject: Re: [PATCH 6/9] mmc: sdhci: allow drivers to pre-allocate bounce
buffer
On 23/09/2025 09:10, Albert Yang wrote:
> 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@...el.com>
> Link: https://lore.kernel.org/lkml/2b23bcb9-abc7-4667-b939-a19ecae935a2@intel.com/
> Signed-off-by: Albert Yang <yangzh0906@...ndersoft.com>
This patch needs to come before patch 5 because patch 5 depends on it.
Otherwise:
Acked-by: Adrian Hunter <adrian.hunter@...el.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;
>
Powered by blists - more mailing lists