From nobody Tue Apr 7 02:57:23 2026 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3B59324B20 for ; Mon, 16 Mar 2026 14:05:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773669926; cv=none; b=UdCTuKHiUkRTWrfHbsWc6Rrt2VAV2RTqy1+75q1SNkDlbDN8sWnbx+6ajrvT2J60mHRsAL3xmFo0LENqhVYOeMq077EOdyj+rdkj+ELgFOtkXUoYZas4hnplUzk1QH2YGjU1bm5hcCDEQhFVRjkmHiTyNIT0ZEX4ZmkiZfQybpI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773669926; c=relaxed/simple; bh=nSIfGQPBuVdYukL6Lat4D4mJ6iUUI81v5zYmOLLojk4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=HQA7G/tq5J1wOF3RfQJJSf3Hm6HBUiW0i4JIGfMXeGPx30hk3huu5mngkXYd78rHXeHLNzMu16hIukMCIMhGTrWCUSMclvfJyTILQ95nQCHYjJs6d4JJR8YBXgf9Box1iRYBNHQgw/3Q4NymfMzIPf+MUE9T4c2qcFsRv0we70w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mupuf.org; spf=pass smtp.mailfrom=mupuf.org; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mupuf.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mupuf.org Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1w28ZN-00BZ7b-9N for linux-kernel@vger.kernel.org; Mon, 16 Mar 2026 15:05:21 +0100 Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1w28ZM-0000hs-Vy for linux-kernel@vger.kernel.org; Mon, 16 Mar 2026 15:05:21 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1057822)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1w28Z8-007L1e-QY; Mon, 16 Mar 2026 15:05:06 +0100 From: =?utf-8?q?Martin_Roukala_=28n=C3=A9_Peres=29?= Date: Mon, 16 Mar 2026 16:05:06 +0200 Subject: [PATCH] RFC: init/main: wait up to 10 second for a console to show up Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260316-init_main_wait_for_console-v1-1-530629b18638@mupuf.org> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/x3M0QpAMBSA4VfRubZiGsurSGvs4BRn2oSSd7fc/ d/N/0DEQBihzR4IeFIkzwllnsG4WJ5RkEsGWci6qMpaENNhNktsLptq8sGMnqNfUeiqGXSjpNL OQhrsASe6/3nXv+8HiNA7XWwAAAA= X-Change-ID: 20260316-init_main_wait_for_console-837b875258da To: linux-kernel@vger.kernel.org Cc: =?utf-8?q?Martin_Roukala_=28n=C3=A9_Peres=29?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1773669906; l=1813; i=martin.roukala@mupuf.org; s=20260309; h=from:subject:message-id; bh=nSIfGQPBuVdYukL6Lat4D4mJ6iUUI81v5zYmOLLojk4=; b=nJLYMk63PcKRHlxcbIb3EZN7+5SwkFvST5vsY9fpfycxlk5FVCSnareQd8hQQrfvvN709D4a1 xv34QdDPbCfCDAKGHUuYHzly21EysT1tFiBR+S5Kr3tiLeDvDKhcfbF X-Developer-Key: i=martin.roukala@mupuf.org; a=ed25519; pk=TyNPQJvzE39EljzGB5lyKu0Ljo0X5RXGjKlVR4LEL9Q= There are some devices (such as tablets, handheld gaming devices, ...) that do not have a readily-available serial port. Our only option for a tty device is thus to use a USB-based one. The issue with USB-based tty devices is that device enumeration takes time, and thus the console may not have been registered by the time init tries to open `/dev/console`, leading to a kernel panic... Make init wait a valid console for up to 10s before panicing, giving more time for the consoles to show up. Signed-off-by: Martin Roukala (n=C3=A9 Peres) --- What do you guys think of this solution? Is this something we do by default? Should we make it a config option? --- init/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/init/main.c b/init/main.c index 1cb395dd94e4..6ecc2b52545f 100644 --- a/init/main.c +++ b/init/main.c @@ -1648,7 +1648,18 @@ static int __ref kernel_init(void *unused) /* Open /dev/console, for stdin/stdout/stderr, this should never fail */ void __init console_on_rootfs(void) { - struct file *file =3D filp_open("/dev/console", O_RDWR, 0); + struct file *file =3D NULL; + int i =3D 0; + + /* Wait for up to 10 seconds for a console to appear. This makes it + * possible to reliably use USB-backed TTY consoles as system consoles + * (ie. `console=3DttyUSB0,115200`). + */ + do { + file =3D filp_open("/dev/console", O_RDWR, 0); + if (IS_ERR(file)) + msleep(100); + } while (IS_ERR(file) && ++i < 100); =20 if (IS_ERR(file)) { pr_err("Warning: unable to open an initial console.\n"); --- base-commit: f338e77383789c0cae23ca3d48adcc5e9e137e3c change-id: 20260316-init_main_wait_for_console-837b875258da Best regards, --=20 Martin Roukala (n=C3=A9 Peres)