From patchwork Mon Sep 21 14:03:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 7231841 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C8FCD9F32B for ; Mon, 21 Sep 2015 14:16:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A1DA206FB for ; Mon, 21 Sep 2015 14:16:36 +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 3A9AB20701 for ; Mon, 21 Sep 2015 14:16:35 +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 1Ze1sQ-0002lA-26; Mon, 21 Sep 2015 14:15:30 +0000 Received: from mail-lb0-x234.google.com ([2a00:1450:4010:c04::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ze1ho-0002G5-3i for linux-arm-kernel@lists.infradead.org; Mon, 21 Sep 2015 14:04:37 +0000 Received: by lbbvu2 with SMTP id vu2so51497487lbb.0 for ; Mon, 21 Sep 2015 07:04:10 -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=kB4WPDsfeEW5p513XQuODfYFpMUbvtcbhf8m8jYt/9o=; b=mromXfkk3IB7uICcd6wILaohy/8OX5klkykzyqagyyo/Wx1P6FuVjtK3RRH+bIDQe5 B8lRmmo23lgVknyQb2T1vgkJRp9kaOCltn1oGu6cFyJPlENbTF3OY536MyX84Od7PvQ7 YdSpCLy6TugPz40OuuQ+YsDWmR59d6jD7VDAH0Xdzs8O6JrJRAMkvNm+DiSI70+6esxT tJDV9nZUEOzxyKcVAsdFaPhPbd91d1ot1gS4KU6BjxhBzxVFICBQ1i3H8IuczuFJeg+7 zV/7EbwVCDaPcI27mvHQrMX55dPkV+cXFeCefebxG0A4h7fu/z2/g07z98jsU8DfXxFi 4cpg== X-Received: by 10.194.116.9 with SMTP id js9mr26930099wjb.51.1442844250037; Mon, 21 Sep 2015 07:04:10 -0700 (PDT) Received: from cizrna.lan ([109.72.12.69]) by smtp.gmail.com with ESMTPSA id gk9sm13687031wib.9.2015.09.21.07.04.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Sep 2015 07:04:09 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [PATCH v6 20/22] driver core: Allow deferring probes until late init Date: Mon, 21 Sep 2015 16:03:00 +0200 Message-Id: <1442844182-27787-21-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1442844182-27787-1-git-send-email-tomeu.vizoso@collabora.com> References: <1442844182-27787-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150921_070432_437195_8E246C8A X-CRM114-Status: GOOD ( 17.31 ) 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,RP_MATCHES_RCVD,T_DKIM_INVALID,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 v4: - Add Kconfig DELAY_DEVICE_PROBES to allow disabling delayed probing in machines with initcalls that depend on devices probing at a given time. 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 7dc04ee81c8b..269ea76c1a4f 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 8e7b806f0744..e64f4c7e243d 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -744,6 +744,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 @@ -828,6 +829,7 @@ struct device { bool offline_disabled:1; bool offline:1; + bool probe_late:1; }; static inline struct device *kobj_to_dev(struct kobject *kobj)