From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: Biju <biju.das.au@gmail.com>
Cc: Ulf Hansson <ulfh@kernel.org>,
Biju Das <biju.das.jz@bp.renesas.com>,
linux-mmc@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-kernel@vger.kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>,
Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: Re: [PATCH v24 03/15] mmc: renesas_sdhi: Add clk_mask field to support flexible clock divider widths
Date: Wed, 2 Sep 2026 12:54:04 +0200 [thread overview]
Message-ID: <apgATHptEbhkohZo@shikoro> (raw)
In-Reply-To: <20260820171657.62815-4-biju.das.jz@bp.renesas.com>
[-- Attachment #1: Type: text/plain, Size: 2614 bytes --]
Hi,
Sashiko found issues with your patch. I curated the list and left only those
which I see as valid. Please have a look at these issues.
Thank you and happy hacking,
Wolfram
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>
> Pre-existing issues:
> - [High] A very low or zero clock rate from the clock provider causes an infinite loop in `renesas_sdhi_set_clock`.
> --
>
> --- Patch [3]: [PATCH v24 03/15] mmc: renesas_sdhi: Add clk_mask field to support flexible clock divider widths ---
> commit 1c7318b14c028686fc8ca703eb8ac2be269937b6
> Author: Biju Das <biju.das.jz@bp.renesas.com>
>
> mmc: renesas_sdhi: Add clk_mask field to support flexible clock divider widths
>
> This patch introduces a clk_mask field in platform data to replace a hardcoded
> 32-bit clock mask, supporting 11-bit clock dividers on newer SoCs like the
> RZ/G3L. It updates renesas_sdhi_set_clock() to use the dynamic mask and sets
> up backward-compatible default mask values.
>
> > diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
> > index f9ec78d699f45..604d886e483c7 100644
> > --- a/drivers/mmc/host/renesas_sdhi_core.c
> > +++ b/drivers/mmc/host/renesas_sdhi_core.c
> [ ... ]
> > @@ -213,7 +213,7 @@ static void renesas_sdhi_set_clock(struct tmio_mmc_host *host,
> > * provided for actual_clock in renesas_sdhi_clk_update().
> > */
> > clk_margin = new_clock >> 10;
> > - for (clk = 0x80000080; new_clock + clk_margin >= (clock << 1); clk >>= 1)
> > + for (clk = host->pdata->clk_mask; new_clock + clk_margin >= (clock << 1); clk >>= 1)
>
> [Severity: High]
> This isn't a bug introduced by this patch, but does this loop risk an
> infinite hang if the clock provider returns a very low rate?
>
> In renesas_sdhi_set_clock(), if the clock provider supplies a rate smaller
> than the maximum divider, the division to calculate the initial clock value
> can evaluate to 0. Since 0 << 1 is still 0, the loop condition
> new_clock + clk_margin >= (clock << 1) will remain permanently true for any
> strictly positive new_clock value.
>
> Could this prevent the loop from ever terminating, causing an unrecoverable
> CPU hang? Should there be an additional safety check (such as clk != 0 or
> clock > 0) added to the loop condition to gracefully handle misbehaving
> clock providers?
>
> > clock <<= 1;
> >
> > /* 1/1 clock is option */
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260820171657.62815-1-biju.das.jz@bp.renesas.com?part=3
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-09-02 10:54 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 17:16 [PATCH v24 00/15] Add Renesas RZ/G3L SD/eMMC support Biju
2026-08-20 17:16 ` [PATCH v24 01/15] dt-bindings: mmc: renesas,sdhi: Document RZ/G3L (r9a08g046) SoC Biju
2026-09-02 10:45 ` Wolfram Sang
2026-08-20 17:16 ` [PATCH v24 02/15] mmc: renesas_sdhi: Clean up whitespace and add OF table sentinels Biju
2026-09-02 10:47 ` Wolfram Sang
2026-09-04 6:40 ` Biju Das
2026-08-20 17:16 ` [PATCH v24 03/15] mmc: renesas_sdhi: Add clk_mask field to support flexible clock divider widths Biju
2026-09-02 10:51 ` Wolfram Sang
2026-09-04 10:54 ` Biju Das
2026-09-02 10:54 ` Wolfram Sang [this message]
2026-09-04 11:03 ` Biju Das
2026-08-20 17:16 ` [PATCH v24 04/15] mmc: renesas_sdhi: Add max_divider field to support SoC-specific clock ranges Biju
2026-09-02 11:05 ` Wolfram Sang
2026-09-04 12:46 ` Biju Das
2026-08-20 17:16 ` [PATCH v24 05/15] mmc: renesas_sdhi: Add SDHI_SD_CLK_CTL_DIV1 macro for 1/1 option Biju
2026-09-02 11:06 ` Wolfram Sang
2026-08-20 17:16 ` [PATCH v24 06/15] mmc: renesas_sdhi: Make clock divider mask configurable Biju
2026-09-02 11:09 ` Wolfram Sang
2026-09-04 12:48 ` Biju Das
2026-08-20 17:16 ` [PATCH v24 07/15] mmc: renesas_sdhi: Add tuning delay support for RZ/G2L Biju
2026-09-03 9:30 ` Wolfram Sang
2026-09-04 14:47 ` Biju Das
2026-09-03 9:34 ` Wolfram Sang
2026-09-04 15:15 ` Biju Das
2026-08-20 17:16 ` [PATCH v24 08/15] mmc: renesas_sdhi: Add TMIO_MMC_INTERNAL_DIVIDER flag Biju
2026-09-03 9:37 ` Wolfram Sang
2026-09-03 9:43 ` Wolfram Sang
2026-08-20 17:16 ` [PATCH v24 09/15] mmc: renesas_sdhi: Add optional axis/axim reset controls Biju
2026-09-03 9:48 ` Wolfram Sang
2026-08-20 17:16 ` [PATCH v24 10/15] mmc: renesas_sdhi: Add write32_hook for CTL_SD_CARD_CLK_CTL register writes Biju
2026-09-03 10:30 ` Wolfram Sang
2026-09-03 10:32 ` Wolfram Sang
2026-08-20 17:16 ` [PATCH v24 11/15] mmc: renesas_sdhi: Add RZ/G3L SDHI support Biju
2026-09-03 12:01 ` Wolfram Sang
2026-08-20 17:16 ` [PATCH v24 12/15] mmc: renesas_sdhi: Save and restore IOVS across suspend/resume Biju
2026-08-20 17:16 ` [PATCH v24 13/15] mmc: renesas_sdhi: Make HS400 OSEL bit configurable per SoC Biju
2026-08-20 17:16 ` [PATCH v24 14/15] mmc: renesas_sdhi: Add RZ/G3L HS400 support Biju
2026-08-20 17:16 ` [PATCH v24 15/15] mmc: renesas_sdhi: Add HS400 enhanced strobe support for RZ/G3L Biju
2026-09-01 14:52 ` [PATCH v24 00/15] Add Renesas RZ/G3L SD/eMMC support Wolfram Sang
2026-09-03 20:11 ` Wolfram Sang
2026-09-04 2:24 ` Biju Das
2026-09-04 8:00 ` Geert Uytterhoeven
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=apgATHptEbhkohZo@shikoro \
--to=wsa+renesas@sang-engineering.com \
--cc=biju.das.au@gmail.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=geert+renesas@glider.be \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=ulfh@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).