Message ID | 20240212213147.489377-4-saravanak@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-62395-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp179067dyb; Mon, 12 Feb 2024 13:33:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAOl6omG7v6tLIotfyIehrh6MS8hj5wU35zH+Pn+cQLxmEobscR/4aHZnniqjlOABGyqVG X-Received: by 2002:aa7:d5c7:0:b0:560:cc04:a96c with SMTP id d7-20020aa7d5c7000000b00560cc04a96cmr5335054eds.24.1707773586857; Mon, 12 Feb 2024 13:33:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707773586; cv=pass; d=google.com; s=arc-20160816; b=C3lQlywdZ9/YO/HHYIojLft72gNhBfjO+e1pJjGKn+WLxUiaL/B8+VN6WCbEmmkxdP kxXsGrjAsTkGg7OVaPYtwLXXbgRFL7nAUyRJAoQHvlsqpXUNPBxAP98SocIXgNYI5tpG 2qORHVT5oul8/KYV8f1VFy44ffONHQSPVWobm1GSuaRl2KbgtpTFKZX3lRquJvafyCA5 FOP/20Dwv3h32PMrEaPuHOYIMgPLaJ01SsFWgwIB7CfJN51tjJwZbQROn2utNTqMlSzC VYs3+3zgZjV7vQ0bJJUGJwWM/oMrO+vgZZ/YVAGvEj9QDF10AG6PGyhNgci+aWRO0/BN Nt+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=JQ35JcQOD8sngOY/PRE6LAzcrcvofp80cB9j/4A7v3U=; fh=WBmxevHKVfsPQuXFplKO+K68PMRXlS2KMEZL2uCCaAE=; b=NXkX+80ZWtGBmiANCB0MjhKhHWKJH1e1S7Mc+s8HOliXWJv7Z4mac8mtmCsKtSyPRu PGPjXQ14n9/4n2lsb+9z46LWRcowcixBZ8pvbkvO/fz2M5vA004PLGN1Zd7CPk00cgQi tjV+B0JbhN0D8NkKkh3+6UieLae/evFDW8MVphQfjqYEFA10jglJCDnYbvsaYpAnZIf7 LONAYRRDWecmU5nwIadQf2z6EjUMR28I4c/OM4W5APxf2kSKJJ0OR0ZgMfluuDrxeY4o WtRxq0bXA31tK1z441KXBIhxR7B8XTbR0njnFLyF6vMk4/rvSVxRJCN6MUs7LwoTAbwD uLXQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=K7SzWMdv; arc=pass (i=1 spf=pass spfdomain=flex--saravanak.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-62395-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62395-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCVsGw18lN45jPmH/UGzaNo2YoX2WpMS8qM4R+lIaiOOvwMf/1Jslz48+NsxLtaZAgKaG73+U8nPZz8mjiFIfuC/m02TUQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 21-20020a508755000000b00561baac1ba4si1246529edv.316.2024.02.12.13.33.06 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 13:33:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62395-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=K7SzWMdv; arc=pass (i=1 spf=pass spfdomain=flex--saravanak.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-62395-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62395-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 47B0B1F22941 for <ouuuleilei@gmail.com>; Mon, 12 Feb 2024 21:33:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 820784CE1B; Mon, 12 Feb 2024 21:32:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="K7SzWMdv" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 241634DA0E for <linux-kernel@vger.kernel.org>; Mon, 12 Feb 2024 21:32:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707773523; cv=none; b=CBn7Yxg/3e17jIb0GgQgUppZrNUtz8xE+xN9wqRUv3EBsMheVa9eEb+H3n1mXxSSE+y4o0MEjSuRsAdi8NqW9Z1nwB2qn99NmBM7AySNV/4KUcMxYv3RX85nBLf8icKBBBY10Dgur1C3aiUk0n6Ja1q6dT4cDkf79dKXa2wC0fM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707773523; c=relaxed/simple; bh=dessp0Y0iydAOQinVxc9bvgHWYMKmwFPgKm6nVqH9Cs=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=pHtHV3YG8967klfGvXNc2l/OomfIfrd93vQyzyWMn9lrCCJmuOlds2V0quQ+8vhd6zgdPOjKmoDjybmtqKeuscxsKBLcsdhx4d3HEB/+KF0afYE+LvEIt7en4L5eTwGsPFVGVyO9bYPU9Pvc91h/JtM3g3eIzxNaC4CpAfciP/4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--saravanak.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=K7SzWMdv; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--saravanak.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dbf216080f5so5709810276.1 for <linux-kernel@vger.kernel.org>; Mon, 12 Feb 2024 13:32:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707773521; x=1708378321; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=JQ35JcQOD8sngOY/PRE6LAzcrcvofp80cB9j/4A7v3U=; b=K7SzWMdvmea3hjbDgaKsjraad4vgI0rdi715XseSAT2erL0qicZ+OJQbMwTxgTW8IA 3JVBEOyTlCqlKTiZHu8uuXGEU/cV/e9e2nVpRIRhrpIHWVnn5W+NQIgKrtJc9mITwzVO FBZU5IoogTq2BMhQTG52HG5W0IMS4+zGrCe4vzcm2kaNwVRUFxvJJxJKh2LRahtyqgSe 4dNIb0eULHWrrWPVz1PgnoTrkJ71wAw4dAPviyCzJFuw/AzBDWRQeCQyKyKD3X8o/PvR sYJLPDW7F8Mv4e30ejWAxObfa0eKPJ9wcuZ+1DGHFT455OCyXsXQbL+aIN6XJK1z5J9d 3x+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707773521; x=1708378321; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JQ35JcQOD8sngOY/PRE6LAzcrcvofp80cB9j/4A7v3U=; b=YqOzwImrs3EU5sgcv+zglOV7JXZJ76Yihxpp9pOzV2ytvZpiBnH1V6Zr2Z8DEELDFx 1fJW/VFqGfbpxHCIiEr697/txDjIJe8V32FP9uD1KgmlVQSzQGaDnUK6aLeXqV58+jNp +hrzpZzRqzgP/tQSmDLrFLPPhtL3p9GM4MCmLvHDpJ4dJuUiehVg4wH/GMED4lZSKMZ2 EE+/s17DLI3dVbVRh90urjOk9mSrsWpIlC6AmkmEyTG+TxDa3nPvR4VRdUB1+1cZwPOF jAxNAJu2U6pyDMRtLsHp5cPZxaoO3MR+GpFcLwWNs6Sye3HU3tj3nu5Ly5KkWfDhT+C9 sUVA== X-Gm-Message-State: AOJu0Yy3bAJElww7Q6IhsxXfVHulM5vV5iW9ACnxt5/rPZvjp//JUPK/ NeeS54DXIM3x4Zz20iztaWAD4yo6zvwXjZELQo0DNMzyOhq1I6Mht8CH8eyV+rVlHfGbYO3PNhp WLfB0a0wTxTET2A== X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:496d:5de1:a404:8bee]) (user=saravanak job=sendgmr) by 2002:a25:6910:0:b0:dc2:398d:a671 with SMTP id e16-20020a256910000000b00dc2398da671mr2027894ybc.10.1707773521205; Mon, 12 Feb 2024 13:32:01 -0800 (PST) Date: Mon, 12 Feb 2024 13:31:44 -0800 In-Reply-To: <20240212213147.489377-1-saravanak@google.com> Message-Id: <20240212213147.489377-4-saravanak@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> Mime-Version: 1.0 References: <20240212213147.489377-1-saravanak@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Subject: [PATCH v2 3/4] dt-bindings: Add post-init-supplier property From: Saravana Kannan <saravanak@google.com> To: Saravana Kannan <saravanak@google.com>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Rafael J. Wysocki" <rafael@kernel.org>, Ard Biesheuvel <ardb@kernel.org>, Frank Rowand <frowand.list@gmail.com>, Len Brown <lenb@kernel.org>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Daniel Scally <djrscally@gmail.com>, Heikki Krogerus <heikki.krogerus@linux.intel.com>, Sakari Ailus <sakari.ailus@linux.intel.com> Cc: kernel-team@android.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-efi@vger.kernel.org, linux-acpi@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790730396380416831 X-GMAIL-MSGID: 1790730396380416831 |
Series |
Add post-init-supplier binding to improve suspend/resume stability
|
|
Commit Message
Saravana Kannan
Feb. 12, 2024, 9:31 p.m. UTC
The post-init-supplier property can be used to break a dependency cycle by
marking some supplier(s) as a post device initialization supplier(s). This
allows an OS to do a better job at ordering initialization and
suspend/resume of the devices in a dependency cycle.
Signed-off-by: Saravana Kannan <saravanak@google.com>
---
.../bindings/post-init-supplier.yaml | 101 ++++++++++++++++++
MAINTAINERS | 13 +--
2 files changed, 108 insertions(+), 6 deletions(-)
create mode 100644 Documentation/devicetree/bindings/post-init-supplier.yaml
Comments
On Mon, 12 Feb 2024 13:31:44 -0800, Saravana Kannan wrote: > The post-init-supplier property can be used to break a dependency cycle by > marking some supplier(s) as a post device initialization supplier(s). This > allows an OS to do a better job at ordering initialization and > suspend/resume of the devices in a dependency cycle. > > Signed-off-by: Saravana Kannan <saravanak@google.com> > --- > .../bindings/post-init-supplier.yaml | 101 ++++++++++++++++++ > MAINTAINERS | 13 +-- > 2 files changed, 108 insertions(+), 6 deletions(-) > create mode 100644 Documentation/devicetree/bindings/post-init-supplier.yaml > My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13): yamllint warnings/errors: /Documentation/devicetree/bindings/post-init-supplier.yaml:84:12: [error] syntax error: mapping values are not allowed here (syntax) dtschema/dtc warnings/errors: make[2]: *** Deleting file 'Documentation/devicetree/bindings/post-init-supplier.example.dts' Documentation/devicetree/bindings/post-init-supplier.yaml:84:12: mapping values are not allowed in this context make[2]: *** [Documentation/devicetree/bindings/Makefile:26: Documentation/devicetree/bindings/post-init-supplier.example.dts] Error 1 make[2]: *** Waiting for unfinished jobs.... /Documentation/devicetree/bindings/post-init-supplier.yaml:84:12: mapping values are not allowed in this context /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/post-init-supplier.yaml: ignoring, error parsing file make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1428: dt_binding_check] Error 2 make: *** [Makefile:240: __sub-make] Error 2 doc reference errors (make refcheckdocs): See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20240212213147.489377-4-saravanak@google.com The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch. If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date: pip3 install dtschema --upgrade Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
On Mon, Feb 12, 2024 at 01:31:44PM -0800, Saravana Kannan wrote: > The post-init-supplier property can be used to break a dependency cycle by > marking some supplier(s) as a post device initialization supplier(s). This > allows an OS to do a better job at ordering initialization and > suspend/resume of the devices in a dependency cycle. > > Signed-off-by: Saravana Kannan <saravanak@google.com> > --- > .../bindings/post-init-supplier.yaml | 101 ++++++++++++++++++ > MAINTAINERS | 13 +-- > 2 files changed, 108 insertions(+), 6 deletions(-) > create mode 100644 Documentation/devicetree/bindings/post-init-supplier.yaml > > diff --git a/Documentation/devicetree/bindings/post-init-supplier.yaml b/Documentation/devicetree/bindings/post-init-supplier.yaml > new file mode 100644 > index 000000000000..aab75b667259 > --- /dev/null > +++ b/Documentation/devicetree/bindings/post-init-supplier.yaml > @@ -0,0 +1,101 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +# Copyright (c) 2020, Google LLC. All rights reserved. > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/post-init-supplier.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Post device initialization supplier > + > +maintainers: > + - Saravana Kannan <saravanak@google.com> > + > +description: | > + This property is used to indicate that the device(s) pointed to by the > + property are not needed for the initialization of the device that lists this > + property. > This property is meaningful only when pointing to direct suppliers > + of a device that are pointed to by other properties in the device. I don't think this sentence makes sense, or at least it is not easy to parse. It implies that it can "point to" other properties too - but that's not the case. It is only valid to "point to" these suppliers. I'd drop this entirely. > + > + A device can list its suppliers in devicetree using one or more of the > + standard devicetree bindings. By default, it would be safe to assume the > + supplier device can be initialized before the consumer device is initialized. "it would be safe to assume" seems odd wording to me - I feel like the default is stronger than "safe to assume". I'd just drop the "would be safe to assume and replace with "is assumed". > + > + However, that assumption cannot be made when there are cyclic dependencies > + between devices. Since each device is a supplier (directly or indirectly) of > + the others in the cycle, there is no guaranteed safe order for initializing > + the devices in a cycle. We can try to initialize them in an arbitrary order > + and eventually successfully initialize all of them, but that doesn't always > + work well. > + > + For example, say, > + * The device tree has the following cyclic dependency X -> Y -> Z -> X (where > + -> denotes "depends on"). > + * But X is not needed to fully initialize Z (X might be needed only when a > + specific functionality is requested post initialization). > + > + If all the other -> are mandatory initialization dependencies, then trying to > + initialize the devices in a loop (or arbitrarily) will always eventually end > + up with the devices being initialized in the order Z, Y and X. > + > + However, if Y is an optional supplier for X (where X provides limited > + functionality when Y is not initialized and providing its services), then > + trying to initialize the devices in a loop (or arbitrarily) could end up with > + the devices being initialized in the following order: > + > + * Z, Y and X - All devices provide full functionality > + * Z, X and Y - X provides partial functionality > + * X, Z and Y - X provides partial functionality > + > + However, we always want to initialize the devices in the order Z, Y and X > + since that provides the full functionality without interruptions. > + > + One alternate option that might be suggested is to have the driver for X > + notice that Y became available at a later point and adjust the functionality > + it provides. However, other userspace applications could have started using X > + with the limited functionality before Y was available and it might not be > + possible to transparently transition X or the users of X to full > + functionality while X is in use. > + > + Similarly, when it comes to suspend (resume) ordering, it's unclear which > + device in a dependency cycle needs to be suspended/resumed first and trying > + arbitrary orders can result in system crashes or instability. > + > + Explicitly calling out which link in a cycle needs to be broken when > + determining the order, simplifies things a lot, improves efficiency, makes > + the behavior more deterministic and maximizes the functionality that can be > + provided without interruption. > + > + This property is used to provide this additional information between devices > + in a cycle by telling which supplier(s) is not needed for initializing the > + device that lists this property. > + > + In the example above, Z would list X as a post-init-supplier and the > + initialization dependency would become X -> Y -> Z -/-> X. So the best order > + to initialize them become clear: Z, Y and then X. Otherwise, I think this is a great description, describing the use case well :) > + > +select: true > +properties: > + post-init-supplier: > + # One or more suppliers can be marked as post initialization supplier > + description: > + List of phandles to suppliers that are not needed for initializing or > + resuming this device. > + $ref: /schemas/types.yaml#/definitions/phandle-array > + items: > + maxItems: 1 Rob's bot rightfully complains here about invalid syntax. What you actually want to enforce here is any number of device phandles, but these phandles all contain only the label and no indices etc, right? > + > +examples: > + - | > + gcc: clock-controller@1000 { > + compatible = "vendor,soc4-gcc", "vendor,soc1-gcc"; > + reg = <0x1000 0x80>; > + clocks = <&dispcc 0x1> This clearly was never tested, Rob's bot warnings aside. You're missing a ; at EOL here and with the other clock below. Cheers, Conor. > + #clock-cells = <1>; > + post-init-supplier = <&dispcc>; > + }; > + dispcc: clock-controller@2000 { > + compatible = "vendor,soc4-dispcc", "vendor,soc1-dispcc"; > + reg = <0x2000 0x80>; > + clocks = <&gcc 0xdd> > + #clock-cells = <1>; > + };
On Wed, Feb 14, 2024 at 06:48:59PM +0000, Conor Dooley wrote: > > + post-init-supplier: > > + # One or more suppliers can be marked as post initialization supplier Also, this should likely be pluralised, to match "clocks" "resets" "interrupts" etc. > > + description: > > + List of phandles to suppliers that are not needed for initializing or > > + resuming this device. > > + $ref: /schemas/types.yaml#/definitions/phandle-array > > + items: > > + maxItems: 1
On Wed, Feb 14, 2024 at 03:32:31PM -0800, Saravana Kannan wrote: > Hi Conon, > > On Wed, Feb 14, 2024 at 10:49 AM Conor Dooley <conor@kernel.org> wrote: > > > > On Mon, Feb 12, 2024 at 01:31:44PM -0800, Saravana Kannan wrote: > > > The post-init-supplier property can be used to break a dependency cycle by > > > marking some supplier(s) as a post device initialization supplier(s). This > > > allows an OS to do a better job at ordering initialization and > > > suspend/resume of the devices in a dependency cycle. > > > > > > Signed-off-by: Saravana Kannan <saravanak@google.com> > > > --- > > > .../bindings/post-init-supplier.yaml | 101 ++++++++++++++++++ > > > MAINTAINERS | 13 +-- > > > 2 files changed, 108 insertions(+), 6 deletions(-) > > > create mode 100644 Documentation/devicetree/bindings/post-init-supplier.yaml > > > > > > diff --git a/Documentation/devicetree/bindings/post-init-supplier.yaml b/Documentation/devicetree/bindings/post-init-supplier.yaml > > > new file mode 100644 > > > index 000000000000..aab75b667259 > > > --- /dev/null > > > +++ b/Documentation/devicetree/bindings/post-init-supplier.yaml > > > @@ -0,0 +1,101 @@ > > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > > > +# Copyright (c) 2020, Google LLC. All rights reserved. > > > +%YAML 1.2 > > > +--- > > > +$id: http://devicetree.org/schemas/post-init-supplier.yaml# > > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > > + > > > +title: Post device initialization supplier > > > + > > > +maintainers: > > > + - Saravana Kannan <saravanak@google.com> > > > + > > > +description: | > > > + This property is used to indicate that the device(s) pointed to by the > > > + property are not needed for the initialization of the device that lists this > > > + property. > > > > > This property is meaningful only when pointing to direct suppliers > > > + of a device that are pointed to by other properties in the device. > > > > I don't think this sentence makes sense, or at least it is not easy to > > parse. It implies that it can "point to" other properties too > > I don't see how this sentence implies this. Because, to me, it reads as if you can put extra stuff in here that will be ignored if not "pointed to" by another property. The word "meaningful" is what implies that you can. > But open to suggestions on > how to reword it. I don't want to drop this line entirely though > because I'm trying to make it clear that this doesn't make a device > (that's not previously a supplier) into a supplier. It only down > grades an existing supplier to a post device initialization supplier. If you wanna keep it, I would just go for what you said in this response - that this property does not make devices into suppliers and is only to mark existing suppliers as post-init. I think that rules out putting other devices in there. > > - but > > that's not the case. It is only valid to "point to" these suppliers. > > I'd drop this entirely. > > > > > > + > > > + A device can list its suppliers in devicetree using one or more of the > > > + standard devicetree bindings. By default, it would be safe to assume the > > > + supplier device can be initialized before the consumer device is initialized. > > > > "it would be safe to assume" seems odd wording to me - I feel like the > > default is stronger than "safe to assume". I'd just drop the "would be > > safe to assume and replace with "is assumed". > > Sounds good. > > > > > > + > > > + However, that assumption cannot be made when there are cyclic dependencies > > > + between devices. Since each device is a supplier (directly or indirectly) of > > > + the others in the cycle, there is no guaranteed safe order for initializing > > > + the devices in a cycle. We can try to initialize them in an arbitrary order > > > + and eventually successfully initialize all of them, but that doesn't always > > > + work well. > > > + > > > + For example, say, > > > + * The device tree has the following cyclic dependency X -> Y -> Z -> X (where > > > + -> denotes "depends on"). > > > + * But X is not needed to fully initialize Z (X might be needed only when a > > > + specific functionality is requested post initialization). > > > + > > > + If all the other -> are mandatory initialization dependencies, then trying to > > > + initialize the devices in a loop (or arbitrarily) will always eventually end > > > + up with the devices being initialized in the order Z, Y and X. > > > + > > > + However, if Y is an optional supplier for X (where X provides limited > > > + functionality when Y is not initialized and providing its services), then > > > + trying to initialize the devices in a loop (or arbitrarily) could end up with > > > + the devices being initialized in the following order: > > > + > > > + * Z, Y and X - All devices provide full functionality > > > + * Z, X and Y - X provides partial functionality > > > + * X, Z and Y - X provides partial functionality > > > + > > > + However, we always want to initialize the devices in the order Z, Y and X > > > + since that provides the full functionality without interruptions. > > > + > > > + One alternate option that might be suggested is to have the driver for X > > > + notice that Y became available at a later point and adjust the functionality > > > + it provides. However, other userspace applications could have started using X > > > + with the limited functionality before Y was available and it might not be > > > + possible to transparently transition X or the users of X to full > > > + functionality while X is in use. > > > + > > > + Similarly, when it comes to suspend (resume) ordering, it's unclear which > > > + device in a dependency cycle needs to be suspended/resumed first and trying > > > + arbitrary orders can result in system crashes or instability. > > > + > > > + Explicitly calling out which link in a cycle needs to be broken when > > > + determining the order, simplifies things a lot, improves efficiency, makes > > > + the behavior more deterministic and maximizes the functionality that can be > > > + provided without interruption. > > > + > > > + This property is used to provide this additional information between devices > > > + in a cycle by telling which supplier(s) is not needed for initializing the > > > + device that lists this property. > > > + > > > + In the example above, Z would list X as a post-init-supplier and the > > > + initialization dependency would become X -> Y -> Z -/-> X. So the best order > > > + to initialize them become clear: Z, Y and then X. > > > > Otherwise, I think this is a great description, describing the use case > > well :) > > Thanks! I always spend more time writing documentation and commit text > than the time I spend writing code. > > > > > > + > > > +select: true > > > +properties: > > > + post-init-supplier: > > [Merging your other email here] > > > Also, this should likely be pluralised, to match "clocks" "resets" > > "interrupts" etc. > > Good point. Done. > > > > + # One or more suppliers can be marked as post initialization supplier > > > + description: > > > + List of phandles to suppliers that are not needed for initializing or > > > + resuming this device. > > > + $ref: /schemas/types.yaml#/definitions/phandle-array > > > + items: > > > + maxItems: 1 > > > > Rob's bot rightfully complains here about invalid syntax. > > I added these two lines based on Rob's feedback. Is the indentation > that's wrong? Aye, both items: and maxItems: need to lose a level of indent. That said, its not actually restricting anything. I fixed it up locally and you can put as many elements as you like into each phandle and it does not care. Maybe Rob can tell what is going wrong there.. > > Yeah, I'm trying to run the dts checker, but I haven't be able to get > it to work on my end. See my email to Rob on the v1 series about this. > > $ make DT_CHECKER_FLAGS=-m dt_binding_check > > The best I could get out of it is a bunch of error reports on other > files and then: > ... > <snip>/Documentation/devicetree/bindings/post-init-suppliers.yaml: > ignoring, error parsing file > ... Yup, that is about right, although you snipped out the actual complaint. > > I also tried to use DT_SCHEMA_FILES so I can only test this one file, > but that wasn't working either: > > $ make DT_CHECKER_FLAGS=-m dt_binding_check > DT_SCHEMA_FILES=Documentation/devicetree/bindings/post-init-suppliers.yaml > or > $ make DT_CHECKER_FLAGS=-m dt_binding_check DT_SCHEMA_FILES=<path to > the .patch file> > > Results in this error early on in the output: > ... > usage: yamllint [-h] [-] [-c CONFIG_FILE | -d CONFIG_DATA] > [--list-files] [-f {parsable,standard,colored,github,auto}] [-s] > [--no-warnings] [-v] [FILE_OR_DIR ...] > yamllint: error: one of the arguments FILE_OR_DIR - is required > ... > /mnt/android/linus-tree/Documentation/devicetree/bindings/post-init-suppliers.yaml: > ignoring, error parsing file > ... That is part of the actual complaint: make dt_binding_check W=1 -j 30 DT_SCHEMA_FILES=post-init-supplier.yaml LINT Documentation/devicetree/bindings DTEX Documentation/devicetree/bindings/post-init-supplier.example.dts Documentation/devicetree/bindings/post-init-supplier.yaml:84:12: mapping values are not allowed here make[2]: *** [Documentation/devicetree/bindings/Makefile:26: Documentation/devicetree/bindings/post-init-supplier.example.dts] Error 1 make[2]: *** Deleting file 'Documentation/devicetree/bindings/post-init-supplier.example.dts' make[2]: *** Waiting for unfinished jobs.... ./Documentation/devicetree/bindings/post-init-supplier.yaml:84:12: [error] syntax error: mapping values are not allowed here (syntax) CHKDT Documentation/devicetree/bindings/processed-schema.json ./Documentation/devicetree/bindings/post-init-supplier.yaml:84:12: mapping values are not allowed here SCHEMA Documentation/devicetree/bindings/processed-schema.json /stuff/linux-dt/Documentation/devicetree/bindings/post-init-supplier.yaml: ignoring, error parsing file make[1]: *** [/stuff/linux-dt/Makefile:1432: dt_binding_check] Error 2 make: *** [Makefile:240: __sub-make] Error 2
On 21/02/2024 05:07, Saravana Kannan wrote: >> >> https://www.linaro.org/blog/tips-and-tricks-for-validating-devicetree-sources-with-the-devicetree-schema/ >> >> I assume you develop on some older trees, because both next and v6.8-rc1 >> work... or standard issues: old dtschema, old yamllint. >> >> I am afraid you do it for some old Android kernel... :( > > No, I always develop on Linus's tree and test it on an android kernel > that's behind Linus's tree by a month or so. > > My yamllint version is 1.32.0, but until 2 weeks ago the latest > yamllint version was 1.33.0. > > And dt-schema is 2022.08.2-5 and I had to revert this from Linus's > tree to get it to work: > b32dcf23a03e dt-bindings: Drop kernel copy of common reserved-memory bindings > > Unfortunately, AFAIK, I don't have permissions to change the package > repo, so can't really install a newer version. pip packages are by default per user, so why you cannot install updated dtschema? Best regards, Krzysztof
On Mon, Feb 12, 2024 at 01:31:44PM -0800, Saravana Kannan wrote: > The post-init-supplier property can be used to break a dependency cycle by > marking some supplier(s) as a post device initialization supplier(s). This > allows an OS to do a better job at ordering initialization and > suspend/resume of the devices in a dependency cycle. > > Signed-off-by: Saravana Kannan <saravanak@google.com> > --- > .../bindings/post-init-supplier.yaml | 101 ++++++++++++++++++ > MAINTAINERS | 13 +-- > 2 files changed, 108 insertions(+), 6 deletions(-) > create mode 100644 Documentation/devicetree/bindings/post-init-supplier.yaml > > diff --git a/Documentation/devicetree/bindings/post-init-supplier.yaml b/Documentation/devicetree/bindings/post-init-supplier.yaml > new file mode 100644 > index 000000000000..aab75b667259 > --- /dev/null > +++ b/Documentation/devicetree/bindings/post-init-supplier.yaml > @@ -0,0 +1,101 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +# Copyright (c) 2020, Google LLC. All rights reserved. > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/post-init-supplier.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Post device initialization supplier > + > +maintainers: > + - Saravana Kannan <saravanak@google.com> > + > +description: | > + This property is used to indicate that the device(s) pointed to by the > + property are not needed for the initialization of the device that lists this > + property. This property is meaningful only when pointing to direct suppliers > + of a device that are pointed to by other properties in the device. > + > + A device can list its suppliers in devicetree using one or more of the > + standard devicetree bindings. By default, it would be safe to assume the > + supplier device can be initialized before the consumer device is initialized. > + > + However, that assumption cannot be made when there are cyclic dependencies > + between devices. Since each device is a supplier (directly or indirectly) of > + the others in the cycle, there is no guaranteed safe order for initializing > + the devices in a cycle. We can try to initialize them in an arbitrary order > + and eventually successfully initialize all of them, but that doesn't always > + work well. > + > + For example, say, > + * The device tree has the following cyclic dependency X -> Y -> Z -> X (where > + -> denotes "depends on"). > + * But X is not needed to fully initialize Z (X might be needed only when a > + specific functionality is requested post initialization). > + > + If all the other -> are mandatory initialization dependencies, then trying to > + initialize the devices in a loop (or arbitrarily) will always eventually end > + up with the devices being initialized in the order Z, Y and X. > + > + However, if Y is an optional supplier for X (where X provides limited > + functionality when Y is not initialized and providing its services), then > + trying to initialize the devices in a loop (or arbitrarily) could end up with > + the devices being initialized in the following order: > + > + * Z, Y and X - All devices provide full functionality > + * Z, X and Y - X provides partial functionality > + * X, Z and Y - X provides partial functionality > + > + However, we always want to initialize the devices in the order Z, Y and X > + since that provides the full functionality without interruptions. > + > + One alternate option that might be suggested is to have the driver for X > + notice that Y became available at a later point and adjust the functionality > + it provides. However, other userspace applications could have started using X > + with the limited functionality before Y was available and it might not be > + possible to transparently transition X or the users of X to full > + functionality while X is in use. > + > + Similarly, when it comes to suspend (resume) ordering, it's unclear which > + device in a dependency cycle needs to be suspended/resumed first and trying > + arbitrary orders can result in system crashes or instability. > + > + Explicitly calling out which link in a cycle needs to be broken when > + determining the order, simplifies things a lot, improves efficiency, makes > + the behavior more deterministic and maximizes the functionality that can be > + provided without interruption. > + > + This property is used to provide this additional information between devices > + in a cycle by telling which supplier(s) is not needed for initializing the > + device that lists this property. > + > + In the example above, Z would list X as a post-init-supplier and the > + initialization dependency would become X -> Y -> Z -/-> X. So the best order > + to initialize them become clear: Z, Y and then X. > + > +select: true blank line > +properties: > + post-init-supplier: 'supply' is already used for regulators. Let's make it 'post-init-providers'. Rob
On Tue, Feb 20, 2024 at 08:13:31PM -0800, Saravana Kannan wrote: > I made that fix and now I'm getting this: > $ make DT_CHECKER_FLAGS=-m dt_binding_check > DT_SCHEMA_FILES=Documentation/devicetree/bindings/post-init-suppliers.yaml > DTEX Documentation/devicetree/bindings/post-init-suppliers.example.dts > LINT Documentation/devicetree/bindings > CHKDT Documentation/devicetree/bindings/processed-schema.json > /mnt/android/linus-tree/Documentation/devicetree/bindings/post-init-suppliers.yaml: > 'oneOf' conditional failed, one must be fixed: > 'unevaluatedProperties' is a required property > 'additionalProperties' is a required property > hint: Either unevaluatedProperties or additionalProperties > must be present > from schema $id: http://devicetree.org/meta-schemas/core.yaml# > SCHEMA Documentation/devicetree/bindings/processed-schema.json > /mnt/android/linus-tree/Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml: > ignoring, error in schema: properties > /mnt/android/linus-tree/Documentation/devicetree/bindings/post-init-suppliers.yaml: > ignoring, error in schema: > /mnt/android/linus-tree/Documentation/devicetree/bindings/soc/tegra/nvidia,tegra20-pmc.yaml: > ignoring, error in schema: allOf: 0: then: properties: pinmux > /mnt/android/linus-tree/Documentation/devicetree/bindings/net/lantiq,pef2256.yaml: > ignoring, error in schema: properties: lantiq,data-rate-bps > /mnt/android/linus-tree/Documentation/devicetree/bindings/post-init-supplier.yaml: > ignoring, error in schema: > /mnt/android/linus-tree/Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml: > ignoring, error in schema: properties: honeywell,pmax-pascal > /mnt/android/linus-tree/Documentation/devicetree/bindings/iio/pressure/honeywell,hsc030pa.yaml: > ignoring, error in schema: properties: honeywell,pmax-pascal > DTC_CHK Documentation/devicetree/bindings/post-init-suppliers.example.dtb > Documentation/devicetree/bindings/post-init-suppliers.example.dtb:0:0: > /example-0/clock-controller@1000: failed to match any schema with > compatible: ['vendor,soc4-gcc', 'vendor,soc1-gcc'] > Documentation/devicetree/bindings/post-init-suppliers.example.dtb:0:0: > /example-0/clock-controller@1000: failed to match any schema with > compatible: ['vendor,soc4-gcc', 'vendor,soc1-gcc'] > Documentation/devicetree/bindings/post-init-suppliers.example.dtb:0:0: > /example-0/clock-controller@2000: failed to match any schema with > compatible: ['vendor,soc4-dispcc', 'vendor,soc1-dispcc'] > Documentation/devicetree/bindings/post-init-suppliers.example.dtb:0:0: > /example-0/clock-controller@2000: failed to match any schema with > compatible: ['vendor,soc4-dispcc', 'vendor,soc1-dispcc'] FWIW, I don't see these or the other errors you see above. You really need to get yourself a newer version of dt-schema, or else avoid working on this using whatever castrated system google provides you with! > But I guess the "oneOf" error is because the yaml is being treated as > a description of a DT node and not a schema? The oneOf is due to missing "additionalProperties: true" - As far as I understand you need that regardless of whether this is going into dt-schema or the kernel.
diff --git a/Documentation/devicetree/bindings/post-init-supplier.yaml b/Documentation/devicetree/bindings/post-init-supplier.yaml new file mode 100644 index 000000000000..aab75b667259 --- /dev/null +++ b/Documentation/devicetree/bindings/post-init-supplier.yaml @@ -0,0 +1,101 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (c) 2020, Google LLC. All rights reserved. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/post-init-supplier.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Post device initialization supplier + +maintainers: + - Saravana Kannan <saravanak@google.com> + +description: | + This property is used to indicate that the device(s) pointed to by the + property are not needed for the initialization of the device that lists this + property. This property is meaningful only when pointing to direct suppliers + of a device that are pointed to by other properties in the device. + + A device can list its suppliers in devicetree using one or more of the + standard devicetree bindings. By default, it would be safe to assume the + supplier device can be initialized before the consumer device is initialized. + + However, that assumption cannot be made when there are cyclic dependencies + between devices. Since each device is a supplier (directly or indirectly) of + the others in the cycle, there is no guaranteed safe order for initializing + the devices in a cycle. We can try to initialize them in an arbitrary order + and eventually successfully initialize all of them, but that doesn't always + work well. + + For example, say, + * The device tree has the following cyclic dependency X -> Y -> Z -> X (where + -> denotes "depends on"). + * But X is not needed to fully initialize Z (X might be needed only when a + specific functionality is requested post initialization). + + If all the other -> are mandatory initialization dependencies, then trying to + initialize the devices in a loop (or arbitrarily) will always eventually end + up with the devices being initialized in the order Z, Y and X. + + However, if Y is an optional supplier for X (where X provides limited + functionality when Y is not initialized and providing its services), then + trying to initialize the devices in a loop (or arbitrarily) could end up with + the devices being initialized in the following order: + + * Z, Y and X - All devices provide full functionality + * Z, X and Y - X provides partial functionality + * X, Z and Y - X provides partial functionality + + However, we always want to initialize the devices in the order Z, Y and X + since that provides the full functionality without interruptions. + + One alternate option that might be suggested is to have the driver for X + notice that Y became available at a later point and adjust the functionality + it provides. However, other userspace applications could have started using X + with the limited functionality before Y was available and it might not be + possible to transparently transition X or the users of X to full + functionality while X is in use. + + Similarly, when it comes to suspend (resume) ordering, it's unclear which + device in a dependency cycle needs to be suspended/resumed first and trying + arbitrary orders can result in system crashes or instability. + + Explicitly calling out which link in a cycle needs to be broken when + determining the order, simplifies things a lot, improves efficiency, makes + the behavior more deterministic and maximizes the functionality that can be + provided without interruption. + + This property is used to provide this additional information between devices + in a cycle by telling which supplier(s) is not needed for initializing the + device that lists this property. + + In the example above, Z would list X as a post-init-supplier and the + initialization dependency would become X -> Y -> Z -/-> X. So the best order + to initialize them become clear: Z, Y and then X. + +select: true +properties: + post-init-supplier: + # One or more suppliers can be marked as post initialization supplier + description: + List of phandles to suppliers that are not needed for initializing or + resuming this device. + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + maxItems: 1 + +examples: + - | + gcc: clock-controller@1000 { + compatible = "vendor,soc4-gcc", "vendor,soc1-gcc"; + reg = <0x1000 0x80>; + clocks = <&dispcc 0x1> + #clock-cells = <1>; + post-init-supplier = <&dispcc>; + }; + dispcc: clock-controller@2000 { + compatible = "vendor,soc4-dispcc", "vendor,soc1-dispcc"; + reg = <0x2000 0x80>; + clocks = <&gcc 0xdd> + #clock-cells = <1>; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 3dfe7ea25320..79719af714be 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6055,12 +6055,6 @@ S: Maintained F: drivers/base/devcoredump.c F: include/linux/devcoredump.h -DEVICE DEPENDENCY HELPER SCRIPT -M: Saravana Kannan <saravanak@google.com> -L: linux-kernel@vger.kernel.org -S: Maintained -F: scripts/dev-needs.sh - DEVICE DIRECT ACCESS (DAX) M: Dan Williams <dan.j.williams@intel.com> M: Vishal Verma <vishal.l.verma@intel.com> @@ -8295,6 +8289,13 @@ F: include/linux/firewire.h F: include/uapi/linux/firewire*.h F: tools/firewire/ +FIRMWARE DEVICE LINK (fw_devlink) +M: Saravana Kannan <saravanak@google.com> +L: linux-kernel@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/post-init-supplier.yaml +F: scripts/dev-needs.sh + FIRMWARE FRAMEWORK FOR ARMV8-A M: Sudeep Holla <sudeep.holla@arm.com> L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)