From: sashiko-bot@kernel.org
To: "Robert Marko" <robert.marko@sartura.hr>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 3/6] mmc: sdhci-of-at91: add LAN969x support
Date: Mon, 07 Sep 2026 13:37:50 +0000 [thread overview]
Message-ID: <20260907133750.9DF481F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260907132617.1198548-4-robert.marko@sartura.hr>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing return value checks for clk_prepare_enable() in probe and resume paths.
- [High] Potential kernel panic due to division by zero if clock rates evaluate to zero.
--
commit cf8b24d3be560d75b9ef2a2a9fd88a1ce6dc9834
Author: Robert Marko <robert.marko@sartura.hr>
mmc: sdhci-of-at91: add LAN969x support
LAN969x uses the same internally generated base clock layout as SAM9X60,
but its SDMMC controller stops responding when runtime PM gates its clocks.
Add LAN969x-specific SoC data using the SAM9X60 clock layout and select the
option to leave its clocks enabled across runtime suspend.
> diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
> index b7e2a89da348a..e7affca8da25f 100644
> --- a/drivers/mmc/host/sdhci-of-at91.c
> +++ b/drivers/mmc/host/sdhci-of-at91.c
> @@ -158,9 +158,17 @@ static const struct sdhci_at91_soc_data soc_data_sam9x60 = {
> .divider_for_baseclk = 2,
> };
>
> +static const struct sdhci_at91_soc_data soc_data_lan969x = {
> + .pdata = &sdhci_sama5d2_pdata,
> + .baseclk_is_generated_internally = true,
> + .keep_clks_on = true,
> + .divider_for_baseclk = 2,
> +};
[Severity: High]
This isn't a bug introduced by this patch, but it exists in the baseline.
In sdhci_at91_probe() and sdhci_at91_runtime_resume(), the return values of
clk_prepare_enable() are ignored before accessing hardware registers.
For example, in sdhci_at91_probe():
clk_prepare_enable(priv->hclock);
sdhci_at91_set_clks_presets(&pdev->dev);
clk_prepare_enable(priv->mainck);
clk_prepare_enable(priv->gck);
And when restoring state in sdhci_at91_runtime_resume():
if (priv->restore_needed) {
if (!priv->soc_data->keep_clks_on)
clk_prepare_enable(priv->hclock);
sdhci_at91_set_clks_presets(dev);
if (!priv->soc_data->keep_clks_on) {
clk_prepare_enable(priv->mainck);
clk_prepare_enable(priv->gck);
}
If these clocks fail to enable, the driver silently proceeds to access hardware
registers via sdhci_at91_set_clks_presets() and subsequent MMIO operations.
Could this lead to a synchronous external abort and a kernel panic from
accessing unclocked peripheral registers? Furthermore, would ignoring these
failures cause unbalanced clock reference counts during cleanup?
[Severity: High]
This is a pre-existing issue, but the configuration here is used during clock
setup in sdhci_at91_set_clks_presets(), which might have a division by zero:
gck_rate = clk_get_rate(priv->gck);
if (priv->soc_data->baseclk_is_generated_internally)
clk_base_rate = gck_rate / priv->soc_data->divider_for_baseclk;
else
clk_base_rate = clk_get_rate(priv->mainck);
clk_base = clk_base_rate / 1000000;
clk_mul = gck_rate / clk_base_rate - 1;
If the clock is misconfigured in the device tree or fails to initialize,
clk_get_rate() can legitimately return 0. If clk_base_rate evaluates to 0,
will the computation of clk_mul trigger a kernel panic due to an unhandled
division by zero exception?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260907132617.1198548-1-robert.marko@sartura.hr?part=3
next prev parent reply other threads:[~2026-09-07 13:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 13:25 [PATCH v2 0/6] mmc: sdhci-of-at91: add LAN969x support Robert Marko
2026-09-07 13:25 ` [PATCH v2 1/6] dt-bindings: mmc: atmel,sama5d2-sdhci: add LAN969x compatible Robert Marko
2026-09-07 13:25 ` [PATCH v2 2/6] mmc: sdhci-of-at91: add option to keep clocks enabled Robert Marko
2026-09-07 13:36 ` sashiko-bot
2026-09-09 10:31 ` Adrian Hunter
2026-09-07 13:25 ` [PATCH v2 3/6] mmc: sdhci-of-at91: add LAN969x support Robert Marko
2026-09-07 13:37 ` sashiko-bot [this message]
2026-09-09 10:36 ` Adrian Hunter
2026-09-07 13:25 ` [PATCH v2 4/6] arm64: dts: microchip: lan969x: add SDMMC nodes Robert Marko
2026-09-07 13:58 ` Aubin Constans
2026-09-07 13:25 ` [PATCH v2 5/6] arm64: dts: microchip: ev23x71a: enable QSPI Robert Marko
2026-09-07 13:33 ` sashiko-bot
2026-09-07 13:25 ` [PATCH v2 6/6] arm64: dts: microchip: ev23x71a: enable eMMC Robert Marko
2026-09-07 14:18 ` Aubin Constans
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=20260907133750.9DF481F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robert.marko@sartura.hr \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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