From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CF34C11D07 for ; Thu, 20 Feb 2020 10:28:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2EB7C20801 for ; Thu, 20 Feb 2020 10:28:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582194524; bh=0AUovQEohakI8fl8MC2WL3aI4Yz5s5YyTEzAOrhKnRc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=saQiBCmUevn+2AIM2yWloK+w2o74jYCXqYLD66YIrmJiS/WDLHlgH5Y1/5oV7NqrV dYzp9RrPxm8gNvlE82o8ODHXFEh2uUunx/8JNiMyKC1ZsCfucgwkauWcBIwUs047rL 83ckHEh4F5gSZ7KZ29+zxXORGAUxTYJ9BqbdKu7M= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727088AbgBTK2m (ORCPT ); Thu, 20 Feb 2020 05:28:42 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:41142 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726801AbgBTK2m (ORCPT ); Thu, 20 Feb 2020 05:28:42 -0500 Received: by mail-oi1-f193.google.com with SMTP id i1so26995252oie.8; Thu, 20 Feb 2020 02:28:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zFBAIbuDCjTjmW06WHYZexwuHI/VktjiadQxllE5tFo=; b=HONQm9eIsvaRDW+4iW2uC9laW5HC6PIzQqVKQa1jDwpbeEfFfrNl1CBGiNNwKAbjvZ PH5hOIsPnACwLDyztCxqEEhHk2EtSp9OB1TJlZknrktm5mO4u6Z3+0ObNxgKgpRHtnIm QwaH4T302tYIIlu6/0ITMIafdwVix4zXBHSUrUb0leJ+eEb2qKnzLfAygL/7H0GGi/dh 31H259DhwYNh+0sE/4xLPgY+kcaWRCtaT2Eio6BH+PDF31YtJCM2a8w/ShK+O6Mmjesl PAxg/l1XwNA680w5+JUsm9GdL3zNnJ8Fc7EQbf2e8L0DtQp02PhQgdyIueclgSP855us GfNw== X-Gm-Message-State: APjAAAX3BHasixomluyuiUcUvgIB6fAjC2ge9uYQXwk4ibH5EONOuqpw 6Gwbip8jc2cP3OYTx4J7dpSvb3HJNZsL/pVOT1M= X-Google-Smtp-Source: APXvYqzZ6ybSzXMcdaP3OhqdQD94MQHqguLaLbx0WQl2FUi/mEWzifAg752SnrHoBp9RtMPM/JcmiG8RTEXRWlzY+0Q= X-Received: by 2002:aca:bfc2:: with SMTP id p185mr1503321oif.57.1582194521672; Thu, 20 Feb 2020 02:28:41 -0800 (PST) MIME-Version: 1.0 References: <20200220050440.45878-1-john.stultz@linaro.org> <20200220050440.45878-2-john.stultz@linaro.org> In-Reply-To: <20200220050440.45878-2-john.stultz@linaro.org> From: "Rafael J. Wysocki" Date: Thu, 20 Feb 2020 11:28:30 +0100 Message-ID: Subject: Re: [PATCH v4 1/6] driver core: Fix driver_deferred_probe_check_state() logic To: John Stultz Cc: lkml , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 20, 2020 at 6:05 AM John Stultz wrote: > > 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(-) > > 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; Makes sense to me. > > 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 s/Returnes/Returns/ And I would write * Return: * -EPROBE_DEFER if initcalls have not completed, or the deferred * probe timeout is set, but not expried. * -ETIMEDOUT if the deferred probe timeout was set and has expired. * -ENODEV if initcalls have completed and the deferred probe timeout was not set. > + * 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. > --