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: 6701901 Return-Path: X-Original-To: patchwork-dri-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 B63749F2F0 for ; Wed, 1 Jul 2015 09:42:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5B7A82066E for ; Wed, 1 Jul 2015 09:42:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 250DD2062A for ; Wed, 1 Jul 2015 09:42:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D0FD36EA7C; Wed, 1 Jul 2015 02:42:32 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) by gabe.freedesktop.org (Postfix) with ESMTPS id 75BF36EA7C for ; Wed, 1 Jul 2015 02:42:31 -0700 (PDT) Received: by wiwl6 with SMTP id l6so159008504wiw.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 Subject: [PATCH v2 01/12] device: property: delay device-driver matches 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.7 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 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);