From: Hugo Villeneuve <hugo@hugovil.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
Hugo Villeneuve <hvilleneuve@dimonoff.com>,
biju.das.jz@bp.renesas.com, linux-kernel@vger.kernel.org,
linux-serial@vger.kernel.org
Subject: Re: [PATCH] serial: sh-sci: optimize max_freq determination
Date: Mon, 20 Apr 2026 12:12:05 -0400 [thread overview]
Message-ID: <20260420121205.f52ae2515cb9ff093c19c6e2@hugovil.com> (raw)
In-Reply-To: <CAMuHMdXpZjVctirMuH=n_PrK4nnEnWqjuCzRjc4y6kC1--99kQ@mail.gmail.com>
Hi Geert,
On Mon, 20 Apr 2026 09:23:55 +0200
Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> Hi Hugo,
>
> On Sat, 18 Apr 2026 at 07:24, Hugo Villeneuve <hugo@hugovil.com> wrote:
> > From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> >
> > Follow example of rsci driver to avoid code duplication and useless
> > max_freq search when port->uartclk is set to zero.
> >
> > Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
>
> Thanks for your patch!
>
> > --- a/drivers/tty/serial/sh-sci.c
> > +++ b/drivers/tty/serial/sh-sci.c
> > @@ -2711,14 +2711,15 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
> > * setup the baud rate generator hardware for us already.
> > */
> > if (!port->uartclk) {
> > - baud = uart_get_baud_rate(port, termios, old, 0, 115200);
> > - goto done;
>
> There was no "useless max_freq search", due to this goto?
You are right, this part of the comment is wrong.
>
> > + max_freq = 115200;
> > + } else {
> > + for (i = 0; i < SCI_NUM_CLKS; i++)
> > + max_freq = max(max_freq, s->clk_rates[i]);
> > +
> > + max_freq /= min_sr(s);
> > }
> >
> > - for (i = 0; i < SCI_NUM_CLKS; i++)
> > - max_freq = max(max_freq, s->clk_rates[i]);
> > -
> > - baud = uart_get_baud_rate(port, termios, old, 0, max_freq / min_sr(s));
> > + baud = uart_get_baud_rate(port, termios, old, 0, max_freq);
> > if (!baud)
> > goto done;
> >
>
> Due to removing the goto above (for the casual reader: this is the
> earlyprintk case, when port->uartclk is zero), the code will now
> continue here, calculating transmission parameters and setting best_clk,
> and overwriting the register configuration done by the bootloader.
Yes, I see it now for sh-sci where we have "if (best_clk >= 0) {"... to
not configure the registers.
However, for the rsci driver, I think that, even after Biju's cleanup
serie V3, we still overwrite the register configuration done by the
bootloader?
Maybe configure only "if (!port->uartclk) {" ?
Hugo.
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
>
--
Hugo Villeneuve
prev parent reply other threads:[~2026-04-20 16:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-17 19:35 [PATCH] serial: sh-sci: optimize max_freq determination Hugo Villeneuve
2026-04-18 7:12 ` Biju Das
2026-04-18 14:39 ` Hugo Villeneuve
2026-04-20 7:13 ` Geert Uytterhoeven
2026-04-20 13:45 ` Hugo Villeneuve
2026-04-20 7:23 ` Geert Uytterhoeven
2026-04-20 16:12 ` Hugo Villeneuve [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=20260420121205.f52ae2515cb9ff093c19c6e2@hugovil.com \
--to=hugo@hugovil.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=hvilleneuve@dimonoff.com \
--cc=jirislaby@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