From patchwork Tue Feb 18 22:07:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 183620 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp6608650ile; Tue, 18 Feb 2020 14:07:55 -0800 (PST) X-Received: by 2002:a17:902:9a85:: with SMTP id w5mr23941761plp.323.1582063675519; Tue, 18 Feb 2020 14:07:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582063675; cv=none; d=google.com; s=arc-20160816; b=n9wrifSp+Vx/B34mGQZqgrfenyXz7MbnBGHbS02H8G9Oeoy3pI1ih7mae/4TjChkY/ 6z8vDpGXdwbSlJvxXvUL+bSL0h4op2eQKdHA6ijJKwsUvxqHFrzrC4LFhFDUHGzGmbfa piHA5utDFx5SzGkdY70Llv9a7Meam8/OC381GIR4j7klOPyN9Bwvf+NdUQ0CyqavuJEO vNdTtl6hjlMHLldryw7c8g1wpqBczICk8ziu3yRyp6xlYr+p+nne1PLMFI4Pv2aKCdwB 3rOwasNjYvrmQegYt0c8hLga7qdvF4/sq1mb/od18MSUeKiUyt7BbgBHFQH+zMRFvI+n hpog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=pIQXW5hE1+eSM3lLosf+UpP271pqaf4+040KGno05/4=; b=GaFr5gTMDX/WP33Z5GTKpXDjv8yAPWlQiarj+VK9PEVpa2pX9pan1BuWB5O7wcSdhq MqDAnoF5Rmo79h/Bt7Gd9IH5SwlejA45IFP+FNaBMxY6ub4qdf3BZGuezUa58UVMov5F Jtmem9BoTh0PODlCrlNvputxCuOr+FaoweiJ/T1JSCjqU4L8uFDf/DBRAQLMJthzt1Mg 2huqSC2WZ7Czmyr4xsd2xrsdvm0xABwMqXFq0UGwX6rS+++CsclxVXbuAa1uQkDl0nXO hl1+emXoPLymwjhkuYScjwhbwjhPLi/3VTuNKksZngx+F8D0dQfEQU5LpoYTigA0P2Dj pMXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SRtKjPvi; 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 h3sor4621886pjs.13.2020.02.18.14.07.55 for (Google Transport Security); Tue, 18 Feb 2020 14:07:55 -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=SRtKjPvi; 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; bh=pIQXW5hE1+eSM3lLosf+UpP271pqaf4+040KGno05/4=; b=SRtKjPviRKEjd1+AkFb+3aF7EF0gSfjDVNUnYCbnP61y6zy0QwngTevwCuBByt54RM NCBHDna6P/lH3I12T466ZtCwtuM3bL81j8Uy+J97lb9E9xMz3su4W67vNe2Jm5/uwg29 rWrp3OcLGEcuwRD3jzS3Ue8q5WiwOrS/I6S+FJIdHWs8nru69mBWX99SxoTIRV2XX0Kj Bg8lf2AdIscIqA9ls5CJ25PKrG+53/wJ4wkJXaftY2kDv1zU+/Ps4cXP4hpKNIepM5jB JaxySFOiycK1STIlUc0//eNyy07OTqRm4DvoYZ1TIJN0FvYwqkz3iAsBNmbYXjeR5Nvy Bqlw== 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; bh=pIQXW5hE1+eSM3lLosf+UpP271pqaf4+040KGno05/4=; b=PTgyL5uG8vY8lFwfzdnSFBrMTMVH48wr1KDFZrIeCZWQQX9St4P/of7jmuu06bkLuj Spq4vESneot88refyvj2sYXB67RIN1gfx+J6n/TRBMeQzzVKoHkpK6HAnRAWlJgWSbEA OqdMVrVZDOVajJZ84H/NMXlw8yVcGIsCBFd+n7+OPpZorGL9h8425WGKMOLd5ro66lII wsoqtcO6CypCZgwuhdFVGaIbeOlfJHwvR2E5XBYo7Nay8A/HNyMKhcws7KeGJsK7hwJ6 XEkdRnq3ezL5dmbQAEph4LceIEZ3LJK8thQ7lW49RgrR7kTOn0rQobO7hWlOG1KyMzKJ chvg== X-Gm-Message-State: APjAAAWW0xTxYPkkq7qKpALwgRK6f4ppHywJs8crR8TtVeARzhl67rTA /zn0HAKtuQp/LpEO1GV9ZHC3I9VV X-Google-Smtp-Source: APXvYqyCxijq9UmWFDyySgQnBxHFONgdNjoM9hfMVUkV+GEVmtIRioztxSn530rGJVEEY1Mr5+8f5A== X-Received: by 2002:a17:90a:8c0f:: with SMTP id a15mr5390408pjo.86.1582063674983; Tue, 18 Feb 2020 14:07:54 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id d69sm5485229pfd.72.2020.02.18.14.07.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 14:07:54 -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 , Greg Kroah-Hartman , linux-pm@vger.kernel.org Subject: [PATCH v3 1/2] driver core: Rework logic in __driver_deferred_probe_check_state to allow EPROBE_DEFER to be returned for longer Date: Tue, 18 Feb 2020 22:07:47 +0000 Message-Id: <20200218220748.54823-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 Due to commit e01afc3250255 ("PM / Domains: Stop deferring probe at the end of initcall"), along with commit 25b4e70dcce9 ("driver core: allow stopping deferred probe after init") after late_initcall, drivers will stop getting EPROBE_DEFER, and instead see an error causing the driver to fail to load. That change causes trouble when trying to use many clk drivers as modules, as the clk modules may not load until much later after init has started. If a dependent driver loads and gets an error instead of EPROBE_DEFER, it won't try to reload later when the dependency is met, and will thus fail to load. This patch reworks some of the logic in __driver_deferred_probe_check_state() so that if the deferred_probe_timeout value is set, we will return EPROBE_DEFER until that timeout expires, which may be after initcalls_done is set to true. Specifically, on db845c, this change (when combined with booting using deferred_probe_timeout=30) allows us to set SDM_GPUCC_845, QCOM_CLK_RPMH and COMMON_CLK_QCOM as modules and get a working system, where as without it the display will fail to load. 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: Greg Kroah-Hartman Cc: linux-pm@vger.kernel.org Signed-off-by: John Stultz --- v2: * Add calls to driver_deferred_probe_trigger() after the two minute timeout, as suggested by Bjorn * Minor whitespace cleanups * Switch to 30 second timeout to match what the regulator code is doing as suggested by Rob. v3: * Rework to reuse existing deferred_probe_timeout value, suggested by Rob * Dropped Fixes: tags as Rob requested (Not my hill to die on :) --- drivers/base/dd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/base/dd.c b/drivers/base/dd.c index b25bcab2a26b..9d916a7b56a6 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -237,13 +237,12 @@ __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 (!deferred_probe_timeout) { + if (initcalls_done && !deferred_probe_timeout) { dev_WARN(dev, "deferred probe timeout, ignoring dependency"); return -ETIMEDOUT; } + if (!initcalls_done || deferred_probe_timeout > 0) + return -EPROBE_DEFER; return 0; } From patchwork Tue Feb 18 22:07:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 183621 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp6608699ile; Tue, 18 Feb 2020 14:08:00 -0800 (PST) X-Received: by 2002:a17:902:b215:: with SMTP id t21mr22797300plr.190.1582063680175; Tue, 18 Feb 2020 14:08:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582063680; cv=none; d=google.com; s=arc-20160816; b=yumrvb5i3ZBZiDn1yY53Vz3H+CEMd3jC+KKz6iCclVe5dqCGDxXEKj43+YbiPp5WGG uF51pUvCMmL7dBVPiSEqi+ztMfmY8dtXESfTYuMfrgSWPeDIWCIemDatiYGqjPUuyKDY o0+SD8oDSZoAn6w64MymIDZnn6x8LCXYViyej6DwRaX9Dr/LVp49n7hBqxgm3OSi3SqX 5HOO7wusHyGAVJIfE6WBI6MOqYfOy1jxo4CbVGl00i5o8kq88JojSIWQ0FSssw3MbCPb LeJf9uHKLLjdYkXpCZONY3CM5MVkKN2f/1RQFXi3TYf2rAww3m+Y8d1XeHwAjv3U5yCb xf0w== 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=fddqMLrJQRzitZYDWKracPUF7ZxdfWRkTJcAoveCrU4=; b=sJ5TX3ryIsSnyE63zWFr0/p4Ua78Jb5Ioi25WiG1xYDqg3bTmCNSIwBtimyIfk38+c 1ti7HAWPvMGx6wvo9fHmdaFYlR7JDgSt20/WAaANZo+/YKY8CCh1VEp7RwZ9eZLzamdw 58FAOeGHbxABX6XTc9/37DDOrvdth21PEvt5UoHlPD5TKU3Sci/CiYzn3NX3v9wSXh/d fpCP+jH40yV2ikncL16Z10DjFCue/MB5vDy2sOSFp1jpQrQb/rNNHmxl5Gk6PquBejmM 4bUR6LP8N+jZ/BXS8yrY3W8ISqOfVTQD+NnWLfPsJD0RnUR85wGmjOm4x91zrX50BKjH wgzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mmw76Nmc; 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 b3sor6214911pgi.35.2020.02.18.14.08.00 for (Google Transport Security); Tue, 18 Feb 2020 14:08:00 -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=mmw76Nmc; 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=fddqMLrJQRzitZYDWKracPUF7ZxdfWRkTJcAoveCrU4=; b=mmw76NmczqpmMPWrvF9Ft4knfpYOpBH1k9zm30aH7yEQMHUhBCzxgjawY42G45pvrr yVy4o05/H4pYCJiyFtK6nuYF2ajeZMNdFCliPZzHwkT2u2GW8/aVBa3/4l/8j1pLxwdj sAMw6G/5BWHnxjLr0v0kMBbraVai3qvzSoE831+6VrRU13KtR7ya8b6DLvInjaMZi1bI W71mrPIUlgkCGlqLG7a4Rz7l6S5Yt5/nbxEM79w3oWxdzB87/zbx+OgpU9Zpic7g+dCE 3JHSB2g/+OLvu8wZGOi0ioAIRB/SlEDkPVG5w3lhzugI1vbh0vJqISRsh9M0P/hSNF3S Ruaw== 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=fddqMLrJQRzitZYDWKracPUF7ZxdfWRkTJcAoveCrU4=; b=C+i3d2cGsi/8/uyafiFi8HgWycCoUQ/I0MljPZ/DmRINgHgAaG3iqLBLubWefsOjL8 CgkoYpFm6YM07YkOwwUZ2z1nTXt6whMwTChQhn9peLs1rBGSBrtX+rrA+o5RPf04phOt RYTQ3XzyCJwTPo0gbYXePf8+SmvIyKvCddktz6/C7Svy3A7GYyBM86lX5lhevpEoTADl JAUdSDLnwM8omqMGVX8QRuPrwRF8r/mkYUXgIqYXWyYXypzf1OlFo4xTbkc9C4GJwzS8 BZPecROkHo9C0bZS75wsYrqN9+5bj49vKdefBPAdhIvzwyklEwDfo0IIUnWe02J1wLmd NLGw== X-Gm-Message-State: APjAAAUpyBejEQ41x9gWryReSsJtAd1Ved1DGNoA7sZto0z8ot1VI71y 0M9mQv31/dhK7ay9l8FX2Znj676v X-Google-Smtp-Source: APXvYqza44F+QlcD0d2mvFzZr70iF4BFKK30MuvV2w4EOISTJkmXAY1nf3jjtKHvFEA9mrY8032psg== X-Received: by 2002:a63:e4d:: with SMTP id 13mr24648668pgo.343.1582063679790; Tue, 18 Feb 2020 14:07:59 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id d69sm5485229pfd.72.2020.02.18.14.07.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 14:07:59 -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 , Greg Kroah-Hartman , linux-pm@vger.kernel.org Subject: [PATCH v3 2/2] driver core: Make deferred_probe_timeout global so it can be shared Date: Tue, 18 Feb 2020 22:07:48 +0000 Message-Id: <20200218220748.54823-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200218220748.54823-1-john.stultz@linaro.org> References: <20200218220748.54823-1-john.stultz@linaro.org> This patch, suggested by Rob, allows deferred_probe_timeout to be global so other substems can use it. This also sets the default to 30 instead of -1 (no timeout) and modifies the regulator code to make use of it instead of its hard-coded 30 second interval. In the case that deferred_probe_timeout is manually set to -1, we preserve the regulator's hard coded 30 second interval (just to be cautious this doesn't change behavior in that case). Feedback would be apprecaited! 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: Greg Kroah-Hartman Cc: linux-pm@vger.kernel.org Signed-off-by: John Stultz --- drivers/base/dd.c | 4 +++- drivers/regulator/core.c | 12 ++++++++---- include/linux/device/driver.h | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 9d916a7b56a6..c8e025a20a9d 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -224,7 +224,9 @@ static int deferred_devs_show(struct seq_file *s, void *data) } DEFINE_SHOW_ATTRIBUTE(deferred_devs); -static int deferred_probe_timeout = -1; +int deferred_probe_timeout = 30; +EXPORT_SYMBOL_GPL(deferred_probe_timeout); + static int __init deferred_probe_timeout_setup(char *str) { int timeout; diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index d015d99cb59d..889d08e65f19 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -5757,6 +5757,11 @@ static DECLARE_DELAYED_WORK(regulator_init_complete_work, static int __init regulator_init_complete(void) { + int delay = deferred_probe_timeout; + + /* preserve 30 second interval if deferred_probe_timeout=-1 */ + if (delay < 0) + delay = 30; /* * Since DT doesn't provide an idiomatic mechanism for * enabling full constraints and since it's much more natural @@ -5767,18 +5772,17 @@ static int __init regulator_init_complete(void) has_full_constraints = true; /* - * We punt completion for an arbitrary amount of time since + * We punt completion for deferred_probe_timeout seconds since * systems like distros will load many drivers from userspace * so consumers might not always be ready yet, this is * particularly an issue with laptops where this might bounce * the display off then on. Ideally we'd get a notification * from userspace when this happens but we don't so just wait * a bit and hope we waited long enough. It'd be better if - * we'd only do this on systems that need it, and a kernel - * command line option might be useful. + * we'd only do this on systems that need it. */ schedule_delayed_work(®ulator_init_complete_work, - msecs_to_jiffies(30000)); + delay * HZ); return 0; } diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h index 1188260f9a02..b3ff8cb3fbd6 100644 --- a/include/linux/device/driver.h +++ b/include/linux/device/driver.h @@ -236,6 +236,7 @@ driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev) } #endif +extern int deferred_probe_timeout; void driver_deferred_probe_add(struct device *dev); int driver_deferred_probe_check_state(struct device *dev); int driver_deferred_probe_check_state_continue(struct device *dev);