serial: 8250: don't register ports that have no hardware
PATCH 1/1 serial: 8250: don't register ports that have no hardware
The 8250 driver creates a fixed set of port slots at boot and registers a ttyS device for each one, even when the slot describes no hardware. On device tree platforms those slots are empty, but they still take the ttyS0..ttyS3 names.
New Amlogic SoCs (S4, T7) name their real UARTs ttyS as well. With both drivers built in, as in arm64 defconfig, the real port fails to bind:
sysfs: cannot create duplicate filename '/class/tty/ttyS0' meson_uart fe078000.serial: Cannot register tty device on line 0
Skip slots that have no I/O and no memory address. Legacy x86 slots come with resources and are not affected.
--- drivers/tty/serial/8250/8250_core.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/tty/serial/8250/8250_core.c +8 -0
@@ -378,6 +378,14 @@ void __init serial8250_register_ports(struct uart_driver *drv, struct device *deif (up->port.dev)continue ; +/* +* Skip slots that describe no hardware: they would only +* take up ttyS<n> names. Real ports get their node when +* they claim a slot in serial8250_register_8250_port(). +*/ +if (!up->port.iobase && !up->port.mapbase && !up->port.membase) +continue ; + up->port.dev = dev;if (uart_console_registered (&up->port))
Signature · 1 line
2.55.0
Jiri Slaby
maintainerQuoted 25 lines · Lucas Tanure
The 8250 driver creates a fixed set of port slots at boot and registers a ttyS device for each one, even when the slot describes no hardware. On device tree platforms those slots are empty, but they still take the ttyS0..ttyS3 names.
New Amlogic SoCs (S4, T7) name their real UARTs ttyS as well. With both drivers built in, as in arm64 defconfig, the real port fails to bind:
sysfs: cannot create duplicate filename '/class/tty/ttyS0'
meson_uartfe078000.serial: Cannot register tty device on line 0Skip slots that have no I/O and no memory address. Legacy x86 slots come with resources and are not affected.
Signed-off-by Lucas Tanure <[email protected]>Assisted-by Claude:claude-fable-5--- drivers/tty/serial/8250/8250_core.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/tty/serial/8250/8250_core.c +0
-0
drivers/tty/serial/8250/8250_core.c void __init serial8250_register_ports(struct uart_driver *drv, struct device *de · line 387
Quoted 10 lines
drivers/tty/serial/8250/8250_core.c +7
-0@@ -378,6 +378,14 @@ void __init serial8250_register_ports(struct uart_driver *drv, struct device *deif (up->port.dev)continue ; +/* +* Skip slots that describe no hardware: they would only +* take up ttyS<n> names. Real ports get their node when +* they claim a slot in serial8250_register_8250_port(). +*/ +if (!up->port.iobase && !up->port.mapbase && !up->port.membase) +continue ;
So you can no longer set up those ports via TIOCSSERIAL?
And what about already registered consoles?
Why does meson register ttyS* in the first place?
F*ck AI proposed changes.
thanks,
Signature · 2 lines
js suse labs
Quoted 21 lines · Jiri Slaby
Quoted 20 lines · Lucas Tanure
The 8250 driver creates a fixed set of port slots at boot and registers a ttyS device for each one, even when the slot describes no hardware. On device tree platforms those slots are empty, but they still take the ttyS0..ttyS3 names.
New Amlogic SoCs (S4, T7) name their real UARTs ttyS as well. With both drivers built in, as in arm64 defconfig, the real port fails to bind:
sysfs: cannot create duplicate filename '/class/tty/ttyS0'
meson_uartfe078000.serial: Cannot register tty device on line 0Skip slots that have no I/O and no memory address. Legacy x86 slots come with resources and are not affected.
Signed-off-by Lucas Tanure <[email protected]>Assisted-by Claude:claude-fable-5---
drivers/tty/serial/8250/8250_core.c| 8 ++++++++1 file changed, 8 insertions(+)
Quoted 16 lines
Quoted 7 lines
drivers/tty/serial/8250/8250_core.c +0
-0@@ -378,6 +378,14 @@ void __init serial8250_register_ports(struct
uart_driver*drv, struct device *de
if (up->port.dev)Quoted 8 lines
continue;
+ /*
+ * Skip slots that describe no hardware: they would only + * take up ttyS<n> names. Real ports get their node when + * they claim a slot inserial8250_register_8250_port(). + */
+ if (!up->port.iobase && !up->port.mapbase && !up->port.membase) + continue;
Hi,
I am working on upstreaming the Khadas VIM4 (Amlogic T7). On that board the serial console does not come up at all: meson_uart fails to register because the 8250 stub ports already own the ttyS names.
Quoted 5 lines
So you can no longer set up those ports via TIOCSSERIAL?
And what about already registered consoles?
Why does meson register ttyS* in the first place?
Because of commit e71aab9d6132 ("tty: serial: meson: apply ttyS devname instead of ttyAML for new SoCs"). meson_uart carries two uart_drivers, ttyAML and ttyS, and A1, S4 and T7 are wired to the ttyS one.
Quoted 4 lines
F*ck AI proposed changes.
thanks,
I will talk to Amlogic list to see if there is other solution.
thanks,
lucas
Greg Kroah-Hartman
maintainerQuoted 7 lines · Lucas Tanure
The 8250 driver creates a fixed set of port slots at boot and registers a ttyS device for each one, even when the slot describes no hardware. On device tree platforms those slots are empty, but they still take the ttyS0..ttyS3 names.
New Amlogic SoCs (S4, T7) name their real UARTs ttyS as well. With both drivers built in, as in arm64 defconfig, the real port fails to bind:
Then fix that bug, don't break everyone else's systems because of it.
greg k-h
Quoted 11 lines · Greg Kroah-Hartman
Quoted 7 lines · Lucas Tanure
The 8250 driver creates a fixed set of port slots at boot and registers a ttyS device for each one, even when the slot describes no hardware. On device tree platforms those slots are empty, but they still take the ttyS0..ttyS3 names.
New Amlogic SoCs (S4, T7) name their real UARTs ttyS as well. With both drivers built in, as in arm64 defconfig, the real port fails to bind:
Then fix that bug, don't break everyone else's systems because of it.
Hi,
Understood. I thought preventing 8250 from probing on devices that don't use it would be a good idea, and fix my bug. Thanks for the feedback.
I will tak to Amlogic list the ttyS name collision introduced for the new Amlogic SoCs in e71aab9d6132.
Thanks,
Lucas
Quoted 1 line
greg k-h
Greg Kroah-Hartman
maintainerQuoted 12 lines · Lucas Tanure
Quoted 11 lines · Greg Kroah-Hartman
Quoted 7 lines · Lucas Tanure
The 8250 driver creates a fixed set of port slots at boot and registers a ttyS device for each one, even when the slot describes no hardware. On device tree platforms those slots are empty, but they still take the ttyS0..ttyS3 names.
New Amlogic SoCs (S4, T7) name their real UARTs ttyS as well. With both drivers built in, as in arm64 defconfig, the real port fails to bind:
Then fix that bug, don't break everyone else's systems because of it.
Quoted 7 lines
Hi,
Understood. I thought preventing 8250 from probing on devices that don't use it would be a good idea, and fix my bug. Thanks for the feedback.
I will tak to Amlogic list the ttyS name collision introduced for the new Amlogic SoCs in
e71aab9d6132.
That was an explicit decision by Amlogic to do that, so there should not be any collisions as their systems should NOT be having the older 8250 device tree entries.
So perhaps just fix your device tree to not be broken?
thanks,
greg k-h
Quoted 25 lines · Greg Kroah-Hartman
Quoted 12 lines · Lucas Tanure
Quoted 11 lines · Greg Kroah-Hartman
Quoted 7 lines · Lucas Tanure
The 8250 driver creates a fixed set of port slots at boot and registers a ttyS device for each one, even when the slot describes no hardware. On device tree platforms those slots are empty, but they still take the ttyS0..ttyS3 names.
New Amlogic SoCs (S4, T7) name their real UARTs ttyS as well. With both drivers built in, as in arm64 defconfig, the real port fails to bind:
Then fix that bug, don't break everyone else's systems because of it.
Quoted 7 lines
Hi,
Understood. I thought preventing 8250 from probing on devices that don't use it would be a good idea, and fix my bug. Thanks for the feedback.
I will tak to Amlogic list the ttyS name collision introduced for the new Amlogic SoCs in
e71aab9d6132.That was an explicit decision by Amlogic to do that, so there should not be any collisions as their systems should NOT be having the older 8250 device tree entries.
Quoted 5 lines
So perhaps just fix your device tree to not be broken?
thanks,
greg k-h
Hi,
There are no 8250 nodes in the Vim4 device tree.
At __serial8250_isa_init_ports() in 8250_platform.c it creates nr_uarts ports unconditionally:
for (i = 0; i < nr_uarts; i++)
serial8250_setup_port(i);And serial8250_init calls serial8250_isa_init_ports unconditionally. So by just probing the module the serial ports are created.
Am I missing something? I can also boot with 8250.nr_uarts=0 to make the issue go away, but I would prefer a code fix for the colision.
I will take the naming question to the Amlogic list, but I wanted to double check my understand of the code.
Thanks,
Lucas
Greg Kroah-Hartman
maintainerQuoted 31 lines · Lucas Tanure
Quoted 25 lines · Greg Kroah-Hartman
Quoted 12 lines · Lucas Tanure
Quoted 11 lines · Greg Kroah-Hartman
Quoted 7 lines · Lucas Tanure
The 8250 driver creates a fixed set of port slots at boot and registers a ttyS device for each one, even when the slot describes no hardware. On device tree platforms those slots are empty, but they still take the ttyS0..ttyS3 names.
New Amlogic SoCs (S4, T7) name their real UARTs ttyS as well. With both drivers built in, as in arm64 defconfig, the real port fails to bind:
Then fix that bug, don't break everyone else's systems because of it.
Quoted 7 lines
Hi,
Understood. I thought preventing 8250 from probing on devices that don't use it would be a good idea, and fix my bug. Thanks for the feedback.
I will tak to Amlogic list the ttyS name collision introduced for the new Amlogic SoCs in
e71aab9d6132.That was an explicit decision by Amlogic to do that, so there should not be any collisions as their systems should NOT be having the older 8250 device tree entries.
Quoted 5 lines
So perhaps just fix your device tree to not be broken?
thanks,
greg k-h
Quoted 8 lines
Hi,
There are no 8250 nodes in the Vim4 device tree.
At__serial8250_isa_init_ports()in8250_platform.cit createsnr_uartsports unconditionally:for (i = 0; i < nr_uarts; i++) serial8250_setup_port(i);
Then the amlogic driver should not be attempting to use the same device nodes. Something is broken somewhere, and I don't think it is in the 30+ year old isa code :)
thanks,
greg k-h