From patchwork Thu Sep 17 12:57:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 7207351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 54EFEBEEC1 for ; Thu, 17 Sep 2015 13:24:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 65DCB208B4 for ; Thu, 17 Sep 2015 13:24:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 629C2208C2 for ; Thu, 17 Sep 2015 13:24:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZcZ9Z-0006ct-9S; Thu, 17 Sep 2015 13:23:09 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZcZ9N-0006Jz-9p for linux-arm-kernel@bombadil.infradead.org; Thu, 17 Sep 2015 13:22:57 +0000 Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZcYlw-0005V4-Q4 for linux-arm-kernel@lists.infradead.org; Thu, 17 Sep 2015 12:58:45 +0000 Received: by wicgb1 with SMTP id gb1so116806416wic.1 for ; Thu, 17 Sep 2015 05:58:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=wk8yHeAdqiqMAMk/KcYGC9zJYM/jQJijs+Tzl2Fo8RU=; b=nkVEL9dl87w+mptLKtUD+7mxoEbaNzIQ1P3Mnx/cIXGFwG5chsCLHb43fhdkucioNp 5xw1CEo70mGBCbEe1vYBenKfRxhYBgkh9U2RqpvO9DXsQ9YRyL9EKi712GgYViTqsro8 b9/ZewJ1slideGjUucADjW8TL7Avlvg0r8zfktBJ6bd9U9m6CwiN05aPC3l9a5NLeTG+ HwnC70M3+HotxbebbKcyln6585iFvlXoK1dfzVciQE8XfbB0zga0RPrnaqV6p9VuhbPa CXE1HLfOTupPyT9Avtx7tIfDTQUKkf6fh5H9JpswMVmgEWfg0h9bBZ+3sIaKiEgjYNhf fx/w== X-Received: by 10.194.84.238 with SMTP id c14mr61423032wjz.33.1442494703369; Thu, 17 Sep 2015 05:58:23 -0700 (PDT) Received: from cizrna.lan ([109.72.12.203]) by smtp.gmail.com with ESMTPSA id jr5sm2203032wjc.26.2015.09.17.05.58.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2015 05:58:22 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [PATCH v5 21/23] driver core: Allow deferring probes until late init Date: Thu, 17 Sep 2015 14:57:15 +0200 Message-Id: <1442494637-3674-22-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1442494637-3674-1-git-send-email-tomeu.vizoso@collabora.com> References: <1442494637-3674-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150917_135844_890681_621AAF3A X-CRM114-Status: GOOD ( 19.45 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomeu Vizoso , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, Arnd Bergmann , Stephen Warren , Greg Kroah-Hartman , Linus Walleij , Dmitry Torokhov , "Rafael J. Wysocki" , Rob Herring , Javier Martinez Canillas , Mark Brown , Thierry Reding , Alan Stern , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a field to struct device that instructs the device-driver core to defer the probe of this device until the late_initcall level. By letting all built-in drivers to register before starting to probe, we can avoid any deferred probes by probing dependencies on demand. Signed-off-by: Tomeu Vizoso --- Changes in v5: None Changes in v4: - Add Kconfig DELAY_DEVICE_PROBES to allow disabling delayed probing in machines with initcalls that depend on devices probing at a given time. Changes in v3: None Changes in v2: None drivers/base/Kconfig | 18 ++++++++++++++++++ drivers/base/dd.c | 7 +++++++ include/linux/device.h | 2 ++ 3 files changed, 27 insertions(+) diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 98504ec99c7d..44b5d33b1f49 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig @@ -324,4 +324,22 @@ config CMA_ALIGNMENT endif +config DELAY_DEVICE_PROBES + bool "Allow delaying the probe of some devices" + default y + help + Devices can be matched to a driver and probed from the moment they + are registered, but early during boot their probes are likely to be + deferred because some dependency isn't available yet because most + drivers haven't been registered yet. + + Enabling this option allows the device registration code to delay the + probing of a specific device until device_initcall_sync, when all + built-in drivers have been registered already. + + In some platforms there may be implicit assumptions about when some + devices are probed, so enabling this option could cause problems there. + + If unsure, say Y here. + endmenu diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 5caa8478404d..300c59562fc9 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -417,6 +417,13 @@ int driver_probe_device(struct device_driver *drv, struct device *dev) if (!device_is_registered(dev)) return -ENODEV; +#if IS_ENABLED(CONFIG_DELAY_DEVICE_PROBES) + if (!driver_deferred_probe_enable && dev->probe_late) { + driver_deferred_probe_add(dev); + return 0; + } +#endif + pr_debug("bus: '%s': %s: matched device %s with driver %s\n", drv->bus->name, __func__, dev_name(dev), drv->name); diff --git a/include/linux/device.h b/include/linux/device.h index d8be07bc9c3f..fe5c50ffd7d3 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -748,6 +748,7 @@ struct device_dma_parameters { * * @offline_disabled: If set, the device is permanently online. * @offline: Set after successful invocation of bus type's .offline(). + * @probe_late: If set, device will be probed in the late initcall level. * * At the lowest level, every device in a Linux system is represented by an * instance of struct device. The device structure contains the information @@ -832,6 +833,7 @@ struct device { bool offline_disabled:1; bool offline:1; + bool probe_late:1; }; static inline struct device *kobj_to_dev(struct kobject *kobj)