Candidates from Spreadtrum 4.14 product kernel
Subsystems (6)
v2 cover Candidates from Spreadtrum 4.14 product 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/[email protected]/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(-)
Signature · 1 line
1.7.9.5
PATCH v2 1/6 ip6: fix skb leak in ip6frag_expire_frag_queue()
From: Eric Dumazet <[email protected]>
[Upstream commit 47d3d7fdb10a21c223036b58bd70ffdc24a472c4]
Since ip6frag_expire_frag_queue() now pulls the head skb from frag queue, we should no longer use skb_get(), since this leads to an skb leak.
Stefan Bader initially reported a problem in 4.4.stable [1] caused by the skb_get(), so this patch should also fix this issue.
296583.091021] kernel BUG at /build/linux-6VmqmP/linux-4.4.0/net/core/skbuff.c:1207!
[296583.091734] Call Trace: [296583.091749] [<ffffffff81740e50>] __pskb_pull_tail+0x50/0x350 [296583.091764] [<ffffffff8183939a>] _decode_session6+0x26a/0x400 [296583.091779] [<ffffffff817ec719>] __xfrm_decode_session+0x39/0x50 [296583.091795] [<ffffffff818239d0>] icmpv6_route_lookup+0xf0/0x1c0 [296583.091809] [<ffffffff81824421>] icmp6_send+0x5e1/0x940 [296583.091823] [<ffffffff81753238>] ? __netif_receive_skb+0x18/0x60 [296583.091838] [<ffffffff817532b2>] ? netif_receive_skb_internal+0x32/0xa0 [296583.091858] [<ffffffffc0199f74>] ? ixgbe_clean_rx_irq+0x594/0xac0 [ixgbe] [296583.091876] [<ffffffffc04eb260>] ? nf_ct_net_exit+0x50/0x50 [nf_defrag_ipv6] [296583.091893] [<ffffffff8183d431>] icmpv6_send+0x21/0x30 [296583.091906] [<ffffffff8182b500>] ip6_expire_frag_queue+0xe0/0x120 [296583.091921] [<ffffffffc04eb27f>] nf_ct_frag6_expire+0x1f/0x30 [nf_defrag_ipv6] [296583.091938] [<ffffffff810f3b57>] call_timer_fn+0x37/0x140 [296583.091951] [<ffffffffc04eb260>] ? nf_ct_net_exit+0x50/0x50 [nf_defrag_ipv6] [296583.091968] [<ffffffff810f5464>] run_timer_softirq+0x234/0x330 [296583.091982] [<ffffffff8108a339>] __do_softirq+0x109/0x2b0
--- include/net/ipv6_frag.h | 1 - 1 file changed, 1 deletion(-)
include/net/ipv6_frag.h +0 -1
@@ -94,7 +94,6 @@ static inline u32 ip6frag_obj_hashfn(const void *data, u32 len, u32 seed) goto out; head->dev = dev; -skb_get (head);spin_unlock (&fq->q.lock);icmpv6_send (head,ICMPV6_TIME_EXCEED ,ICMPV6_EXC_FRAGTIME ,0 );
Signature · 1 line
1.7.9.5
PATCH v2 2/6 locking/lockdep: Add debug_locks check in __lock_downgrade()
In reply to Baolin WangFrom: Waiman Long <[email protected]>
[Upstream commit 513e1073d52e55b8024b4f238a48de7587c64ccf]
Tetsuo Handa had reported he saw an incorrect "downgrading a read lock" warning right after a previous lockdep warning. It is likely that the previous warning turned off lock debugging causing the lockdep to have inconsistency states leading to the lock downgrade warning.
Fix that by add a check for debug_locks at the beginning of __lock_downgrade().
--- kernel/locking/lockdep.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/locking/lockdep.c +3 -0
@@ -3650,6 +3650,9 @@ static int reacquire_held_locks(struct task_struct *curr, unsigned int depth,unsigned int depth;int i; +if (unlikely (!debug_locks)) +return 0 ; + depth = curr->lockdep_depth;/* * This function is about (re)setting the class of a held lock,
Signature · 1 line
1.7.9.5
Re: [BACKPORT 4.14.y v2 2/6] locking/lockdep: Add debug_locks check in __lock_downgrade()
Quoted 25 lines · Baolin Wang
From: Waiman Long <[email protected]>
[Upstream commit
513e1073d52e55b8024b4f238a48de7587c64ccf]Tetsuo Handa had reported he saw an incorrect "downgrading a read lock" warning right after a previous lockdep warning. It is likely that the previous warning turned off lock debugging causing the lockdep to have inconsistency states leading to the lock downgrade warning.
Fix that by add a check for
debug_locksat the beginning of__lock_downgrade().Reported-by Tetsuo Handa <[email protected]>Reported-by [email protected]Signed-off-by Waiman Long <[email protected]>Signed-off-by Peter Zijlstra (Intel) <[email protected]>Cc Andrew Morton <[email protected]>Cc Linus Torvalds <[email protected]>Cc Paul E. McKenney <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Ingo Molnar <[email protected]>Signed-off-by Baolin Wang <[email protected]>
Quoted 3 lines
--- kernel/locking/lockdep.c | 3 +++ 1 file changed, 3 insertions(+)
Why isn't this relevant for 4.19.y? I can't add a patch to 4.14.y and then have someone upgrade to 4.19.y and not have the same fix in there, that would be a regression.
So can you redo this series also with a 4.19.y set at the same so we don't get out of sync? I've queued up your first patch already as that was in 4.19.y (and also needed in 4.9.y).
thanks,
greg k-h
Re: [BACKPORT 4.14.y v2 2/6] locking/lockdep: Add debug_locks check in __lock_downgrade()
Quoted 31 lines · Greg KH
Quoted 25 lines · Baolin Wang
From: Waiman Long <[email protected]>
[Upstream commit
513e1073d52e55b8024b4f238a48de7587c64ccf]Tetsuo Handa had reported he saw an incorrect "downgrading a read lock" warning right after a previous lockdep warning. It is likely that the previous warning turned off lock debugging causing the lockdep to have inconsistency states leading to the lock downgrade warning.
Fix that by add a check for
debug_locksat the beginning of__lock_downgrade().Reported-by Tetsuo Handa <[email protected]>Reported-by [email protected]Signed-off-by Waiman Long <[email protected]>Signed-off-by Peter Zijlstra (Intel) <[email protected]>Cc Andrew Morton <[email protected]>Cc Linus Torvalds <[email protected]>Cc Paul E. McKenney <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Ingo Molnar <[email protected]>Signed-off-by Baolin Wang <[email protected]>Quoted 3 lines
--- kernel/locking/lockdep.c | 3 +++ 1 file changed, 3 insertions(+)
Quoted 7 lines
Why isn't this relevant for 4.19.y? I can't add a patch to 4.14.y and then have someone upgrade to 4.19.y and not have the same fix in there, that would be a regression.
So can you redo this series also with a 4.19.y set at the same so we don't get out of sync? I've queued up your first patch already as that was in 4.19.y (and also needed in 4.9.y).
I understood, will do. Thanks.
Signature · 2 lines
Baolin Wang Best Regards
PATCH v2 3/6 pinctrl: sprd: Use define directive for sprd_pinconf_params values
In reply to Baolin WangFrom: Nathan Chancellor <[email protected]>
[Upstream commit 957063c924736d4341e5d588757b9f31e8f6fa24]
Clang warns when one enumerated type is implicitly converted to another:
drivers/pinctrl/sprd/pinctrl-sprd.c:845:19: warning: implicit conversion from enumeration type 'enum sprd_pinconf_params' to different enumeration type 'enum pin_config_param' [-Wenum-conversion]
{"sprd,control", SPRD_PIN_CONFIG_CONTROL, 0},
~ ^~~~~~~~~~~~~~~~~~~~~~~
drivers/pinctrl/sprd/pinctrl-sprd.c:846:22: warning: implicit conversion
from enumeration type 'enum sprd_pinconf_params' to different
enumeration type 'enum pin_config_param' [-Wenum-conversion]
{"sprd,sleep-mode", SPRD_PIN_CONFIG_SLEEP_MODE, 0},
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~It is expected that pinctrl drivers can extend pin_config_param because of the gap between PIN_CONFIG_END and PIN_CONFIG_MAX so this conversion isn't an issue. Most drivers that take advantage of this define the PIN_CONFIG variables as constants, rather than enumerated values. Do the same thing here so that Clang no longer warns.
--- drivers/pinctrl/sprd/pinctrl-sprd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pinctrl/sprd/pinctrl-sprd.c +2 -4
@@ -159,10 +159,8 @@ struct sprd_pinctrl {struct sprd_pinctrl_soc_info *info; }; -enum sprd_pinconf_params { -SPRD_PIN_CONFIG_CONTROL =PIN_CONFIG_END +1 , -SPRD_PIN_CONFIG_SLEEP_MODE =PIN_CONFIG_END +2 , -}; +#define SPRD_PIN_CONFIG_CONTROL (PIN_CONFIG_END + 1) +#define SPRD_PIN_CONFIG_SLEEP_MODE (PIN_CONFIG_END + 2)static int sprd_pinctrl_get_id_by_name (struct sprd_pinctrl *sprd_pctl,const char *name)
Signature · 1 line
1.7.9.5
PATCH v2 4/6 power: supply: sysfs: ratelimit property read error message
In reply to Baolin WangFrom: David Lechner <[email protected]>
[Upstream commit 87a2b65fc855e6be50f791c2ebbb492541896827]
This adds rate limiting to the message that is printed when reading a power supply property via sysfs returns an error. This will prevent userspace applications from unintentionally dDOSing the system by continuously reading a property that returns an error.
--- drivers/power/supply/power_supply_sysfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/power/supply/power_supply_sysfs.c +2 -1
@@ -91,7 +91,8 @@ static ssize_t power_supply_show_property(struct device *dev,dev_dbg (dev,"driver has no data for `%s' property\n" , attr->attr.name); else if (ret != -ENODEV && ret != -EAGAIN) -dev_err (dev,"driver failed to report `%s' property: %zd\n" , +dev_err_ratelimited (dev, +"driver failed to report `%s' property: %zd\n" , attr->attr.name, ret);return ret; }
Signature · 1 line
1.7.9.5
PATCH v2 5/6 ppp: mppe: Revert "ppp: mppe: Add softdep to arc4"
In reply to Baolin WangFrom: Eric Biggers <[email protected]>
[Upstream commit 25a09ce79639a8775244808c17282c491cff89cf]
Commit 0e5a610b5ca5 ("ppp: mppe: switch to RC4 library interface"), which was merged through the crypto tree for v5.3, changed ppp_mppe.c to use the new arc4_crypt() library function rather than access RC4 through the dynamic crypto_skcipher API.
Meanwhile commit aad1dcc4f011 ("ppp: mppe: Add softdep to arc4") was merged through the net tree and added a module soft-dependency on "arc4".
The latter commit no longer makes sense because the code now uses the "libarc4" module rather than "arc4", and also due to the direct use of arc4_crypt(), no module soft-dependency is required.
So revert the latter commit.
--- drivers/net/ppp/ppp_mppe.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ppp/ppp_mppe.c +0 -1
@@ -63,7 +63,6 @@MODULE_DESCRIPTION ("Point-to-Point Protocol Microsoft Point-to-Point Encryption support" );MODULE_LICENSE ("Dual BSD/GPL" );MODULE_ALIAS ("ppp-compress-" __stringify(CI_MPPE )); -MODULE_SOFTDEP ("pre: arc4" );MODULE_VERSION ("1.0.2" ); static unsigned int
Signature · 1 line
1.7.9.5
Re: [BACKPORT 4.14.y v2 5/6] ppp: mppe: Revert "ppp: mppe: Add softdep to arc4"
Quoted 32 lines · Baolin Wang
From: Eric Biggers <[email protected]>
[Upstream commit
25a09ce79639a8775244808c17282c491cff89cf]Commit
0e5a610b5ca5("ppp: mppe: switch to RC4 library interface"), which was merged through the crypto tree for v5.3, changedppp_mppe.cto use the newarc4_crypt()library function rather than access RC4 through the dynamiccrypto_skcipherAPI.Meanwhile commit
aad1dcc4f011("ppp: mppe: Add softdep to arc4") was merged through the net tree and added a module soft-dependency on "arc4".The latter commit no longer makes sense because the code now uses the "libarc4" module rather than "arc4", and also due to the direct use of
arc4_crypt(), no module soft-dependency is required.So revert the latter commit.
Cc Takashi Iwai <[email protected]>Cc Ard Biesheuvel <[email protected]>Signed-off-by Eric Biggers <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Baolin Wang <[email protected]>--- drivers/net/ppp/ppp_mppe.c | 1 - 1 file changed, 1 deletion(-)drivers/net/ppp/ppp_mppe.c +0
-0
drivers/net/ppp/ppp_mppe.c line 66
Quoted 4 lines
drivers/net/ppp/ppp_mppe.c +0
-1@@ -63,7 +63,6 @@MODULE_DESCRIPTION ("Point-to-Point Protocol Microsoft Point-to-Point Encryption support" );MODULE_LICENSE ("Dual BSD/GPL" );MODULE_ALIAS ("ppp-compress-" __stringify(CI_MPPE )); -MODULE_SOFTDEP ("pre: arc4" );
Why is this being backported? This revert was only needed because of a different patch that was merged in v5.3, as I explained in the commit message.
- Eric
Re: [BACKPORT 4.14.y v2 5/6] ppp: mppe: Revert "ppp: mppe: Add softdep to arc4"
Quoted 29 lines · Eric Biggers
Quoted 27 lines · Baolin Wang
From: Eric Biggers <[email protected]>
[Upstream commit
25a09ce79639a8775244808c17282c491cff89cf]Commit
0e5a610b5ca5("ppp: mppe: switch to RC4 library interface"), which was merged through the crypto tree for v5.3, changedppp_mppe.cto use the newarc4_crypt()library function rather than access RC4 through the dynamiccrypto_skcipherAPI.Meanwhile commit
aad1dcc4f011("ppp: mppe: Add softdep to arc4") was merged through the net tree and added a module soft-dependency on "arc4".The latter commit no longer makes sense because the code now uses the "libarc4" module rather than "arc4", and also due to the direct use of
arc4_crypt(), no module soft-dependency is required.So revert the latter commit.
Cc Takashi Iwai <[email protected]>Cc Ard Biesheuvel <[email protected]>Signed-off-by Eric Biggers <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Baolin Wang <[email protected]>--- drivers/net/ppp/ppp_mppe.c | 1 - 1 file changed, 1 deletion(-)
Quoted 12 lines
drivers/net/ppp/ppp_mppe.c line 66
Quoted 9 lines
drivers/net/ppp/ppp_mppe.c +0
-1@@ -63,7 +63,6 @@MODULE_DESCRIPTION ("Point-to-Point Protocol Microsoft Point-to-Point Encryption support" );MODULE_LICENSE ("Dual BSD/GPL" );MODULE_ALIAS ("ppp-compress-" __stringify(CI_MPPE )); -MODULE_SOFTDEP ("pre: arc4" );Why is this being backported? This revert was only needed because of a different patch that was merged in v5.3, as I explained in the commit message.
Sorry I missed this. I should remove this patch from our product kernel too.
Signature · 2 lines
Baolin Wang Best Regards
PATCH v2 6/6 serial: sprd: Modify the baud rate calculation formula
In reply to Baolin WangFrom: Lanqing Liu <[email protected]>
[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.
--- drivers/tty/serial/sprd_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/sprd_serial.c +1 -1
@@ -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 ) {
Signature · 1 line
1.7.9.5
Re: [BACKPORT 4.14.y v2 6/6] serial: sprd: Modify the baud rate calculation formula
Quoted 26 lines · Baolin Wang
From: Lanqing Liu <[email protected]>
[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 <[email protected]>Signed-off-by Baolin Wang <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Baolin Wang <[email protected]>--- drivers/tty/serial/sprd_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/tty/serial/sprd_serial.c +0
-0
drivers/tty/serial/sprd_serial.c static void sprd_set_termios(struct uart_port *port, · line 383
Quoted 5 lines
drivers/tty/serial/sprd_serial.c +1
-1@@ -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.
drivers/tty/serial/sprd_serial.c static void sprd_set_termios(struct uart_port *port, · line 386
Quoted 3 lines
drivers/tty/serial/sprd_serial.c +0
-0/* set data length */ switch (termios->c_cflag &CSIZE ) {
Johan
Re: [BACKPORT 4.14.y v2 6/6] serial: sprd: Modify the baud rate calculation formula
Hi Johan,
Quoted 31 lines · Johan Hovold
Quoted 29 lines · Baolin Wang
From: Lanqing Liu <[email protected]>
[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 <[email protected]>Signed-off-by Baolin Wang <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Baolin Wang <[email protected]>--- drivers/tty/serial/sprd_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/tty/serial/sprd_serial.c +0
-0@@ -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 );
Quoted 8 lines
drivers/tty/serial/sprd_serial.c static void sprd_set_termios(struct uart_port *port, · line 383
Quoted 2 lines
drivers/tty/serial/sprd_serial.c +1
-1- 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.
Quoted 9 lines
Perhaps the original patch should even be reverted, but in any case backporting this to stable looks questionable.
drivers/tty/serial/sprd_serial.c static void sprd_set_termios(struct uart_port *port, · line 386
Quoted 3 lines
drivers/tty/serial/sprd_serial.c +0
-0/* set data length */ switch (termios->c_cflag &CSIZE ) {Johan
Signature · 2 lines
Baolin Wang Best Regards
Re: [BACKPORT 4.14.y v2 6/6] serial: sprd: Modify the baud rate calculation formula
Quoted 39 lines · Baolin Wang
Hi Johan,
Quoted 36 lines · Johan Hovold
Quoted 26 lines · Baolin Wang
From: Lanqing Liu <[email protected]>
[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 <[email protected]>Signed-off-by Baolin Wang <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Baolin Wang <[email protected]>--- drivers/tty/serial/sprd_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/tty/serial/sprd_serial.c +0
-0drivers/tty/serial/sprd_serial.c static void sprd_set_termios(struct uart_port *port, · line 383
Quoted 5 lines
drivers/tty/serial/sprd_serial.c +1
-1@@ -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?
Quoted 6 lines
Quoted 3 lines
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.
Quoted 9 lines
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_tablesince 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.
Quoted 2 lines
Quoted 2 lines
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