linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <swboyd@chromium.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	satya priya <skakit@codeaurora.org>
Cc: mgautam@codeaurora.org, linux-arm-msm@vger.kernel.org,
	linux-serial@vger.kernel.org, akashast@codeaurora.org,
	rojay@codeaurora.org, msavaliy@qti.qualcomm.com,
	satya priya <skakit@codeaurora.org>
Subject: Re: [PATCH] tty: serial: qcom_geni_serial: Remove the UART frequency table
Date: Wed, 12 Aug 2020 00:42:00 -0700	[thread overview]
Message-ID: <159721812037.1360974.11604578290766022830@swboyd.mtv.corp.google.com> (raw)
In-Reply-To: <1597211328-23500-1-git-send-email-skakit@codeaurora.org>

Quoting satya priya (2020-08-11 22:48:48)
> diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
> index 3aa29d2..312daa24 100644
> --- a/drivers/tty/serial/qcom_geni_serial.c
> +++ b/drivers/tty/serial/qcom_geni_serial.c
> @@ -941,30 +935,22 @@ static int qcom_geni_serial_startup(struct uart_port *uport)
>         return 0;
>  }
>  
> -static unsigned long get_clk_cfg(unsigned long clk_freq)
> -{
> -       int i;
> -
> -       for (i = 0; i < ARRAY_SIZE(root_freq); i++) {
> -               if (!(root_freq[i] % clk_freq))
> -                       return root_freq[i];
> -       }
> -       return 0;
> -}
> -
> -static unsigned long get_clk_div_rate(unsigned int baud,
> -                       unsigned int sampling_rate, unsigned int *clk_div)
> +static unsigned long get_clk_div_rate(const struct geni_se *se,
> +                       unsigned int baud, unsigned int sampling_rate,
> +                       unsigned int *clk_div)
>  {
>         unsigned long ser_clk;
>         unsigned long desired_clk;
> +       long actual_clk;
>  
>         desired_clk = baud * sampling_rate;
> -       ser_clk = get_clk_cfg(desired_clk);
> -       if (!ser_clk) {
> +       actual_clk = clk_round_rate(se->clk, desired_clk);
> +       if (actual_clk % desired_clk != 0) {

The logic isn't the same. Is that a concern? Before we would loop
through all the frequencies this driver knew about and try to find a
frequency that evenly divides by the 'desired_clk'. With this patch
we'll do that calculation exactly once, and ask the clk driver what rate
can be achieved if we call clk_set_rate() with 'desired_clk' as the
argument.

Maybe we need to loop and call clk_round_rate() with 'desired_clk <<= 1'
until it overflows or reaches some limit?

>                 pr_err("%s: Can't find matching DFS entry for baud %d\n",
>                                                                 __func__, baud);
> -               return ser_clk;
> +               return 0;
>         }
> +       ser_clk = actual_clk;
>  
>         *clk_div = ser_clk / desired_clk;
>         return ser_clk;

      reply	other threads:[~2020-08-12  7:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-12  5:48 [PATCH] tty: serial: qcom_geni_serial: Remove the UART frequency table satya priya
2020-08-12  7:42 ` Stephen Boyd [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=159721812037.1360974.11604578290766022830@swboyd.mtv.corp.google.com \
    --to=swboyd@chromium.org \
    --cc=akashast@codeaurora.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=mgautam@codeaurora.org \
    --cc=msavaliy@qti.qualcomm.com \
    --cc=rojay@codeaurora.org \
    --cc=skakit@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).