From patchwork Thu May 24 17:50:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 136760 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2526716lji; Thu, 24 May 2018 10:50:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoNyAg1GD44qX96wVnHA+YQnBxJNYALc+51h125XNV165bxkWLfZxpTrEAsfBYNz8bLs1yt X-Received: by 2002:a62:8b92:: with SMTP id e18-v6mr8292580pfl.60.1527184247789; Thu, 24 May 2018 10:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527184247; cv=none; d=google.com; s=arc-20160816; b=Ma3OOZ9o/B5Tj4//PzeTs7XXb8MpatXScj3ZDgG7LLFfocSusAUd7YQzx61et0E5Uw +lhjjonDsNg5RT0MEfbea/2gMjiMaQLJjSOR2LIyKxJDeREJUjHjMM3fp5QXIFfMT3Gr n3IzH26VsmQ1XLXao2fxSQjMjbzaxFWrcq/Cl44IHNVeE0W4vos36KfvVx50MJly3HIv 6kac/V5WzX3DXEhOivyVXbu2aLJ7JK48MJD0SJLSiVFakeq0sN2OcUFqvVcdtK96ZjX1 Y15RMtLv68WgWBSGJY+pWHB4aPTYlAHHISxu/91hvKnzh5XXqKtN/tPc/Gh70uFUa6XB rF+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=cS8ROXMSFF5tKvPLVR8o9D6gPGVX5L3DlPWdWmBTbqI=; b=LLwUB7CMT+sjdGRBP2VVaOp7SoP9zLQgK1pQnxcpHDTrogjqtJnSmoHi0Ed1mAQuaG gR5BPg3ctRGqk/drF3e4FWAQjyRyUeqv72LceAZuZOvUGIva8nXMlAp9hE+/42ByBjg3 yODLsVK0mia/u8/eEf4PaA++aOp5zO0jmrQM6bfl1kou6LzslWsaRZ7j8dZa+djfNpKK KTD8eS9rFyomXl2ePlNAb+OMdMmOrdWYlFI1iBAnD21IgYcV/l1qHFPezQ0O1Q0AjcnG fIfkX5LDVrAYpUlHhHwIWV2b7iJhGPWV/rU1N4PYlh/NupixhDNBIqx0DTExa7YtAmpr W0Mg== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si22057197plh.34.2018.05.24.10.50.47; Thu, 24 May 2018 10:50:47 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031316AbeEXRun (ORCPT + 30 others); Thu, 24 May 2018 13:50:43 -0400 Received: from mail-yw0-f195.google.com ([209.85.161.195]:34623 "EHLO mail-yw0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031146AbeEXRug (ORCPT ); Thu, 24 May 2018 13:50:36 -0400 Received: by mail-yw0-f195.google.com with SMTP id x27-v6so841624ywj.1; Thu, 24 May 2018 10:50:35 -0700 (PDT) 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=cS8ROXMSFF5tKvPLVR8o9D6gPGVX5L3DlPWdWmBTbqI=; b=aYSqg2bLp77rvmE22X2LlX5jo72WClxdunddZHFYAqjktZuRfcXvWF/2Zla0tWcpcM ar1RpjL1abgx8K4l5ca7yuiD8/u90DxLZd1ixfzNxrVclQjWRoh/am3EfSwwOfJ8MUOa 9OcyCyeBhFWq5E1YclGfbRwbynhsGX90IupTtk7Dlucc12KwdOjAtCnaDzWtLpGGqrbn tC6yZfiMqw9o91OZ5tbzU63FO/F+CA59YBuYya0pxcVpmMLVN/F6FxZawcrLGarux14w hj6Jent0/Pl6deKmZW5DOVD1spOGQjNqrQBYXApBn582F0JA+LWq5PFX1jNjudwEtVJJ zNWw== X-Gm-Message-State: ALKqPwdjpKcs3AaKPtHxdxEuQI+YIXAsSl52IOsnLgQ7tLhueaA+zhX4 e8BavI1H7YH0OubfMKwgSg== X-Received: by 2002:a81:c84a:: with SMTP id k10-v6mr4749922ywl.54.1527184234036; Thu, 24 May 2018 10:50:34 -0700 (PDT) Received: from localhost.localdomain (24-223-123-72.static.usa-companies.net. [24.223.123.72]) by smtp.googlemail.com with ESMTPSA id v73-v6sm9183814ywa.92.2018.05.24.10.50.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 10:50:33 -0700 (PDT) From: Rob Herring To: Greg Kroah-Hartman , Linus Walleij , Alexander Graf , Bjorn Andersson , "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , Joerg Roedel , Robin Murphy , Mark Brown , Frank Rowand Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, boot-architecture@lists.linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 2/8] driver core: add a deferred probe timeout Date: Thu, 24 May 2018 12:50:18 -0500 Message-Id: <20180524175024.19874-3-robh@kernel.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524175024.19874-1-robh@kernel.org> References: <20180524175024.19874-1-robh@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Deferring probe can wait forever on dependencies that may never appear for a variety of reasons. This can be difficult to debug especially if the console has dependencies or userspace fails to boot to a shell. Add a timeout to retry probing without possibly optional dependencies and to dump out the deferred probe pending list after retrying. This mechanism is intended for debug purposes. It won't work for the console which needs to be enabled before userspace starts. However, if the console's dependencies are resolved, then the kernel log will be printed (as opposed to no output). Signed-off-by: Rob Herring --- .../admin-guide/kernel-parameters.txt | 7 +++++ drivers/base/dd.c | 28 ++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) -- 2.17.0 diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 11fc28ecdb6d..dd3f40b34a24 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -809,6 +809,13 @@ Defaults to the default architecture's huge page size if not specified. + deferred_probe_timeout= + [KNL] Set a timeout in seconds for deferred probe to + give up waiting on dependencies to probe. Only specific + dependencies (subsystems or drivers) that have opted in + will be ignored. This option also dumps out devices + still on the deferred probe list after retrying. + dhash_entries= [KNL] Set number of hash buckets for dentry cache. diff --git a/drivers/base/dd.c b/drivers/base/dd.c index d6034718da6f..4133b240c7e4 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -226,9 +226,17 @@ void device_unblock_probing(void) driver_deferred_probe_trigger(); } +static int deferred_probe_timeout = -1; +static int __init deferred_probe_timeout_setup(char *str) +{ + deferred_probe_timeout = simple_strtol(str, NULL, 0); + return 1; +} +__setup("deferred_probe_timeout=", deferred_probe_timeout_setup); + int driver_deferred_probe_check_init_done(struct device *dev, bool optional) { - if (optional && initcalls_done) { + if ((optional || !deferred_probe_timeout) && initcalls_done) { dev_WARN(dev, "ignoring dependency for device, assuming no driver"); return -ENODEV; } @@ -236,6 +244,19 @@ int driver_deferred_probe_check_init_done(struct device *dev, bool optional) return -EPROBE_DEFER; } +static void deferred_probe_timeout_work_func(struct work_struct *work) +{ + struct device_private *private, *p; + + deferred_probe_timeout = 0; + driver_deferred_probe_trigger(); + flush_work(&deferred_probe_work); + + list_for_each_entry_safe(private, p, &deferred_probe_pending_list, deferred_probe) + dev_info(private->device, "deferred probe pending"); +} +static DECLARE_DELAYED_WORK(deferred_probe_timeout_work, deferred_probe_timeout_work_func); + /** * deferred_probe_initcall() - Enable probing of deferred devices * @@ -257,6 +278,11 @@ static int deferred_probe_initcall(void) */ driver_deferred_probe_trigger(); flush_work(&deferred_probe_work); + + if (deferred_probe_timeout > 0) { + schedule_delayed_work(&deferred_probe_timeout_work, + deferred_probe_timeout * HZ); + } return 0; } late_initcall(deferred_probe_initcall);