[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <63c898e4-fedf-44eb-8887-ffda4a81e1e6@wanadoo.fr>
Date: Sat, 9 Mar 2024 08:19:57 +0100
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Andy Shevchenko <andy.shevchenko@...il.com>, linux-clk@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>, Heiko Stuebner <heiko@...ech.de>
Subject: Re: [PATCH v1 1/1] clk: fractional-divider: Move mask calculations
out of lock
Le 03/03/2024 à 13:14, Andy Shevchenko a écrit :
> There is no need to calculate masks under the lock taken.
> Move them out of it.
>
> Signed-off-by: Andy Shevchenko <andy.shevchenko@...il.com>
> ---
> drivers/clk/clk-fractional-divider.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/clk-fractional-divider.c b/drivers/clk/clk-fractional-divider.c
> index a0178182fc72..da057172cc90 100644
> --- a/drivers/clk/clk-fractional-divider.c
> +++ b/drivers/clk/clk-fractional-divider.c
> @@ -195,14 +195,14 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate,
> n--;
> }
>
> + mmask = GENMASK(fd->mwidth - 1, 0) << fd->mshift;
> + nmask = GENMASK(fd->nwidth - 1, 0) << fd->nshift;
> +
Hi,
if this is a hot path, you could maybe even compute:
mask = ~(GENMASK(fd->mwidth - 1, 0) << fd->mshift |
GENMASK(fd->nwidth - 1, 0) << fd->nshift)
unless gcc is smart enough to do it by itself.
> if (fd->lock)
> spin_lock_irqsave(fd->lock, flags);
> else
> __acquire(fd->lock);
>
> - mmask = GENMASK(fd->mwidth - 1, 0) << fd->mshift;
> - nmask = GENMASK(fd->nwidth - 1, 0) << fd->nshift;
> -
> val = clk_fd_readl(fd);
> val &= ~(mmask | nmask);
val &= mask;
> val |= (m << fd->mshift) | (n << fd->nshift);
and pre-compute "(m << fd->mshift) | (n << fd->nshift)" outside of the
lock too.
CJ
Powered by blists - more mailing lists