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]
Message-ID: <c7f1fb05a6b7703ab18770bb5b58af0c58154f1f.camel@gmail.com>
Date: Mon, 11 Aug 2025 18:00:47 +0200
From: Alexander Sverdlin <alexander.sverdlin@...il.com>
To: bmasney@...hat.com, Michael Turquette <mturquette@...libre.com>, Stephen
 Boyd <sboyd@...nel.org>, Sudeep Holla <sudeep.holla@....com>, Cristian
 Marussi	 <cristian.marussi@....com>, Chen Wang <unicorn_wang@...look.com>,
 Inochi Amaoto	 <inochiama@...il.com>, Nicolas Ferre
 <nicolas.ferre@...rochip.com>,  Alexandre Belloni
 <alexandre.belloni@...tlin.com>, Claudiu Beznea <claudiu.beznea@...on.dev>,
 Paul Cercueil	 <paul@...pouillou.net>, Keguang Zhang
 <keguang.zhang@...il.com>, Taichi Sugaya	 <sugaya.taichi@...ionext.com>,
 Takao Orito <orito.takao@...ionext.com>,  Shawn Guo <shawnguo@...nel.org>,
 Sascha Hauer <s.hauer@...gutronix.de>, Pengutronix Kernel Team	
 <kernel@...gutronix.de>, Fabio Estevam <festevam@...il.com>, Jacky Huang	
 <ychuang3@...oton.com>, Shan-Chun Hung <schung@...oton.com>, Vladimir
 Zapolskiy	 <vz@...ia.com>, Piotr Wojtaszczyk
 <piotr.wojtaszczyk@...esys.com>, Paul Walmsley <paul.walmsley@...ive.com>,
 Samuel Holland <samuel.holland@...ive.com>, Yixun Lan	 <dlan@...too.org>,
 Steen Hegelund <Steen.Hegelund@...rochip.com>, Daniel Machon	
 <daniel.machon@...rochip.com>, UNGLinuxDriver@...rochip.com, Orson Zhai	
 <orsonzhai@...il.com>, Baolin Wang <baolin.wang@...ux.alibaba.com>, Chunyan
 Zhang <zhang.lyra@...il.com>, Maxime Coquelin <mcoquelin.stm32@...il.com>,
 Alexandre Torgue	 <alexandre.torgue@...s.st.com>, Michal Simek
 <michal.simek@....com>, Maxime Ripard <mripard@...nel.org>, Andreas
 Färber <afaerber@...e.de>,  Manivannan Sadhasivam	
 <mani@...nel.org>, Sven Peter <sven@...nel.org>, Janne Grunau
 <j@...nau.net>,  Alyssa Rosenzweig <alyssa@...enzweig.io>, Neal Gompa
 <neal@...pa.dev>, Eugeniy Paltsev <Eugeniy.Paltsev@...opsys.com>,  Ray Jui
 <rjui@...adcom.com>, Scott Branden <sbranden@...adcom.com>, Broadcom
 internal kernel review list <bcm-kernel-feedback-list@...adcom.com>, Max
 Filippov <jcmvbkbc@...il.com>, Matthias Brugger	 <matthias.bgg@...il.com>,
 AngeloGioacchino Del Regno	 <angelogioacchino.delregno@...labora.com>,
 Daniel Palmer <daniel@...ngy.jp>,  Romain Perier <romain.perier@...il.com>,
 Andrew Lunn <andrew@...n.ch>, Gregory Clement	
 <gregory.clement@...tlin.com>, Sebastian Hesselbarth	
 <sebastian.hesselbarth@...il.com>, Bjorn Andersson <andersson@...nel.org>, 
 Geert Uytterhoeven <geert+renesas@...der.be>, Heiko Stuebner
 <heiko@...ech.de>, Andrea della Porta <andrea.porta@...e.com>,  Krzysztof
 Kozlowski	 <krzk@...nel.org>, Sylwester Nawrocki <s.nawrocki@...sung.com>,
 Chanwoo Choi	 <cw00.choi@...sung.com>, Alim Akhtar
 <alim.akhtar@...sung.com>, Qin Jian	 <qinjian@...lus1.com>, Viresh Kumar
 <vireshk@...nel.org>, Ulf Hansson	 <ulf.hansson@...aro.org>, Luca Ceresoli
 <luca.ceresoli@...tlin.com>, Alex Helms	 <alexander.helms.jy@...esas.com>,
 Linus Walleij <linus.walleij@...aro.org>,  Liviu Dudau
 <liviu.dudau@....com>, Lorenzo Pieralisi <lpieralisi@...nel.org>, Nobuhiro
 Iwamatsu	 <nobuhiro1.iwamatsu@...hiba.co.jp>
Cc: linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org, 
	arm-scmi@...r.kernel.org, linux-arm-kernel@...ts.infradead.org, 
	sophgo@...ts.linux.dev, linux-mips@...r.kernel.org, imx@...ts.linux.dev, 
	linux-riscv@...ts.infradead.org, spacemit@...ts.linux.dev, 
	linux-stm32@...md-mailman.stormreply.com, patches@...nsource.cirrus.com, 
	linux-actions@...ts.infradead.org, asahi@...ts.linux.dev, 
	linux-mediatek@...ts.infradead.org, linux-arm-msm@...r.kernel.org, 
	linux-renesas-soc@...r.kernel.org, linux-rockchip@...ts.infradead.org, 
	linux-samsung-soc@...r.kernel.org, soc@...ts.linux.dev
Subject: Re: [PATCH 002/114] clk: at91: peripheral: convert from
 round_rate() to determine_rate()

On Mon, 2025-08-11 at 11:17 -0400, Brian Masney via B4 Relay wrote:
> From: Brian Masney <bmasney@...hat.com>
> 
> The round_rate() clk ops is deprecated, so migrate this driver from
> round_rate() to determine_rate() using the Coccinelle semantic patch
> on the cover letter of this series.
> 
> This driver already has a clk_sam9x5_peripheral_determine_rate()
> implementation, however it can change the parent rate. The existing
> round rate does not have this functionality. I could add a check
> for CLK_SET_RATE_PARENT, and combine the two functions, however there
> are some other minor differences in the two implementations. I don't
> have access to this particular hardware. I believe that they could
> be combined, however it would need to be tested on real hardware.
> So, let's play it safe and convert the existing round rate
> implementation to ensure that the driver keeps the same functionality
> as before.
> 
> Signed-off-by: Brian Masney <bmasney@...hat.com>

Reviewed-by: Alexander Sverdlin <alexander.sverdlin@...il.com>

> ---
>  drivers/clk/at91/clk-peripheral.c | 41 +++++++++++++++++++++++----------------
>  1 file changed, 24 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/clk/at91/clk-peripheral.c b/drivers/clk/at91/clk-peripheral.c
> index 629f050a855aaebfd1a03ff87c2b016cd2284a5a..e700f40fd87f9327365f250366f7f7bde01f5987 100644
> --- a/drivers/clk/at91/clk-peripheral.c
> +++ b/drivers/clk/at91/clk-peripheral.c
> @@ -335,50 +335,57 @@ static int clk_sam9x5_peripheral_determine_rate(struct clk_hw *hw,
>  	return 0;
>  }
>  
> -static long clk_sam9x5_peripheral_round_rate(struct clk_hw *hw,
> -					     unsigned long rate,
> -					     unsigned long *parent_rate)
> +static int clk_sam9x5_peripheral_no_parent_determine_rate(struct clk_hw *hw,
> +							  struct clk_rate_request *req)
>  {
>  	int shift = 0;
>  	unsigned long best_rate;
>  	unsigned long best_diff;
> -	unsigned long cur_rate = *parent_rate;
> +	unsigned long cur_rate = req->best_parent_rate;
>  	unsigned long cur_diff;
>  	struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw);
>  
> -	if (periph->id < PERIPHERAL_ID_MIN || !periph->range.max)
> -		return *parent_rate;
> +	if (periph->id < PERIPHERAL_ID_MIN || !periph->range.max) {
> +		req->rate = req->best_parent_rate;
> +
> +		return 0;
> +	}
>  
>  	if (periph->range.max) {
>  		for (; shift <= PERIPHERAL_MAX_SHIFT; shift++) {
> -			cur_rate = *parent_rate >> shift;
> +			cur_rate = req->best_parent_rate >> shift;
>  			if (cur_rate <= periph->range.max)
>  				break;
>  		}
>  	}
>  
> -	if (rate >= cur_rate)
> -		return cur_rate;
> +	if (req->rate >= cur_rate) {
> +		req->rate = cur_rate;
> +
> +		return 0;
> +	}
>  
> -	best_diff = cur_rate - rate;
> +	best_diff = cur_rate - req->rate;
>  	best_rate = cur_rate;
>  	for (; shift <= PERIPHERAL_MAX_SHIFT; shift++) {
> -		cur_rate = *parent_rate >> shift;
> -		if (cur_rate < rate)
> -			cur_diff = rate - cur_rate;
> +		cur_rate = req->best_parent_rate >> shift;
> +		if (cur_rate < req->rate)
> +			cur_diff = req->rate - cur_rate;
>  		else
> -			cur_diff = cur_rate - rate;
> +			cur_diff = cur_rate - req->rate;
>  
>  		if (cur_diff < best_diff) {
>  			best_diff = cur_diff;
>  			best_rate = cur_rate;
>  		}
>  
> -		if (!best_diff || cur_rate < rate)
> +		if (!best_diff || cur_rate < req->rate)
>  			break;
>  	}
>  
> -	return best_rate;
> +	req->rate = best_rate;
> +
> +	return 0;
>  }
>  
>  static int clk_sam9x5_peripheral_set_rate(struct clk_hw *hw,
> @@ -430,7 +437,7 @@ static const struct clk_ops sam9x5_peripheral_ops = {
>  	.disable = clk_sam9x5_peripheral_disable,
>  	.is_enabled = clk_sam9x5_peripheral_is_enabled,
>  	.recalc_rate = clk_sam9x5_peripheral_recalc_rate,
> -	.round_rate = clk_sam9x5_peripheral_round_rate,
> +	.determine_rate = clk_sam9x5_peripheral_no_parent_determine_rate,
>  	.set_rate = clk_sam9x5_peripheral_set_rate,
>  	.save_context = clk_sam9x5_peripheral_save_context,
>  	.restore_context = clk_sam9x5_peripheral_restore_context,

-- 
Alexander Sverdlin.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ