Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3408357imm; Mon, 13 Aug 2018 11:08:35 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxU9Lib5UjWUygMZsRw3LsklssgjcwkZSNy/YmpwjVPlPX/tZ6Y1AvMtqwNLCyyU8ggfPKY X-Received: by 2002:a17:902:7486:: with SMTP id h6-v6mr17930332pll.165.1534183715478; Mon, 13 Aug 2018 11:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534183715; cv=none; d=google.com; s=arc-20160816; b=DjtW2AqchgqMlE0VGRI40AxetQ62VcprNMYwnNpCb3ULTFwirrDi+IT+/jIvAvUrPe h00XfaUUZIE50BYsDznmzx3Adp2Obm6Jr7nkg3RGHvdoa3eBnW2Y24HVJDCfbDZCpA/T hu84QUVaSvHQIlZRlNdczsk3dMzLilqoXVeONTUauX89ahPbEJq0hfHV8Mz2MImqgn4v yX7x09uvo2dpNuidXIY+vr7/BepUlmPmatIoFmVcTkT7cpTxVWWFrsU5JcBlO/fDEsbL BlAwepwsVLpDsfS1rqnSaO5zR+1mggox5/2BYyVaxKzMlN/JKlTh42MfkTvyNMdV85/j Ze/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:arc-authentication-results; bh=EFxodyJ8f1KWpJker4f+o+dbtJuJotcpDfIedhCwbaM=; b=kWxkzDOmORPk7MCcTvyGQgqZaWJi4K8W++BBQo1l9ESrSzSq+43KdgHyxwr4mZZVFA nLIjuD3Ey1VJ2oelZcDqaNl5AusjzsRSHbE86PhkGmwBYFEMXqfiu0pUOu5lXAt2TAQd QgVo2paqWqz8GYrDy9zHlIJ6o+h2LDmw2SV/GNEW7hzbtCh1K5Lyo4JsXnPM/r4LfCKx dJUbnR7eHg/F9a1HhEJI6Rf/olwqU62TWTniSUfplWEWi3Gu97vPSTIlEsCbxs/OlQ92 500VNsgvRmzzDM0JjURN7DkUT+e1t+M0TFHFI2AljNKqT/PpgYh6bMOJPI1uLmWD9gba GTdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s17-v6si15108804plr.120.2018.08.13.11.08.20; Mon, 13 Aug 2018 11:08:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730363AbeHMUXu (ORCPT + 99 others); Mon, 13 Aug 2018 16:23:50 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45532 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728533AbeHMUXu (ORCPT ); Mon, 13 Aug 2018 16:23:50 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 5CB2F6079C; Mon, 13 Aug 2018 17:40:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL autolearn=no autolearn_force=no version=3.4.0 Received: from rishabhb-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: rishabhb@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 9C975606CF; Mon, 13 Aug 2018 17:40:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 9C975606CF Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=fail (p=none dis=none) header.from=quicinc.com Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=fail smtp.mailfrom=rishabhb@quicinc.com From: Rishabh Bhatnagar To: rafael@kernel.org Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, psodagud@codeaurora.org, ckadabi@codeaurora.org, tsoni@codeaurora.org, linux-pm@vger.kernel.org, Rishabh Bhatnagar , Vikram Mulukutla Subject: [PATCH v1] dd: Invoke one probe retry cycle after some initcall levels Date: Mon, 13 Aug 2018 10:39:49 -0700 Message-Id: <1534181989-22536-1-git-send-email-rishabhb@quicinc.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rishabh Bhatnagar Drivers that are registered at an initcall level may have to wait until late_init before the probe deferral mechanism can retry their probe functions. It is possible that their dependencies were resolved much earlier, in some cases even before the next initcall level. Invoke one probe retry cycle at every _sync initcall level after subsys initcall, allowing these drivers to be probed earlier. To give an example many Qualcomm drivers are dependent on the regulator and bus driver. Both the regulator and bus driver are probed in the subsys_initcall level. Now the probe of bus driver requires regulator to be working. If the probe of bus driver happens before regulator, then bus driver's probe will be deferred and all other device's probes which depend on bus driver will also be deferred. The impact of this problem is reduced if we have this patch. Signed-off-by: Vikram Mulukutla Signed-off-by: Rishabh Bhatnagar --- Changes since v0: * Remove arch_initcall_sync(deferred_probe_initcall) from patch. This is not really needed as none of the devices are re-probed in arch_initcall_sync level. drivers/base/dd.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 1435d72..9aa41aa 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -224,23 +224,43 @@ void device_unblock_probing(void) driver_deferred_probe_trigger(); } +static void enable_trigger_defer_cycle(void) +{ + driver_deferred_probe_enable = true; + driver_deferred_probe_trigger(); + /* + * Sort as many dependencies as possible before the next initcall + * level + */ + flush_work(&deferred_probe_work); +} + /** * deferred_probe_initcall() - Enable probing of deferred devices * * We don't want to get in the way when the bulk of drivers are getting probed. * Instead, this initcall makes sure that deferred probing is delayed until - * late_initcall time. + * all the registered initcall functions at a particular level are completed. + * This function is invoked at every *_initcall_sync level. */ static int deferred_probe_initcall(void) { - driver_deferred_probe_enable = true; - driver_deferred_probe_trigger(); - /* Sort as many dependencies as possible before exiting initcalls */ - flush_work(&deferred_probe_work); + enable_trigger_defer_cycle(); + driver_deferred_probe_enable = false; + return 0; +} +subsys_initcall_sync(deferred_probe_initcall); +fs_initcall_sync(deferred_probe_initcall); +device_initcall_sync(deferred_probe_initcall); + +static int deferred_probe_enable_fn(void) +{ + /* Enable deferred probing for all time */ + enable_trigger_defer_cycle(); initcalls_done = true; return 0; } -late_initcall(deferred_probe_initcall); +late_initcall(deferred_probe_enable_fn); /** * device_is_bound() - Check if device is bound to a driver -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project