From: Jerome Brunet <jbrunet@baylibre.com>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
Neil Armstrong <neil.armstrong@linaro.org>,
Kevin Hilman <khilman@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] mmc: meson-gx: fix wrong conversion of __bf_shf to __ffs
Date: Mon, 12 Aug 2024 14:23:48 +0200 [thread overview]
Message-ID: <1j8qx2x73f.fsf@starbuckisacylon.baylibre.com> (raw)
In-Reply-To: <20240812115515.20158-1-ansuelsmth@gmail.com> (Christian Marangi's message of "Mon, 12 Aug 2024 13:55:10 +0200")
On Mon 12 Aug 2024 at 13:55, Christian Marangi <ansuelsmth@gmail.com> wrote:
> Commit 795c633f6093 ("mmc: meson-gx: fix __ffsdi2 undefined on arm32")
> changed __bf_shf to __ffs to fix a compile error on 32bit arch that have
> problems with __ffsdi2. This comes from the fact that __bf_shf use
> __builtin_ffsll and on 32bit __ffsdi2 is missing.
>
> Problem is that __bf_shf is defined as
>
> #define __bf_shf(x) (__builtin_ffsll(x) - 1)
>
> but the patch doesn't account for the - 1.
>
> Fix this by using the __builtin_ffs and add the - 1 to reflect the
> original implementation.
>
> The commit also converted other entry of __bf_shf in the code but those
> got dropped in later patches.
>
> Fixes: 795c633f6093 ("mmc: meson-gx: fix __ffsdi2 undefined on arm32")
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Hi Christian,
Are you fixing an actual problem you've seen with the platform and or
this solely based on the original commit description ?
If I dump the shift values with what we have right now, on sm1 at least
* Mux shift is 6
* Div shift is 0
This is aligned with the datasheet and has been working for while now.
> Cc: stable@vger.kernel.org # see patch description, needs adjustements for < 5.2
> ---
> drivers/mmc/host/meson-gx-mmc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
> index c7c067b9415a..8f64083a08fa 100644
> --- a/drivers/mmc/host/meson-gx-mmc.c
> +++ b/drivers/mmc/host/meson-gx-mmc.c
> @@ -464,7 +464,7 @@ static int meson_mmc_clk_init(struct meson_host *host)
> init.num_parents = MUX_CLK_NUM_PARENTS;
>
> mux->reg = host->regs + SD_EMMC_CLOCK;
> - mux->shift = __ffs(CLK_SRC_MASK);
> + mux->shift = __builtin_ffs(CLK_SRC_MASK) - 1;
> mux->mask = CLK_SRC_MASK >> mux->shift;
> mux->hw.init = &init;
>
> @@ -486,7 +486,7 @@ static int meson_mmc_clk_init(struct meson_host *host)
> init.num_parents = 1;
>
> div->reg = host->regs + SD_EMMC_CLOCK;
> - div->shift = __ffs(CLK_DIV_MASK);
> + div->shift = __builtin_ffs(CLK_DIV_MASK) - 1;
> div->width = __builtin_popcountl(CLK_DIV_MASK);
> div->hw.init = &init;
> div->flags = CLK_DIVIDER_ONE_BASED;
--
Jerome
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
prev parent reply other threads:[~2024-08-12 12:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-12 11:55 Christian Marangi
2024-08-12 12:23 ` Jerome Brunet [this message]
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=1j8qx2x73f.fsf@starbuckisacylon.baylibre.com \
--to=jbrunet@baylibre.com \
--cc=ansuelsmth@gmail.com \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.org \
--cc=stable@vger.kernel.org \
--cc=ulf.hansson@linaro.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
all inboxes | Powered by JetHome®