From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Johan Hovold <johan@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
Serge Semin <Sergey.Semin@baikalelectronics.ru>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] serial: 8250_dw: drop bogus uartclk optimisation
Date: Fri, 15 Oct 2021 17:25:31 +0300 [thread overview]
Message-ID: <YWmPW5Yg0X8Kcck9@smile.fi.intel.com> (raw)
In-Reply-To: <20211015111422.1027-4-johan@kernel.org>
On Fri, Oct 15, 2021 at 01:14:22PM +0200, Johan Hovold wrote:
> The driver was updating the port uartclk before setting the new rate in
> an attempt to avoid having the clock notifier redundantly update the
> divisors.
>
> The set_termios() callback is however called under the termios semaphore
> and tty-port mutex so the worker scheduled by the clock notifier will
> block in serial8250_update_uartclk() until the uartclk and divisors have
> been updated anyway.
>
> Drop the unnecessary swaps and incorrect comment and simply update the
> uartclk field if the clock-rate change was successful.
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
> drivers/tty/serial/8250/8250_dw.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
> index a3a0154da567..52e03dd0eb3b 100644
> --- a/drivers/tty/serial/8250/8250_dw.c
> +++ b/drivers/tty/serial/8250/8250_dw.c
> @@ -338,15 +338,12 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios,
> rate = clk_round_rate(d->clk, newrate);
> if (rate > 0) {
> /*
> - * Premilinary set the uartclk to the new clock rate so the
> - * clock update event handler caused by the clk_set_rate()
> - * calling wouldn't actually update the UART divisor since
> - * we about to do this anyway.
> + * Note that any clock-notifer worker will block in
> + * serial8250_update_uartclk() until we are done.
> */
> - swap(p->uartclk, rate);
> ret = clk_set_rate(d->clk, newrate);
> - if (ret)
> - swap(p->uartclk, rate);
> + if (!ret)
> + p->uartclk = rate;
> }
> clk_prepare_enable(d->clk);
>
> --
> 2.32.0
>
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2021-10-15 11:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-15 11:14 [PATCH 0/3] serial: 8250: fix racy uartclk update Johan Hovold
2021-10-15 11:14 ` [PATCH 1/3] " Johan Hovold
2021-10-15 14:23 ` Andy Shevchenko
2021-10-15 11:14 ` [PATCH 2/3] serial: 8250: rename unlock labels Johan Hovold
2021-10-15 14:24 ` Andy Shevchenko
2021-10-16 15:40 ` Serge Semin
2021-10-15 11:14 ` [PATCH 3/3] serial: 8250_dw: drop bogus uartclk optimisation Johan Hovold
2021-10-15 14:25 ` Andy Shevchenko [this message]
2021-10-15 19:10 ` [PATCH 0/3] serial: 8250: fix racy uartclk update Serge Semin
2021-10-16 15:25 ` Serge Semin
2021-10-18 6:29 ` Johan Hovold
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=YWmPW5Yg0X8Kcck9@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=Sergey.Semin@baikalelectronics.ru \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.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