Skip to contentSkip to conversation

MIPS: AR7: assorted fixes

PATCH In review Jonas Gorski 5 participants 12 messages Oct 29, 2017 – Jan 22, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover MIPS: AR7: assorted fixes

This patchset fixes a few issues found in AR7 that accumulated in the past few years. One was fixed for ages in OpenWrt/LEDE and never made it upstream, the others weren't noticed until now.

Jonas Gorski (2):
MIPS: AR7: defer registration of GPIO
MIPS: AR7: ensure the port type's FCR value is used

Oswald Buddenhagen (1):
MIPS: AR7: ensure that serial ports are properly set up

 arch/mips/ar7/platform.c | 5 +++++
 arch/mips/ar7/prom.c     | 2 --
 2 files changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.13.2
#1 lore raw

PATCH 1/3 MIPS: AR7: defer registration of GPIO

When called from prom init code, ar7_gpio_init() will fail as it will call gpiochip_add() which relies on a working kmalloc() to alloc the gpio_desc array and kmalloc is not useable yet at prom init time.

Move ar7_gpio_init() to ar7_register_devices() (a device_initcall) where kmalloc works.

Fixes 14e85c0e69d5 ("gpio: remove gpio_descs global array")

---
Text shamelessy stolen from commit 2ec459f2a77b8.

 arch/mips/ar7/platform.c | 4 ++++
 arch/mips/ar7/prom.c     | 2 --
 2 files changed, 4 insertions(+), 2 deletions(-)
arch/mips/ar7/platform.c +4 -0
index df7acea3747a..f2c9f90c5f13 100644
@@ -653,6 +653,10 @@ static int __init ar7_register_devices(void)
 	u32 val;
 	int res;
 
+	res = ar7_gpio_init();
+	if (res)
+		pr_warn("unable to register gpios: %d\n", res);
+
 	res = ar7_register_uarts();
 	if (res)
 		pr_err("unable to setup uart(s): %d\n", res);
arch/mips/ar7/prom.c +0 -2
index 4fd83336131a..dd53987a690f 100644
@@ -246,8 +246,6 @@ void __init prom_init(void)
 	ar7_init_cmdline(fw_arg0, (char **)fw_arg1);
 	ar7_init_env((struct env_var *)fw_arg2);
 	console_config();
-
-	ar7_gpio_init();
 }
 
 #define PORT(offset) (KSEG1ADDR(AR7_REGS_UART0 + (offset * 4)))
Signature · 1 line
2.13.2
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] MIPS: AR7: defer registration of GPIO

Quoted 9 lines · Jonas Gorski

When called from prom init code, ar7_gpio_init() will fail as it will call gpiochip_add() which relies on a working kmalloc() to alloc the gpio_desc array and kmalloc is not useable yet at prom init time.

Move ar7_gpio_init() to ar7_register_devices() (a device_initcall) where kmalloc works.

Fixes 14e85c0e69d5 ("gpio: remove gpio_descs global array")
Signature · 1 line
Florian
#3 lore raw

PATCH 2/3 MIPS: AR7: ensure that serial ports are properly set up

In reply to Jonas Gorski

From: Oswald Buddenhagen <[email protected]>

without UPF_FIXED_TYPE, the data from the PORT_AR7 uart_config entry is never copied, resulting in a dead port.

Fixes 154615d55459 ("MIPS: AR7: Use correct UART port type")
[jonas.gorski: add Fixes tag]
---
 arch/mips/ar7/platform.c | 1 +
 1 file changed, 1 insertion(+)
arch/mips/ar7/platform.c +1 -0
index f2c9f90c5f13..4674f1efbe7a 100644
@@ -575,6 +575,7 @@ static int __init ar7_register_uarts(void)
 	uart_port.type		= PORT_AR7;
 	uart_port.uartclk	= clk_get_rate(bus_clk) / 2;
 	uart_port.iotype	= UPIO_MEM32;
+	uart_port.flags		= UPF_FIXED_TYPE;
 	uart_port.regshift	= 2;
 
 	uart_port.line		= 0;
Signature · 1 line
2.13.2
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] MIPS: AR7: ensure that serial ports are properly set up

Quoted 9 lines · Jonas Gorski

From: Oswald Buddenhagen <[email protected]>

without UPF_FIXED_TYPE, the data from the PORT_AR7 uart_config entry is never copied, resulting in a dead port.

Fixes 154615d55459 ("MIPS: AR7: Use correct UART port type")
[jonas.gorski: add Fixes tag]
Signature · 1 line
Florian
#5 lore raw

RFC PATCH 3/3 MIPS: AR7: ensure the port type's FCR value is used

In reply to Jonas Gorski

Since commit aef9a7bd9b67 ("serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers"), the port's default FCR value isn't used in serial8250_do_set_termios anymore, but copied over once in serial8250_config_port and then modified as needed.

Unfortunately, serial8250_config_port will never be called if the port is shared between kernel and userspace, and the port's flag doesn't have UPF_BOOT_AUTOCONF, which would trigger a serial8250_config_port as well.

This causes garbled output from userspace:

[    5.220000] random: procd urandom read with 49 bits of entropy available

ers
[kee

Fix this by forcing it to be configured on boot, resulting in the expected output:

[    5.250000] random: procd urandom read with 50 bits of entropy available

Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level

Fixes aef9a7bd9b67 ("serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers")

---
I'm not sure if this is just AR7's issue, or if this points to a general issue for UARTs used as kernel console and login console with the "fixed" commit.

 arch/mips/ar7/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/ar7/platform.c +1 -1
index 4674f1efbe7a..e1675c25d5d4 100644
@@ -575,7 +575,7 @@ static int __init ar7_register_uarts(void)
 	uart_port.type		= PORT_AR7;
 	uart_port.uartclk	= clk_get_rate(bus_clk) / 2;
 	uart_port.iotype	= UPIO_MEM32;
-	uart_port.flags		= UPF_FIXED_TYPE;
+	uart_port.flags		= UPF_FIXED_TYPE | UPF_BOOT_AUTOCONF;
 	uart_port.regshift	= 2;
 
 	uart_port.line		= 0;
Signature · 1 line
2.13.2
#6 lore raw

Re: [PATCH RFC 3/3] MIPS: AR7: ensure the port type's FCR value is used

Quoted 22 lines · Jonas Gorski

Since commit aef9a7bd9b67 ("serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers"), the port's default FCR value isn't used in serial8250_do_set_termios anymore, but copied over once in serial8250_config_port and then modified as needed.

Unfortunately, serial8250_config_port will never be called if the port is shared between kernel and userspace, and the port's flag doesn't have UPF_BOOT_AUTOCONF, which would trigger a serial8250_config_port as well.

This causes garbled output from userspace:

[    5.220000] random: procd urandom read with 49 bits of entropy available

ers
[kee

Fix this by forcing it to be configured on boot, resulting in the expected output:

[    5.250000] random: procd urandom read with 50 bits of entropy available

Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level

Quoted 6 lines
Fixes aef9a7bd9b67 ("serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers")

---
I'm not sure if this is just AR7's issue, or if this points to a general issue for UARTs used as kernel console and login console with the "fixed" commit.

Thanks. Given nobody seems to have objected, I've applied to my mips-fixes branch, with stable tag for 3.17+.

Cheers
James

Quoted 21 lines
 arch/mips/ar7/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/ar7/platform.c +1 -1
index 4674f1efbe7a..e1675c25d5d4 100644
@@ -575,7 +575,7 @@ static int __init ar7_register_uarts(void)
 	uart_port.type		= PORT_AR7;
 	uart_port.uartclk	= clk_get_rate(bus_clk) / 2;
 	uart_port.iotype	= UPIO_MEM32;
-	uart_port.flags		= UPF_FIXED_TYPE;
+	uart_port.flags		= UPF_FIXED_TYPE | UPF_BOOT_AUTOCONF;
 	uart_port.regshift	= 2;
 
 	uart_port.line		= 0;
Signature · 1 line
2.13.2
#7 lore raw

Re: [PATCH RFC 3/3] MIPS: AR7: ensure the port type's FCR value is used

Quoted 30 lines · James Hogan
Quoted 22 lines · Jonas Gorski

Since commit aef9a7bd9b67 ("serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers"), the port's default FCR value isn't used in serial8250_do_set_termios anymore, but copied over once in serial8250_config_port and then modified as needed.

Unfortunately, serial8250_config_port will never be called if the port is shared between kernel and userspace, and the port's flag doesn't have UPF_BOOT_AUTOCONF, which would trigger a serial8250_config_port as well.

This causes garbled output from userspace:

[    5.220000] random: procd urandom read with 49 bits of entropy available

ers
[kee

Fix this by forcing it to be configured on boot, resulting in the expected output:

[    5.250000] random: procd urandom read with 50 bits of entropy available

Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level

Quoted 6 lines
Fixes aef9a7bd9b67 ("serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers")

---
I'm not sure if this is just AR7's issue, or if this points to a general issue for UARTs used as kernel console and login console with the "fixed" commit.

Quoted 2 lines

Thanks. Given nobody seems to have objected, I've applied to my mips-fixes branch, with stable tag for 3.17+.

Hmm, I don't see it in
https://git.kernel.org/pub/scm/linux/kernel/git/jhogan/mips.git/log/?h=mips-fixes
- did you maybe forget to push?

Regards
Jonas

#8 lore raw

Re: [PATCH RFC 3/3] MIPS: AR7: ensure the port type's FCR value is used

Quoted 31 lines · Jonas Gorski
Quoted 30 lines · James Hogan
Quoted 28 lines · Jonas Gorski

Since commit aef9a7bd9b67 ("serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers"), the port's default FCR value isn't used in serial8250_do_set_termios anymore, but copied over once in serial8250_config_port and then modified as needed.

Unfortunately, serial8250_config_port will never be called if the port is shared between kernel and userspace, and the port's flag doesn't have UPF_BOOT_AUTOCONF, which would trigger a serial8250_config_port as well.

This causes garbled output from userspace:

[    5.220000] random: procd urandom read with 49 bits of entropy available

ers
[kee

Fix this by forcing it to be configured on boot, resulting in the expected output:

[    5.250000] random: procd urandom read with 50 bits of entropy available

Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level

Fixes aef9a7bd9b67 ("serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers")

---
I'm not sure if this is just AR7's issue, or if this points to a general issue for UARTs used as kernel console and login console with the "fixed" commit.

Quoted 6 lines
Quoted 2 lines

Thanks. Given nobody seems to have objected, I've applied to my mips-fixes branch, with stable tag for 3.17+.

Hmm, I don't see it in
https://git.kernel.org/pub/scm/linux/kernel/git/jhogan/mips.git/log/?h=mips-fixes
- did you maybe forget to push?

Ralf reappeared so I delegated the patch to him in patchwork, and he has apparently marked it as accepted.

But perhaps that only just happened and he hasn't pushed yet. Ralf?

Cheers
James

#9 lore raw

Re: [PATCH RFC 3/3] MIPS: AR7: ensure the port type's FCR value is used

In reply to Jonas Gorski

Hi stable maintainers,

Quoted 18 lines · Jonas Gorski

Since commit aef9a7bd9b67 ("serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers"), the port's default FCR value isn't used in serial8250_do_set_termios anymore, but copied over once in serial8250_config_port and then modified as needed.

Unfortunately, serial8250_config_port will never be called if the port is shared between kernel and userspace, and the port's flag doesn't have UPF_BOOT_AUTOCONF, which would trigger a serial8250_config_port as well.

This causes garbled output from userspace:

[    5.220000] random: procd urandom read with 49 bits of entropy available

ers
[kee

Fix this by forcing it to be configured on boot, resulting in the expected output:

Quoted 6 lines
[    5.250000] random: procd urandom read with 50 bits of entropy available

Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level

Fixes aef9a7bd9b67 ("serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers")

Please can this patch be applied to stable branches 3.17+. It is now merged into mainline as commit 0a5191efe06b ("MIPS: AR7: ensure the port type's FCR value is used").

Commit b084116f8587 ("MIPS: AR7: Ensure that serial ports are properly set up") is a prerequisite for it to apply cleanly, but is already tagged for stable.

Thanks
James

#10 lore raw

Re: [PATCH RFC 3/3] MIPS: AR7: ensure the port type's FCR value is used

Quoted 28 lines · James Hogan

Hi stable maintainers,

Quoted 18 lines · Jonas Gorski

Since commit aef9a7bd9b67 ("serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers"), the port's default FCR value isn't used in serial8250_do_set_termios anymore, but copied over once in serial8250_config_port and then modified as needed.

Unfortunately, serial8250_config_port will never be called if the port is shared between kernel and userspace, and the port's flag doesn't have UPF_BOOT_AUTOCONF, which would trigger a serial8250_config_port as well.

This causes garbled output from userspace:

[    5.220000] random: procd urandom read with 49 bits of entropy available

ers
[kee

Fix this by forcing it to be configured on boot, resulting in the expected output:

Quoted 6 lines
[    5.250000] random: procd urandom read with 50 bits of entropy available

Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level

Fixes aef9a7bd9b67 ("serial/uart/8250: Add tunable RX interrupt trigger I/F of FIFO buffers")
Quoted 7 lines

Please can this patch be applied to stable branches 3.17+. It is now merged into mainline as commit 0a5191efe06b ("MIPS: AR7: ensure the port type's FCR value is used").

Commit b084116f8587 ("MIPS: AR7: Ensure that serial ports are properly set up") is a prerequisite for it to apply cleanly, but is already tagged for stable.

Now snuck into this round of stable -rc review :)

thanks,

greg k-h

#11 lore raw
In reply to Jonas Gorski
Quoted 10 lines · Jonas Gorski

This patchset fixes a few issues found in AR7 that accumulated in the past few years. One was fixed for ages in OpenWrt/LEDE and never made it upstream, the others weren't noticed until now.

Jonas Gorski (2):
MIPS: AR7: defer registration of GPIO
MIPS: AR7: ensure the port type's FCR value is used

Oswald Buddenhagen (1):
MIPS: AR7: ensure that serial ports are properly set up

Thanks. Patches 1 + 2 applied for 4.14.

Cheers
James