From patchwork Thu May 26 03:46:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 576430 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 0E1EEC433EF for ; Thu, 26 May 2022 03:46:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244719AbiEZDqc (ORCPT ); Wed, 25 May 2022 23:46:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235500AbiEZDqY (ORCPT ); Wed, 25 May 2022 23:46:24 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B185FBDA2A for ; Wed, 25 May 2022 20:46:18 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id e195-20020a25e7cc000000b0065343cb6c39so585982ybh.6 for ; Wed, 25 May 2022 20:46:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=o/QH0joN+MugcyRHull52tGgjdzjVgF+TdLryasZ3OQ=; b=RGPxjbKyMwcIxA2s03U5bdMAKmdBqar/f9ZLCnfb2UZlQH9CZS4tHnNV6daOpRgUNd wFwuE/fyGzgV+7YzA06Dyp8Cv9lGrB/NCoggmDp0xiqq2OsU2CDT70ANtBd/9H6RK8EW n8gpulIOK8U5yciXzMafYX69ntsdkCopahJA1BMxX8qhWZHNu1r2aGN9Ms07JlO6mPa/ KNr9m6gIonyZvJb/NlGauCfUs+xNrcdIIKhYzRdgjZ37xULcphyrKW/3HhP7QMZ3s8ol BDHkO7ZOP/NTzHHG9yPPc2io1Z+f/zgD5h2lLO0VI2kDS9wZg7djwkBwygbLtWO7ZpI1 zmsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=o/QH0joN+MugcyRHull52tGgjdzjVgF+TdLryasZ3OQ=; b=NnjXwS7Bk38Ka6ev4AhfUfHKNq+Gb8qo4hYn5itn281Vd9tTYgFXshJ+ZKWDVI0zSK B9Y7IDy5NJVJMDkTevLjCVLgHKCfDAtvyIPq2wCYIguMBHxC6JjJtYzqI6kqWvR3RjUx P4NifC6tMVTdkeXSQHHO3/MFJR46rCr1T3wFnEJi1ytcpxcEQk4wv9ZfUHH5Jn3STT+g MYyRMfiu4gXtuQJS+UnRtQ2eNRTrvX8WRYlXg+chLP+/0qvnsiu66vrW/anlSbtucvRT Yh4KN/JfTL4ZZRK1TfPdeE1Z74rA4F2IdonDk5Ors7T5Ci0+vRZOEHBr3vjmelRbuoSh jNZA== X-Gm-Message-State: AOAM531P5kRQHqx1cA84wLTf1n/QimZ2NLH/6rjALhk8V/HEsqOv6LEz pKXfqQMe/N9Ke69PVD1mUMnc7yg3vfYVtWY= X-Google-Smtp-Source: ABdhPJyTq9NixuM0Ihvbq7fgWYMs3p9ob+kOt9sgXq4qKiYBdS/V6BnGyENeSt/NfIcvpHnbJuwRLLL+/EBqkHM= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:cbc9:88bf:e847:ab95]) (user=saravanak job=sendgmr) by 2002:a05:6902:102a:b0:64f:4132:9be with SMTP id x10-20020a056902102a00b0064f413209bemr32123591ybt.288.1653536777885; Wed, 25 May 2022 20:46:17 -0700 (PDT) Date: Wed, 25 May 2022 20:46:08 -0700 In-Reply-To: <20220526034609.480766-1-saravanak@google.com> Message-Id: <20220526034609.480766-2-saravanak@google.com> Mime-Version: 1.0 References: <20220526034609.480766-1-saravanak@google.com> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog Subject: [PATCH v1 1/2] driver core: Fix wait_for_device_probe() & deferred_probe_timeout interaction From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , John Stultz , Mark Brown , Rob Herring , Saravana Kannan Cc: kernel-team@android.com, linux-kernel@vger.kernel.org, John Stultz , "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Jakub Kicinski , "Rafael J . Wysocki" , Geert Uytterhoeven , Yoshihiro Shimoda , Robin Murphy , Andy Shevchenko , Sudeep Holla , Andy Shevchenko , Naresh Kamboju , Basil Eljuse , Ferry Toth , Arnd Bergmann , Anders Roxell , linux-pm@vger.kernel.org, Nathan Chancellor , Sebastian Andrzej Siewior Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Mounting NFS rootfs was timing out when deferred_probe_timeout was non-zero [1]. This was because ip_auto_config() initcall times out waiting for the network interfaces to show up when deferred_probe_timeout was non-zero. While ip_auto_config() calls wait_for_device_probe() to make sure any currently running deferred probe work or asynchronous probe finishes, that wasn't sufficient to account for devices being deferred until deferred_probe_timeout. Commit 35a672363ab3 ("driver core: Ensure wait_for_device_probe() waits until the deferred_probe_timeout fires") tried to fix that by making sure wait_for_device_probe() waits for deferred_probe_timeout to expire before returning. However, if wait_for_device_probe() is called from the kernel_init() context: - Before deferred_probe_initcall() [2], it causes the boot process to hang due to a deadlock. - After deferred_probe_initcall() [3], it blocks kernel_init() from continuing till deferred_probe_timeout expires and beats the point of deferred_probe_timeout that's trying to wait for userspace to load modules. Neither of this is good. So revert the changes to wait_for_device_probe(). [1] - https://lore.kernel.org/lkml/TYAPR01MB45443DF63B9EF29054F7C41FD8C60@TYAPR01MB4544.jpnprd01.prod.outlook.com/ [2] - https://lore.kernel.org/lkml/YowHNo4sBjr9ijZr@dev-arch.thelio-3990X/ [3] - https://lore.kernel.org/lkml/Yo3WvGnNk3LvLb7R@linutronix.de/ Cc: John Stultz Cc: "David S. Miller" Cc: Alexey Kuznetsov Cc: Hideaki YOSHIFUJI Cc: Jakub Kicinski Cc: Rafael J. Wysocki Cc: Rob Herring Cc: Geert Uytterhoeven Cc: Yoshihiro Shimoda Cc: Robin Murphy Cc: Andy Shevchenko Cc: Sudeep Holla Cc: Andy Shevchenko Cc: Naresh Kamboju Cc: Basil Eljuse Cc: Ferry Toth Cc: Arnd Bergmann Cc: Anders Roxell Cc: linux-pm@vger.kernel.org Fixes: 35a672363ab3 ("driver core: Ensure wait_for_device_probe() waits until the deferred_probe_timeout fires") Reported-by: Nathan Chancellor Reported-by: Sebastian Andrzej Siewior Signed-off-by: Saravana Kannan --- drivers/base/dd.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 2fc8507f59ee..91f63cd33b12 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -263,7 +263,6 @@ int driver_deferred_probe_timeout; #endif EXPORT_SYMBOL_GPL(driver_deferred_probe_timeout); -static DECLARE_WAIT_QUEUE_HEAD(probe_timeout_waitqueue); static int __init deferred_probe_timeout_setup(char *str) { @@ -318,7 +317,6 @@ static void deferred_probe_timeout_work_func(struct work_struct *work) list_for_each_entry(p, &deferred_probe_pending_list, deferred_probe) dev_info(p->device, "deferred probe pending\n"); mutex_unlock(&deferred_probe_mutex); - wake_up_all(&probe_timeout_waitqueue); } static DECLARE_DELAYED_WORK(deferred_probe_timeout_work, deferred_probe_timeout_work_func); @@ -736,9 +734,6 @@ int driver_probe_done(void) */ void wait_for_device_probe(void) { - /* wait for probe timeout */ - wait_event(probe_timeout_waitqueue, !driver_deferred_probe_timeout); - /* wait for the deferred probe workqueue to finish */ flush_work(&deferred_probe_work);