From patchwork Wed Jul 1 09:40:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6702081 Return-Path: X-Original-To: patchwork-alsa-devel@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 E543A9F2F0 for ; Wed, 1 Jul 2015 09:43:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 08F3E203AC for ; Wed, 1 Jul 2015 09:43:22 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C0530203F3 for ; Wed, 1 Jul 2015 09:43:20 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4BBEA2606FC; Wed, 1 Jul 2015 11:43:19 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, NO_DNS_FOR_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id A884C260651; Wed, 1 Jul 2015 11:42:45 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1C151260651; Wed, 1 Jul 2015 11:42:43 +0200 (CEST) Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com [74.125.82.45]) by alsa0.perex.cz (Postfix) with ESMTP id 5C599260616 for ; Wed, 1 Jul 2015 11:42:30 +0200 (CEST) Received: by wgck11 with SMTP id k11so31762707wgc.0 for ; Wed, 01 Jul 2015 02:42:30 -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=fuEiLp4OtZtHx61zRbQokVNWWrvpSieoPloKnuxrc+8=; b=MW8CEMxc/ZGF/xzQhPk20/KUyglWmU+NNER2un9m1+5Zygux3Eg4rZCtJGLRL2Y90T pdtCpHabQv1shx9TQgm4AQMA0lxBUY7do4hUHMXfol33C8hW77gw2hyUDMwjwKLvwH8c QT8HdEN9AFG5/VdSEYAULfP02oTnpGRHKJGaMdG6egpjCJ6EOrp8qcEO56C1E9NFtW32 QX9Z/MVTVYqQUPBR5e2oQmNyCpAhsWQeL1AZJH8qVa1q9E4dc8S6EbmFtdIcSxJrgv3g K5v3G7xM5TcDPAxVlcAeV8rv67eG8Q5xiJ7yUgeob4mymDAgN6ml8Z2snYK1hFFv3vDk Z7/g== X-Received: by 10.180.9.6 with SMTP id v6mr42749140wia.83.1435743750162; Wed, 01 Jul 2015 02:42:30 -0700 (PDT) Received: from cizrna.lan ([109.72.12.160]) by mx.google.com with ESMTPSA id x10sm1992663wjr.25.2015.07.01.02.42.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jul 2015 02:42:28 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Date: Wed, 1 Jul 2015 11:40:56 +0200 Message-Id: <1435743667-11987-2-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.1 In-Reply-To: <1435743667-11987-1-git-send-email-tomeu.vizoso@collabora.com> References: <1435743667-11987-1-git-send-email-tomeu.vizoso@collabora.com> Cc: devicetree@vger.kernel.org, linux-fbdev@vger.kernel.org, Tomeu Vizoso , linux-gpio@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , alsa-devel@alsa-project.org, dri-devel@lists.freedesktop.org, linux-acpi@vger.kernel.org, Mark Brown , linux-pwm@vger.kernel.org Subject: [alsa-devel] [PATCH v2 01/12] device: property: delay device-driver matches X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Delay matches of platform devices until late_initcall, when we are sure that all built-in drivers have been registered already. This is needed to prevent deferred probes because of some dependencies' drivers not having registered yet. This reduces the total amount of work that the kernel does during boot because it won't try to match devices to drivers when built-in drivers are still registering but also reduces some parallelism, so total boot time might slightly increase or decrease depending on the platform and kernel configuration. This change will make make possible to prevent any deferred probes once devices are probed in dependency order. Signed-off-by: Tomeu Vizoso --- Changes in v2: - Instead of delaying all probes until late_initcall, only delay matches of platform devices that have a firmware node attached. drivers/base/property.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 8528eb9..8ead1ba 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -16,8 +16,11 @@ #include #include #include +#include #include +static bool fwnode_match_enable = false; + /** * device_add_property_set - Add a collection of properties to a device object. * @dev: Device to add properties to. @@ -604,6 +607,15 @@ EXPORT_SYMBOL_GPL(fwnode_is_compatible); bool fwnode_driver_match_device(struct device *dev, const struct device_driver *drv) { + /* + * Delay matches of platform devices until late_initcall, when we are + * sure that all built-in drivers have been registered already. This + * is needed to prevent deferred probes because of some drivers + * not having registered yet. + */ + if(dev->bus == &platform_bus_type && !fwnode_match_enable) + return false; + if (is_of_node(dev->fwnode)) return of_driver_match_device(dev, drv); else if (is_acpi_node(dev->fwnode)) @@ -612,3 +624,20 @@ bool fwnode_driver_match_device(struct device *dev, return false; } EXPORT_SYMBOL_GPL(fwnode_driver_match_device); + +static int __device_attach(struct device *dev, void *data) +{ + device_initial_probe(dev); + + return 0; +} + +static int fwnode_match_initcall(void) +{ + fwnode_match_enable = true; + + bus_for_each_dev(&platform_bus_type, NULL, NULL, __device_attach); + + return 0; +} +late_initcall(fwnode_match_initcall);