Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp861318rwd; Thu, 1 Jun 2023 07:29:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ47A6TV8FcW1DFyd+yINurWsU3kcz5xNwlNn19nbtmxZ6+GyulbPxD4xFP7Fyn7jG9wFtaY X-Received: by 2002:a05:6a00:1825:b0:64d:3227:b800 with SMTP id y37-20020a056a00182500b0064d3227b800mr8153900pfa.16.1685629786164; Thu, 01 Jun 2023 07:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685629786; cv=none; d=google.com; s=arc-20160816; b=YaBYj8d560g2kQnpDC7haoDuWn7MDCUlqHK2sb6lyFbrHcLFk7U0BO4ddsplTLlIM8 YrE9WWTmnL1YiQgFWLDYgqQIzcUsa9dZwMId0VnRGzydCLJ5cjUcSDL4IVYHiqNBULK/ npCxXdG22D8yVrkd3bhlSnxrBQBsx8uZxfEATO5j8JS5P47bJukx7myubJeib5gzBknD eE/T+B1AufDUtHVuuJsLP7odS/JH7Z6jBuShsKKv6mNRDqB8HPUBAO3m4RyXHWtGKka2 zrmqhzP8pUvLzUKETRWnnzlyPesU1Znm/rZqhTWnVTzDrLYBsK2XzKnXwBuprYvwbq4W H0cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ZRbsWXvXAVBIUcOobYQgtCNBMRMUYMMNhGMig065jQc=; b=JzEjkswaa9QOPI3/CeqPc1I7VAuXEmhjEHCsSYYppHmwFYCQqxO0Oo1Xl7Wl0Wyoe2 qpWqZI1JZSyfNqJ1Z5B3n4dua0AhkBWQqH8GdOkmPI2v2sllnk6xXLXkuhlTUj+zSLaK EhqKMTIrgbBGp6LJoXvWcX2dcXi6UTVSOh51kh99GTiVml5wiQG/w8DHVxb1tm9Hz51J WizjSOiszu5ci8CKR86ns+DFwfjkYySgYIhShNi+wxATDZm3SvKh62QhJQ/8oc16QAFk yq47ZK/JnQD5Yle9g6GXvLlNtgcLv6z4jcJrrcQhWYbBIkU8pGmzRKBZtaPYzsJkDEHg UMSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 143-20020a621795000000b0062d7d3c6cadsi5387652pfx.333.2023.06.01.07.29.32; Thu, 01 Jun 2023 07:29:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234181AbjFAOPH (ORCPT + 99 others); Thu, 1 Jun 2023 10:15:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234107AbjFAOPB (ORCPT ); Thu, 1 Jun 2023 10:15:01 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 90E058E; Thu, 1 Jun 2023 07:15:00 -0700 (PDT) Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 0386F80F1; Thu, 1 Jun 2023 14:14:57 +0000 (UTC) From: Tony Lindgren To: Greg Kroah-Hartman , Jiri Slaby , Andy Shevchenko Cc: Andy Shevchenko , Dhruva Gole , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , John Ogness , Johan Hovold , Sebastian Andrzej Siewior , Vignesh Raghavendra , linux-omap@vger.kernel.org, Marek Szyprowski , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] serial: core: Fix probing serial_base_bus devices Date: Thu, 1 Jun 2023 17:14:44 +0300 Message-Id: <20230601141445.11321-1-tony@atomide.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 --- 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