[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230601141445.11321-1-tony@atomide.com>
Date: Thu, 1 Jun 2023 17:14:44 +0300
From: Tony Lindgren <tony@...mide.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jirislaby@...nel.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@...el.com>,
Dhruva Gole <d-gole@...com>,
Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
John Ogness <john.ogness@...utronix.de>,
Johan Hovold <johan@...nel.org>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Vignesh Raghavendra <vigneshr@...com>,
linux-omap@...r.kernel.org,
Marek Szyprowski <m.szyprowski@...sung.com>,
linux-serial@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] serial: core: Fix probing serial_base_bus devices
If a physical serial port device driver uses arch_initcall() we fail to
probe the serial_base_bus devices and the serial port tx fails. This is
because as serial_base_bus uses module_initcall().
Let's fix the issue by changing serial_base_bus to use arch_initcall().
Let's also return an error if a driver attempts to call uart_add_one_port()
too early.
Reported-by: Marek Szyprowski <m.szyprowski@...sung.com>
Closes: https://lore.kernel.org/linux-serial/20230601132012.GB14287@atomide.com/T/#m6a40440fc04d551d27b147da8602e065c982a115
Fixes: 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM")
Signed-off-by: Tony Lindgren <tony@...mide.com>
---
drivers/tty/serial/serial_base_bus.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/serial_base_bus.c b/drivers/tty/serial/serial_base_bus.c
--- a/drivers/tty/serial/serial_base_bus.c
+++ b/drivers/tty/serial/serial_base_bus.c
@@ -17,6 +17,8 @@
#include "serial_base.h"
+static bool serial_base_initialized;
+
static int serial_base_match(struct device *dev, struct device_driver *drv)
{
int len = strlen(drv->name);
@@ -48,6 +50,11 @@ static int serial_base_device_init(struct uart_port *port,
void (*release)(struct device *dev),
int id)
{
+ if (!serial_base_initialized) {
+ dev_err(port->dev, "uart_add_one_port() called before arch_initcall()?\n");
+ return -EPROBE_DEFER;
+ }
+
device_initialize(dev);
dev->type = type;
dev->parent = parent_dev;
@@ -175,6 +182,8 @@ static int serial_base_init(void)
if (ret)
goto err_ctrl_exit;
+ serial_base_initialized = true;
+
return 0;
err_ctrl_exit:
@@ -185,7 +194,7 @@ static int serial_base_init(void)
return ret;
}
-module_init(serial_base_init);
+arch_initcall(serial_base_init);
static void serial_base_exit(void)
{
--
2.40.1
Powered by blists - more mailing lists