From patchwork Thu May 24 17:50:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 136766 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2528452lji; Thu, 24 May 2018 10:52:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr3jtwzRNcP+6eSzW8F3E6YUpcrFPDE3nIiokhRC4a8Qf/QXQeDNWCwErh0wlY802QpPSZ9 X-Received: by 2002:a65:5b4d:: with SMTP id y13-v6mr6713684pgr.152.1527184352065; Thu, 24 May 2018 10:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527184352; cv=none; d=google.com; s=arc-20160816; b=aYAcC4kVEKpqvaDwbMlquieJ4tDzCqxlese2HauoYltxpVyYsgxiEBuxOm+xnfxZ3F ByPa4KYsLo4JIgLPpwjRevpeGIkJkX9fyZJb1RNpkEjV6sBT56U2dTfEYhg9S2cY3FQG pzW1KSFwhBEBJjAAo0TtUr2xRG/+JqYaBiZaB24aJBeyBnlvy5X2Akc8/lXEATVk2yVw 6vUo89d/yOcDDpr3X9k53vtSF1eWYL2Y5FwI9U5r9Z+pMmBGKSjEGXcJ1VWSnH4y7liD w+UW2iMg5t4fUS8PhMgtSdLG/iXZiiwbL04/lC516tNYJJDyw91Lo/z2TgFTnGliTn2M 0JmA== 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 w4-v6si11141025plp.357.2018.05.24.10.52.31; Thu, 24 May 2018 10:52:32 -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 S1032109AbeEXRw3 (ORCPT + 30 others); Thu, 24 May 2018 13:52:29 -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(+) -- 2.17.0 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