* [BACKPORT 4.14.y v2 0/6] Candidates from Spreadtrum 4.14 product kernel
@ 2019-09-05 3:05 Baolin Wang
2019-09-05 3:11 ` [BACKPORT 4.14.y v2 6/6] serial: sprd: Modify the baud rate calculation formula Baolin Wang
0 siblings, 1 reply; 5+ messages in thread
From: Baolin Wang @ 2019-09-05 3:05 UTC (permalink / raw)
To: stable, davem, kuznet, yoshfuji, peterz, mingo, linus.walleij,
natechancellor, sre, paulus, gregkh
Cc: edumazet, netdev, longman, linux-gpio, david, linux-pm, ebiggers,
linux-ppp, lanqing.liu, linux-serial, arnd, baolin.wang,
orsonzhai, vincent.guittot, linux-kernel
With Arnd's script [1] help, I found some bugfixes in Spreadtrum 4.14 product
kernel, but missing in v4.14.141:
25a09ce79639 ppp: mppe: Revert "ppp: mppe: Add softdep to arc4"
47d3d7fdb10a ip6: fix skb leak in ip6frag_expire_frag_queue()
5b9cea15a3de serial: sprd: Modify the baud rate calculation formula
513e1073d52e locking/lockdep: Add debug_locks check in __lock_downgrade()
957063c92473 pinctrl: sprd: Use define directive for sprd_pinconf_params values
87a2b65fc855 power: supply: sysfs: ratelimit property read error message
[1] https://lore.kernel.org/lkml/20190322154425.3852517-19-arnd@arndb.de/T/
Changes from v1:
- Drop 2 unnecessary patches (patch 1 and patch 4) from v1 patch set.
- Add upstream commit id in change log for each stable patch.
David Lechner (1):
power: supply: sysfs: ratelimit property read error message
Eric Biggers (1):
ppp: mppe: Revert "ppp: mppe: Add softdep to arc4"
Eric Dumazet (1):
ip6: fix skb leak in ip6frag_expire_frag_queue()
Lanqing Liu (1):
serial: sprd: Modify the baud rate calculation formula
Nathan Chancellor (1):
pinctrl: sprd: Use define directive for sprd_pinconf_params values
Waiman Long (1):
locking/lockdep: Add debug_locks check in __lock_downgrade()
drivers/net/ppp/ppp_mppe.c | 1 -
drivers/pinctrl/sprd/pinctrl-sprd.c | 6 ++----
drivers/power/supply/power_supply_sysfs.c | 3 ++-
drivers/tty/serial/sprd_serial.c | 2 +-
include/net/ipv6_frag.h | 1 -
kernel/locking/lockdep.c | 3 +++
6 files changed, 8 insertions(+), 8 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [BACKPORT 4.14.y v2 6/6] serial: sprd: Modify the baud rate calculation formula
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:11 ` Baolin Wang
2019-09-05 9:01 ` Johan Hovold
0 siblings, 1 reply; 5+ messages in thread
From: Baolin Wang @ 2019-09-05 3:11 UTC (permalink / raw)
To: stable, gregkh
Cc: lanqing.liu, linux-serial, arnd, baolin.wang, orsonzhai,
vincent.guittot, linux-kernel
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;
/* set data length */
switch (termios->c_cflag & CSIZE) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [BACKPORT 4.14.y v2 6/6] serial: sprd: Modify the baud rate calculation formula
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
0 siblings, 1 reply; 5+ messages in thread
From: Johan Hovold @ 2019-09-05 9:01 UTC (permalink / raw)
To: Baolin Wang
Cc: stable, gregkh, lanqing.liu, linux-serial, arnd, orsonzhai,
vincent.guittot, linux-kernel
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.
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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [BACKPORT 4.14.y v2 6/6] serial: sprd: Modify the baud rate calculation formula
2019-09-05 9:01 ` Johan Hovold
@ 2019-09-05 9:58 ` Baolin Wang
2019-09-20 8:06 ` Johan Hovold
0 siblings, 1 reply; 5+ messages in thread
From: Baolin Wang @ 2019-09-05 9:58 UTC (permalink / raw)
To: Johan Hovold
Cc: # 3.4.x, Greg KH, lanqing.liu, linux-serial, Arnd Bergmann,
Orson Zhai, Vincent Guittot, LKML
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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [BACKPORT 4.14.y v2 6/6] serial: sprd: Modify the baud rate calculation formula
2019-09-05 9:58 ` Baolin Wang
@ 2019-09-20 8:06 ` Johan Hovold
0 siblings, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2019-09-20 8:06 UTC (permalink / raw)
To: Baolin Wang
Cc: Johan Hovold, # 3.4.x, Greg KH, lanqing.liu, linux-serial,
Arnd Bergmann, Orson Zhai, Vincent Guittot, LKML
On Thu, Sep 05, 2019 at 05:58:05PM +0800, Baolin Wang wrote:
> 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 there is; you have introduced larger errors for at least a few
standard rates by changing to truncation.
> 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.
Yeah, I don't think purposefully introducing larger errors, and risk
breaking other people's setups, to work around that use case is
warranted.
We have an interface for setting arbitrary baudrates (TCSETS2) which you
can you use (even if glibc support is still not in place). You'd just
need to lift the seemingly arbitrary limitation to 3 Mbaud in the driver
first.
> > Perhaps the original patch should even be reverted, but in any case
> > backporting this to stable looks questionable.
So I think reverting this may be the right thing to do.
Johan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-09-20 8:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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: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
2019-09-20 8:06 ` Johan Hovold
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).