stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linaro.org>
To: Johan Hovold <johan@kernel.org>
Cc: "# 3.4.x" <stable@vger.kernel.org>,
	Greg KH <gregkh@linuxfoundation.org>,
	lanqing.liu@unisoc.com, linux-serial@vger.kernel.org,
	Arnd Bergmann <arnd@arndb.de>, Orson Zhai <orsonzhai@gmail.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [BACKPORT 4.14.y v2 6/6] serial: sprd: Modify the baud rate calculation formula
Date: Thu, 5 Sep 2019 17:58:05 +0800	[thread overview]
Message-ID: <CAMz4kuJGmQxfy5mi1aZNL8SA8MQBSTTyDeWcHHEtG2aXsFZgug@mail.gmail.com> (raw)
In-Reply-To: <20190905090130.GF1701@localhost>

Hi Johan,

On Thu, 5 Sep 2019 at 17:01, Johan Hovold <johan@kernel.org> wrote:
>
> On Thu, Sep 05, 2019 at 11:11:26AM +0800, Baolin Wang wrote:
> > From: Lanqing Liu <lanqing.liu@unisoc.com>
> >
> > [Upstream commit 5b9cea15a3de5d65000d49f626b71b00d42a0577]
> >
> > When the source clock is not divisible by the expected baud rate and
> > the remainder is not less than half of the expected baud rate, the old
> > formular will round up the frequency division coefficient. This will
> > make the actual baud rate less than the expected value and can not meet
> > the external transmission requirements.
> >
> > Thus this patch modifies the baud rate calculation formula to support
> > the serial controller output the maximum baud rate.
> >
> > Signed-off-by: Lanqing Liu <lanqing.liu@unisoc.com>
> > Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
> > ---
> >  drivers/tty/serial/sprd_serial.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
> > index e902494..72e96ab8 100644
> > --- a/drivers/tty/serial/sprd_serial.c
> > +++ b/drivers/tty/serial/sprd_serial.c
> > @@ -380,7 +380,7 @@ static void sprd_set_termios(struct uart_port *port,
> >       /* ask the core to calculate the divisor for us */
> >       baud = uart_get_baud_rate(port, termios, old, 0, SPRD_BAUD_IO_LIMIT);
> >
> > -     quot = (unsigned int)((port->uartclk + baud / 2) / baud);
> > +     quot = port->uartclk / baud;
>
> Are you sure the original patch is even correct?
>
> By replacing the divisor rounding with truncation you are introducing
> larger errors for some baud rates, something which could possibly even
> break working systems.

Our UART clock source is 26M, and there is no difference for lower
than 3M baud rate between dividing closest or dividing down. But we
have one special use case is our BT/GPS want to set 3.25M baud rate,
but we have to select 3M baud rate in baud_table since no 3.25M
setting. So in this case if we use the old formula, we will only get
about 2.8M baud rate, which can not meet our requirement. If we change
the dividing down method, we can get 3.25M baud rate.

I have to say this is a workaroud for our special case, and can solve
our problem. If you have any good suggestion, we can change to a
better solution. Thanks.

>
> Perhaps the original patch should even be reverted, but in any case
> backporting this to stable looks questionable.
>
> >
> >       /* set data length */
> >       switch (termios->c_cflag & CSIZE) {
>
> Johan



-- 
Baolin Wang
Best Regards

  reply	other threads:[~2019-09-05  9:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-05  3:05 [BACKPORT 4.14.y v2 0/6] Candidates from Spreadtrum 4.14 product kernel Baolin Wang
2019-09-05  3:06 ` [BACKPORT 4.14.y v2 1/6] ip6: fix skb leak in ip6frag_expire_frag_queue() Baolin Wang
2019-09-05  3:07 ` [BACKPORT 4.14.y v2 2/6] locking/lockdep: Add debug_locks check in __lock_downgrade() Baolin Wang
2019-09-10 14:32   ` Greg KH
2019-09-11  3:39     ` Baolin Wang
2019-09-05  3:07 ` [BACKPORT 4.14.y v2 3/6] pinctrl: sprd: Use define directive for sprd_pinconf_params values Baolin Wang
2019-09-05  3:08 ` [BACKPORT 4.14.y v2 4/6] power: supply: sysfs: ratelimit property read error message Baolin Wang
2019-09-05  3:10 ` [BACKPORT 4.14.y v2 5/6] ppp: mppe: Revert "ppp: mppe: Add softdep to arc4" Baolin Wang
2019-09-05 16:16   ` Eric Biggers
2019-09-06  6:13     ` Baolin Wang
2019-09-05  3:11 ` [BACKPORT 4.14.y v2 6/6] serial: sprd: Modify the baud rate calculation formula Baolin Wang
2019-09-05  9:01   ` Johan Hovold
2019-09-05  9:58     ` Baolin Wang [this message]
2019-09-20  8:06       ` 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=CAMz4kuJGmQxfy5mi1aZNL8SA8MQBSTTyDeWcHHEtG2aXsFZgug@mail.gmail.com \
    --to=baolin.wang@linaro.org \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=lanqing.liu@unisoc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=orsonzhai@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=vincent.guittot@linaro.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).