From: sashiko-bot@kernel.org
To: "Benoît Monin" <benoit.monin@bootlin.com>
Cc: devicetree@vger.kernel.org, linux-phy@lists.infradead.org,
linux-usb@vger.kernel.org, linux-watchdog@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org, vkoul@kernel.org,
neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH 21/25] mmc: sdhci-of-dwcmshc: add MT2824 tuning and HS400 support
Date: Fri, 06 Nov 2026 09:59:05 +0000 [thread overview]
Message-ID: <sashiko-outbox-201165@kernel.org> (raw)
In-Reply-To: <20261106-mt2824-v1-21-86087eaf5af4@bootlin.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] mmc: sdhci-of-dwcmshc: improper HS400 PHY DLL handling in
mt2824_set_clock()
- [Medium] mmc: sdhci-of-dwcmshc: incomplete error rollback in
mt2824_execute_tuning()
- [Low] mmc: sdhci-of-dwcmshc: duplicate PHY DLL register macros for
MT2824
--
commit 6e69732340199284e68817329ed4f3bf3f474149
Author: Benoît Monin <benoit.monin@bootlin.com>
mmc: sdhci-of-dwcmshc: add MT2824 tuning and HS400 support
This commit adds software tuning over the 128-tap sampling delay line, a
filter for stray data interrupts during tuning, and manual PHY DLL locking
for HS400 mode on the Metanoia MT2824 controller.
> diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c
> index cb248fc572e21..324ae93295af0 100644
> --- a/drivers/mmc/host/sdhci-of-dwcmshc.c
> +++ b/drivers/mmc/host/sdhci-of-dwcmshc.c
[ ... ]
> @@ -98,6 +103,10 @@
> #define MT2824_PHY_TXSLEW_P_STROBE 0x3
> #define MT2824_PHY_SMPLDL_CNFG 0x0c
> #define MT2824_PHY_ATDL_CNFG 0x0c
> +#define MT2824_PHY_DLL_CNFG1 0x20
> +#define MT2824_PHY_DLLDL_CNFG 0x60
> +#define MT2824_PHY_DLL_LOCKED BIT(0)
> +#define MT2824_PHY_DLL_LOCK_ERR BIT(1)
[Severity: Low]
This isn't a bug, but these macros duplicate the Synopsys DWC MSHC PHY DLL
definitions already present in this file (PHY_DLL_CNFG1_SLVDLY_MASK /
PHY_DLL_CNFG1_SLVDLY, PHY_DLLDL_CNFG_SLV_INPSEL_MASK /
PHY_DLLDL_CNFG_SLV_INPSEL, DLL_LOCK_STS, and DLL_ERROR_STS), while
mt2824_set_dll() already uses the shared PHY_DLL_*_R register offsets.
[ ... ]
> @@ -2271,6 +2281,38 @@ static int mt2824_phy_init(struct sdhci_host *host, bool v1v8)
> return 0;
> }
>
> +/* HS400 needs the PHY DLL locked on the card clock; lock it by hand */
> +static void mt2824_set_dll(struct sdhci_host *host)
> +{
> + u16 clk;
> + u8 status;
> + int ret;
> +
> + clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
> + clk &= ~SDHCI_CLOCK_CARD_EN;
> + sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
> +
> + sdhci_writeb(host, MT2824_PHY_DLL_CNFG1, PHY_DLL_CNFG1_R);
> + sdhci_writeb(host, MT2824_PHY_DLLDL_CNFG, PHY_DLLDL_CNFG_R);
> +
> + sdhci_enable_clk(host, clk);
> + usleep_range(10, 20);
> +
> + sdhci_writeb(host, PHY_DLL_CTRL_ENABLE, PHY_DLL_CTRL_R);
> + ret = read_poll_timeout(sdhci_readb, status,
> + status & MT2824_PHY_DLL_LOCKED, 10, 150000,
> + false, host, PHY_DLL_STATUS_R);
> + if (ret) {
> + dev_err(mmc_dev(host->mmc), "PHY DLL did not lock: 0x%02x\n",
> + status);
> + return;
> + }
> +
> + if (status & MT2824_PHY_DLL_LOCK_ERR)
> + dev_err(mmc_dev(host->mmc), "PHY DLL locked with error: 0x%02x\n",
> + status);
> +}
[ ... ]
> @@ -2332,6 +2374,11 @@ static void mt2824_set_clock(struct sdhci_host *host, unsigned int clock)
> if (clock)
> mt2824_enable_clk(host, sdhci_calc_clk(host, clock,
> &mmc->actual_clock));
> +
> + if (clock && host->timing == MMC_TIMING_MMC_HS400) {
> + mt2824_set_dll(host);
> + dwcmshc_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
> + }
> }
[Severity: High]
Does mt2824_set_clock() try to lock the HS400 PHY DLL at 52 MHz and then
fail to re-lock it when the clock is raised to 200 MHz?
During HS400 selection in mmc_select_hs400() (and mmc_select_hs400es()),
the MMC core calls mmc_set_timing(host, MMC_TIMING_MMC_HS400) while
host->clock is still 52 MHz, before calling mmc_set_bus_speed(card) to
switch to 200 MHz. Because mt2824_set_clock() only checks for a non-zero
clock in MMC_TIMING_MMC_HS400, the first call enables PHY_DLL_CTRL_R at
52 MHz. Neither mt2824_set_clock() nor mt2824_set_dll() ever writes
PHY_DLL_CTRL_DISABLE to PHY_DLL_CTRL_R, so when mmc_set_bus_speed() later
calls mt2824_set_clock() at 200 MHz, the clock is stopped and changed
while the DLL stays enabled, and writing PHY_DLL_CTRL_ENABLE again never
creates a 0-to-1 enable transition to lock onto the 200 MHz clock.
Leaving HS400 (such as via mmc_hs400_to_hs200()) also leaves the DLL
enabled at lower speeds.
Should PHY_DLL_CTRL_R be disabled before changing the clock, and only
configured and enabled when host->timing is MMC_TIMING_MMC_HS400 and the
clock is above 52 MHz?
[ ... ]
> @@ -2460,6 +2507,156 @@ static void mt2824_hw_reset(struct sdhci_host *host)
[ ... ]
> + /*
> + * AT_CTRL_R must not be written while SAMPLE_CLK_SEL is set: enable
> + * software tuning first, then select the tuned sampling clock.
> + */
> + at_ctrl = sdhci_readl(host, at_ctrl_reg);
> + sdhci_writel(host, at_ctrl | AT_CTRL_SW_TUNE_EN, at_ctrl_reg);
> + ctrl2 = sdhci_readw(host, SDHCI_HOST_CONTROL2);
> + sdhci_writew(host, ctrl2 | SDHCI_CTRL_TUNED_CLK, SDHCI_HOST_CONTROL2);
> + /*
> + * That HOST_CONTROL2 write breaks the response of the next command:
> + * send one tuning command for nothing before the scan.
> + */
> + mmc_send_tuning(host->mmc, opcode, NULL);
> + host->ops->reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
[ ... ]
> +fail:
> + /* clear SAMPLE_CLK_SEL before AT_CTRL_R is written again */
> + sdhci_reset_tuning(host);
> + sdhci_writel(host, at_ctrl, at_ctrl_reg);
> + host->ops->reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
> + sdhci_end_tuning(host);
> + WRITE_ONCE(dwc_priv->flags, dwc_priv->flags & ~FLAG_SW_TUNING);
> + return ret;
> +}
[Severity: Medium]
If a re-tuning pass fails after an earlier tuning pass succeeded, does the
fail path leave AT_CTRL_SW_TUNE_EN enabled with the delay line stuck at the
last scanned phase?
A successful mt2824_execute_tuning() call leaves AT_CTRL_SW_TUNE_EN set in
at_ctrl_reg, so on a subsequent tuning run at_ctrl is read with
AT_CTRL_SW_TUNE_EN already set. If that scan fails, writing at_ctrl back
verbatim does not clear AT_CTRL_SW_TUNE_EN, leaving software tuning active
with DWCMSHC_AT_STAT set to phase 127. In addition, sdhci_reset_tuning()
modifies the low byte of SDHCI_HOST_CONTROL2 while the card clock is
enabled without a dummy command or stopping the card clock around the
reset, which on this controller breaks the response of the next command.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106-mt2824-v1-0-86087eaf5af4@bootlin.com?part=21
next prev parent reply other threads:[~2026-11-06 9:59 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 9:29 [PATCH 00/25] riscv: add support for the Metanoia MT2824 SoC and MT5824 EVB Benoît Monin
2026-11-06 9:29 ` [PATCH 01/25] dt-bindings: vendor-prefixes: add Metanoia Communications Benoît Monin
2026-11-06 9:35 ` sashiko-bot
2026-11-06 11:17 ` Krzysztof Kozlowski
2026-11-06 11:39 ` Mark Brown
2026-11-06 11:50 ` Krzysztof Kozlowski
2026-11-06 9:29 ` [PATCH 02/25] dt-bindings: riscv: add Metanoia SoC-based boards Benoît Monin
2026-11-06 9:35 ` sashiko-bot
2026-11-06 9:30 ` [PATCH 03/25] dt-bindings: reset: add Metanoia MT2824 Benoît Monin
2026-11-06 9:41 ` sashiko-bot
2026-11-06 11:19 ` Krzysztof Kozlowski
2026-11-06 9:30 ` [PATCH 04/25] dt-bindings: power: reset: add Metanoia MT2824 reboot Benoît Monin
2026-11-06 9:44 ` sashiko-bot
2026-11-06 11:23 ` Krzysztof Kozlowski
2026-11-06 9:30 ` [PATCH 05/25] dt-bindings: phy: add Metanoia USB2 PHY Benoît Monin
2026-11-06 9:42 ` sashiko-bot
2026-11-06 9:30 ` [PATCH 06/25] dt-bindings: cache: andestech,ax45mp-cache: add MT2824 compatible Benoît Monin
2026-11-06 9:35 ` sashiko-bot
2026-11-06 9:30 ` [PATCH 07/25] dt-bindings: interrupt-controller: sifive,plic-1.0.0: add Metanoia MT2824 Benoît Monin
2026-11-06 9:35 ` sashiko-bot
2026-11-06 9:30 ` [PATCH 08/25] dt-bindings: interrupt-controller: andestech,plicsw: " Benoît Monin
2026-11-06 9:35 ` sashiko-bot
2026-11-06 9:30 ` [PATCH 09/25] dt-bindings: timer: andestech,plmt0: " Benoît Monin
2026-11-06 9:36 ` sashiko-bot
2026-11-06 9:30 ` [PATCH 10/25] dt-bindings: mmc: snps,dwcmshc-sdhci: " Benoît Monin
2026-11-06 9:37 ` sashiko-bot
2026-11-06 9:30 ` [PATCH 11/25] dt-bindings: spi: andestech,ae350-spi: make DMA and interrupts optional Benoît Monin
2026-11-06 9:37 ` sashiko-bot
2026-11-06 11:11 ` Mark Brown
2026-11-06 11:49 ` Krzysztof Kozlowski
2026-11-06 9:30 ` [PATCH 12/25] dt-bindings: spi: andestech,ae350-spi: add Metanoia MT2824 Benoît Monin
2026-11-06 9:36 ` sashiko-bot
2026-11-06 9:30 ` [PATCH 13/25] dt-bindings: usb: dwc2: " Benoît Monin
2026-11-06 9:36 ` sashiko-bot
2026-11-06 11:54 ` Krzysztof Kozlowski
2026-11-06 9:30 ` [PATCH 14/25] dt-bindings: watchdog: andestech,ae350-wdt: " Benoît Monin
2026-11-06 9:36 ` sashiko-bot
2026-11-06 9:30 ` [PATCH 15/25] riscv: add ARCH_METANOIA Kconfig entry Benoît Monin
2026-11-06 9:38 ` sashiko-bot
2026-11-06 9:30 ` [PATCH 16/25] reset: simple: add Metanoia MT2824 support Benoît Monin
2026-11-06 9:38 ` sashiko-bot
2026-11-06 9:30 ` [PATCH 17/25] spi: atcspi200: add optional interrupt support Benoît Monin
2026-11-06 9:49 ` sashiko-bot
2026-11-06 9:30 ` [PATCH 18/25] spi: atcspi200: allow building for Metanoia SoCs Benoît Monin
2026-11-06 9:38 ` sashiko-bot
2026-11-06 9:30 ` [PATCH 19/25] watchdog: atcwdt200: " Benoît Monin
2026-11-06 9:43 ` sashiko-bot
2026-11-06 9:30 ` [PATCH 20/25] mmc: sdhci-of-dwcmshc: add MT2824 support Benoît Monin
2026-11-06 10:04 ` sashiko-bot
2026-11-06 9:30 ` [PATCH 21/25] mmc: sdhci-of-dwcmshc: add MT2824 tuning and HS400 support Benoît Monin
2026-11-06 9:59 ` sashiko-bot [this message]
2026-11-06 9:30 ` [PATCH 22/25] phy: metanoia: add USB2 PHY driver Benoît Monin
2026-11-06 9:41 ` sashiko-bot
2026-11-06 9:56 ` Philipp Zabel
2026-11-06 9:30 ` [PATCH 23/25] usb: dwc2: add support for Metanoia MT2824 Benoît Monin
2026-11-06 9:43 ` sashiko-bot
2026-11-06 11:52 ` Krzysztof Kozlowski
2026-11-06 11:52 ` Krzysztof Kozlowski
2026-11-06 9:30 ` [PATCH 24/25] riscv: add Metanoia MT2824 SoC and MT5824 EVB support Benoît Monin
2026-11-06 9:50 ` sashiko-bot
2026-11-06 10:04 ` Philipp Zabel
2026-11-06 11:21 ` Krzysztof Kozlowski
2026-11-06 18:30 ` Conor Dooley
2026-11-06 9:30 ` [PATCH 25/25] MAINTAINERS: add RISC-V Metanoia SoC support Benoît Monin
2026-11-06 11:22 ` Krzysztof Kozlowski
2026-11-06 18:19 ` Conor Dooley
2026-11-06 11:15 ` [PATCH 00/25] riscv: add support for the Metanoia MT2824 SoC and MT5824 EVB Mark Brown
2026-11-06 18:46 ` Conor Dooley
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=sashiko-outbox-201165@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=benoit.monin@bootlin.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@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