From patchwork Mon Sep 7 12:23:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 7134861 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 F2ECDBF036 for ; Mon, 7 Sep 2015 12:48:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 137B2206D4 for ; Mon, 7 Sep 2015 12:48:32 +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 2400C2060B for ; Mon, 7 Sep 2015 12:48:31 +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 1ZYvoV-0003B6-9q; Mon, 07 Sep 2015 12:46:23 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZYvoK-000349-OD for linux-arm-kernel@bombadil.infradead.org; Mon, 07 Sep 2015 12:46:12 +0000 Received: from mail-wi0-x22e.google.com ([2a00:1450:400c:c05::22e]) by merlin.infradead.org with esmtps (Exim 4.85 #2 (Red Hat Linux)) id 1ZYvTs-00053Z-IT for linux-arm-kernel@lists.infradead.org; Mon, 07 Sep 2015 12:25:05 +0000 Received: by wiclk2 with SMTP id lk2so87058567wic.0 for ; Mon, 07 Sep 2015 05:24:42 -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=rh7wTUJ3qSqkLVnj6wX6Phe326N/1u6SEofZRqJRh3A=; b=g3uo1Cgr+fkO9LuuR1pKJd6lJhGCrJNidpEqfBfyosnXqOqLvmzXjF5Byz1Sj3mQ5P 5O4BachDtqensRZyN2L4uOJebiUv8s1TM3SQ7MtICCoIipyd8Grr+TBi4AKVQWK9Qxem wpHs0NWcLn4bsTz9Ub9N0tH8S0zm7URFhjhhA3YsxExbBwvCQdkyZDkRlgcXLCrtiXxC jXdMWuywpye0s91BJiXa7z3f7vlFfi9f3HE2/BkGWaY8G3wBWXNbo+qjqdmKSN0W5dPK mo6khrJgWfIwz8fIxt9F/pBr9o5rch3cY3ckJtMDVGGWz1yU7DVQJfPMHANOhGOSWjNp HV5Q== X-Received: by 10.194.23.167 with SMTP id n7mr33963811wjf.112.1441628682901; Mon, 07 Sep 2015 05:24:42 -0700 (PDT) Received: from cizrna.lan ([109.72.12.78]) by smtp.gmail.com with ESMTPSA id cm6sm15438wib.22.2015.09.07.05.24.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2015 05:24:42 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [PATCH v4 20/22] driver core: Allow deferring probes until late init Date: Mon, 7 Sep 2015 14:23:45 +0200 Message-Id: <1441628627-5143-21-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1441628627-5143-1-git-send-email-tomeu.vizoso@collabora.com> References: <1441628627-5143-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150907_082504_884990_70DF37A1 X-CRM114-Status: GOOD ( 18.75 ) 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, 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 , 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 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 faf60bfc46b3..0654fb771a53 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)