From patchwork Tue Feb 25 05:08:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 183809 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp1262790ile; Mon, 24 Feb 2020 21:08:38 -0800 (PST) X-Received: by 2002:a17:902:7589:: with SMTP id j9mr53250933pll.312.1582607318195; Mon, 24 Feb 2020 21:08:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582607318; cv=none; d=google.com; s=arc-20160816; b=cny+HUbUpJQ4SnvBJFmNHEpFipmzjVm1SO9TQvfZGx306o3vAc1leryhpGbc8EgRBF 009RlXTes8X3gLwy0zLjTY/8UGKnD4XjrNb6WPJpluEE89d4SBo2Qd50RgKV+GWImwrZ rC4CPWlg4HBbRuCVmotxO4sqcPiiexvIfqxRLswF8o72UXaeyrKQCBY0FQG0UTxvP3C4 O05etqScsUuAXSbR/4nM7BSXzjoBXIUjhjMrgKASJMIClYv7zjBxoVXjlpZ7o3ZH4If3 EP4im8CLARAfsFwxFm/uh3cF7yjZN+kp0khjpv8Ju1PrLJFYKylbluZi8sxUAD5h6ZOy /QfQ== 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=VjGy9mDSQTtqTfodJGzoJsBP+0BqRCAD5WnADk/Arw0=; b=Kf9HFKT0GABinO1kF6WoaeJ6XnwZDgNlHkH3lYQOJ30ffAHI9DSTOmPDlgHR0y12W8 kUuToR1XpbQ7tlF2Rx134UyNPUDWqTO3AEMwea/HydTfZWouysGOR3OqaeCKOcWgylMM W262kfoxT3jlKl7k1CHcfutkN39v3TkX69bBY4O5tPVoFI2B5x5D+vK7j+++29I9jXKG S3NTIdl/uoU6wYvuGkaZ0FupGzHu0t3AOHHuRtm/+EGrZoZHnaqxXXGOcHF7AWqVlRui 0GQmDmMUVPwvVdxnffFWLbI18WivI0sZMwbkv8KgFx+Xs+VuBDtFWx+3LjUr9QAJMe/J ukWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QWV3p9i6; 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 y14sor16251175pgg.66.2020.02.24.21.08.38 for (Google Transport Security); Mon, 24 Feb 2020 21:08:38 -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=QWV3p9i6; 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=VjGy9mDSQTtqTfodJGzoJsBP+0BqRCAD5WnADk/Arw0=; b=QWV3p9i6zgdUqYL2d/2B5WDRt4NHawZ9OByHIbJAMrmiLd0KSO3xLeTNpgJVmrcp/0 xqki/c8H0Iv/9yANo6VcgCAnCWj0iuko5+4Zdp5ODNwpyOHZWaIktGmCJ4nXAC1JJFvd 9R0uvmxHps9ROinDk3kyZ1XeAxdr1S8gUarQvwvao6S4nhJ28Mb+vxsSFiHYEQ77omgN 8YI9LWrxpITC+nnOg+Pl1Y8Wg8b7YZ1plkloQDfuNpIDS1xzwboO0elIFvuYW3y2r778 3CTF+ftFwL+WNquuDIU4RbR2zZrtmrpGNppSCYBZdzbJkCqbczkrn/uvD9cmlAewHCBb ugsA== 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=VjGy9mDSQTtqTfodJGzoJsBP+0BqRCAD5WnADk/Arw0=; b=emrSFBOKW/XeAed5DmjflNUUGuwW/eVhGTck2HdOkfUcY08vS8a7O13oHAwUjPfjhC oQU96HbsKxKvHF2DVQa6WUb3f4m8QGUuTpHvhGExDsSkmvsvIswBfBw5C/BzSB5V6IAl lv9LaZXZkKK2HoSLGnzTE1pX0+mHA+yodKUEn+LBGKlxQX4thuTF1On/ARnL7E781QBn tf6E7NUHk5Ce/lCodJRn3GESej0/KCFeAhKBZio9/3Bme/ds6RFE16ttQk0zODQkqaQj fGjUiuCt7N0373tkHL5hrtqUDyMd9eooI5lyGmbdIbnAQw+1xbePFjmXz/WXulPuHzw2 livA== X-Gm-Message-State: APjAAAWWyGzEazI9HizbiuryIxRcD8v5F9bQGE/qIBovNaRmOFqslI10 C8jDDO5oHHMm2ud3HNuPAJD2uZ6h X-Google-Smtp-Source: APXvYqx5KRNfMIWOAh/4UQZeEBO6iVmZ2gYODKQvJ1DZC3K6GWCUjoTKnkYshlse4PleF/uQhjP5Qg== X-Received: by 2002:a63:60a:: with SMTP id 10mr49705597pgg.302.1582607317741; Mon, 24 Feb 2020 21:08:37 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id r66sm15156450pfc.74.2020.02.24.21.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 21:08:37 -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 , Saravana Kannan , Bjorn Andersson , Liam Girdwood , Mark Brown , Thierry Reding , Linus Walleij , Greg Kroah-Hartman , linux-pm@vger.kernel.org Subject: [PATCH v5 1/6] driver core: Fix driver_deferred_probe_check_state() logic Date: Tue, 25 Feb 2020 05:08:23 +0000 Message-Id: <20200225050828.56458-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200225050828.56458-1-john.stultz@linaro.org> References: <20200225050828.56458-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 late_initcall has passed, and modules are not enabled it returns -ENODEV * If modules are enabled and deferred_probe_timeout is set, it returns -EPROBE_DEFER until the timeout, afterwhich it returns -ETIMEDOUT. * In all other cases, it returns -EPROBE_DEFER 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: Saravana Kannan 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 --- v4: * Simplified logic suggested by Andy Shevchenko * Clarified commit message to focus on logic change v5: * Cleanup comment wording as suggested by Rafael * Tweaked the logic to use Saravana's suggested conditionals --- drivers/base/dd.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/drivers/base/dd.c b/drivers/base/dd.c index b25bcab2a26b..d75b34de6964 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -237,24 +237,26 @@ __setup("deferred_probe_timeout=", deferred_probe_timeout_setup); static int __driver_deferred_probe_check_state(struct device *dev) { - if (!initcalls_done) - return -EPROBE_DEFER; + if (!IS_ENABLED(CONFIG_MODULES) && initcalls_done) + return -ENODEV; if (!deferred_probe_timeout) { dev_WARN(dev, "deferred probe timeout, ignoring dependency"); return -ETIMEDOUT; } - return 0; + return -EPROBE_DEFER; } /** * 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. + * Return: + * -ENODEV if initcalls have completed and modules are disabled. + * -ETIMEDOUT if the deferred probe timeout was set and has expired + * and modules are enabled. + * -EPROBE_DEFER in other cases. * * Drivers or subsystems can opt-in to calling this function instead of directly * returning -EPROBE_DEFER. @@ -264,7 +266,7 @@ int driver_deferred_probe_check_state(struct device *dev) int ret; ret = __driver_deferred_probe_check_state(dev); - if (ret < 0) + if (ret != -ENODEV) return ret; dev_warn(dev, "ignoring dependency for device, assuming no driver"); @@ -292,7 +294,7 @@ int driver_deferred_probe_check_state_continue(struct device *dev) int ret; ret = __driver_deferred_probe_check_state(dev); - if (ret < 0) + if (ret != -ENODEV) return ret; return -EPROBE_DEFER;