Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2945023imm; Thu, 24 May 2018 19:37:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpXF0iTBg2awa3wl65+Tfr5HdVQbfAdvGNJvuAAtr/EQhwB1C1Mzhrds75LfyXgPnamOQ5v X-Received: by 2002:a65:61a5:: with SMTP id i5-v6mr421792pgv.405.1527215830863; Thu, 24 May 2018 19:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527215830; cv=none; d=google.com; s=arc-20160816; b=GraJSuLxEgA7hyvP7wWT1ErPyV0tiE9U/X5QX32mnbSyH4PNJOlZ9BKlpJSwgnovI8 mLaa6wL73kz1H20JfNdRQ7D6B45LD6chjyKpUpA6iPdg0tY9LU2hEZy7Yh4AV8lvHjf6 rdYelnCMStHnyRcLQxT5lr012Rex+0rDvYZnogh+aUXV1tznftXn10MFEqgzju7Jm3s9 sMVt2wcb5ffCrdNqgnLU0JqDk3pv3a96Wut4enV8paxbz9AxWJxYc8yE6ek863awcThm Zjfb6Rj0IRG8yMv7W6L+/UBPIPQwUxCUFwcMyP/H+HpADYcxZ2O5xO5F8KqCXz8DaXIb Q0Sg== 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=jSsr5AKyHYUp04OQersuDfpGvb89i0IKuaN1Cyk7ZAE=; b=WIiUwSj0PdvyKxCWrzHosTOsUlI6ncKj+85LkGOrhIiphfEdRGjjOuhI3DTEUFCX0V dyTg5QdQTc7ZFVBsb4ONUHaD87R+HzcWqn9SI3q4N8zT19Pro3H7s0qfLgmDhhfvKNQu HNjDxp20U8QbkNMW8Z3XtLbpxS3g/FNY2vGEHDEC3TODF84ARqAoTSir8gHc5By5CqKz aZrCj5HS3TlGdflM/zxc3ZO9htwOUTe70gOpPmHL9G6fuRG4aMvLfOaH6JQduRimO/Yb WCGtdJqjdoyRaZWr/RYyyfmm6Yz973BO4ZKplkEveuV2vd4f1WTz8xTd93NlsaYQ++ou 6pAA== 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 a11-v6si3412689plt.39.2018.05.24.19.36.56; Thu, 24 May 2018 19:37:10 -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 S1032100AbeEXRw2 (ORCPT + 99 others); Thu, 24 May 2018 13:52:28 -0400 Received: from mail-yw0-f193.google.com ([209.85.161.193]:45527 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031090AbeEXRuc (ORCPT ); Thu, 24 May 2018 13:50:32 -0400 Received: by mail-yw0-f193.google.com with SMTP id m65-v6so836271ywc.12; Thu, 24 May 2018 10:50:32 -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=jSsr5AKyHYUp04OQersuDfpGvb89i0IKuaN1Cyk7ZAE=; b=qDcikGhLFH5YHO9okJcjUoz9tZWA2ME6wTKn+ZqfDkrey+TcwBlmmeAqg0WnyrUjO6 zcXDKwuLbTtp6NLkK8uqp4kqnEQ/BAC4FW7kXTy2Oc0JuPEv4S40Odr98dxXqroKd0hR q3WKvuMgrqF6wNN9nsPX62DPzhi9fNsa06nC4wwXW2a3uWXw15taHY/+asBCEPOSH20P YwVtiPp2IUtQT99cnVqroltrHYcK8zzLHQyMXbdq7BCD9IG/Re3SiQ9LU1zSDYuOI26Q Crb4Aq9OsRs0WoRSkgTAPYkJaIKyOBVtsLIyeg2V2T9Phe85/XVZIegQMU+kuyCGIB8o vKBA== X-Gm-Message-State: ALKqPweZFkq692mxN/P24Rby/2QJpUxr4HM9UrGE4ja3FuAyu236xes7 XU80BtkMJIwkhRxwudVcxA== X-Received: by 2002:a81:274d:: with SMTP id n74-v6mr2187688ywn.370.1527184231472; Thu, 24 May 2018 10:50:31 -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.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 10:50:31 -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 1/8] driver core: make deferring probe after init optional Date: Thu, 24 May 2018 12:50:17 -0500 Message-Id: <20180524175024.19874-2-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 Deferred probe will currently wait forever on dependent devices to probe, but sometimes a driver will never exist. It's also not always critical for a driver to exist. Platforms can rely on default configuration from the bootloader or reset defaults for things such as pinctrl and power domains. This is often the case with initial platform support until various drivers get enabled. There's at least 2 scenarios where deferred probe can render a platform broken. Both involve using a DT which has more devices and dependencies than the kernel supports. The 1st case is a driver may be disabled in the kernel config. The 2nd case is the kernel version may simply not have the dependent driver. This can happen if using a newer DT (provided by firmware perhaps) with a stable kernel version. Subsystems or drivers may opt-in to this behavior by calling driver_deferred_probe_check_init_done() instead of just returning -EPROBE_DEFER. They may use additional information from DT or kernel's config to decide whether to continue to defer probe or not. Cc: Alexander Graf Signed-off-by: Rob Herring --- drivers/base/dd.c | 17 +++++++++++++++++ include/linux/device.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index c9f54089429b..d6034718da6f 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -226,6 +226,16 @@ void device_unblock_probing(void) driver_deferred_probe_trigger(); } +int driver_deferred_probe_check_init_done(struct device *dev, bool optional) +{ + if (optional && initcalls_done) { + dev_WARN(dev, "ignoring dependency for device, assuming no driver"); + return -ENODEV; + } + + return -EPROBE_DEFER; +} + /** * deferred_probe_initcall() - Enable probing of deferred devices * @@ -240,6 +250,13 @@ static int deferred_probe_initcall(void) /* Sort as many dependencies as possible before exiting initcalls */ flush_work(&deferred_probe_work); initcalls_done = true; + + /* + * Trigger deferred probe again, this time we won't defer anything + * that is optional + */ + driver_deferred_probe_trigger(); + flush_work(&deferred_probe_work); return 0; } late_initcall(deferred_probe_initcall); diff --git a/include/linux/device.h b/include/linux/device.h index 477956990f5e..f3dafd44c285 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -334,6 +334,8 @@ struct device *driver_find_device(struct device_driver *drv, struct device *start, void *data, int (*match)(struct device *dev, void *data)); +int driver_deferred_probe_check_init_done(struct device *dev, bool optional); + /** * struct subsys_interface - interfaces to device functions * @name: name of the device function -- 2.17.0