lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 17 Jul 2023 16:14:58 +0200
From:   Maxime Ripard <mripard@...nel.org>
To:     Frank Oltmanns <frank@...manns.dev>
Cc:     Michael Turquette <mturquette@...libre.com>,
        Stephen Boyd <sboyd@...nel.org>, Chen-Yu Tsai <wens@...e.org>,
        Jernej Skrabec <jernej.skrabec@...il.com>,
        Samuel Holland <samuel@...lland.org>,
        Andre Przywara <andre.przywara@....com>,
        Roman Beranek <me@...y.cz>, linux-clk@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, linux-sunxi@...ts.linux.dev,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 08/11] clk: sunxi-ng: nkm: Support finding closest rate

On Mon, Jul 17, 2023 at 03:34:32PM +0200, Frank Oltmanns wrote:
> When finding the best rate for a NKM clock, consider rates that are
> higher than the requested rate, if the CCU_FEATURE_CLOSEST_RATE flag is
> set by using the helper function ccu_is_better_rate().
> 
> Accommodate ccu_mux_helper_determine_rate to this change.
> 
> Signed-off-by: Frank Oltmanns <frank@...manns.dev>
> ---
>  drivers/clk/sunxi-ng/ccu_mux.c |  2 +-
>  drivers/clk/sunxi-ng/ccu_nkm.c | 18 ++++++++----------
>  2 files changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/clk/sunxi-ng/ccu_mux.c b/drivers/clk/sunxi-ng/ccu_mux.c
> index 1d557e323169..3ca695439620 100644
> --- a/drivers/clk/sunxi-ng/ccu_mux.c
> +++ b/drivers/clk/sunxi-ng/ccu_mux.c
> @@ -139,7 +139,7 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common,
>  			goto out;
>  		}
>  
> -		if ((req->rate - tmp_rate) < (req->rate - best_rate)) {
> +		if (ccu_is_better_rate(common, req->rate, tmp_rate, best_rate)) {
>  			best_rate = tmp_rate;
>  			best_parent_rate = parent_rate;
>  			best_parent = parent;
> diff --git a/drivers/clk/sunxi-ng/ccu_nkm.c b/drivers/clk/sunxi-ng/ccu_nkm.c
> index 793160bc2d47..5439b9351cd7 100644
> --- a/drivers/clk/sunxi-ng/ccu_nkm.c
> +++ b/drivers/clk/sunxi-ng/ccu_nkm.c
> @@ -39,6 +39,7 @@ static unsigned long ccu_nkm_optimal_parent_rate(unsigned long rate, unsigned lo
>  }
>  
>  static unsigned long ccu_nkm_find_best_with_parent_adj(struct clk_hw *phw, struct _ccu_nkm *nkm,
> +						       struct ccu_common *common,
>  						       unsigned long *parent, unsigned long rate)
>  {
>  	unsigned long best_rate = 0, best_parent_rate = *parent, tmp_parent = *parent;
> @@ -54,10 +55,8 @@ static unsigned long ccu_nkm_find_best_with_parent_adj(struct clk_hw *phw, struc
>  				tmp_parent = clk_hw_round_rate(phw, tmp_parent);
>  
>  				tmp_rate = tmp_parent * _n * _k / _m;
> -				if (tmp_rate > rate)
> -					continue;
>  
> -				if ((rate - tmp_rate) < (rate - best_rate)) {
> +				if (ccu_is_better_rate(common, rate, tmp_rate, best_rate)) {
>  					best_rate = tmp_rate;
>  					best_parent_rate = tmp_parent;
>  					best_n = _n;
> @@ -78,7 +77,7 @@ static unsigned long ccu_nkm_find_best_with_parent_adj(struct clk_hw *phw, struc
>  }
>  
>  static unsigned long ccu_nkm_find_best(unsigned long parent, unsigned long rate,
> -				       struct _ccu_nkm *nkm)
> +				       struct _ccu_nkm *nkm, struct ccu_common *common)

Same comment than on patch 7, common should be first in those two functions.

Once fixed,
Acked-by: Maxime Ripard <mripard@...nel.org>

Maxime

Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ