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: 6701991 Return-Path: X-Original-To: patchwork-linux-fbdev@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 96F1D9F2F0 for ; Wed, 1 Jul 2015 09:42:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B79922062A for ; Wed, 1 Jul 2015 09:42:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C53CA20670 for ; Wed, 1 Jul 2015 09:42:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753816AbbGAJmr (ORCPT ); Wed, 1 Jul 2015 05:42:47 -0400 Received: from mail-wg0-f47.google.com ([74.125.82.47]:36539 "EHLO mail-wg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751170AbbGAJmc (ORCPT ); Wed, 1 Jul 2015 05:42:32 -0400 Received: by wguu7 with SMTP id u7so31657647wgu.3; 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 Cc: Mark Brown , linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-pwm@vger.kernel.org, "Rafael J. Wysocki" , alsa-devel@alsa-project.org, Tomeu Vizoso , Greg Kroah-Hartman 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> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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);