Devicetree
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Stabilize serial line numbers on MediaTek boards
@ 2026-07-27  7:38 Carlo Caione
  2026-07-27  7:38 ` [PATCH v2 1/2] arm64: dts: mediatek: alias all enabled serial ports Carlo Caione
  2026-07-27  7:38 ` [PATCH v2 2/2] serial: 8250_mtk: honor DT serial aliases Carlo Caione
  0 siblings, 2 replies; 9+ messages in thread
From: Carlo Caione @ 2026-07-27  7:38 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	AngeloGioacchino Del Regno, Greg Kroah-Hartman, Jiri Slaby
  Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-serial, dlechner, jstephan, Carlo Caione

On MediaTek boards typically only serial0 is aliased, so the remaining
enabled UARTs get first-free ttyS line numbers from the 8250 core at
probe time. Line numbers are handed out in probe order, and probe order
is not deterministic once a UART defers on its clocks, so the console
UART can lose ttyS0 to another port.

This was observed on the Genio 700 EVK running the Ubuntu 26.04 generic
kernel: uart0 (the debug console) deferred waiting for its clocks while
uart1 probed first and claimed ttyS0. With console=ttyS0 on the kernel
command line the console then pointed at the wrong UART, and the boot
looked like it had hung on the serial console. The failure is
intermittent and depends purely on probe timing.

Pin the line numbers explicitly instead:

- Patch 1 aliases every enabled UART on the affected Mediatek boards, so
  DT expresses the intended serial<N> -> ttyS<N> mapping.

- Patch 2 makes the 8250_mtk driver read that alias with
  of_alias_get_id() and seed uart.port.line before registering the
  port, so the 8250 core reserves the requested ttyS slot instead of
  falling back to first-free.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
---
Changes in v2:
- Added some missing MTK boards
- Link to v1: https://patch.msgid.link/20260708-ccaione-genio-serial-aliases-v1-0-bf22229e9383@baylibre.com

---
Carlo Caione (2):
      arm64: dts: mediatek: alias all enabled serial ports
      serial: 8250_mtk: honor DT serial aliases

 arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts    | 1 +
 arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts              | 1 +
 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts  | 2 ++
 arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts              | 2 ++
 arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi            | 1 +
 arch/arm64/boot/dts/mediatek/mt8192-asurada-hayato-r1.dts | 4 ++++
 arch/arm64/boot/dts/mediatek/mt8195-demo.dts              | 1 +
 arch/arm64/boot/dts/mediatek/mt8365-evk.dts               | 2 ++
 arch/arm64/boot/dts/mediatek/mt8390-genio-common.dtsi     | 2 ++
 arch/arm64/boot/dts/mediatek/mt8390-grinn-genio-sbc.dtsi  | 2 ++
 arch/arm64/boot/dts/mediatek/mt8390-tungsten-smarc.dtsi   | 2 ++
 arch/arm64/boot/dts/mediatek/mt8395-genio-common.dtsi     | 1 +
 drivers/tty/serial/8250/8250_mtk.c                        | 7 ++++++-
 13 files changed, 27 insertions(+), 1 deletion(-)
---
base-commit: f5098b6bae761e346ebcd9da7f95622c04733cff
change-id: 20260708-ccaione-genio-serial-aliases-e5f2c28b5ff6

Best regards,
--  
Carlo Caione <ccaione@baylibre.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/2] arm64: dts: mediatek: alias all enabled serial ports
  2026-07-27  7:38 [PATCH v2 0/2] Stabilize serial line numbers on MediaTek boards Carlo Caione
@ 2026-07-27  7:38 ` Carlo Caione
  2026-07-27  9:49   ` Chen-Yu Tsai
  2026-07-27 11:30   ` AngeloGioacchino Del Regno
  2026-07-27  7:38 ` [PATCH v2 2/2] serial: 8250_mtk: honor DT serial aliases Carlo Caione
  1 sibling, 2 replies; 9+ messages in thread
From: Carlo Caione @ 2026-07-27  7:38 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	AngeloGioacchino Del Regno, Greg Kroah-Hartman, Jiri Slaby
  Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-serial, dlechner, jstephan, Carlo Caione

On most MediaTek boards only serial0 is aliased, so the remaining
enabled uarts get first-free ttyS line numbers from the 8250 core in
probe order. When the console uart defers on its clocks another uart can
win line 0: console=ttyS0 then ends up on the wrong port and the boot
looks like a hang on the serial console, depending on probe order.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
---
 arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts    | 1 +
 arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts              | 1 +
 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts  | 2 ++
 arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts              | 2 ++
 arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi            | 1 +
 arch/arm64/boot/dts/mediatek/mt8192-asurada-hayato-r1.dts | 4 ++++
 arch/arm64/boot/dts/mediatek/mt8195-demo.dts              | 1 +
 arch/arm64/boot/dts/mediatek/mt8365-evk.dts               | 2 ++
 arch/arm64/boot/dts/mediatek/mt8390-genio-common.dtsi     | 2 ++
 arch/arm64/boot/dts/mediatek/mt8390-grinn-genio-sbc.dtsi  | 2 ++
 arch/arm64/boot/dts/mediatek/mt8390-tungsten-smarc.dtsi   | 2 ++
 arch/arm64/boot/dts/mediatek/mt8395-genio-common.dtsi     | 1 +
 12 files changed, 21 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts b/arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts
index 0e086dd487d9..63659e240b1d 100644
--- a/arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts
+++ b/arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts
@@ -20,6 +20,7 @@ aliases {
 		mmc2 = &mmc2;
 		serial0 = &uart0;
 		serial1 = &uart1;
+		serial2 = &uart2;
 	};
 
 	backlight_lcd0: backlight {
diff --git a/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts b/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts
index 8c3e2e2578bc..7bccad118d24 100644
--- a/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts
+++ b/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts
@@ -20,6 +20,7 @@ / {
 
 	aliases {
 		serial0 = &uart0;
+		serial2 = &uart2;
 	};
 
 	chosen {
diff --git a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts
index 19f538d160ab..637e5567c1e0 100644
--- a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts
@@ -21,6 +21,8 @@ / {
 
 	aliases {
 		serial0 = &uart0;
+		serial1 = &uart1;
+		serial2 = &uart2;
 		ethernet0 = &gmac0;
 		ethernet1 = &gmac1;
 	};
diff --git a/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts b/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
index 5d8e3d3f6c20..9dfd882ca484 100644
--- a/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
@@ -16,6 +16,8 @@ / {
 
 	aliases {
 		serial0 = &uart0;
+		serial1 = &uart1;
+		serial2 = &uart2;
 	};
 
 	chosen {
diff --git a/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi b/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi
index a8e257b21a88..ae957deac8df 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi
@@ -13,6 +13,7 @@
 / {
 	aliases {
 		serial0 = &uart0;
+		serial1 = &uart1;
 		mmc0 = &mmc0;
 		mmc1 = &mmc1;
 	};
diff --git a/arch/arm64/boot/dts/mediatek/mt8192-asurada-hayato-r1.dts b/arch/arm64/boot/dts/mediatek/mt8192-asurada-hayato-r1.dts
index ac2673e56fb8..233711cb4556 100644
--- a/arch/arm64/boot/dts/mediatek/mt8192-asurada-hayato-r1.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8192-asurada-hayato-r1.dts
@@ -9,6 +9,10 @@ / {
 	model = "Google Hayato rev1";
 	chassis-type = "convertible";
 	compatible = "google,hayato-rev1", "google,hayato", "mediatek,mt8192";
+
+	aliases {
+		serial1 = &uart1;
+	};
 };
 
 &keyboard_controller {
diff --git a/arch/arm64/boot/dts/mediatek/mt8195-demo.dts b/arch/arm64/boot/dts/mediatek/mt8195-demo.dts
index 1f59b5786b81..13132a35080f 100644
--- a/arch/arm64/boot/dts/mediatek/mt8195-demo.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8195-demo.dts
@@ -19,6 +19,7 @@ / {
 
 	aliases {
 		serial0 = &uart0;
+		serial1 = &uart1;
 	};
 
 	chosen {
diff --git a/arch/arm64/boot/dts/mediatek/mt8365-evk.dts b/arch/arm64/boot/dts/mediatek/mt8365-evk.dts
index a30ee523b0b5..c535de34dfac 100644
--- a/arch/arm64/boot/dts/mediatek/mt8365-evk.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8365-evk.dts
@@ -24,6 +24,8 @@ aliases {
 		mmc0 = &mmc0;
 		mmc1 = &mmc1;
 		serial0 = &uart0;
+		serial1 = &uart1;
+		serial2 = &uart2;
 	};
 
 	chosen {
diff --git a/arch/arm64/boot/dts/mediatek/mt8390-genio-common.dtsi b/arch/arm64/boot/dts/mediatek/mt8390-genio-common.dtsi
index b0c97930a0e6..26e24431d467 100644
--- a/arch/arm64/boot/dts/mediatek/mt8390-genio-common.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8390-genio-common.dtsi
@@ -33,6 +33,8 @@ aliases {
 		mmc0 = &mmc0;
 		mmc1 = &mmc1;
 		serial0 = &uart0;
+		serial1 = &uart1;
+		serial2 = &uart2;
 	};
 
 	backlight_lcm1: backlight-lcm1 {
diff --git a/arch/arm64/boot/dts/mediatek/mt8390-grinn-genio-sbc.dtsi b/arch/arm64/boot/dts/mediatek/mt8390-grinn-genio-sbc.dtsi
index 888248a75e93..51f12328a1d6 100644
--- a/arch/arm64/boot/dts/mediatek/mt8390-grinn-genio-sbc.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8390-grinn-genio-sbc.dtsi
@@ -17,6 +17,8 @@ aliases {
 		i2c5 = &i2c5;
 		i2c6 = &i2c6;
 		serial0 = &uart0;
+		serial1 = &uart1;
+		serial2 = &uart2;
 	};
 
 	chosen {
diff --git a/arch/arm64/boot/dts/mediatek/mt8390-tungsten-smarc.dtsi b/arch/arm64/boot/dts/mediatek/mt8390-tungsten-smarc.dtsi
index 9f5a0ec563e8..668985428fc2 100644
--- a/arch/arm64/boot/dts/mediatek/mt8390-tungsten-smarc.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8390-tungsten-smarc.dtsi
@@ -31,6 +31,8 @@ aliases {
 		rtc0 = &rv3028;
 		rtc1 = &mt6359rtc;
 		serial0 = &uart0;
+		serial1 = &uart1;
+		serial2 = &uart2;
 	};
 
 	backlight_lcd0: backlight-lcd0 {
diff --git a/arch/arm64/boot/dts/mediatek/mt8395-genio-common.dtsi b/arch/arm64/boot/dts/mediatek/mt8395-genio-common.dtsi
index edc5539bebde..86e487fb1832 100644
--- a/arch/arm64/boot/dts/mediatek/mt8395-genio-common.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8395-genio-common.dtsi
@@ -22,6 +22,7 @@ aliases {
 		mmc0 = &mmc0;
 		mmc1 = &mmc1;
 		serial0 = &uart0;
+		serial1 = &uart1;
 	};
 
 	chosen {

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/2] serial: 8250_mtk: honor DT serial aliases
  2026-07-27  7:38 [PATCH v2 0/2] Stabilize serial line numbers on MediaTek boards Carlo Caione
  2026-07-27  7:38 ` [PATCH v2 1/2] arm64: dts: mediatek: alias all enabled serial ports Carlo Caione
@ 2026-07-27  7:38 ` Carlo Caione
  2026-07-27  7:51   ` sashiko-bot
  2026-07-27  9:39   ` Chen-Yu Tsai
  1 sibling, 2 replies; 9+ messages in thread
From: Carlo Caione @ 2026-07-27  7:38 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	AngeloGioacchino Del Regno, Greg Kroah-Hartman, Jiri Slaby
  Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-serial, dlechner, jstephan, Carlo Caione

The Genio board DTs provide serial aliases for all enabled UARTs, but
the MTK 8250 driver still registered every port with the default line
number. If uart0 deferred and another UART probed first, the 8250 core
could still assign ttyS0 to the wrong port despite the DT aliases.

Read the serial alias during OF probe and seed uart.port.line before
registering the port so the 8250 core reserves the requested ttyS slot.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
---
 drivers/tty/serial/8250/8250_mtk.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
index e6a56cf54ae0..841d64f6a707 100644
--- a/drivers/tty/serial/8250/8250_mtk.c
+++ b/drivers/tty/serial/8250/8250_mtk.c
@@ -8,6 +8,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/pinctrl/consumer.h>
@@ -521,7 +522,7 @@ static int mtk8250_probe(struct platform_device *pdev)
 	struct uart_8250_port uart = {};
 	struct mtk8250_data *data;
 	struct resource *regs;
-	int irq, err;
+	int irq, err, line;
 	struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev);
 
 	irq = platform_get_irq(pdev, 0);
@@ -575,6 +576,10 @@ static int mtk8250_probe(struct platform_device *pdev)
 #endif
 
 	if (is_of_node(fwnode)) {
+		line = of_alias_get_id(pdev->dev.of_node, "serial");
+		if (line >= 0)
+			uart.port.line = line;
+
 		/* Disable Rate Fix function */
 		writel(0x0, uart.port.membase +
 			(MTK_UART_RATE_FIX << uart.port.regshift));

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/2] serial: 8250_mtk: honor DT serial aliases
  2026-07-27  7:38 ` [PATCH v2 2/2] serial: 8250_mtk: honor DT serial aliases Carlo Caione
@ 2026-07-27  7:51   ` sashiko-bot
  2026-07-27  7:53     ` Carlo Caione
  2026-07-27  9:39   ` Chen-Yu Tsai
  1 sibling, 1 reply; 9+ messages in thread
From: sashiko-bot @ 2026-07-27  7:51 UTC (permalink / raw)
  To: Carlo Caione; +Cc: devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] The driver registers the 8250 port before enabling runtime PM, violating TTY subsystem guidelines and causing circular dependencies during probe.
- [High] An integer overflow in baud rate calculation can cause a divide-by-zero kernel panic and incorrect fractional divisor calculations.
--

--- Patch [2]: [PATCH v2 2/2] serial: 8250_mtk: honor DT serial aliases ---
commit 6b60029ee6f08f62cd575815bb6a017e9c0d10a3
Author: Carlo Caione <ccaione@baylibre.com>

serial: 8250_mtk: honor DT serial aliases

The Genio board DTs provide serial aliases for all enabled UARTs, but
the MTK 8250 driver still registered every port with the default line
number. This patch reads the serial alias during OF probe and seeds
uart.port.line before registering the port so the 8250 core reserves
the requested ttyS slot.

> diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
> --- a/drivers/tty/serial/8250/8250_mtk.c
> +++ b/drivers/tty/serial/8250/8250_mtk.c

[ ... ]

> @@ -575,6 +576,10 @@ static int mtk8250_probe(struct platform_device *pdev)
>  #endif
>  
>  	if (is_of_node(fwnode)) {
> +		line = of_alias_get_id(pdev->dev.of_node, "serial");
> +		if (line >= 0)
> +			uart.port.line = line;
> +
>  		/* Disable Rate Fix function */
>  		writel(0x0, uart.port.membase +
>  			(MTK_UART_RATE_FIX << uart.port.regshift));

[Severity: High]
This is a pre-existing issue, but while looking at mtk8250_probe(), I noticed
a potential circular dependency during port registration.

Further down in mtk8250_probe(), the driver registers the 8250 port before
enabling runtime PM:

    data->line = serial8250_register_8250_port(&uart);
    if (data->line < 0)
        return data->line;

    data->rx_wakeup_irq = platform_get_irq_optional(pdev, 1);

    pm_runtime_set_active(&pdev->dev);
    pm_runtime_enable(&pdev->dev);

During port registration, the TTY core may synchronously invoke the driver's
pm() callback, mtk8250_do_pm(). If that callback invokes pm_runtime_get_sync()
before runtime PM is initialized on the device, it can cause blocked tasks and
hung worker threads.

Could this be fixed by moving pm_runtime_set_active() and pm_runtime_enable()
above the call to serial8250_register_8250_port()?

[Severity: High]
This is another pre-existing issue, but I noticed a potential integer overflow
in the baud rate calculation inside mtk8250_set_termios():

    } else {
        serial_port_out(port, MTK_UART_HIGHS, 0x3);
        quot = DIV_ROUND_UP(port->uartclk, 256 * baud);
    }

If a custom baud rate of exactly 16,777,216 is requested, does the 32-bit
arithmetic in 256 * baud overflow to 0? This would result in a kernel panic
due to division by zero in DIV_ROUND_UP().

Additionally, a bit further down in the same function:

    fraction = ((port->uartclk  * 100) / baud / quot) % 100;

Does port->uartclk * 100 overflow on clocks larger than 42.94 MHz, leading to
incorrect fractional divisor calculations?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260727-ccaione-genio-serial-aliases-v2-0-0f2ae41a8e89@baylibre.com?part=2

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/2] serial: 8250_mtk: honor DT serial aliases
  2026-07-27  7:51   ` sashiko-bot
@ 2026-07-27  7:53     ` Carlo Caione
  0 siblings, 0 replies; 9+ messages in thread
From: Carlo Caione @ 2026-07-27  7:53 UTC (permalink / raw)
  To: sashiko-reviews, Carlo Caione; +Cc: devicetree, robh, conor+dt

On Mon Jul 27, 2026 at 9:51 AM CEST, sashiko-bot wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
>
> Pre-existing issues:
> - [High] The driver registers the 8250 port before enabling runtime PM, violating TTY subsystem guidelines and causing circular dependencies during probe.
> - [High] An integer overflow in baud rate calculation can cause a divide-by-zero kernel panic and incorrect fractional divisor calculations.

[...]
> [Severity: High]
> This is a pre-existing issue, but while looking at mtk8250_probe(), I noticed

[...]
> [Severity: High]
> This is another pre-existing issue, but I noticed a potential integer overflow

This is annoying. I'm NOT fixing pre-existing issue. There will always
be pre-existing issue.

--
Carlo Caione

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/2] serial: 8250_mtk: honor DT serial aliases
  2026-07-27  7:38 ` [PATCH v2 2/2] serial: 8250_mtk: honor DT serial aliases Carlo Caione
  2026-07-27  7:51   ` sashiko-bot
@ 2026-07-27  9:39   ` Chen-Yu Tsai
  1 sibling, 0 replies; 9+ messages in thread
From: Chen-Yu Tsai @ 2026-07-27  9:39 UTC (permalink / raw)
  To: Carlo Caione
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	AngeloGioacchino Del Regno, Greg Kroah-Hartman, Jiri Slaby,
	devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-serial, dlechner, jstephan

On Mon, Jul 27, 2026 at 3:40 PM Carlo Caione <ccaione@baylibre.com> wrote:
>
> The Genio board DTs provide serial aliases for all enabled UARTs, but
> the MTK 8250 driver still registered every port with the default line
> number. If uart0 deferred and another UART probed first, the 8250 core
> could still assign ttyS0 to the wrong port despite the DT aliases.
>
> Read the serial alias during OF probe and seed uart.port.line before
> registering the port so the 8250 core reserves the requested ttyS slot.
>
> Signed-off-by: Carlo Caione <ccaione@baylibre.com>

Matches what is done in __uart_read_properties(),

Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>

> ---
>  drivers/tty/serial/8250/8250_mtk.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
> index e6a56cf54ae0..841d64f6a707 100644
> --- a/drivers/tty/serial/8250/8250_mtk.c
> +++ b/drivers/tty/serial/8250/8250_mtk.c
> @@ -8,6 +8,7 @@
>  #include <linux/clk.h>
>  #include <linux/io.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
>  #include <linux/of_irq.h>
>  #include <linux/of_platform.h>
>  #include <linux/pinctrl/consumer.h>
> @@ -521,7 +522,7 @@ static int mtk8250_probe(struct platform_device *pdev)
>         struct uart_8250_port uart = {};
>         struct mtk8250_data *data;
>         struct resource *regs;
> -       int irq, err;
> +       int irq, err, line;
>         struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev);
>
>         irq = platform_get_irq(pdev, 0);
> @@ -575,6 +576,10 @@ static int mtk8250_probe(struct platform_device *pdev)
>  #endif
>
>         if (is_of_node(fwnode)) {
> +               line = of_alias_get_id(pdev->dev.of_node, "serial");
> +               if (line >= 0)
> +                       uart.port.line = line;
> +
>                 /* Disable Rate Fix function */
>                 writel(0x0, uart.port.membase +
>                         (MTK_UART_RATE_FIX << uart.port.regshift));
>
> --
> 2.55.0
>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/2] arm64: dts: mediatek: alias all enabled serial ports
  2026-07-27  7:38 ` [PATCH v2 1/2] arm64: dts: mediatek: alias all enabled serial ports Carlo Caione
@ 2026-07-27  9:49   ` Chen-Yu Tsai
  2026-07-27 11:30   ` AngeloGioacchino Del Regno
  1 sibling, 0 replies; 9+ messages in thread
From: Chen-Yu Tsai @ 2026-07-27  9:49 UTC (permalink / raw)
  To: Carlo Caione
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	AngeloGioacchino Del Regno, Greg Kroah-Hartman, Jiri Slaby,
	devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-serial, dlechner, jstephan

On Mon, Jul 27, 2026 at 3:40 PM Carlo Caione <ccaione@baylibre.com> wrote:
>
> On most MediaTek boards only serial0 is aliased, so the remaining
> enabled uarts get first-free ttyS line numbers from the 8250 core in
> probe order. When the console uart defers on its clocks another uart can
> win line 0: console=ttyS0 then ends up on the wrong port and the boot
> looks like a hang on the serial console, depending on probe order.
>
> Signed-off-by: Carlo Caione <ccaione@baylibre.com>
> ---
>  arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts    | 1 +
>  arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts              | 1 +
>  arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts  | 2 ++
>  arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts              | 2 ++

>  arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi            | 1 +
>  arch/arm64/boot/dts/mediatek/mt8192-asurada-hayato-r1.dts | 4 ++++

These are the only two MediaTek-based Chromebook designs that use
Bluetooth over UART and have a second UART enabled.

Reviewed-by: Chen-Yu Tsai <wenst@chromium.org> # kukui & asurada-hayato

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/2] arm64: dts: mediatek: alias all enabled serial ports
  2026-07-27  7:38 ` [PATCH v2 1/2] arm64: dts: mediatek: alias all enabled serial ports Carlo Caione
  2026-07-27  9:49   ` Chen-Yu Tsai
@ 2026-07-27 11:30   ` AngeloGioacchino Del Regno
  2026-07-27 11:49     ` Carlo Caione
  1 sibling, 1 reply; 9+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-07-27 11:30 UTC (permalink / raw)
  To: Carlo Caione, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Matthias Brugger, Greg Kroah-Hartman, Jiri Slaby
  Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-serial, dlechner, jstephan

On 7/27/26 09:38, Carlo Caione wrote:
> On most MediaTek boards only serial0 is aliased, so the remaining
> enabled uarts get first-free ttyS line numbers from the 8250 core in
> probe order. When the console uart defers on its clocks another uart can
> win line 0: console=ttyS0 then ends up on the wrong port and the boot
> looks like a hang on the serial console, depending on probe order.
> 
> Signed-off-by: Carlo Caione <ccaione@baylibre.com>
> ---
>   arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts    | 1 +
>   arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts              | 1 +
>   arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts  | 2 ++
>   arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts              | 2 ++
>   arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi            | 1 +
>   arch/arm64/boot/dts/mediatek/mt8192-asurada-hayato-r1.dts | 4 ++++
>   arch/arm64/boot/dts/mediatek/mt8195-demo.dts              | 1 +
>   arch/arm64/boot/dts/mediatek/mt8365-evk.dts               | 2 ++
>   arch/arm64/boot/dts/mediatek/mt8390-genio-common.dtsi     | 2 ++
>   arch/arm64/boot/dts/mediatek/mt8390-grinn-genio-sbc.dtsi  | 2 ++
>   arch/arm64/boot/dts/mediatek/mt8390-tungsten-smarc.dtsi   | 2 ++
>   arch/arm64/boot/dts/mediatek/mt8395-genio-common.dtsi     | 1 +
>   12 files changed, 21 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts b/arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts
> index 0e086dd487d9..63659e240b1d 100644
> --- a/arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts
> +++ b/arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts
> @@ -20,6 +20,7 @@ aliases {
>   		mmc2 = &mmc2;
>   		serial0 = &uart0;
>   		serial1 = &uart1;
> +		serial2 = &uart2;
>   	};
>   
>   	backlight_lcd0: backlight {
> diff --git a/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts b/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts
> index 8c3e2e2578bc..7bccad118d24 100644
> --- a/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts
> +++ b/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts
> @@ -20,6 +20,7 @@ / {
>   
>   	aliases {
>   		serial0 = &uart0;
> +		serial2 = &uart2;

Why is that serial2 and not serial1 = &uart2?

Cheers,
Angelo

>   	};
>   
>   	chosen {

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/2] arm64: dts: mediatek: alias all enabled serial ports
  2026-07-27 11:30   ` AngeloGioacchino Del Regno
@ 2026-07-27 11:49     ` Carlo Caione
  0 siblings, 0 replies; 9+ messages in thread
From: Carlo Caione @ 2026-07-27 11:49 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno, Carlo Caione, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	Greg Kroah-Hartman, Jiri Slaby
  Cc: devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
	linux-serial, dlechner, jstephan

On Mon Jul 27, 2026 at 1:30 PM CEST, AngeloGioacchino Del Regno wrote:
> On 7/27/26 09:38, Carlo Caione wrote:
>> On most MediaTek boards only serial0 is aliased, so the remaining
>> enabled uarts get first-free ttyS line numbers from the 8250 core in
>> probe order. When the console uart defers on its clocks another uart can
>> win line 0: console=ttyS0 then ends up on the wrong port and the boot
>> looks like a hang on the serial console, depending on probe order.
>> 
>> Signed-off-by: Carlo Caione <ccaione@baylibre.com>
>> ---
>>   arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts    | 1 +
>>   arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts              | 1 +
>>   arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts  | 2 ++
>>   arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts              | 2 ++
>>   arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi            | 1 +
>>   arch/arm64/boot/dts/mediatek/mt8192-asurada-hayato-r1.dts | 4 ++++
>>   arch/arm64/boot/dts/mediatek/mt8195-demo.dts              | 1 +
>>   arch/arm64/boot/dts/mediatek/mt8365-evk.dts               | 2 ++
>>   arch/arm64/boot/dts/mediatek/mt8390-genio-common.dtsi     | 2 ++
>>   arch/arm64/boot/dts/mediatek/mt8390-grinn-genio-sbc.dtsi  | 2 ++
>>   arch/arm64/boot/dts/mediatek/mt8390-tungsten-smarc.dtsi   | 2 ++
>>   arch/arm64/boot/dts/mediatek/mt8395-genio-common.dtsi     | 1 +
>>   12 files changed, 21 insertions(+)
>> 
>> diff --git a/arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts b/arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts
>> index 0e086dd487d9..63659e240b1d 100644
>> --- a/arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts
>> +++ b/arch/arm64/boot/dts/mediatek/mt6795-sony-xperia-m5.dts
>> @@ -20,6 +20,7 @@ aliases {
>>   		mmc2 = &mmc2;
>>   		serial0 = &uart0;
>>   		serial1 = &uart1;
>> +		serial2 = &uart2;
>>   	};
>>   
>>   	backlight_lcd0: backlight {
>> diff --git a/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts b/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts
>> index 8c3e2e2578bc..7bccad118d24 100644
>> --- a/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts
>> +++ b/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts
>> @@ -20,6 +20,7 @@ / {
>>   
>>   	aliases {
>>   		serial0 = &uart0;
>> +		serial2 = &uart2;
>
> Why is that serial2 and not serial1 = &uart2?

To tie the alias number to the SoC uart index instead of to the set of
currently-enabled ports.

The problem is that uart1 exists on mt7622 but is disabled. With serial1
= &uart2, the day uart1 gets enabled the aliases have to be renumbered
and uart2 silently moves from ttyS1 to ttyS2 (or we have to again mix
serial and uart number).

Also in general it keeps ttyS<N> matching the schematics' UART<N>.

Ciao,

--
Carlo Caione

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-07-27 11:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-27  7:38 [PATCH v2 0/2] Stabilize serial line numbers on MediaTek boards Carlo Caione
2026-07-27  7:38 ` [PATCH v2 1/2] arm64: dts: mediatek: alias all enabled serial ports Carlo Caione
2026-07-27  9:49   ` Chen-Yu Tsai
2026-07-27 11:30   ` AngeloGioacchino Del Regno
2026-07-27 11:49     ` Carlo Caione
2026-07-27  7:38 ` [PATCH v2 2/2] serial: 8250_mtk: honor DT serial aliases Carlo Caione
2026-07-27  7:51   ` sashiko-bot
2026-07-27  7:53     ` Carlo Caione
2026-07-27  9:39   ` Chen-Yu Tsai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox