From: "Yicong Yang" <yang.yicong@picoheart.com>
To: <rafael@kernel.org>, <lenb@kernel.org>, <tglx@kernel.org>,
<gregkh@linuxfoundation.org>, <dakr@kernel.org>
Cc: <akpm@linux-foundation.org>, <apatel@ventanamicro.com>,
<pjw@kernel.org>, <palmer@dabbelt.com>, <aou@eecs.berkeley.edu>,
<alex@ghiti.fr>, <geshijian@picoheart.com>,
<weidong.wd@picoheart.com>, <yang.yicong@picoheart.com>,
<linux-acpi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-riscv@lists.infradead.org>
Subject: [PATCH 2/2] init: Move console_on_rootfs after async_synchronize_full
Date: Thu, 22 Jan 2026 15:34:46 +0800 [thread overview]
Message-ID: <20260122073446.45628-3-yang.yicong@picoheart.com> (raw)
In-Reply-To: <20260122073446.45628-1-yang.yicong@picoheart.com>
Currently the console_on_rootfs() is called before
async_synchronize_full(), the console initialization
could be still in process in theory due to async
probe, etc. Make it after the async_synchronize_full()
to make sure the initialization work is done.
Log the error code as well if we failed to open the console.
Signed-off-by: Yicong Yang <yang.yicong@picoheart.com>
---
init/main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/init/main.c b/init/main.c
index b84818ad9685..c37ba5f89b96 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1578,6 +1578,7 @@ static int __ref kernel_init(void *unused)
kernel_init_freeable();
/* need to finish all async __init code before freeing the memory */
async_synchronize_full();
+ console_on_rootfs();
system_state = SYSTEM_FREEING_INITMEM;
kprobe_free_init_mem();
@@ -1647,7 +1648,7 @@ void __init console_on_rootfs(void)
struct file *file = filp_open("/dev/console", O_RDWR, 0);
if (IS_ERR(file)) {
- pr_err("Warning: unable to open an initial console.\n");
+ pr_err("Warning: unable to open an initial console, err = %ld\n", PTR_ERR(file));
return;
}
init_dup(file);
@@ -1690,7 +1691,6 @@ static noinline void __init kernel_init_freeable(void)
kunit_run_all_tests();
wait_for_initramfs();
- console_on_rootfs();
/*
* check if there is an early userspace init. If yes, let it do all
--
2.34.1
next prev parent reply other threads:[~2026-01-22 7:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-22 7:34 [PATCH 0/2] Ensure some device initialization before init task Yicong Yang
2026-01-22 7:34 ` [PATCH 1/2] ACPI: scan: Use async schedule function for acpi_scan_clear_dep_fn Yicong Yang
2026-01-22 10:29 ` Greg KH
2026-01-22 12:43 ` Yicong Yang
2026-01-22 13:21 ` Rafael J. Wysocki
2026-01-22 13:48 ` Yicong Yang
2026-01-22 13:57 ` Rafael J. Wysocki
2026-01-22 16:27 ` Yicong Yang
2026-01-22 11:19 ` Rafael J. Wysocki
2026-01-22 12:50 ` Yicong Yang
2026-01-22 13:22 ` Rafael J. Wysocki
2026-01-22 7:34 ` Yicong Yang [this message]
2026-01-22 10:27 ` [PATCH 2/2] init: Move console_on_rootfs after async_synchronize_full Greg KH
2026-01-22 13:12 ` Yicong Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260122073446.45628-3-yang.yicong@picoheart.com \
--to=yang.yicong@picoheart.com \
--cc=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=apatel@ventanamicro.com \
--cc=dakr@kernel.org \
--cc=geshijian@picoheart.com \
--cc=gregkh@linuxfoundation.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=rafael@kernel.org \
--cc=tglx@kernel.org \
--cc=weidong.wd@picoheart.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®