From nobody Sun Feb 8 12:51:39 2026 Received: from sg-1-38.ptr.blmpb.com (sg-1-38.ptr.blmpb.com [118.26.132.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED7EB480962 for ; Thu, 22 Jan 2026 07:36:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=118.26.132.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769067416; cv=none; b=IUFoO9SZ4zb8nZznnYpOMEfTWKLEtETALwZZrEwfx/kUAkecjSAfywxIW85rBTZ05E88l6SKlfcdkTSsFI+rtcENHyuf1QaygWKyXEJXn1ee0avUSToRPUHIrn4sPGpx70peH7i9kHPG/ZB178PjBk0tJoER9olVAhHwCPCDVZs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769067416; c=relaxed/simple; bh=ZA0dShh7LmxgkvKWG26Qxxa83Xo5UPsRGqNF5OMLKA4=; h=References:Date:Message-Id:Mime-Version:To:Cc:In-Reply-To: Content-Type:From:Subject; b=Yli8qokqWzCMQOAtu5mjqa/5K5GPAbVh41fvvw3dbFegav0QGZPD1sfEorjQXp16PIWXouAAxVR6Wn/l3RRdMXvcFCpjcxNEb2qwXEYbZEhu+NzucZYW1px2HOoqZmUbETDCEqEyLFDa2lGbnFFjeWc/OM9WN9tBVPAagNej0yw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=picoheart.com; spf=pass smtp.mailfrom=picoheart.com; dkim=pass (2048-bit key) header.d=picoheart-com.20200927.dkim.feishu.cn header.i=@picoheart-com.20200927.dkim.feishu.cn header.b=jhH9+h6A; arc=none smtp.client-ip=118.26.132.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=picoheart.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=picoheart.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=picoheart-com.20200927.dkim.feishu.cn header.i=@picoheart-com.20200927.dkim.feishu.cn header.b="jhH9+h6A" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=s1; d=picoheart-com.20200927.dkim.feishu.cn; t=1769067294; h=from:subject:mime-version:from:date:message-id:subject:to:cc: reply-to:content-type:mime-version:in-reply-to:message-id; bh=01FP4vC/jj6alLbiTxMoouO+ZRSgO8bEdY/088MJqcA=; b=jhH9+h6AHNS2KkO5f4Zec42IGeHlvuo9vSXwxd+jiKkpEJOKkTi7rWdJOMGHXLKhctyhPR VrM7bErmHnwghcMI2vPN6QRu96+Cd+atsZoFvpaV11yiHRg5sNwmaH20M+ihAsIwVvA0l9 Sg/QFlD1GUF86MUqVG0snmzxsb+rTZ0rOcxR6Vg5VJAO+dyuanMByrag3S5ero+XtR70jf niyjNX07WFXktwMWPbnoQM8IxnwwotNp/qOoq/vEMklXOcWsQWm/weqvwfR+Mvs/TXwF6h 181ZMf9pdCNmBuJd0ry9aW/Nd/IAGZ10BJWmneEDmG7xAbO3VerXEV54v/IdNw== References: <20260122073446.45628-1-yang.yicong@picoheart.com> Date: Thu, 22 Jan 2026 15:34:45 +0800 Message-Id: <20260122073446.45628-2-yang.yicong@picoheart.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 To: , , , , Content-Transfer-Encoding: quoted-printable Cc: , , , , , , , , , , , In-Reply-To: <20260122073446.45628-1-yang.yicong@picoheart.com> Received: from G9WYR9K0VW ([58.250.122.114]) by smtp.feishu.cn with ESMTPS; Thu, 22 Jan 2026 15:34:52 +0800 X-Original-From: Yicong Yang X-Lms-Return-Path: From: "Yicong Yang" Subject: [PATCH 1/2] ACPI: scan: Use async schedule function for acpi_scan_clear_dep_fn X-Mailer: git-send-email 2.50.1 Content-Type: text/plain; charset="utf-8" The device object rescan in acpi_scan_clear_dep_fn is scheduled in the system workqueue which is not guaranteed to be finished before entering userspace. This will cause the problem that some key devices are missed when the init task try to find them, e.g. console devices and root devices (PCIe nvme, etc). This issues is more possbile to happen on RISCV since these devices using GSI interrupt may depend on APLIC and will be scanned in acpi_scan_clear_dep_queue() after APLIC initialized. Fix this by scheduling the acpi_scan_clear_dep_queue() using async schedule function rather than the system workqueue. The deferred works will be synchronized by async_synchronize_full() before entering init task. Update the comment as well. Signed-off-by: Yicong Yang --- drivers/acpi/scan.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 416d87f9bd10..bf0d8ba9ba19 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -5,6 +5,7 @@ =20 #define pr_fmt(fmt) "ACPI: " fmt =20 +#include #include #include #include @@ -2365,39 +2366,35 @@ struct acpi_scan_clear_dep_work { struct acpi_device *adev; }; =20 -static void acpi_scan_clear_dep_fn(struct work_struct *work) +static void acpi_scan_clear_dep_fn(void *dev, async_cookie_t cookie) { - struct acpi_scan_clear_dep_work *cdw; - - cdw =3D container_of(work, struct acpi_scan_clear_dep_work, work); + struct acpi_device *adev =3D to_acpi_device(dev); =20 acpi_scan_lock_acquire(); - acpi_bus_attach(cdw->adev, (void *)true); + acpi_bus_attach(adev, (void *)true); acpi_scan_lock_release(); =20 - acpi_dev_put(cdw->adev); - kfree(cdw); + acpi_dev_put(adev); } =20 static bool acpi_scan_clear_dep_queue(struct acpi_device *adev) { - struct acpi_scan_clear_dep_work *cdw; - if (adev->dep_unmet) return false; =20 - cdw =3D kmalloc(sizeof(*cdw), GFP_KERNEL); - if (!cdw) - return false; - - cdw->adev =3D adev; - INIT_WORK(&cdw->work, acpi_scan_clear_dep_fn); /* - * Since the work function may block on the lock until the entire - * initial enumeration of devices is complete, put it into the unbound - * workqueue. + * Async schedule the deferred acpi_scan_clear_dep_fn() since: + * - acpi_bus_attach() needs to hold acpi_scan_lock which cannot + * be acquired under acpi_dep_list_lock (held here) + * - the deferred work at boot stage is ensured to be finished + * before entering init task by the async_synchronize_full() + * barrier + * + * Use _nocall variant since it'll return on failure instead of + * run the function synchronously. */ - queue_work(system_dfl_wq, &cdw->work); + if (!async_schedule_dev_nocall(acpi_scan_clear_dep_fn, &adev->dev)) + return false; =20 return true; } --=20 2.34.1 From nobody Sun Feb 8 12:51:39 2026 Received: from va-2-45.ptr.blmpb.com (va-2-45.ptr.blmpb.com [209.127.231.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 632F4481249 for ; Thu, 22 Jan 2026 07:35:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.127.231.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769067346; cv=none; b=MhmHF9zFhXEDEeBEVYmqpQwwvapfwS2jQ4fVvMbtHO6rKQFC/rjz1NtTk1Xg6KfbzjzV6yGI4OgYW1KXbRdvX2BdqyGU8HRP8OZ0pBXyiilXVP333AZWOrmgu/mOck4/ox3FnulIFBx7A9zLwElU7k5GTb89lGM22XBJp/hOco4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769067346; c=relaxed/simple; bh=Zg4V6RJ5CX9TkQlNvozgJSw3th6d9YeG4f0THZUNWK4=; h=Date:In-Reply-To:To:Cc:Mime-Version:From:Subject:References: Message-Id:Content-Type; b=ELqVM/JFuG5dV2ogwseZwVreF2dJ1INfJi7Equzb6yVOJnMR5yrskNSsg9Q5UTEZzAMX8m7N9+8pxZAHIQdV+vE7LOi8deirTHt2nRE0YgB/g2gaIIg4KhL8aeXTcglEqTA+AGsaGJcgu+tQcSW171E5c/R/qF0QfU1+96SPFog= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=picoheart.com; spf=pass smtp.mailfrom=picoheart.com; dkim=pass (2048-bit key) header.d=picoheart-com.20200927.dkim.feishu.cn header.i=@picoheart-com.20200927.dkim.feishu.cn header.b=wNQzGcVg; arc=none smtp.client-ip=209.127.231.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=picoheart.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=picoheart.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=picoheart-com.20200927.dkim.feishu.cn header.i=@picoheart-com.20200927.dkim.feishu.cn header.b="wNQzGcVg" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=s1; d=picoheart-com.20200927.dkim.feishu.cn; t=1769067297; h=from:subject:mime-version:from:date:message-id:subject:to:cc: reply-to:content-type:mime-version:in-reply-to:message-id; bh=+g/3tjO+rV9WYb2Jh/rm5GHV4Veu7YSdogQYF3BcWcg=; b=wNQzGcVgLadD5kvUkSUhWc45cDCxqGNGk6kd/+Wz0BUSIemBHHh9+csbwE5Lol9hTFdnSx lnDZNlRR+79edruORKpTgTilX5NN3Df7nP4eDQjYgLTtpB2k7e+A3mO3k35LX2QkuYGqfq +HYh0Z6Mj8kSsz4CygQGQGIsuN/U9Jfa/UqKNGfb3YLrzCZgboO/lo9jqP4qz/u0vMPzIu dEM0lIys8QnUps1Lcltctl6o2i2Yrt0O5QcBr33LcrzqoQdqA2ur8uLOgJKS2xrcOBJ4vl QC1TbrPduy45WUvBIN30u0XxrjloAjEMU8p58mzFrI29VsImUHE+9/Z5vYaoSg== Date: Thu, 22 Jan 2026 15:34:46 +0800 In-Reply-To: <20260122073446.45628-1-yang.yicong@picoheart.com> Content-Transfer-Encoding: quoted-printable X-Original-From: Yicong Yang X-Lms-Return-Path: To: , , , , Cc: , , , , , , , , , , , Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 From: "Yicong Yang" Subject: [PATCH 2/2] init: Move console_on_rootfs after async_synchronize_full Received: from G9WYR9K0VW ([58.250.122.114]) by smtp.feishu.cn with ESMTPS; Thu, 22 Jan 2026 15:34:54 +0800 X-Mailer: git-send-email 2.50.1 References: <20260122073446.45628-1-yang.yicong@picoheart.com> Message-Id: <20260122073446.45628-3-yang.yicong@picoheart.com> Content-Type: text/plain; charset="utf-8" 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 --- 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(); =20 system_state =3D SYSTEM_FREEING_INITMEM; kprobe_free_init_mem(); @@ -1647,7 +1648,7 @@ void __init console_on_rootfs(void) struct file *file =3D filp_open("/dev/console", O_RDWR, 0); =20 if (IS_ERR(file)) { - pr_err("Warning: unable to open an initial console.\n"); + pr_err("Warning: unable to open an initial console, err =3D %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(); =20 wait_for_initramfs(); - console_on_rootfs(); =20 /* * check if there is an early userspace init. If yes, let it do all --=20 2.34.1