From patchwork Thu Feb 20 05:04:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 183651 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp140907ile; Wed, 19 Feb 2020 21:05:00 -0800 (PST) X-Received: by 2002:a63:2e42:: with SMTP id u63mr30583846pgu.137.1582175099818; Wed, 19 Feb 2020 21:04:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582175099; cv=none; d=google.com; s=arc-20160816; b=idTGLtAv1qJYKzNZqEMiYw9XSlIiibb/1fnjPQZqrzxm/5PQQB4UrrKXePIxm+f9JX JhXGz3wDHJTRDgYq7Jxt69x03kUcC0DMWaGXdI9EJAWUegcRZnWLNIRzjHE6cgZ69+5A uaRGw2z1tQzEiNSgyJro90cBRkOaDreTkOg9eNRWG6+NtCxUA40M7m4fl3XDg6Dll73w FFCwiVO3Qo/kGLGSryprRNFOX+1Or43BUXVGihOqVxbjYKDqjNk1imBmTzXZT39T2e8h pBOKmtUe9jKwF7eze3TrIioYdzwOfYugUNhX7HcHwrKdVY2RoudDISi24COS6QHT8QLZ co2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/T58NGHopB3l5IaHe5dr2sMuh4DNsWpX5Bm1fmPX41g=; b=i38VtQYlKQs16PsNyVMMbZSjfbbUu2QYhdw6OCAZYBm4tQEN27TtShG9mFZdUGx1l7 L65MIctdn0nCC6Kkaqljl86vhP8G6bzPfMWRaI3mzBz8S2syjOrK1yqswmyhYe9v39qt IInU+Z7Y9sv2KwFxQK0dm7d97lwb86mrxaYchD/LHk0+Xclst5U/BQDoCF+6X/LpoxYO YrDuckfMKnGyct9rqGy/mRaMBdvt6uV7HGMkRs29gjfTNsb46H0tt3wrknDqLkgcl5CW JhBmLOzPiS8FcCvxRJOLMfk5kv5xlffxaPUU8r7PqZUjhMrrl4r9pYD3Bzf59oH2BndM xs3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S2OqtMi4; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id u12sor2200898plm.62.2020.02.19.21.04.59 for (Google Transport Security); Wed, 19 Feb 2020 21:04:59 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S2OqtMi4; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/T58NGHopB3l5IaHe5dr2sMuh4DNsWpX5Bm1fmPX41g=; b=S2OqtMi4d7N85eKmqs1n60PvHhJ3iczKNhZd3H4xFKxZrquUWEjkKNOYhKwBBrq/yK +eOA9gZ5h1AMNe5U3gT3ELiZIEh5UG8Pfe1ACDe0dWSLrLzkN9t9IWgWyou0SwbC2YDT DtjeAbTk1XwtwSzd9qqZQhHoXaF/RykNvfqrqFM67BpFMRdjPowh1ijaNpcSZEfzOzj2 MJMNg9nJeeq8g+SPs/wEbrtaJXAuLPRczDvjJacgR8ntcZMI9FOqASEU/2DQr+R/U8Ma P+aTOaOUMgky6Uwxjg/SYPT5W9wlt5RcVA+iNFMdQQw7VydaYEDcOTX63cWT0I+rgX4P e8PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/T58NGHopB3l5IaHe5dr2sMuh4DNsWpX5Bm1fmPX41g=; b=lR5QStI5vbZTKsh92DO2ROGCM9OMs+Fas/sSZfapZ4LpS5LojERAzvQ6nc8hJRrviR ALrQWORtK7X7g3rGk2inggwg5ZorHL9pEB4t1AF4guApAtKYddJH9EnNHiTez8u5Dq7d 3xcE0bm8+9d+A7iNs6jLFJXlz9KTj6C6O9u8JbNZ+M7dwI2JRJoXX18ktXQ0vvsDhAMA RhHuJnonA7sLIUibfVOPlI+DVk25J1Aa4/lDaMr/oZX21sEvEuYqGVBdDKGmI4u/84fg veOOdz7nlXLyNnAk1ER4CaseTwV7xMtUMYX2ZihJwFD1xJ2IDfDJPY7rkMyKd2yTDWlR dY8w== X-Gm-Message-State: APjAAAXFCVDJVaOdKRIEy9yhWdzKNNxpbNoN5xyIo/o8G/M7HYRYdlga RbhXA6BWTDNXufMJYBQJX7GBWsil X-Google-Smtp-Source: APXvYqx7blf57WRdqHC+FiTTfSehSN8U0lLCPg8GgWjsosKUg28yXPBGYhNTcpJXcdEWuI0YfQrQnA== X-Received: by 2002:a17:902:820b:: with SMTP id x11mr29388518pln.196.1582175099414; Wed, 19 Feb 2020 21:04:59 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id z4sm1400847pfn.42.2020.02.19.21.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 21:04:58 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Rob Herring , "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , Todd Kjos , Bjorn Andersson , Liam Girdwood , Mark Brown , Thierry Reding , Linus Walleij , Greg Kroah-Hartman , linux-pm@vger.kernel.org Subject: [PATCH v4 1/6] driver core: Fix driver_deferred_probe_check_state() logic Date: Thu, 20 Feb 2020 05:04:35 +0000 Message-Id: <20200220050440.45878-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200220050440.45878-1-john.stultz@linaro.org> References: <20200220050440.45878-1-john.stultz@linaro.org> driver_deferred_probe_check_state() has some uninituitive behavior. * From boot to late_initcall, it returns -EPROBE_DEFER * From late_initcall to the deferred_probe_timeout (if set) it returns -ENODEV * If the deferred_probe_timeout it set, after it fires, it returns -ETIMEDOUT This is a bit confusing, as its useful to have the function return -EPROBE_DEFER while the timeout is still running. This behavior has resulted in the somwhat duplicative driver_deferred_probe_check_state_continue() function being added. Thus this patch tries to improve the logic, so that it behaves as such: * If deferred_probe_timeout is set, it returns -EPROBE_DEFER until the timeout, afterwhich it returns -ETIMEDOUT. * If deferred_probe_timeout is not set (-1), it returns -EPROBE_DEFER until late_initcall, after which it returns This will make the deferred_probe_timeout value much more functional, and will allow us to consolidate the driver_deferred_probe_check_state() and driver_deferred_probe_check_state_continue() logic in a later patch. Cc: Rob Herring Cc: "Rafael J. Wysocki" Cc: Kevin Hilman Cc: Ulf Hansson Cc: Pavel Machek Cc: Len Brown Cc: Todd Kjos Cc: Bjorn Andersson Cc: Liam Girdwood Cc: Mark Brown Cc: Thierry Reding Cc: Linus Walleij Cc: Greg Kroah-Hartman Cc: linux-pm@vger.kernel.org Signed-off-by: John Stultz Change-Id: I8349b7a403ce8cbce485ea0a0a5512fddffb635c --- v4: * Simplified logic suggested by Andy Shevchenko * Clarified commit message to focus on logic change --- drivers/base/dd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/base/dd.c b/drivers/base/dd.c index b25bcab2a26b..bb383dca39c1 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -237,7 +237,7 @@ __setup("deferred_probe_timeout=", deferred_probe_timeout_setup); static int __driver_deferred_probe_check_state(struct device *dev) { - if (!initcalls_done) + if (!initcalls_done || deferred_probe_timeout > 0) return -EPROBE_DEFER; if (!deferred_probe_timeout) { @@ -252,9 +252,11 @@ static int __driver_deferred_probe_check_state(struct device *dev) * driver_deferred_probe_check_state() - Check deferred probe state * @dev: device to check * - * Returns -ENODEV if init is done and all built-in drivers have had a chance - * to probe (i.e. initcalls are done), -ETIMEDOUT if deferred probe debug - * timeout has expired, or -EPROBE_DEFER if none of those conditions are met. + * Returnes -EPROBE_DEFER if initcalls have not completed, or the deferred + * probe timeout is set, but not expried. + * Returns -ETIMEDOUT if the probe timeout was set and has expired. + * Returns -ENODEV if initcalls have completed and the deferred probe timeout + * was not set. * * Drivers or subsystems can opt-in to calling this function instead of directly * returning -EPROBE_DEFER.