Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 04/13] mmc: meson-gx: Fail request when descriptor chain DMA mapping fails
       [not found] <20261123191703.179283-1-lee@kernel.org>
@ 2026-11-23 19:15 ` Lee Jones
  2026-11-23 19:15 ` [PATCH 13/13] mmc: sdhci-brcmstb: Handle absent optional sdio_freq clock in probe Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2026-11-23 19:15 UTC (permalink / raw)
  To: lee, Ulf Hansson, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Heiner Kallweit, linux-mmc, linux-arm-kernel,
	linux-amlogic, linux-kernel
  Cc: stable

meson_mmc_pre_req() flags eligible transfers with
SD_EMMC_DESC_CHAIN_MODE before mapping the scatterlist with
dma_map_sg().  If dma_map_sg() fails and returns 0, meson_mmc_pre_req()
logs an error but leaves SD_EMMC_DESC_CHAIN_MODE set with
data->sg_count equal to 0.  When meson_mmc_request() subsequently
dispatches the transfer to meson_mmc_desc_chain_transfer(), the
for_each_sg() loop executes zero iterations and
desc[data->sg_count - 1].cmd_cfg writes to desc[-1], corrupting memory
immediately preceding the coherent descriptor buffer before starting the
DMA engine.

Check that data->sg_count is non-zero before starting a descriptor chain
request in meson_mmc_request() and complete the request with -EINVAL if
mapping failed.

Fixes: 79ed05e329c3 ("mmc: meson-gx: add support for descriptor chain mode")
Closes: https://sashiko.dev/#/bug/linux-e22e5db6-4232-447c-82b0-6850ad48d2a2
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/mmc/host/meson-gx-mmc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
index d2b9b5df9596..f859d9ac0a0a 100644
--- a/drivers/mmc/host/meson-gx-mmc.c
+++ b/drivers/mmc/host/meson-gx-mmc.c
@@ -914,6 +914,13 @@ static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
 	if (host->needs_pre_post_req)
 		meson_mmc_pre_req(mmc, mrq);
 
+	if (mrq->data && meson_mmc_desc_chain_mode(mrq->data) &&
+	    !mrq->data->sg_count) {
+		mrq->cmd->error = -EINVAL;
+		mmc_request_done(mmc, mrq);
+		return;
+	}
+
 	/* Stop execution */
 	writel(0, host->regs + SD_EMMC_START);
 
-- 
2.56.1.750.gf70dc682cf-goog



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 13/13] mmc: sdhci-brcmstb: Handle absent optional sdio_freq clock in probe
       [not found] <20261123191703.179283-1-lee@kernel.org>
  2026-11-23 19:15 ` [PATCH 04/13] mmc: meson-gx: Fail request when descriptor chain DMA mapping fails Lee Jones
@ 2026-11-23 19:15 ` Lee Jones
  2026-11-23 19:31   ` Florian Fainelli
  1 sibling, 1 reply; 3+ messages in thread
From: Lee Jones @ 2026-11-23 19:15 UTC (permalink / raw)
  To: lee, Adrian Hunter, Kamal Dasu, Al Cooper,
	Broadcom internal kernel review list, Ulf Hansson,
	Florian Fainelli, linux-mmc, linux-arm-kernel, linux-kernel
  Cc: stable

Standard MMC Device Tree nodes may specify "clock-frequency" on SoCs
that do not provide the optional 72116B0 "sdio_freq" clock, in which
case devm_clk_get_optional() legitimately returns NULL.  However,
sdhci_brcmstb_probe() only checks IS_ERR(base_clk): when base_clk is
NULL, clk_get_rate(base_clk) evaluates to 0 and overwrites
SDHCI_CLOCK_V3_BASE_MASK in host->caps with 0 MHz while leaving
priv->base_freq_hz non-zero for system resume.

Check IS_ERR_OR_NULL(base_clk) and clear priv->base_freq_hz on the
fallback path before jumping to add_host.

Fixes: 97904a59855c ("mmc: sdhci-brcmstb: Add ability to increase max clock rate for 72116b0")
Closes: https://sashiko.dev/#/bug/linux-88799a75-1ece-4f9d-bdab-eeb713627ab2
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/mmc/host/sdhci-brcmstb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c
index db857f2273e2..976cddb2ca9e 100644
--- a/drivers/mmc/host/sdhci-brcmstb.c
+++ b/drivers/mmc/host/sdhci-brcmstb.c
@@ -585,8 +585,10 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 		goto add_host;
 
 	base_clk = devm_clk_get_optional(&pdev->dev, "sdio_freq");
-	if (IS_ERR(base_clk)) {
-		dev_warn(&pdev->dev, "Clock for \"sdio_freq\" not found\n");
+	if (IS_ERR_OR_NULL(base_clk)) {
+		if (IS_ERR(base_clk))
+			dev_warn(&pdev->dev, "Clock for \"sdio_freq\" not found\n");
+		priv->base_freq_hz = 0;
 		goto add_host;
 	}
 
-- 
2.56.1.750.gf70dc682cf-goog



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 13/13] mmc: sdhci-brcmstb: Handle absent optional sdio_freq clock in probe
  2026-11-23 19:15 ` [PATCH 13/13] mmc: sdhci-brcmstb: Handle absent optional sdio_freq clock in probe Lee Jones
@ 2026-11-23 19:31   ` Florian Fainelli
  0 siblings, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2026-11-23 19:31 UTC (permalink / raw)
  To: Lee Jones, Adrian Hunter, Kamal Dasu, Al Cooper,
	Broadcom internal kernel review list, Ulf Hansson, linux-mmc,
	linux-arm-kernel, linux-kernel
  Cc: stable



On 11/23/2026 11:15 AM, Lee Jones wrote:
> Standard MMC Device Tree nodes may specify "clock-frequency" on SoCs
> that do not provide the optional 72116B0 "sdio_freq" clock, in which
> case devm_clk_get_optional() legitimately returns NULL.  However,
> sdhci_brcmstb_probe() only checks IS_ERR(base_clk): when base_clk is
> NULL, clk_get_rate(base_clk) evaluates to 0 and overwrites
> SDHCI_CLOCK_V3_BASE_MASK in host->caps with 0 MHz while leaving
> priv->base_freq_hz non-zero for system resume.
> 
> Check IS_ERR_OR_NULL(base_clk) and clear priv->base_freq_hz on the
> fallback path before jumping to add_host.
> 
> Fixes: 97904a59855c ("mmc: sdhci-brcmstb: Add ability to increase max clock rate for 72116b0")
> Closes: https://sashiko.dev/#/bug/linux-88799a75-1ece-4f9d-bdab-eeb713627ab2
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>

Not sure this deserves a Fixes: tag.
-- 
Florian



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-23 19:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20261123191703.179283-1-lee@kernel.org>
2026-11-23 19:15 ` [PATCH 04/13] mmc: meson-gx: Fail request when descriptor chain DMA mapping fails Lee Jones
2026-11-23 19:15 ` [PATCH 13/13] mmc: sdhci-brcmstb: Handle absent optional sdio_freq clock in probe Lee Jones
2026-11-23 19:31   ` Florian Fainelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox