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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b973cfc2-d9a8-5d62-036f-14671cf56799@kernel.org>
Date:   Thu, 14 Jul 2022 12:46:23 +0200
From:   Jiri Slaby <jirislaby@...nel.org>
To:     Vijaya Krishna Nivarthi <quic_vnivarth@...cinc.com>,
        agross@...nel.org, bjorn.andersson@...aro.org,
        konrad.dybcio@...ainline.org, gregkh@...uxfoundation.org,
        linux-arm-msm@...r.kernel.org, linux-serial@...r.kernel.org,
        linux-kernel@...r.kernel.org
Cc:     quic_msavaliy@...cinc.com, dianders@...omium.org, mka@...omium.org,
        swboyd@...omium.org
Subject: Re: [V5] tty: serial: qcom-geni-serial: Fix get_clk_div_rate() which
 otherwise could return a sub-optimal clock rate.

On 12. 07. 22, 14:45, Vijaya Krishna Nivarthi wrote:
...
> +static unsigned long get_clk_div_rate(struct clk *clk, struct device *dev,
> +		unsigned int baud, unsigned int sampling_rate, unsigned int *clk_div)
> +{
> +	unsigned long ser_clk;
> +	unsigned long desired_clk;
> +
> +	desired_clk = baud * sampling_rate;
> +	if (!desired_clk) {
> +		dev_dbg(dev, "Invalid frequency\n");
> +		return 0;
>   	}
>   
> -	*clk_div = ser_clk / desired_clk;
> -	if (!(*clk_div))
> -		*clk_div = 1;
> +	/*
> +	 * try to find a clock rate within 2% tolerance, then within

"then within" ... "5" is missing, perhaps?

> +	 */
> +	ser_clk = find_clk_rate_in_tol(clk, desired_clk, clk_div, 2);
> +	if (!ser_clk)
> +		ser_clk = find_clk_rate_in_tol(clk, desired_clk, clk_div, 5);
> +
> +	if (!ser_clk)
> +		dev_err(dev, "Couldn't find suitable clock rate for %lu\n", desired_clk);
> +	else
> +		dev_dbg(dev, "desired_clk-%lu, ser_clk-%lu, clk_div-%u\n",
> +				desired_clk, ser_clk, *clk_div);
>   
>   	return ser_clk;
>   }
> @@ -1021,8 +1040,8 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
>   	if (ver >= QUP_SE_VERSION_2_5)
>   		sampling_rate /= 2;
>   
> -	clk_rate = get_clk_div_rate(port->se.clk, baud,
> -		sampling_rate, &clk_div);
> +	clk_rate = get_clk_div_rate(port->se.clk, port->se.dev, baud,

Maybe worth passing whole geni_se (port->se) then?

> +					sampling_rate, &clk_div);
>   	if (!clk_rate)
>   		goto out_restart_rx;
>   

thanks,
-- 
js
suse labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ