Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp22960rdb; Wed, 14 Feb 2024 11:23:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXSEB9rS7/bneL3XOreavCBiKLkmKMzT3IIZFD95qjFpCAuWojEDhZVbOgfS+PVZj9sO0XRqemXeOm/uBAr6B+pSm906DScvF3HnQOzfQ== X-Google-Smtp-Source: AGHT+IEKS4WhMU+06I3UaKS47876ExaTtd6/hL9oIGlFQe/fA9I9CjS1K8vbuORkbD3BXQdhdjMt X-Received: by 2002:a05:6e02:92e:b0:364:22c0:df9a with SMTP id o14-20020a056e02092e00b0036422c0df9amr4148016ilt.0.1707938605332; Wed, 14 Feb 2024 11:23:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707938605; cv=pass; d=google.com; s=arc-20160816; b=lhSE7y0Yw50l+XMcS38T8po+ye50WNX67RygKQZ9n1rN939qgdzj8hDaxKfV4uxCxC NpdJIlQrlDYWVlPNhrLZfOzoBnkxBI86uMvOoT7xoHN1DSpdxIzgZiXYoJfyqlkkDJKb Ypu7LC7UGEG8XZb9voNoqJEq4H7AiolUY9ZwC3sJv+9+IYCeOoUNvtJLfRbTuau8hlH3 o9lxAczaDJpztJJD3sy1FuDsgLKlua9w/YOtvmQr+V6ju4yIalQPyAQrhXr4+fM2EOv+ fu2UYNeShOKcJB3lqD6cMgaCZ3EF3IayUrZJNZWYcsb/8/1/lev4jDWejOcFy4nOdZVQ yWMQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=z7VdnRJZlKw/Kpp4vnrBHj6pPbCRj6s4eikZzNc/0sQ=; fh=RCblxnzIvDf714eFx5q1NwNH9k4/Ue/CGDVqTCqHs8I=; b=ETjXfsJrpAGxYTW8o9tS54JbzTIbtdy/X263h1Ne2to0tvDYisSbuP6w7rKsi1Sbe5 Wcqvm9rtoYtJE7kQ420ISuY/L7GEhtZChtCCr92jTomqBYnnzOO/aLy6TF+DUfc9tPdF eRKDSvLSzFGoFZumAR8d1YQACUHZSefmP+fJubpsdu8v/QcAzhVb+Tj89p5JgRePXbTx /GEpQcPjftVUEW5EVL0wW+MRKGpwF6lQ0+be9l/fuPNALgSR68LNNyOikBjxpoZCCagQ 1oxJaCgOQR1cyyXhgn6I0qV/MXa6Yz2VLAIHMhTJFs5ucZqJy8qiMlxiN+ymMnrCmXDb /HCA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OxwE+IaQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65835-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCWO7Y4LNjhm/PBn9ZP0QKvfKLf/VFguDviQSQ8kpWmpcs/G3k4SxJ/rHNoP1z9E0n/xyQh2lwpeGrC/UZp7VMNxkmILzVwYkgg0yAJ4Pw== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x26-20020a63b21a000000b005dc422f07easi3955952pge.902.2024.02.14.11.23.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 11:23:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OxwE+IaQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65835-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id C3C8EB28BC0 for ; Wed, 14 Feb 2024 18:49:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75277134738; Wed, 14 Feb 2024 18:49:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OxwE+IaQ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47657138488; Wed, 14 Feb 2024 18:49:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707936545; cv=none; b=G2ukOuCbhvDdLCwE+oSi6fitSLc9TJnd0SXMALr+XbPtPqFD8fTKaHYM+IwKCFe2+lEXcS+dMFfCvTiqVHND6QGizPkI//u+Fw4O+C4hktkOlnVak8Et3Fstb2knQZ6u2unMOKvIEOEWXJX3gyAfDQ6f8Tc3bjDodaR2rHWT+/U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707936545; c=relaxed/simple; bh=CGCI+ays+bSdN67l7c5rVd9uV736XGKDr50F41/4vY4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LtNt6MvPOV6DBbww/9+KZNou5KNAH0t24SdDW0WJvMN+qmuXIkRibJPca3KqKNOIPGG9FtMwiLjWGiRDoBeUUhjkIBsLvCMTF6rES8PGQ0RP+ZvaEZb6Q3MOCtn+2YM9YY+nITMuvG5cALprwZBZGPCuVEylNekimhjIdjnrqJE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OxwE+IaQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74F86C43390; Wed, 14 Feb 2024 18:49:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707936544; bh=CGCI+ays+bSdN67l7c5rVd9uV736XGKDr50F41/4vY4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OxwE+IaQ8XZ/UP2IumLnClE9+YUKEMSBHvYUUNAvtBcq08HnHxA6QWYXt1Uqww2/S tTA/B9+a2YnT1ux0INYgiAXrHMMD2zfLsoGbTYMPMJQrKd6wdwxJJ7dhXazTxtGKt/ SJ0TiLDw+XiyqG3hDZttZGHh4K7HzETHhdMK0WUywKvzE2NIrR1d3zPGKWx6mwbq6Y aKJFnvIPm4zystN1azztn5J3KoSlsQKwhRhShVHZihmcvxrWLyb8i52ZTWaBWNZc9a b7VXpsp/1tMvMpTiYZOJoh5CEXVD21q3mL9/Fnd0Z3v/RZVUkOlf0609gS/EvTVt17 zJdDxn2S+pd8A== Date: Wed, 14 Feb 2024 18:48:59 +0000 From: Conor Dooley To: Saravana Kannan Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , "Rafael J. Wysocki" , Ard Biesheuvel , Frank Rowand , Len Brown , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , kernel-team@android.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-efi@vger.kernel.org, linux-acpi@vger.kernel.org Subject: Re: [PATCH v2 3/4] dt-bindings: Add post-init-supplier property Message-ID: <20240214-stable-anytime-b51b898d87af@spud> References: <20240212213147.489377-1-saravanak@google.com> <20240212213147.489377-4-saravanak@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xFR+xkhlg19+nOVS" Content-Disposition: inline In-Reply-To: <20240212213147.489377-4-saravanak@google.com> --xFR+xkhlg19+nOVS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > Signed-off-by: Saravana Kannan > --- > .../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 >=20 > 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 > + > +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 list= s 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 t= he > + supplier device can be initialized before the consumer device is initi= alized. "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 dependen= cies > + between devices. Since each device is a supplier (directly or indirect= ly) of > + the others in the cycle, there is no guaranteed safe order for initial= izing > + 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 a= lways > + 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 wh= en a > + specific functionality is requested post initialization). > + > + If all the other -> are mandatory initialization dependencies, then tr= ying to > + initialize the devices in a loop (or arbitrarily) will always eventual= ly 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), t= hen > + 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 an= d 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 functio= nality > + 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 wh= ich > + device in a dependency cycle needs to be suspended/resumed first and t= rying > + 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, m= akes > + the behavior more deterministic and maximizes the functionality that c= an be > + provided without interruption. > + > + This property is used to provide this additional information between d= evices > + 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 =3D "vendor,soc4-gcc", "vendor,soc1-gcc"; > + reg =3D <0x1000 0x80>; > + clocks =3D <&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.=20 Cheers, Conor. > + #clock-cells =3D <1>; > + post-init-supplier =3D <&dispcc>; > + }; > + dispcc: clock-controller@2000 { > + compatible =3D "vendor,soc4-dispcc", "vendor,soc1-dispcc"; > + reg =3D <0x2000 0x80>; > + clocks =3D <&gcc 0xdd> > + #clock-cells =3D <1>; > + }; --xFR+xkhlg19+nOVS Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZc0LGwAKCRB4tDGHoIJi 0pU/AP93C04kIYnkbEXW1OLHWZ7dAqt6T3xeM0PBndtH5wGHMQEAgIOFjmmWMsIQ yFU5JXHBJmUbzI9DltuGAst0sbo7Hgw= =daBO -----END PGP SIGNATURE----- --xFR+xkhlg19+nOVS--