Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp427587ybi; Fri, 24 May 2019 06:07:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHRuZ8aiLwietXW8Ccz2b3ZmfRnhfOCsJ5K2vidtAT+PV4AeIbw+CuIcOa4E7NJH8AZr9c X-Received: by 2002:a63:5c5f:: with SMTP id n31mr106791126pgm.325.1558703246816; Fri, 24 May 2019 06:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558703246; cv=none; d=google.com; s=arc-20160816; b=s6/NtThyyHjXj48zziBzocd5XrBru/0n/xgg49ppQjDyHV9Cx305a6SsRq2CjqMx/R AK1gizY+ZahtrW2L2Wm/O8hnuNIIboUXlNKwDPhDNSZceYkzQdnF19D9UZp02r024yyw pjGvwf3T/LGu4on0PAl5s48SL4SUvcKXhxakQk8YLLOMOKlJyTaBQ20mhjoSGUxOMRmD L3l7zzwCjKbDN4OgrcVckMIfG5gqQxssdxIkK6iMtnUQ5tgyslIJdGNwx75+IFYKxMXt RDSJ6xrJsb65ZzJiXG3dEaIdCCl6XtIxmG4rQLMoBbfGuP3m9xoqEvUIoJGJWkhspzbI xq8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=zxQxUFzcc8crw3qWPqtMYCkQS3xeW4Gr7Kvfqg+8tco=; b=lbI+LeAXdffR/IwKjp+YSehXxgRR25WYRCo7yLZiegB15E71G4HOxnFV4iyXsjiW52 z17SQZfumZM3/RAHsL44VHtiMypvdfv44o99FkBMx2Sy0BObvEXSWzanDMwHeMkI1reM BXngeADntUsaVwamFSTk+7CbJRENaj+/fydREWChmtNM5n0bOB2xG4TmdmTb4lxW/1IN Uo7AP5aos+McpB3F3IrKh6HohloV1FcAzhh3/HtzVaCQuaWaQ6kG/1L6gObfS4L1DD5P 4IvrQ4Haa568sB6QNuhpHs7sVy4lpceOGanuMmmmvm6fi0cMfG+kJlCkNxml/NLYxMOP nT+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B5GkERmE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l27si3835901pgm.172.2019.05.24.06.07.08; Fri, 24 May 2019 06:07:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B5GkERmE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391465AbfEXNEz (ORCPT + 99 others); Fri, 24 May 2019 09:04:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:57588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391193AbfEXNEz (ORCPT ); Fri, 24 May 2019 09:04:55 -0400 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 762912184E; Fri, 24 May 2019 13:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558703094; bh=l4t6CtyS8OAuOzB3K8zNqJtlqJ5eH46BJbroNn6tWdo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=B5GkERmExuEsL0nNeOynZFaOkUNEmjjvC5mPYRnQCgCbA4lWg6zPzs9Ir/UW90vI/ i7tb8OciJvD6Bl2srehW9BPgaGOOJsa1wbhPn/YRnDvmE8gfh3R4MwYv58j41IxwnB IjMj2kAKQHlpg2Xafx6ZDVO4tUGM9LnYWgn7oEko= Received: by mail-qk1-f173.google.com with SMTP id t64so7204572qkh.1; Fri, 24 May 2019 06:04:54 -0700 (PDT) X-Gm-Message-State: APjAAAWS16+CGTnerKdIVi3/0Q41b22p3gWFFAFzRZCaE1eO5BFjUIAL NuO0XDDo25QIXRuNuc966cZw2sh8DZiHwjLlAg== X-Received: by 2002:a0c:ad23:: with SMTP id u32mr46430375qvc.39.1558703093679; Fri, 24 May 2019 06:04:53 -0700 (PDT) MIME-Version: 1.0 References: <20190524010117.225219-1-saravanak@google.com> In-Reply-To: <20190524010117.225219-1-saravanak@google.com> From: Rob Herring Date: Fri, 24 May 2019 08:04:41 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 0/5] Solve postboot supplier cleanup and optimize probe ordering To: Saravana Kannan Cc: Mark Rutland , Greg Kroah-Hartman , "Rafael J. Wysocki" , Frank Rowand , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" , Android Kernel Team Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 23, 2019 at 8:01 PM Saravana Kannan wrote: > > Add a generic "depends-on" property that allows specifying mandatory > functional dependencies between devices. Add device-links after the > devices are created (but before they are probed) by looking at this > "depends-on" property. The DT already has dependency information. A node with 'clocks' property has its dependency right there. We should use that. We don't need to duplicate the information. > This property is used instead of existing DT properties that specify > phandles of other devices (Eg: clocks, pinctrl, regulators, etc). This > is because not all resources referred to by existing DT properties are > mandatory functional dependencies. Some devices/drivers might be able > to operate with reduced functionality when some of the resources > aren't available. For example, a device could operate in polling mode > if no IRQ is available, a device could skip doing power management if > clock or voltage control isn't available and they are left on, etc. Yeah, but none of these examples are typically what you'd want to happen. These cases are a property of the OS, not the DT. For example, until recently, If you added pinctrl bindings to your DT, the kernel would no longer boot because it would be looking for pinctrl driver. That's wrong because the DT should not be coupled to the OS like that. Adding this property will cause the same problem. > So, adding mandatory functional dependency links between devices by > looking at referred phandles in DT properties won't work as it would > prevent probing devices that could be probed. By having an explicit > depends-on property, we can handle these cases correctly. > > Having functional dependencies explicitly called out in DT and > automatically added before the devices are probed, provides the > following benefits: > > - Optimizes device probe order and avoids the useless work of > attempting probes of devices that will not probe successfully > (because their suppliers aren't present or haven't probed yet). > > For example, in a commonly available mobile SoC, registering just > one consumer device's driver at an initcall level earlier than the > supplier device's driver causes 11 failed probe attempts before the > consumer device probes successfully. This was with a kernel with all > the drivers statically compiled in. This problem gets a lot worse if > all the drivers are loaded as modules without direct symbol > dependencies. Do you have data on how much time is spent. Past 'smarter probing' attempts have not shown a significant difference. > - Supplier devices like clock providers, regulators providers, etc > need to keep the resources they provide active and at a particular > state(s) during boot up even if their current set of consumers don't > request the resource to be active. This is because the rest of the > consumers might not have probed yet and turning off the resource > before all the consumers have probed could lead to a hang or > undesired user experience. We already know generally what devices are dependencies because you just listed them. Why don't we make the kernel smarter by instantiating these core devices/drivers first instead of relying on initcall and link order. > Some frameworks (Eg: regulator) handle this today by turning off > "unused" resources at late_initcall_sync and hoping all the devices > have probed by then. This is not a valid assumption for systems with > loadable modules. Other frameworks (Eg: clock) just don't handle > this due to the lack of a clear signal for when they can turn off > resources. This leads to downstream hacks to handle cases like this > that can easily be solved in the upstream kernel. IMO, we should get rid of this auto disabling. Rob