Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1465770rdb; Sat, 10 Feb 2024 03:26:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IGju96T6iLY6+EGmGh/8rcsTuljQgvaRACrklIOB8rxbiSxQJOOZOWySfz1K4OLhVf56j1w X-Received: by 2002:a17:902:ee55:b0:1d8:b2f4:28ce with SMTP id 21-20020a170902ee5500b001d8b2f428cemr1691086plo.42.1707564397142; Sat, 10 Feb 2024 03:26:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707564397; cv=pass; d=google.com; s=arc-20160816; b=YOFpzioqS2IVHuWGNQtnGoMoZ6DSRVG1Im0RCXPtNKiNX0piz5Z56y43idCmPG9QA3 3S0QAbiZCNwgOtGSA/dBvZP0W2mGdeRrbJZSrXmqzivJm177/FEwyRMi8GkA7mrja4OT T6e06a8atYXAiI2eYWGYwYekfe36DuyThQfyaNR3Xm9L1egR7rWlvvEObn9u+c/ukkkD c/y7fV6AUD2h6BCf06nyqHgb/Xf5JECszzYTpeF0DY3wOG4wTThOU2fYl457y8B2DYb1 kXH7urJ/buUbPeMzLB8+lmB/M8zKShcwOCf6ZpXpBohm1taeQUilx1nrDH2Djg4vx4qu QlEQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=/2u7ugpRRjTSiniBFXQ2hFrVHWlFalos8v62aw2cYcY=; fh=sS2gQaBT9qji/FZz0vakvUtE/0idC/Etz/BAizoe3SE=; b=aJmVzIHSFWi6x8z/BddKnyc9iIExW1L6UgJm87++2OjzcqHgTcFj6yk4QZLujAsnHT hWEV6DBj70dsg3qJ/pjiXXg816hQ6GpSZPLAhs6v4Wyvzi0I6/7bA61T2wlRkhRmZptP GIkfWRJul2JYowwAvKMVTrB2c7CjDXPCCfM6lKUxh8iVwn45669szKIo4bQGTq3OMxvh mWEMu3a2HuA8R4TzZUV9MY29oh51GYDK5H6FjL9PGoYJaQiOKKfcYVgwwl072uxNljWF mrVmXK8iK1fIRb1gHhb2e/vzO38TQd2iMru2opCEbUnkPdASQvvYS1QoCSW/nCIGoARJ y8vA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uS3WTuqW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60372-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60372-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; AJvYcCXLHdY4RETuWWZ+cdWH5cUbYM4Gwf76yhCFFdWno6D2Msmj8TVz6li1ibu+XFrS6c0Dtl9ncj1ZQ9dYA37QQ47l/XN9rVchyXaCWSi2OQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u3-20020a170902b28300b001d6e8fa5b3asi3256475plr.610.2024.02.10.03.26.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 03:26:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60372-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uS3WTuqW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60372-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60372-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C2DBD2865A2 for ; Sat, 10 Feb 2024 11:26:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82EA53CF61; Sat, 10 Feb 2024 11:26:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uS3WTuqW" 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 6302D3C099; Sat, 10 Feb 2024 11:26:27 +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=1707564387; cv=none; b=KEmkINylO/VN+rEJwzJnwfb5iSUYT1+8CK0Yy8QtZzywXa4PFSeRW1i+6u1SnD+N3wi48YTL3wIT7hK04+KviWqdbvdEMj+7VBscBh7SgPAspWsbuMZL0wS5/NjP4/8vp2oFMBxMe579SB3WhpX8eEWfwb1zrQ95hu49ZIapDHg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707564387; c=relaxed/simple; bh=L0ci31G0jYzl6VBiXaBLl3DHMQtouFJCjuDEsEbmM1I=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ZchU8M1j21yJInIKqNDEGWgwR+Inktm8k6WseqM88hjd6MXU7WVjdTSqJKJDZn5b0QXrtbpKk5dlEbxYmtDqrZOAMhBV556P2Z+jOF0K5vjwB9Xt40+MjuFvR4aGmKy98RA7Xa2lMP9tCc3EAvnj8oaUIDv4PUrNwOAoY6fMkRw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uS3WTuqW; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D428DC43390; Sat, 10 Feb 2024 11:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707564386; bh=L0ci31G0jYzl6VBiXaBLl3DHMQtouFJCjuDEsEbmM1I=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=uS3WTuqWK5m//0XlZlfvv4zylVUZ6S1WBcNbg5UoupukNn7eZbc2MMVolo7OqWUpl lMdcqn9VeaW4OqVX9JHgcPcc0E8UvhSukGP/eM5Wk78n1x9gCwj3785IwZhrHFAJcd cEPGa2K+WqwxWmzsMBhdoabMcGMLtlHQPf/uqsCxTq5C1FlDBA43WXzzAA46RtBXRr csMkRCZXqW+rDPhoFwiqFoLe7EFau/A76vVSvfSYpT8f3aVWbtLn7IKaF7UTdGXDd0 aAwYQFc8t6FnBzwlfV5+P/zQSq88iLWPS1Vus1t9O0ic2HoWYzWPXVRPPYPHn5hVgd 9QtYeMTEFMZqw== Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2d0cdbd67f0so22921821fa.3; Sat, 10 Feb 2024 03:26:26 -0800 (PST) X-Gm-Message-State: AOJu0YzzhXhCSBwgmoNB2tBFMzEYkUCxPuqAATgGAfagxORAcYSyt0yR Ms1en/TkTaEv/kJkH8wXHRIr0ijNb1DEwMgGOkjOtj2ap0jYBfiGCyVE3e525/7i1HpwFluLrGH teAUIWFFKQ+fdB+gEspZdhkUqmA== X-Received: by 2002:a2e:3806:0:b0:2d0:a71f:5eab with SMTP id f6-20020a2e3806000000b002d0a71f5eabmr1287112lja.23.1707564384958; Sat, 10 Feb 2024 03:26:24 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240210030549.4048795-1-saravanak@google.com> <20240210030549.4048795-4-saravanak@google.com> In-Reply-To: <20240210030549.4048795-4-saravanak@google.com> From: Rob Herring Date: Sat, 10 Feb 2024 11:26:13 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 3/4] dt-bindings: Add post-init-supplier property To: Saravana Kannan Cc: Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , "Rafael J. Wysocki" , Ard Biesheuvel , Frank Rowand , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Len Brown , 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" Content-Transfer-Encoding: quoted-printable On Sat, Feb 10, 2024 at 3:06=E2=80=AFAM Saravana Kannan wrote: > > The post-init-supplier property can be used to break a dependency cycle b= y > marking some supplier(s) as a post device initialization supplier(s). Thi= s > allows the kernel to do a better job at ordering initialization and s/the kernel/an OS/ > suspend/resume of the devices in a dependency cycle. > > Signed-off-by: Saravana Kannan > --- > .../bindings/post-init-supplier.yaml | 99 +++++++++++++++++++ This should probably go into dtschema instead, but fine here now for review= ing. We have to consider if this property should be automatically allowed on any node or nodes with specific suppliers, or if it should be explicit for users. The former needs tool support. I'm leaning towards the latter as I want to know when this is needed. > MAINTAINERS | 3 +- > 2 files changed, 101 insertions(+), 1 deletion(-) > 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..cf9071ecd06e > --- /dev/null > +++ b/Documentation/devicetree/bindings/post-init-supplier.yaml > @@ -0,0 +1,99 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +# Copyright 2018 Linaro Ltd. ? > +%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. > + > + 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. > + > + However, that assumption cannot be made when there are cyclic dependec= ies typo > + 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 initali= zing typo > + 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 if 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. > + select: true Otherwise, this is never applied. > +properties: > + # A dictionary of DT properties for this binding schema Drop > + post-init-supplier: > + # One or more suppliers can be marked as post initialization supplie= r > + minItems: 1 That's the default. > + description: > + List of phandles to suppliers that are not needed for initializing= or > + resuming this device. > + $ref: /schemas/types.yaml#/definitions/phandle Should be phandle-array plus: items: maxItems: 1 (as each entry is a single phandle) > + > +examples: > + - | > + gcc: general-clock-controller@1000 { clock-controller@1000 > + compatible =3D "vendor,soc4-gcc", "vendor,soc1-gcc"; > + reg =3D <0x1000 0x80>;> + clocks =3D <&dispcc 0x1> > + #clock-cells =3D <1>; > + post-init-supplier =3D <&dispcc>; > + }; > + dispcc: display-clock-controller@2000 { clock-controller@2000 > + compatible =3D "vendor,soc4-dispcc", "vendor,soc1-dispcc"; > + reg =3D <0x2000 0x80>; > + clocks =3D <&gcc 0xdd> > + #clock-cells =3D <1>; > + }; > diff --git a/MAINTAINERS b/MAINTAINERS > index 3dfe7ea25320..40fd498543a5 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -6055,10 +6055,11 @@ S: Maintained > F: drivers/base/devcoredump.c > F: include/linux/devcoredump.h > > -DEVICE DEPENDENCY HELPER SCRIPT > +FIRMWARE DEVICE LINK (fw_devlink) > M: Saravana Kannan > L: linux-kernel@vger.kernel.org > S: Maintained > +F: Documentation/devicetree/bindings/post-init-supplier.yaml > F: scripts/dev-needs.sh > > DEVICE DIRECT ACCESS (DAX) > -- > 2.43.0.687.g38aa6559b0-goog >