From patchwork Mon Feb 12 21:31:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 200043 Return-Path: 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 (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 ; 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 ; 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 ; 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: List-Subscribe: List-Unsubscribe: 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 To: Saravana Kannan , 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 Cc: kernel-team@android.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-efi@vger.kernel.org, linux-acpi@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790730396380416831 X-GMAIL-MSGID: 1790730396380416831 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 --- .../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 + +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 -L: linux-kernel@vger.kernel.org -S: Maintained -F: scripts/dev-needs.sh - DEVICE DIRECT ACCESS (DAX) M: Dan Williams M: Vishal Verma @@ -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 +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 L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)