From patchwork Tue Sep 29 09:10:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 7284491 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 BE029BEEA4 for ; Tue, 29 Sep 2015 09:30:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CDF7F206CC for ; Tue, 29 Sep 2015 09:30:24 +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 E32D5206C5 for ; Tue, 29 Sep 2015 09:30:22 +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 1ZgrDU-0007G8-OH; Tue, 29 Sep 2015 09:28:56 +0000 Received: from mail-wi0-x233.google.com ([2a00:1450:400c:c05::233]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zgqxy-0000On-UC for linux-arm-kernel@lists.infradead.org; Tue, 29 Sep 2015 09:12:55 +0000 Received: by wicgb1 with SMTP id gb1so139412110wic.1 for ; Tue, 29 Sep 2015 02:12:33 -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=upfMZ48p0ZfSU/24bi6cCTIZGUsBNelU0My/d5M/dW0=; b=sluhydjDDokZSjOrRid1/+HxaGaPEYmjdymMK7UKlH0wYRZDuc/96vpwqlTieq+KpY 1WXfzBG9nVDstJ8iiE/wbaRWSIqiysovnAsnDQ7BFWn35VfIkz1uisXGN1jd2fVrzR9G E2LWWEosVv7nAvcX2DwuXpw8Nogmnhhs8k2Hy1Ebrfog6qYWuGwnTVJXqMU8+13MZJ59 xC3HbG4IPZuDzuuDBQ8AwJNNG8lhkqL81UhkLpXNSdEWTZ6GfJU6d5wTrelyioMxkxp3 8cP/nT2T3jfmaF3YnE1pBKq8xrMcxUUQBSTSKVB8J63Kb9wtMOAa78NY36Qfq4qZEAh4 e+sQ== X-Received: by 10.180.101.163 with SMTP id fh3mr25089123wib.94.1443517953723; Tue, 29 Sep 2015 02:12:33 -0700 (PDT) Received: from cizrna.lan ([109.72.12.204]) by smtp.gmail.com with ESMTPSA id lj12sm22757276wic.0.2015.09.29.02.12.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Sep 2015 02:12:32 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [PATCH v7 19/20] driver core: Allow deferring probes until late init Date: Tue, 29 Sep 2015 11:10:57 +0200 Message-Id: <1443517859-30376-20-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443517859-30376-1-git-send-email-tomeu.vizoso@collabora.com> References: <1443517859-30376-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150929_021255_119390_A0B73E0E X-CRM114-Status: GOOD ( 17.29 ) X-Spam-Score: -2.4 (--) 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, Ulf Hansson , 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 , Russell King , 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 v7: - Move IS_ENABLED(CONFIG_DELAY_DEVICE_PROBES) into if condition - Hide CONFIG_DELAY_DEVICE_PROBES behind EXPERT 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 | 6 ++++++ include/linux/device.h | 2 ++ 3 files changed, 26 insertions(+) diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 98504ec99c7d..8bb7b556da1b 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" if EXPERT + 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..c4a3f298e726 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -417,6 +417,12 @@ 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) && + !driver_deferred_probe_enable && dev->probe_late) { + driver_deferred_probe_add(dev); + return 0; + } + 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)