Re: [V2] tty: serial: qcom-geni-serial: Fix get_clk_div_rate() which otherwise could return a sub-optimal clock rate.

From: Vijaya Krishna Nivarthi
Date: Thu Jul 07 2022 - 15:24:58 EST



On 7/6/2022 11:51 PM, Doug Anderson wrote:
Hi,

On Wed, Jul 6, 2022 at 10:44 AM Vijaya Krishna Nivarthi
<quic_vnivarth@xxxxxxxxxxx> wrote:
Hi,


On 7/6/2022 8:56 PM, Doug Anderson wrote:
Hi,

On Mon, Jul 4, 2022 at 11:57 AM Vijaya Krishna Nivarthi (Temp)
<vnivarth@xxxxxxxxxxxxxxxx> wrote:
Hi,


-----Original Message-----
From: Doug Anderson <dianders@xxxxxxxxxxxx>
Sent: Friday, July 1, 2022 8:38 PM
To: Vijaya Krishna Nivarthi (Temp) (QUIC) <quic_vnivarth@xxxxxxxxxxx>
Cc: Andy Gross <agross@xxxxxxxxxx>; bjorn.andersson@xxxxxxxxxx; Konrad
Dybcio <konrad.dybcio@xxxxxxxxxxxxxx>; Greg Kroah-Hartman
<gregkh@xxxxxxxxxxxxxxxxxxx>; Jiri Slaby <jirislaby@xxxxxxxxxx>; linux-arm-
msm <linux-arm-msm@xxxxxxxxxxxxxxx>; linux-serial@xxxxxxxxxxxxxxx; LKML
<linux-kernel@xxxxxxxxxxxxxxx>; Mukesh Savaliya (QUIC)
<quic_msavaliy@xxxxxxxxxxx>; Matthias Kaehlcke <mka@xxxxxxxxxxxx>;
Stephen Boyd <swboyd@xxxxxxxxxxxx>
Subject: Re: [V2] tty: serial: qcom-geni-serial: Fix get_clk_div_rate() which
otherwise could return a sub-optimal clock rate.

WARNING: This email originated from outside of Qualcomm. Please be wary
of any links or attachments, and do not enable macros.

Hi,

On Fri, Jul 1, 2022 at 4:04 AM Vijaya Krishna Nivarthi (Temp) (QUIC)
<quic_vnivarth@xxxxxxxxxxx> wrote:

Ah, you are correct. So just:

div = DIV_ROUND_UP(freq, desired_clk);

...because freq _has_ to be greater than mult. If it was < "mult -
offset" we would have ended the loop. If it was between "mult -
offset" and "mult + offset" (inclusive) then we would have success. So
freq must be > "mult + offset" at the end of the loop.

-Doug


Thank you, uploaded V3.