* [PATCH v2 0/8] serial: Some yak shaving
@ 2026-08-04 8:57 Uwe Kleine-König (The Capable Hub)
2026-08-04 8:57 ` [PATCH v2 1/8] serial: txx9: Drop noop probe function and dangerous remove callback Uwe Kleine-König (The Capable Hub)
` (8 more replies)
0 siblings, 9 replies; 15+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-08-04 8:57 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: Hugo Villeneuve, John Ogness, Alan Cox, Atsushi Nemoto,
linux-kernel, linux-serial, Jonathan Corbet, Shuah Khan,
Fushuai Wang, Kees Cook, linux-doc, Ilpo Järvinen,
Andy Shevchenko, Abinash Singh, Rahul Bukte, Randy Dunlap,
Lukas Wunner, Huacai Chen, Haowei Zheng, Rong Zhang,
Gerhard Engleder, Binbin Zhou, Russell King
Hello,
changes since v1
(https://lore.kernel.org/linux-serial/cover.1785489518.git.ukleinek@kernel.org)
- Fix author to be my Capable Hub identity for proper attribution
- Rebase to more recent next
- Actually build test (rant: For mips compile coverage of an
allmodconfig build is rather bad)
- Two compile fixes (I spare you and me the details)
- patches #2 and #5 are new, originating from suggestions in v1
feedback
- slight commit log improvements (Ilpo Järvinen)
Uwe Kleine-König (The Capable Hub) (8):
serial: txx9: Drop noop probe function and dangerous remove callback
serial: txx9: Simplify knowing that .iotype is always UPIO_PORT
serial: txx9: Drop usage of uart_match_port()
serial: 8250: Make uart_match_port() a 8250 specific function
serial: 8250: Simplify serial8250_match_port()
serial: 8250: Fix corner case for port matching
serial: 8250: hub6: Add cleanup code
serial: 8250: pnp: Annotate init and exit functions for conditional
discarding
Documentation/driver-api/serial/driver.rst | 2 +-
drivers/tty/serial/8250/8250.h | 10 +-
drivers/tty/serial/8250/8250_core.c | 25 +++-
drivers/tty/serial/8250/8250_hub6.c | 11 +-
drivers/tty/serial/8250/8250_platform.c | 9 +-
drivers/tty/serial/8250/8250_pnp.c | 4 +-
drivers/tty/serial/8250/Kconfig | 4 +-
drivers/tty/serial/8250/Makefile | 2 +-
drivers/tty/serial/serial_core.c | 27 -----
drivers/tty/serial/serial_txx9.c | 126 ++-------------------
include/linux/serial_core.h | 2 -
11 files changed, 63 insertions(+), 159 deletions(-)
base-commit: 415606a7be939835db9b0d6b711887586646346d
--
2.55.0.11.g153666a7d9bb
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 1/8] serial: txx9: Drop noop probe function and dangerous remove callback
2026-08-04 8:57 [PATCH v2 0/8] serial: Some yak shaving Uwe Kleine-König (The Capable Hub)
@ 2026-08-04 8:57 ` Uwe Kleine-König (The Capable Hub)
2026-08-04 13:52 ` Atsushi Nemoto
2026-08-04 8:57 ` [PATCH v2 2/8] serial: txx9: Simplify knowing that .iotype is always UPIO_PORT Uwe Kleine-König (The Capable Hub)
` (7 subsequent siblings)
8 siblings, 1 reply; 15+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-08-04 8:57 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: Hugo Villeneuve, John Ogness, Alan Cox, Atsushi Nemoto,
linux-kernel, linux-serial
The only platform device that can be bound to the driver is allocated by
the driver itself. That device doesn't have platdata, so the probe
function only consists of a loop that is never run and thus can be
dropped without loss of functionality.
The remove function then should better not undo things that were not
done in the first place. That happens because serial_txx9_init() calls
serial_txx9_register_ports() with the created platform device and so
up->dev == &dev->dev evaluates to true and uart_remove_one_port() is
called twice for each port.
So let serial_txx9_exit() undo exactly what serial_txx9_init() does and
remove the useless respectively wrong functions.
Fixes: 0970769aceb9 ("[SERIAL] serial_txx9 driver update")
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
drivers/tty/serial/serial_txx9.c | 55 ++------------------------------
1 file changed, 3 insertions(+), 52 deletions(-)
diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
index 4ae9a45c8e3a..ef56979321b9 100644
--- a/drivers/tty/serial/serial_txx9.c
+++ b/drivers/tty/serial/serial_txx9.c
@@ -1009,7 +1009,8 @@ static void serial_txx9_unregister_port(int line)
struct uart_port *uart = &serial_txx9_ports[line];
mutex_lock(&serial_txx9_mutex);
- uart_remove_one_port(&serial_txx9_reg, uart);
+ if (uart->iobase || uart->mapbase)
+ uart_remove_one_port(&serial_txx9_reg, uart);
uart->flags = 0;
uart->type = PORT_UNKNOWN;
uart->iobase = 0;
@@ -1019,52 +1020,6 @@ static void serial_txx9_unregister_port(int line)
mutex_unlock(&serial_txx9_mutex);
}
-/*
- * Register a set of serial devices attached to a platform device.
- */
-static int serial_txx9_probe(struct platform_device *dev)
-{
- struct uart_port *p = dev_get_platdata(&dev->dev);
- struct uart_port port;
- int ret, i;
-
- memset(&port, 0, sizeof(struct uart_port));
- for (i = 0; p && p->uartclk != 0; p++, i++) {
- port.iobase = p->iobase;
- port.membase = p->membase;
- port.irq = p->irq;
- port.uartclk = p->uartclk;
- port.iotype = p->iotype;
- port.flags = p->flags;
- port.mapbase = p->mapbase;
- port.dev = &dev->dev;
- port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_TXX9_CONSOLE);
- ret = serial_txx9_register_port(&port);
- if (ret < 0) {
- dev_err(&dev->dev, "unable to register port at index %d "
- "(IO%lx MEM%llx IRQ%d): %d\n", i,
- p->iobase, (unsigned long long)p->mapbase,
- p->irq, ret);
- }
- }
- return 0;
-}
-
-/*
- * Remove serial ports registered against a platform device.
- */
-static void serial_txx9_remove(struct platform_device *dev)
-{
- int i;
-
- for (i = 0; i < UART_NR; i++) {
- struct uart_port *up = &serial_txx9_ports[i];
-
- if (up->dev == &dev->dev)
- serial_txx9_unregister_port(i);
- }
-}
-
#ifdef CONFIG_PM
static int serial_txx9_suspend(struct platform_device *dev, pm_message_t state)
{
@@ -1096,8 +1051,6 @@ static int serial_txx9_resume(struct platform_device *dev)
#endif
static struct platform_driver serial_txx9_plat_driver = {
- .probe = serial_txx9_probe,
- .remove = serial_txx9_remove,
#ifdef CONFIG_PM
.suspend = serial_txx9_suspend,
.resume = serial_txx9_resume,
@@ -1251,9 +1204,7 @@ static void __exit serial_txx9_exit(void)
platform_driver_unregister(&serial_txx9_plat_driver);
platform_device_unregister(serial_txx9_plat_devs);
for (i = 0; i < UART_NR; i++) {
- struct uart_port *up = &serial_txx9_ports[i];
- if (up->iobase || up->mapbase)
- uart_remove_one_port(&serial_txx9_reg, up);
+ serial_txx9_unregister_port(i);
}
uart_unregister_driver(&serial_txx9_reg);
--
2.55.0.11.g153666a7d9bb
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 2/8] serial: txx9: Simplify knowing that .iotype is always UPIO_PORT
2026-08-04 8:57 [PATCH v2 0/8] serial: Some yak shaving Uwe Kleine-König (The Capable Hub)
2026-08-04 8:57 ` [PATCH v2 1/8] serial: txx9: Drop noop probe function and dangerous remove callback Uwe Kleine-König (The Capable Hub)
@ 2026-08-04 8:57 ` Uwe Kleine-König (The Capable Hub)
2026-08-04 14:00 ` Atsushi Nemoto
2026-08-04 14:05 ` Atsushi Nemoto
2026-08-04 8:57 ` [PATCH v2 3/8] serial: txx9: Drop usage of uart_match_port() Uwe Kleine-König (The Capable Hub)
` (6 subsequent siblings)
8 siblings, 2 replies; 15+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-08-04 8:57 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: Hugo Villeneuve, John Ogness, linux-kernel, linux-serial,
Ilpo Järvinen
After the previous commit it's obvious that .iotype is always UPIO_PORT.
Simplify some functions accordingly.
Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/linux-serial/01a84877-9cc7-8136-d5a8-e368a36cda93@linux.intel.com
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
drivers/tty/serial/serial_txx9.c | 69 ++++----------------------------
1 file changed, 7 insertions(+), 62 deletions(-)
diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
index ef56979321b9..bda7f7527b8d 100644
--- a/drivers/tty/serial/serial_txx9.c
+++ b/drivers/tty/serial/serial_txx9.c
@@ -158,25 +158,13 @@
static inline unsigned int sio_in(struct uart_port *up, int offset)
{
- switch (up->iotype) {
- default:
- return __raw_readl(up->membase + offset);
- case UPIO_PORT:
- return inl(up->iobase + offset);
- }
+ return inl(up->iobase + offset);
}
static inline void
sio_out(struct uart_port *up, int offset, int value)
{
- switch (up->iotype) {
- default:
- __raw_writel(value, up->membase + offset);
- break;
- case UPIO_PORT:
- outl(value, up->iobase + offset);
- break;
- }
+ outl(value, up->iobase + offset);
}
static inline void
@@ -698,57 +686,15 @@ serial_txx9_pm(struct uart_port *port, unsigned int state,
static int serial_txx9_request_resource(struct uart_port *up)
{
- unsigned int size = TXX9_REGION_SIZE;
- int ret = 0;
+ if (!request_region(up->iobase, TXX9_REGION_SIZE, "serial_txx9"))
+ return -EBUSY;
- switch (up->iotype) {
- default:
- if (!up->mapbase)
- break;
-
- if (!request_mem_region(up->mapbase, size, "serial_txx9")) {
- ret = -EBUSY;
- break;
- }
-
- if (up->flags & UPF_IOREMAP) {
- up->membase = ioremap(up->mapbase, size);
- if (!up->membase) {
- release_mem_region(up->mapbase, size);
- ret = -ENOMEM;
- }
- }
- break;
-
- case UPIO_PORT:
- if (!request_region(up->iobase, size, "serial_txx9"))
- ret = -EBUSY;
- break;
- }
- return ret;
+ return 0;
}
static void serial_txx9_release_resource(struct uart_port *up)
{
- unsigned int size = TXX9_REGION_SIZE;
-
- switch (up->iotype) {
- default:
- if (!up->mapbase)
- break;
-
- if (up->flags & UPF_IOREMAP) {
- iounmap(up->membase);
- up->membase = NULL;
- }
-
- release_mem_region(up->mapbase, size);
- break;
-
- case UPIO_PORT:
- release_region(up->iobase, size);
- break;
- }
+ release_region(up->iobase, TXX9_REGION_SIZE);
}
static void serial_txx9_release_port(struct uart_port *up)
@@ -983,7 +929,7 @@ static int serial_txx9_register_port(struct uart_port *port)
uart->membase = port->membase;
uart->irq = port->irq;
uart->uartclk = port->uartclk;
- uart->iotype = port->iotype;
+ uart->iotype = UPIO_PORT;
uart->flags = port->flags
| UPF_BOOT_AUTOCONF | UPF_FIXED_PORT;
uart->mapbase = port->mapbase;
@@ -1081,7 +1027,6 @@ pciserial_txx9_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
port.flags |= UPF_TXX9_HAVE_CTS_LINE;
port.uartclk = 66670000;
port.irq = dev->irq;
- port.iotype = UPIO_PORT;
port.iobase = pci_resource_start(dev, 1);
port.dev = &dev->dev;
line = serial_txx9_register_port(&port);
--
2.55.0.11.g153666a7d9bb
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 3/8] serial: txx9: Drop usage of uart_match_port()
2026-08-04 8:57 [PATCH v2 0/8] serial: Some yak shaving Uwe Kleine-König (The Capable Hub)
2026-08-04 8:57 ` [PATCH v2 1/8] serial: txx9: Drop noop probe function and dangerous remove callback Uwe Kleine-König (The Capable Hub)
2026-08-04 8:57 ` [PATCH v2 2/8] serial: txx9: Simplify knowing that .iotype is always UPIO_PORT Uwe Kleine-König (The Capable Hub)
@ 2026-08-04 8:57 ` Uwe Kleine-König (The Capable Hub)
2026-08-04 8:57 ` [PATCH v2 4/8] serial: 8250: Make uart_match_port() a 8250 specific function Uwe Kleine-König (The Capable Hub)
` (5 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-08-04 8:57 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: Hugo Villeneuve, John Ogness, linux-kernel, linux-serial
In the txx9 driver .iotype is always UPIO_PORT. So uart_match_port() is
equivalent to comparing .iobase. Remove the call to uart_match_port()
which then only has a single caller that is handled in the next commit.
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
drivers/tty/serial/serial_txx9.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
index bda7f7527b8d..8febc0549f76 100644
--- a/drivers/tty/serial/serial_txx9.c
+++ b/drivers/tty/serial/serial_txx9.c
@@ -911,7 +911,7 @@ static int serial_txx9_register_port(struct uart_port *port)
mutex_lock(&serial_txx9_mutex);
for (i = 0; i < UART_NR; i++) {
uart = &serial_txx9_ports[i];
- if (uart_match_port(uart, port)) {
+ if (uart->iobase == port->iobase) {
uart_remove_one_port(&serial_txx9_reg, uart);
break;
}
--
2.55.0.11.g153666a7d9bb
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 4/8] serial: 8250: Make uart_match_port() a 8250 specific function
2026-08-04 8:57 [PATCH v2 0/8] serial: Some yak shaving Uwe Kleine-König (The Capable Hub)
` (2 preceding siblings ...)
2026-08-04 8:57 ` [PATCH v2 3/8] serial: txx9: Drop usage of uart_match_port() Uwe Kleine-König (The Capable Hub)
@ 2026-08-04 8:57 ` Uwe Kleine-König (The Capable Hub)
2026-08-04 8:57 ` [PATCH v2 5/8] serial: 8250: Simplify serial8250_match_port() Uwe Kleine-König (The Capable Hub)
` (4 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-08-04 8:57 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: Jonathan Corbet, Shuah Khan, John Ogness, Fushuai Wang, Kees Cook,
Hugo Villeneuve, linux-kernel, linux-serial, linux-doc
The 8250 driver conglomerate is the only user of uart_match_port() and
in fact it already is 8250 specific as it uses hub6_match_port() which
is defined in drivers/tty/serial/8250/8250_hub6.c unless the dummy
implementation is in use.
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
Documentation/driver-api/serial/driver.rst | 2 +-
drivers/tty/serial/8250/8250_core.c | 27 +++++++++++++++++++++-
drivers/tty/serial/serial_core.c | 27 ----------------------
include/linux/serial_core.h | 2 --
4 files changed, 27 insertions(+), 31 deletions(-)
diff --git a/Documentation/driver-api/serial/driver.rst b/Documentation/driver-api/serial/driver.rst
index c1db6a1a67c4..975b0ba53e98 100644
--- a/Documentation/driver-api/serial/driver.rst
+++ b/Documentation/driver-api/serial/driver.rst
@@ -70,7 +70,7 @@ Other functions
.. kernel-doc:: drivers/tty/serial/serial_core.c
:identifiers: uart_update_timeout uart_get_baud_rate uart_get_divisor
- uart_match_port uart_write_wakeup uart_register_driver
+ uart_write_wakeup uart_register_driver
uart_unregister_driver uart_suspend_port uart_resume_port
uart_add_one_port uart_remove_one_port uart_console_write
uart_parse_earlycon uart_parse_options uart_set_options
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index f49862d90eeb..3e53ef54ad7d 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -630,6 +630,31 @@ EXPORT_SYMBOL(serial8250_resume_port);
*/
static DEFINE_MUTEX(serial_mutex);
+/**
+ * serial8250_match_port - are the two ports equivalent?
+ * @port1: first port
+ * @port2: second port
+ *
+ * This utility function can be used to determine whether two uart_port
+ * structures describe the same port.
+ */
+static bool serial8250_match_port(const struct uart_port *port1,
+ const struct uart_port *port2)
+{
+ if (port1->iotype != port2->iotype)
+ return false;
+ else if (port1->iotype == UPIO_PORT)
+ return port1->iobase == port2->iobase;
+ else if (port1->iotype == UPIO_HUB6)
+ return hub6_match_port(port1, port2);
+ else if (uart_iotype_mmio(port1->iotype))
+ return port1->mapbase == port2->mapbase;
+ else if (port1->iotype == UPIO_BUS)
+ return true;
+ else
+ return false;
+}
+
static struct uart_8250_port *serial8250_find_match_or_unused(const struct uart_port *port)
{
int i;
@@ -638,7 +663,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(const struct uart_
* First, find a port entry which matches.
*/
for (i = 0; i < nr_uarts; i++)
- if (uart_match_port(&serial8250_ports[i].port, port))
+ if (serial8250_match_port(&serial8250_ports[i].port, port))
return &serial8250_ports[i];
/* try line number first if still available */
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index edd1e7be2a5c..8a6c53a9996e 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -33,7 +33,6 @@
#include <linux/uaccess.h>
#include "serial_base.h"
-#include "8250/8250.h" /* For hub6_match_port() */
/*
* This is used to lock changes in serial line configuration.
@@ -3229,32 +3228,6 @@ static void serial_core_remove_one_port(struct uart_driver *drv,
state->uart_port = NULL;
}
-/**
- * uart_match_port - are the two ports equivalent?
- * @port1: first port
- * @port2: second port
- *
- * This utility function can be used to determine whether two uart_port
- * structures describe the same port.
- */
-bool uart_match_port(const struct uart_port *port1,
- const struct uart_port *port2)
-{
- if (port1->iotype != port2->iotype)
- return false;
- else if (port1->iotype == UPIO_PORT)
- return port1->iobase == port2->iobase;
- else if (port1->iotype == UPIO_HUB6)
- return hub6_match_port(port1, port2);
- else if (uart_iotype_mmio(port1->iotype))
- return port1->mapbase == port2->mapbase;
- else if (port1->iotype == UPIO_BUS)
- return true;
- else
- return false;
-}
-EXPORT_SYMBOL(uart_match_port);
-
static struct serial_ctrl_device *
serial_core_get_ctrl_dev(struct serial_port_device *port_dev)
{
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index c4cc4f66af4b..1659805e2233 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -1137,8 +1137,6 @@ int uart_add_one_port(struct uart_driver *reg, struct uart_port *port);
void uart_remove_one_port(struct uart_driver *reg, struct uart_port *port);
int uart_read_port_properties(struct uart_port *port);
int uart_read_and_validate_port_properties(struct uart_port *port);
-bool uart_match_port(const struct uart_port *port1,
- const struct uart_port *port2);
/*
* Power Management
--
2.55.0.11.g153666a7d9bb
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 5/8] serial: 8250: Simplify serial8250_match_port()
2026-08-04 8:57 [PATCH v2 0/8] serial: Some yak shaving Uwe Kleine-König (The Capable Hub)
` (3 preceding siblings ...)
2026-08-04 8:57 ` [PATCH v2 4/8] serial: 8250: Make uart_match_port() a 8250 specific function Uwe Kleine-König (The Capable Hub)
@ 2026-08-04 8:57 ` Uwe Kleine-König (The Capable Hub)
2026-08-04 8:57 ` [PATCH v2 6/8] serial: 8250: Fix corner case for port matching Uwe Kleine-König (The Capable Hub)
` (3 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-08-04 8:57 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: Hugo Villeneuve, John Ogness, Fushuai Wang, Kees Cook,
linux-kernel, linux-serial, Hugo Villeneuve
For 8250 devices .iotype is never UPIO_BUS, so drop the respective if
branch.
Suggested-by: Hugo Villeneuve <hugo@hugovil.com>
Link: https://lore.kernel.org/linux-serial/20260803152228.9e3cd296a41e68304b82a22a@hugovil.com
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
drivers/tty/serial/8250/8250_core.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 3e53ef54ad7d..f113f8d5d158 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -649,8 +649,6 @@ static bool serial8250_match_port(const struct uart_port *port1,
return hub6_match_port(port1, port2);
else if (uart_iotype_mmio(port1->iotype))
return port1->mapbase == port2->mapbase;
- else if (port1->iotype == UPIO_BUS)
- return true;
else
return false;
}
--
2.55.0.11.g153666a7d9bb
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 6/8] serial: 8250: Fix corner case for port matching
2026-08-04 8:57 [PATCH v2 0/8] serial: Some yak shaving Uwe Kleine-König (The Capable Hub)
` (4 preceding siblings ...)
2026-08-04 8:57 ` [PATCH v2 5/8] serial: 8250: Simplify serial8250_match_port() Uwe Kleine-König (The Capable Hub)
@ 2026-08-04 8:57 ` Uwe Kleine-König (The Capable Hub)
2026-08-04 8:57 ` [PATCH v2 7/8] serial: 8250: hub6: Add cleanup code Uwe Kleine-König (The Capable Hub)
` (2 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-08-04 8:57 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: Ilpo Järvinen, Andy Shevchenko, Hugo Villeneuve,
Abinash Singh, Rahul Bukte, Kees Cook, Randy Dunlap, Lukas Wunner,
Huacai Chen, Haowei Zheng, Rong Zhang, Gerhard Engleder,
Binbin Zhou, linux-kernel, linux-serial
In the case CONFIG_SERIAL_8250=y + CONFIG_SERIAL_8250_HUB6=m
hub6_match_port() evaluates statically to false in
serial8250_match_port() which is a bug and a change in behavior compared
to before commit 7ab80d1e7243 ("serial: 8250: fix compile error with
hub6_match_port() when compiled as a module").
To make the comparison correct, the dummy implementation of
hub6_match_port() must only be used if CONFIG_SERIAL_8250_HUB6 is
disabled. Then as there is a bidirectional dependency between
8250_hub6.c and 8250_core.c, put both in the same module.
Fixes: 7ab80d1e7243 ("serial: 8250: fix compile error with hub6_match_port() when compiled as a module")
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
drivers/tty/serial/8250/8250.h | 8 +++++++-
drivers/tty/serial/8250/8250_hub6.c | 8 +-------
drivers/tty/serial/8250/8250_platform.c | 4 ++++
drivers/tty/serial/8250/Kconfig | 4 ++--
drivers/tty/serial/8250/Makefile | 2 +-
5 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index b62f88eec881..39d72f1480c0 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -315,6 +315,12 @@ static inline int serial8250_pnp_init(void) { return 0; }
static inline void serial8250_pnp_exit(void) { }
#endif
+#ifdef CONFIG_SERIAL_8250_HUB6
+int serial8250_hub6_init(void);
+#else
+static inline int serial8250_hub6_init(void) { return 0; }
+#endif
+
#ifdef CONFIG_SERIAL_8250_RSA
void univ8250_rsa_support(struct uart_ops *ops, const struct uart_ops *core_ops);
void rsa_enable(struct uart_8250_port *up);
@@ -335,7 +341,7 @@ int fintek_8250_probe(struct uart_8250_port *uart);
static inline int fintek_8250_probe(struct uart_8250_port *uart) { return 0; }
#endif
-#if IS_REACHABLE(CONFIG_SERIAL_8250_HUB6)
+#if IS_ENABLED(CONFIG_SERIAL_8250_HUB6)
bool hub6_match_port(const struct uart_port *port1, const struct uart_port *port2);
#else
static inline bool hub6_match_port(const struct uart_port *port1, const struct uart_port *port2)
diff --git a/drivers/tty/serial/8250/8250_hub6.c b/drivers/tty/serial/8250/8250_hub6.c
index b6767633c966..3e548530ec4e 100644
--- a/drivers/tty/serial/8250/8250_hub6.c
+++ b/drivers/tty/serial/8250/8250_hub6.c
@@ -49,13 +49,7 @@ bool hub6_match_port(const struct uart_port *port1, const struct uart_port *port
}
EXPORT_SYMBOL_GPL(hub6_match_port);
-static int __init hub6_init(void)
+int __init serial8250_hub6_init(void)
{
return platform_device_register(&hub6_device);
}
-
-module_init(hub6_init);
-
-MODULE_AUTHOR("Russell King");
-MODULE_DESCRIPTION("8250 serial probe module for Hub6 cards");
-MODULE_LICENSE("GPL");
diff --git a/drivers/tty/serial/8250/8250_platform.c b/drivers/tty/serial/8250/8250_platform.c
index af946d12e764..3a2dff9ce7b7 100644
--- a/drivers/tty/serial/8250/8250_platform.c
+++ b/drivers/tty/serial/8250/8250_platform.c
@@ -319,6 +319,10 @@ static int __init serial8250_init(void)
if (ret)
goto unreg_uart_drv;
+ ret = serial8250_hub6_init();
+ if (ret)
+ goto unreg_pnp;
+
serial8250_isa_devs = platform_device_alloc("serial8250", PLAT8250_DEV_LEGACY);
if (!serial8250_isa_devs) {
ret = -ENOMEM;
diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig
index fc3e58d62233..00c2ced12717 100644
--- a/drivers/tty/serial/8250/Kconfig
+++ b/drivers/tty/serial/8250/Kconfig
@@ -294,8 +294,8 @@ config SERIAL_8250_EXAR_ST16C554
will be called 8250_exar_st16c554.
config SERIAL_8250_HUB6
- tristate "Support Hub6 cards"
- depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
+ bool "Support Hub6 cards"
+ depends on SERIAL_8250_MANY_PORTS && ISA
help
Say Y here if you have a HUB6 serial board.
diff --git a/drivers/tty/serial/8250/Makefile b/drivers/tty/serial/8250/Makefile
index 6d21402b4435..416c32e3aba2 100644
--- a/drivers/tty/serial/8250/Makefile
+++ b/drivers/tty/serial/8250/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_SERIAL_8250) += 8250.o
8250-y := 8250_core.o
8250-y += 8250_platform.o
8250-$(CONFIG_SERIAL_8250_PNP) += 8250_pnp.o
+8250-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o
obj-$(CONFIG_SERIAL_8250) += 8250_base.o
8250_base-y := 8250_port.o
@@ -35,7 +36,6 @@ obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) += 8250_exar_st16c554.o
obj-$(CONFIG_SERIAL_8250_FOURPORT) += 8250_fourport.o
obj-$(CONFIG_SERIAL_8250_FSL) += 8250_fsl.o
obj-$(CONFIG_SERIAL_8250_HP300) += 8250_hp300.o
-obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o
obj-$(CONFIG_SERIAL_8250_INGENIC) += 8250_ingenic.o
obj-$(CONFIG_SERIAL_8250_IOC3) += 8250_ioc3.o
obj-$(CONFIG_SERIAL_8250_KEBA) += 8250_keba.o
--
2.55.0.11.g153666a7d9bb
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 7/8] serial: 8250: hub6: Add cleanup code
2026-08-04 8:57 [PATCH v2 0/8] serial: Some yak shaving Uwe Kleine-König (The Capable Hub)
` (5 preceding siblings ...)
2026-08-04 8:57 ` [PATCH v2 6/8] serial: 8250: Fix corner case for port matching Uwe Kleine-König (The Capable Hub)
@ 2026-08-04 8:57 ` Uwe Kleine-König (The Capable Hub)
2026-08-04 8:58 ` [PATCH v2 8/8] serial: 8250: pnp: Annotate init and exit functions for conditional discarding Uwe Kleine-König (The Capable Hub)
2026-08-08 21:01 ` [PATCH v2 0/8] serial: Some yak shaving Andy Shevchenko
8 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-08-04 8:57 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: Ilpo Järvinen, Andy Shevchenko, Hugo Villeneuve,
Abinash Singh, Rahul Bukte, Kees Cook, Russell King, linux-kernel,
linux-serial
At module load time a platform device is registered. That should be
undone when the module is unloaded.
Fixes: ec9f47cd6a14 ("[PATCH] Serial: Split 8250 port table")
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
drivers/tty/serial/8250/8250.h | 2 ++
drivers/tty/serial/8250/8250_hub6.c | 5 +++++
drivers/tty/serial/8250/8250_platform.c | 5 ++++-
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index 39d72f1480c0..01fed8d44b7b 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -317,8 +317,10 @@ static inline void serial8250_pnp_exit(void) { }
#ifdef CONFIG_SERIAL_8250_HUB6
int serial8250_hub6_init(void);
+void serial8250_hub6_exit(void);
#else
static inline int serial8250_hub6_init(void) { return 0; }
+static inline void serial8250_hub6_exit(void) { }
#endif
#ifdef CONFIG_SERIAL_8250_RSA
diff --git a/drivers/tty/serial/8250/8250_hub6.c b/drivers/tty/serial/8250/8250_hub6.c
index 3e548530ec4e..55320b794165 100644
--- a/drivers/tty/serial/8250/8250_hub6.c
+++ b/drivers/tty/serial/8250/8250_hub6.c
@@ -53,3 +53,8 @@ int __init serial8250_hub6_init(void)
{
return platform_device_register(&hub6_device);
}
+
+int __init_or_module serial8250_hub6_exit(void)
+{
+ return platform_device_unregister(&hub6_device);
+}
diff --git a/drivers/tty/serial/8250/8250_platform.c b/drivers/tty/serial/8250/8250_platform.c
index 3a2dff9ce7b7..0570366a71d0 100644
--- a/drivers/tty/serial/8250/8250_platform.c
+++ b/drivers/tty/serial/8250/8250_platform.c
@@ -326,7 +326,7 @@ static int __init serial8250_init(void)
serial8250_isa_devs = platform_device_alloc("serial8250", PLAT8250_DEV_LEGACY);
if (!serial8250_isa_devs) {
ret = -ENOMEM;
- goto unreg_pnp;
+ goto unreg_hub6;
}
ret = platform_device_add(serial8250_isa_devs);
@@ -342,6 +342,8 @@ static int __init serial8250_init(void)
platform_device_del(serial8250_isa_devs);
put_dev:
platform_device_put(serial8250_isa_devs);
+unreg_hub6:
+ serial8250_hub6_exit();
unreg_pnp:
serial8250_pnp_exit();
unreg_uart_drv:
@@ -369,6 +371,7 @@ static void __exit serial8250_exit(void)
platform_driver_unregister(&serial8250_isa_driver);
platform_device_unregister(isa_dev);
+ serial8250_hub6_exit();
serial8250_pnp_exit();
#ifdef CONFIG_SPARC
--
2.55.0.11.g153666a7d9bb
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2 8/8] serial: 8250: pnp: Annotate init and exit functions for conditional discarding
2026-08-04 8:57 [PATCH v2 0/8] serial: Some yak shaving Uwe Kleine-König (The Capable Hub)
` (6 preceding siblings ...)
2026-08-04 8:57 ` [PATCH v2 7/8] serial: 8250: hub6: Add cleanup code Uwe Kleine-König (The Capable Hub)
@ 2026-08-04 8:58 ` Uwe Kleine-König (The Capable Hub)
2026-08-08 21:01 ` [PATCH v2 0/8] serial: Some yak shaving Andy Shevchenko
8 siblings, 0 replies; 15+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-08-04 8:58 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby; +Cc: Rahul Bukte, linux-kernel, linux-serial
serial8250_pnp_init() is only called from serial8250_init() which is
marked with __init, so the pnp init function can also get the same
marking. serial8250_pnp_exit() is only called from __init and __exit
code, so __init_or_module is appropriate for that.
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
drivers/tty/serial/8250/8250_pnp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_pnp.c b/drivers/tty/serial/8250/8250_pnp.c
index 6bfdeff5fe22..7decf62400ab 100644
--- a/drivers/tty/serial/8250/8250_pnp.c
+++ b/drivers/tty/serial/8250/8250_pnp.c
@@ -526,12 +526,12 @@ static struct pnp_driver serial_pnp_driver = {
.id_table = pnp_dev_table,
};
-int serial8250_pnp_init(void)
+int __init serial8250_pnp_init(void)
{
return pnp_register_driver(&serial_pnp_driver);
}
-void serial8250_pnp_exit(void)
+void __init_or_module serial8250_pnp_exit(void)
{
pnp_unregister_driver(&serial_pnp_driver);
}
--
2.55.0.11.g153666a7d9bb
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/8] serial: txx9: Drop noop probe function and dangerous remove callback
2026-08-04 8:57 ` [PATCH v2 1/8] serial: txx9: Drop noop probe function and dangerous remove callback Uwe Kleine-König (The Capable Hub)
@ 2026-08-04 13:52 ` Atsushi Nemoto
2026-08-04 14:26 ` Geert Uytterhoeven
0 siblings, 1 reply; 15+ messages in thread
From: Atsushi Nemoto @ 2026-08-04 13:52 UTC (permalink / raw)
To: u.kleine-koenig
Cc: gregkh, jirislaby, hvilleneuve, john.ogness, alan, linux-kernel,
linux-serial, Geert Uytterhoeven
On Tue, 4 Aug 2026 10:57:53 +0200, Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> wrote:
> The only platform device that can be bound to the driver is allocated by
> the driver itself. That device doesn't have platdata, so the probe
> function only consists of a loop that is never run and thus can be
> dropped without loss of functionality.
The noop loop might came from old 8250 driver I referenced at that time.
Now I think it can be removed safely.
Thank you for this cleanup.
Reviewed-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
Atsushi Nemoto
On Tue, 4 Aug 2026 10:57:53 +0200, Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> wrote:
> The only platform device that can be bound to the driver is allocated by
> the driver itself. That device doesn't have platdata, so the probe
> function only consists of a loop that is never run and thus can be
> dropped without loss of functionality.
>
> The remove function then should better not undo things that were not
> done in the first place. That happens because serial_txx9_init() calls
> serial_txx9_register_ports() with the created platform device and so
> up->dev == &dev->dev evaluates to true and uart_remove_one_port() is
> called twice for each port.
>
> So let serial_txx9_exit() undo exactly what serial_txx9_init() does and
> remove the useless respectively wrong functions.
>
> Fixes: 0970769aceb9 ("[SERIAL] serial_txx9 driver update")
> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
> ---
> drivers/tty/serial/serial_txx9.c | 55 ++------------------------------
> 1 file changed, 3 insertions(+), 52 deletions(-)
>
> diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
> index 4ae9a45c8e3a..ef56979321b9 100644
> --- a/drivers/tty/serial/serial_txx9.c
> +++ b/drivers/tty/serial/serial_txx9.c
> @@ -1009,7 +1009,8 @@ static void serial_txx9_unregister_port(int line)
> struct uart_port *uart = &serial_txx9_ports[line];
>
> mutex_lock(&serial_txx9_mutex);
> - uart_remove_one_port(&serial_txx9_reg, uart);
> + if (uart->iobase || uart->mapbase)
> + uart_remove_one_port(&serial_txx9_reg, uart);
> uart->flags = 0;
> uart->type = PORT_UNKNOWN;
> uart->iobase = 0;
> @@ -1019,52 +1020,6 @@ static void serial_txx9_unregister_port(int line)
> mutex_unlock(&serial_txx9_mutex);
> }
>
> -/*
> - * Register a set of serial devices attached to a platform device.
> - */
> -static int serial_txx9_probe(struct platform_device *dev)
> -{
> - struct uart_port *p = dev_get_platdata(&dev->dev);
> - struct uart_port port;
> - int ret, i;
> -
> - memset(&port, 0, sizeof(struct uart_port));
> - for (i = 0; p && p->uartclk != 0; p++, i++) {
> - port.iobase = p->iobase;
> - port.membase = p->membase;
> - port.irq = p->irq;
> - port.uartclk = p->uartclk;
> - port.iotype = p->iotype;
> - port.flags = p->flags;
> - port.mapbase = p->mapbase;
> - port.dev = &dev->dev;
> - port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_TXX9_CONSOLE);
> - ret = serial_txx9_register_port(&port);
> - if (ret < 0) {
> - dev_err(&dev->dev, "unable to register port at index %d "
> - "(IO%lx MEM%llx IRQ%d): %d\n", i,
> - p->iobase, (unsigned long long)p->mapbase,
> - p->irq, ret);
> - }
> - }
> - return 0;
> -}
> -
> -/*
> - * Remove serial ports registered against a platform device.
> - */
> -static void serial_txx9_remove(struct platform_device *dev)
> -{
> - int i;
> -
> - for (i = 0; i < UART_NR; i++) {
> - struct uart_port *up = &serial_txx9_ports[i];
> -
> - if (up->dev == &dev->dev)
> - serial_txx9_unregister_port(i);
> - }
> -}
> -
> #ifdef CONFIG_PM
> static int serial_txx9_suspend(struct platform_device *dev, pm_message_t state)
> {
> @@ -1096,8 +1051,6 @@ static int serial_txx9_resume(struct platform_device *dev)
> #endif
>
> static struct platform_driver serial_txx9_plat_driver = {
> - .probe = serial_txx9_probe,
> - .remove = serial_txx9_remove,
> #ifdef CONFIG_PM
> .suspend = serial_txx9_suspend,
> .resume = serial_txx9_resume,
> @@ -1251,9 +1204,7 @@ static void __exit serial_txx9_exit(void)
> platform_driver_unregister(&serial_txx9_plat_driver);
> platform_device_unregister(serial_txx9_plat_devs);
> for (i = 0; i < UART_NR; i++) {
> - struct uart_port *up = &serial_txx9_ports[i];
> - if (up->iobase || up->mapbase)
> - uart_remove_one_port(&serial_txx9_reg, up);
> + serial_txx9_unregister_port(i);
> }
>
> uart_unregister_driver(&serial_txx9_reg);
> --
> 2.55.0.11.g153666a7d9bb
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 2/8] serial: txx9: Simplify knowing that .iotype is always UPIO_PORT
2026-08-04 8:57 ` [PATCH v2 2/8] serial: txx9: Simplify knowing that .iotype is always UPIO_PORT Uwe Kleine-König (The Capable Hub)
@ 2026-08-04 14:00 ` Atsushi Nemoto
2026-08-04 14:05 ` Atsushi Nemoto
1 sibling, 0 replies; 15+ messages in thread
From: Atsushi Nemoto @ 2026-08-04 14:00 UTC (permalink / raw)
To: u.kleine-koenig
Cc: gregkh, jirislaby, hvilleneuve, john.ogness, linux-kernel,
linux-serial, ilpo.jarvinen, Geert Uytterhoeven
On Tue, 4 Aug 2026 10:57:54 +0200, Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> wrote:
> After the previous commit it's obvious that .iotype is always UPIO_PORT.
> Simplify some functions accordingly.
No, .iotype can be UPIO_MEM if early_serial_txx9_setup() was called from
arch/mips/txx9/generic/setup.c.
---
Atsushi Nemoto
On Tue, 4 Aug 2026 10:57:54 +0200, Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> wrote:
> After the previous commit it's obvious that .iotype is always UPIO_PORT.
> Simplify some functions accordingly.
>
> Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Link: https://lore.kernel.org/linux-serial/01a84877-9cc7-8136-d5a8-e368a36cda93@linux.intel.com
> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
> ---
> drivers/tty/serial/serial_txx9.c | 69 ++++----------------------------
> 1 file changed, 7 insertions(+), 62 deletions(-)
>
> diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
> index ef56979321b9..bda7f7527b8d 100644
> --- a/drivers/tty/serial/serial_txx9.c
> +++ b/drivers/tty/serial/serial_txx9.c
> @@ -158,25 +158,13 @@
>
> static inline unsigned int sio_in(struct uart_port *up, int offset)
> {
> - switch (up->iotype) {
> - default:
> - return __raw_readl(up->membase + offset);
> - case UPIO_PORT:
> - return inl(up->iobase + offset);
> - }
> + return inl(up->iobase + offset);
> }
>
> static inline void
> sio_out(struct uart_port *up, int offset, int value)
> {
> - switch (up->iotype) {
> - default:
> - __raw_writel(value, up->membase + offset);
> - break;
> - case UPIO_PORT:
> - outl(value, up->iobase + offset);
> - break;
> - }
> + outl(value, up->iobase + offset);
> }
>
> static inline void
> @@ -698,57 +686,15 @@ serial_txx9_pm(struct uart_port *port, unsigned int state,
>
> static int serial_txx9_request_resource(struct uart_port *up)
> {
> - unsigned int size = TXX9_REGION_SIZE;
> - int ret = 0;
> + if (!request_region(up->iobase, TXX9_REGION_SIZE, "serial_txx9"))
> + return -EBUSY;
>
> - switch (up->iotype) {
> - default:
> - if (!up->mapbase)
> - break;
> -
> - if (!request_mem_region(up->mapbase, size, "serial_txx9")) {
> - ret = -EBUSY;
> - break;
> - }
> -
> - if (up->flags & UPF_IOREMAP) {
> - up->membase = ioremap(up->mapbase, size);
> - if (!up->membase) {
> - release_mem_region(up->mapbase, size);
> - ret = -ENOMEM;
> - }
> - }
> - break;
> -
> - case UPIO_PORT:
> - if (!request_region(up->iobase, size, "serial_txx9"))
> - ret = -EBUSY;
> - break;
> - }
> - return ret;
> + return 0;
> }
>
> static void serial_txx9_release_resource(struct uart_port *up)
> {
> - unsigned int size = TXX9_REGION_SIZE;
> -
> - switch (up->iotype) {
> - default:
> - if (!up->mapbase)
> - break;
> -
> - if (up->flags & UPF_IOREMAP) {
> - iounmap(up->membase);
> - up->membase = NULL;
> - }
> -
> - release_mem_region(up->mapbase, size);
> - break;
> -
> - case UPIO_PORT:
> - release_region(up->iobase, size);
> - break;
> - }
> + release_region(up->iobase, TXX9_REGION_SIZE);
> }
>
> static void serial_txx9_release_port(struct uart_port *up)
> @@ -983,7 +929,7 @@ static int serial_txx9_register_port(struct uart_port *port)
> uart->membase = port->membase;
> uart->irq = port->irq;
> uart->uartclk = port->uartclk;
> - uart->iotype = port->iotype;
> + uart->iotype = UPIO_PORT;
> uart->flags = port->flags
> | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT;
> uart->mapbase = port->mapbase;
> @@ -1081,7 +1027,6 @@ pciserial_txx9_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
> port.flags |= UPF_TXX9_HAVE_CTS_LINE;
> port.uartclk = 66670000;
> port.irq = dev->irq;
> - port.iotype = UPIO_PORT;
> port.iobase = pci_resource_start(dev, 1);
> port.dev = &dev->dev;
> line = serial_txx9_register_port(&port);
> --
> 2.55.0.11.g153666a7d9bb
>
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 2/8] serial: txx9: Simplify knowing that .iotype is always UPIO_PORT
2026-08-04 8:57 ` [PATCH v2 2/8] serial: txx9: Simplify knowing that .iotype is always UPIO_PORT Uwe Kleine-König (The Capable Hub)
2026-08-04 14:00 ` Atsushi Nemoto
@ 2026-08-04 14:05 ` Atsushi Nemoto
2026-08-04 14:26 ` Geert Uytterhoeven
1 sibling, 1 reply; 15+ messages in thread
From: Atsushi Nemoto @ 2026-08-04 14:05 UTC (permalink / raw)
To: u.kleine-koenig
Cc: gregkh, jirislaby, hvilleneuve, john.ogness, linux-kernel,
linux-serial, ilpo.jarvinen, Geert Uytterhoeven
On Tue, 4 Aug 2026 10:57:54 +0200, Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> wrote:
> After the previous commit it's obvious that .iotype is always UPIO_PORT.
> Simplify some functions accordingly.
No, .iotype can be UPIO_MEM if early_serial_txx9_setup() was called from
arch/mips/txx9/generic/setup.c.
Please drop this patch from your series.
---
Atsushi Nemoto
On Tue, 4 Aug 2026 10:57:54 +0200, Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> wrote:
> After the previous commit it's obvious that .iotype is always UPIO_PORT.
> Simplify some functions accordingly.
>
> Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Link: https://lore.kernel.org/linux-serial/01a84877-9cc7-8136-d5a8-e368a36cda93@linux.intel.com
> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
> ---
> drivers/tty/serial/serial_txx9.c | 69 ++++----------------------------
> 1 file changed, 7 insertions(+), 62 deletions(-)
>
> diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
> index ef56979321b9..bda7f7527b8d 100644
> --- a/drivers/tty/serial/serial_txx9.c
> +++ b/drivers/tty/serial/serial_txx9.c
> @@ -158,25 +158,13 @@
>
> static inline unsigned int sio_in(struct uart_port *up, int offset)
> {
> - switch (up->iotype) {
> - default:
> - return __raw_readl(up->membase + offset);
> - case UPIO_PORT:
> - return inl(up->iobase + offset);
> - }
> + return inl(up->iobase + offset);
> }
>
> static inline void
> sio_out(struct uart_port *up, int offset, int value)
> {
> - switch (up->iotype) {
> - default:
> - __raw_writel(value, up->membase + offset);
> - break;
> - case UPIO_PORT:
> - outl(value, up->iobase + offset);
> - break;
> - }
> + outl(value, up->iobase + offset);
> }
>
> static inline void
> @@ -698,57 +686,15 @@ serial_txx9_pm(struct uart_port *port, unsigned int state,
>
> static int serial_txx9_request_resource(struct uart_port *up)
> {
> - unsigned int size = TXX9_REGION_SIZE;
> - int ret = 0;
> + if (!request_region(up->iobase, TXX9_REGION_SIZE, "serial_txx9"))
> + return -EBUSY;
>
> - switch (up->iotype) {
> - default:
> - if (!up->mapbase)
> - break;
> -
> - if (!request_mem_region(up->mapbase, size, "serial_txx9")) {
> - ret = -EBUSY;
> - break;
> - }
> -
> - if (up->flags & UPF_IOREMAP) {
> - up->membase = ioremap(up->mapbase, size);
> - if (!up->membase) {
> - release_mem_region(up->mapbase, size);
> - ret = -ENOMEM;
> - }
> - }
> - break;
> -
> - case UPIO_PORT:
> - if (!request_region(up->iobase, size, "serial_txx9"))
> - ret = -EBUSY;
> - break;
> - }
> - return ret;
> + return 0;
> }
>
> static void serial_txx9_release_resource(struct uart_port *up)
> {
> - unsigned int size = TXX9_REGION_SIZE;
> -
> - switch (up->iotype) {
> - default:
> - if (!up->mapbase)
> - break;
> -
> - if (up->flags & UPF_IOREMAP) {
> - iounmap(up->membase);
> - up->membase = NULL;
> - }
> -
> - release_mem_region(up->mapbase, size);
> - break;
> -
> - case UPIO_PORT:
> - release_region(up->iobase, size);
> - break;
> - }
> + release_region(up->iobase, TXX9_REGION_SIZE);
> }
>
> static void serial_txx9_release_port(struct uart_port *up)
> @@ -983,7 +929,7 @@ static int serial_txx9_register_port(struct uart_port *port)
> uart->membase = port->membase;
> uart->irq = port->irq;
> uart->uartclk = port->uartclk;
> - uart->iotype = port->iotype;
> + uart->iotype = UPIO_PORT;
> uart->flags = port->flags
> | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT;
> uart->mapbase = port->mapbase;
> @@ -1081,7 +1027,6 @@ pciserial_txx9_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
> port.flags |= UPF_TXX9_HAVE_CTS_LINE;
> port.uartclk = 66670000;
> port.irq = dev->irq;
> - port.iotype = UPIO_PORT;
> port.iobase = pci_resource_start(dev, 1);
> port.dev = &dev->dev;
> line = serial_txx9_register_port(&port);
> --
> 2.55.0.11.g153666a7d9bb
>
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/8] serial: txx9: Drop noop probe function and dangerous remove callback
2026-08-04 13:52 ` Atsushi Nemoto
@ 2026-08-04 14:26 ` Geert Uytterhoeven
0 siblings, 0 replies; 15+ messages in thread
From: Geert Uytterhoeven @ 2026-08-04 14:26 UTC (permalink / raw)
To: Atsushi Nemoto
Cc: u.kleine-koenig, gregkh, jirislaby, hvilleneuve, john.ogness,
alan, linux-kernel, linux-serial
On Tue, 4 Aug 2026 at 15:52, Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> On Tue, 4 Aug 2026 10:57:53 +0200, Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> wrote:
> > The only platform device that can be bound to the driver is allocated by
> > the driver itself. That device doesn't have platdata, so the probe
> > function only consists of a loop that is never run and thus can be
> > dropped without loss of functionality.
>
> The noop loop might came from old 8250 driver I referenced at that time.
> Now I think it can be removed safely.
> Thank you for this cleanup.
>
> Reviewed-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
TX4927 actually has two serial ports:
$ cat proc/iomem
[...]
fff1f0000-fff1fffff : TX4927
[...]
fff1ff300-fff1ff323 : serial_txx9
fff1ff400-fff1ff423 : serial_txx9
At first sight, I don't see how these are registered, but it still works
after your patch, so
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 2/8] serial: txx9: Simplify knowing that .iotype is always UPIO_PORT
2026-08-04 14:05 ` Atsushi Nemoto
@ 2026-08-04 14:26 ` Geert Uytterhoeven
0 siblings, 0 replies; 15+ messages in thread
From: Geert Uytterhoeven @ 2026-08-04 14:26 UTC (permalink / raw)
To: Atsushi Nemoto
Cc: u.kleine-koenig, gregkh, jirislaby, hvilleneuve, john.ogness,
linux-kernel, linux-serial, ilpo.jarvinen
On Tue, 4 Aug 2026 at 16:05, Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> On Tue, 4 Aug 2026 10:57:54 +0200, Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> wrote:
> > After the previous commit it's obvious that .iotype is always UPIO_PORT.
> > Simplify some functions accordingly.
>
> No, .iotype can be UPIO_MEM if early_serial_txx9_setup() was called from
> arch/mips/txx9/generic/setup.c.
>
> Please drop this patch from your series.
Indeed:
serial_txx9: ttyS0 MMIO:0x0000000fff1ff300 (irq = 32, base_baud =
3125000) is a txx9
** 19695 printk messages dropped **
pcistat:22b0(ReceivedMasterAbort)
PCIERR interrupt at 0xffffffff80379aec
[...]
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 0/8] serial: Some yak shaving
2026-08-04 8:57 [PATCH v2 0/8] serial: Some yak shaving Uwe Kleine-König (The Capable Hub)
` (7 preceding siblings ...)
2026-08-04 8:58 ` [PATCH v2 8/8] serial: 8250: pnp: Annotate init and exit functions for conditional discarding Uwe Kleine-König (The Capable Hub)
@ 2026-08-08 21:01 ` Andy Shevchenko
8 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2026-08-08 21:01 UTC (permalink / raw)
To: Uwe Kleine-König (The Capable Hub)
Cc: Greg Kroah-Hartman, Jiri Slaby, Hugo Villeneuve, John Ogness,
Alan Cox, Atsushi Nemoto, linux-kernel, linux-serial,
Jonathan Corbet, Shuah Khan, Fushuai Wang, Kees Cook, linux-doc,
Ilpo Järvinen, Abinash Singh, Rahul Bukte, Randy Dunlap,
Lukas Wunner, Huacai Chen, Haowei Zheng, Rong Zhang,
Gerhard Engleder, Binbin Zhou, Russell King
On Tue, Aug 04, 2026 at 10:57:52AM +0200, Uwe Kleine-König (The Capable Hub) wrote:
> Hello,
>
> changes since v1
> (https://lore.kernel.org/linux-serial/cover.1785489518.git.ukleinek@kernel.org)
>
> - Fix author to be my Capable Hub identity for proper attribution
> - Rebase to more recent next
> - Actually build test (rant: For mips compile coverage of an
> allmodconfig build is rather bad)
> - Two compile fixes (I spare you and me the details)
> - patches #2 and #5 are new, originating from suggestions in v1
> feedback
> - slight commit log improvements (Ilpo Järvinen)
I like this series.
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-08-08 21:02 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-04 8:57 [PATCH v2 0/8] serial: Some yak shaving Uwe Kleine-König (The Capable Hub)
2026-08-04 8:57 ` [PATCH v2 1/8] serial: txx9: Drop noop probe function and dangerous remove callback Uwe Kleine-König (The Capable Hub)
2026-08-04 13:52 ` Atsushi Nemoto
2026-08-04 14:26 ` Geert Uytterhoeven
2026-08-04 8:57 ` [PATCH v2 2/8] serial: txx9: Simplify knowing that .iotype is always UPIO_PORT Uwe Kleine-König (The Capable Hub)
2026-08-04 14:00 ` Atsushi Nemoto
2026-08-04 14:05 ` Atsushi Nemoto
2026-08-04 14:26 ` Geert Uytterhoeven
2026-08-04 8:57 ` [PATCH v2 3/8] serial: txx9: Drop usage of uart_match_port() Uwe Kleine-König (The Capable Hub)
2026-08-04 8:57 ` [PATCH v2 4/8] serial: 8250: Make uart_match_port() a 8250 specific function Uwe Kleine-König (The Capable Hub)
2026-08-04 8:57 ` [PATCH v2 5/8] serial: 8250: Simplify serial8250_match_port() Uwe Kleine-König (The Capable Hub)
2026-08-04 8:57 ` [PATCH v2 6/8] serial: 8250: Fix corner case for port matching Uwe Kleine-König (The Capable Hub)
2026-08-04 8:57 ` [PATCH v2 7/8] serial: 8250: hub6: Add cleanup code Uwe Kleine-König (The Capable Hub)
2026-08-04 8:58 ` [PATCH v2 8/8] serial: 8250: pnp: Annotate init and exit functions for conditional discarding Uwe Kleine-König (The Capable Hub)
2026-08-08 21:01 ` [PATCH v2 0/8] serial: Some yak shaving Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox