From nobody Mon Feb 9 02:08:17 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D69CC77B7C for ; Fri, 26 May 2023 13:07:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243539AbjEZNHg (ORCPT ); Fri, 26 May 2023 09:07:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231158AbjEZNHe (ORCPT ); Fri, 26 May 2023 09:07:34 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C14C5198 for ; Fri, 26 May 2023 06:07:29 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f611ccd06eso5319595e9.0 for ; Fri, 26 May 2023 06:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685106448; x=1687698448; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=3OYN7dZABhmYimN+TZxc/LvZq8eCNJGJVqa65c9esQQ=; b=hVt1U943xtcdOo2EhnLU8fSa9SaQAhhJAK9fHvIygC7JJ8lzJKKxP4k7u5OHw8Cp4/ GsuhTsj7XzA72Zxe9iq2RfLMhyqlEB0pzSIDDgSSYWZsnp/ykcjQeDwPRVz7kDJvnGPl KgZToumD2FoaSZR9jpQgonIffD2DIgJPuF4qX7LxLYn3tz66EN6ljaxsV+OcT9Ih0IGM LzrS01FjPnYyjJyAtBTRPL8ZsTEM4QgBcxkM4ldHr/JZvlU2r/KZxoQquvr8tjs/l+mW BJ0oV+JvPFQW+SJPIkGkl+u9pJ9qj152wZMxlg/TDIGZq+oeD3SUbA0kwEs4sgbvGxpB je3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685106448; x=1687698448; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3OYN7dZABhmYimN+TZxc/LvZq8eCNJGJVqa65c9esQQ=; b=TN6MqB2hc3000bkZou7EtbcmAZT3gyZZtZ9rMdlKOJXEop6EzELHpsnOIH+4sbdl+j lFSQjjVvcob3gylvKdyLM/5hoSD5L2Xk+M/wiYiObaPjIdknBjWcBhPpvi3YvF+8fRv9 AYiSOlRQ0bwM6wznR28odQ4iI2xy7UHkHkw0e/WCh+9nz1dhHyOqHdqiXwiFMjQvRLWZ BcSqWY9Jip2+owbRud1mOmc2Tv60no6AnviczV812gfbnlrXHQDXdpQ0OpItGR584buN kDqSX/nDZpvy34yP/ejbDhzHxzqGrnD00WcRLGEZwtZdaQAYUBTxWZHW6CouocJf4oQN ++Cw== X-Gm-Message-State: AC+VfDwvPd5K6p2n5pfhXl/uVZpK1fDaxmwFyRxAHmo4PMd+sN5PN1Dr lgiQrhDEx37WSUd0k8Tf6I0Ibw== X-Google-Smtp-Source: ACHHUZ7YKORMpC4RuNFuNl96MUWxk3+APLsN1PXwJ89q18j6GEnvJOhIRtKVBHTuz15K85dTVUYMJQ== X-Received: by 2002:a05:600c:3658:b0:3f5:fb83:62b0 with SMTP id y24-20020a05600c365800b003f5fb8362b0mr1473701wmq.36.1685106448115; Fri, 26 May 2023 06:07:28 -0700 (PDT) Received: from loic-ThinkPad-T470p.. ([2a01:e0a:82c:5f0:73c8:c098:1848:c7ac]) by smtp.gmail.com with ESMTPSA id i2-20020a05600c290200b003eddc6aa5fasm8731390wmd.39.2023.05.26.06.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 06:07:27 -0700 (PDT) From: Loic Poulain To: corbet@lwn.net, viro@zeniv.linux.org.uk, brauner@kernel.org Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, Loic Poulain Subject: [PATCH] init: Add support for rootwait timeout parameter Date: Fri, 26 May 2023 15:07:16 +0200 Message-Id: <20230526130716.2932507-1-loic.poulain@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add an optional timeout arg to 'rootwait' as the maximum time in seconds to wait for the root device to show up before attempting forced mount of the root filesystem. This can be helpful to force boot failure and restart in case the root device does not show up in time, allowing the bootloader to take any appropriate measures (e.g. recovery, A/B switch, retry...). In success case, mounting happens as soon as the root device is ready, contrary to the existing 'rootdelay' parameter (unconditional delay). Signed-off-by: Loic Poulain --- .../admin-guide/kernel-parameters.txt | 4 ++++ init/do_mounts.c | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 9e5bab29685f..6e351d4c84a5 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5465,6 +5465,10 @@ Useful for devices that are detected asynchronously (e.g. USB and MMC devices). =20 + rootwait=3D [KNL] Maximum time (in seconds) to wait for root device + to show up before attempting to mount the root + filesystem. + rproc_mem=3Dnn[KMG][@address] [KNL,ARM,CMA] Remoteproc physical memory block. Memory area to be used by remote processor image, diff --git a/init/do_mounts.c b/init/do_mounts.c index 811e94daf0a8..942458e7d1c0 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c @@ -18,6 +18,7 @@ #include #include #include +#include =20 #include #include @@ -306,12 +307,20 @@ static int __init rootwait_setup(char *str) { if (*str) return 0; - root_wait =3D 1; + root_wait =3D -1; return 1; } =20 __setup("rootwait", rootwait_setup); =20 +static int __init rootwait_timeout_setup(char *str) +{ + root_wait =3D simple_strtoul(str, NULL, 0); + return 1; +} + +__setup("rootwait=3D", rootwait_timeout_setup); + static char * __initdata root_mount_data; static int __init root_data_setup(char *str) { @@ -633,11 +642,17 @@ void __init prepare_namespace(void) =20 /* wait for any asynchronous scanning to complete */ if ((ROOT_DEV =3D=3D 0) && root_wait) { + const ktime_t end =3D ktime_add_ms(ktime_get_raw(), root_wait * MSEC_PER= _SEC); + printk(KERN_INFO "Waiting for root device %s...\n", saved_root_name); while (driver_probe_done() !=3D 0 || - (ROOT_DEV =3D name_to_dev_t(saved_root_name)) =3D=3D 0) + (ROOT_DEV =3D name_to_dev_t(saved_root_name)) =3D=3D 0) { msleep(5); + + if (root_wait > 0 && ktime_after(ktime_get_raw(), end)) + break; + } async_synchronize_full(); } =20 --=20 2.34.1