Debian Codegraph @

dtschema/schemas/post-init-providers.yaml

raw
1 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2 # Copyright (c) 2024, Google LLC. All rights reserved.
3 %YAML 1.2
4 ---
5 $id: http://devicetree.org/schemas/post-init-providers.yaml#
6 $schema: http://devicetree.org/meta-schemas/core.yaml#
7
8 title: Post-device-initialization providers
9
10 maintainers:
11 - Saravana Kannan <[email protected]>
12
13 description: |
14 This property is used to indicate that the device(s) pointed to by the
15 property are not needed for the initialization of the device that lists this
16 property. This property does not make a device (that's previously not a
17 provider) into a provider. It simply downgrades an existing provider to a
18 post-device-initialization provider.
19
20 A device can list its providers in devicetree using one or more of the
21 standard devicetree bindings. By default, it is assumed that the provider
22 device can be initialized before the consumer device is initialized.
23
24 However, that assumption cannot be made when there are cyclic dependencies
25 between devices. Since each device is a provider (directly or indirectly) of
26 the others in the cycle, there is no guaranteed safe order for initializing
27 the devices in a cycle. We can try to initialize them in an arbitrary order
28 and eventually successfully initialize all of them, but that doesn't always
29 work well.
30
31 For example, say,
32 * The device tree has the following cyclic dependency X -> Y -> Z -> X (where
33 -> denotes "depends on").
34 * But X is not needed to fully initialize Z (X might be needed only when a
35 specific functionality is requested after initialization of Z).
36
37 If all the other -> are mandatory initialization dependencies, then trying to
38 initialize the devices in a loop (or arbitrarily) will always eventually end
39 up with the devices being initialized in the order Z, Y and X.
40
41 However, if Y is an optional provider for X (where X provides limited
42 functionality when Y is not initialized and providing its services), then
43 trying to initialize the devices in a loop (or arbitrarily) could end up with
44 the devices being initialized in the following order:
45
46 * Z, Y and X - All devices provide full functionality
47 * Z, X and Y - X provides partial functionality
48 * X, Z and Y - X provides partial functionality
49
50 However, we always want to initialize the devices in the order Z, Y and X
51 since that provides the full functionality without interruptions.
52
53 One alternate option that might be suggested is to have the driver for X
54 notice that Y became available at a later point and adjust the functionality
55 it provides. However, other userspace applications could have started using X
56 with the limited functionality before Y was available and it might not be
57 possible to transparently transition X or the users of X to full
58 functionality while X is in use.
59
60 Similarly, when it comes to suspend (resume) ordering, it's unclear which
61 device in a dependency cycle needs to be suspended/resumed first and trying
62 arbitrary orders can result in system crashes or instability.
63
64 Explicitly calling out which link in a cycle needs to be broken when
65 determining the order, simplifies things a lot, improves efficiency, makes
66 the behavior more deterministic and maximizes the functionality that can be
67 provided without interruption.
68
69 This property is used to provide this additional information between devices
70 in a cycle by telling which provider(s) is not needed for initializing the
71 device that lists this property.
72
73 In the example above, Z would list X as a post-init-providers and the
74 initialization dependency would become X -> Y -> Z -/-> X. So the best order
75 to initialize them becomes clear: Z, Y and then X.
76
77 select: true
78
79 properties:
80 post-init-providers:
81 # One or more providers can be marked as post initialization provider
82 description:
83 List of phandles to providers that are not needed for initializing or
84 resuming this device.
85 $ref: /schemas/types.yaml#/definitions/phandle-array
86 items:
87 maxItems: 1
88
89 additionalProperties: true
90
91 examples:
92 - |
93 gcc: clock-controller@1000 {
94 compatible = "vendor,soc4-gcc", "vendor,soc1-gcc";
95 reg = <0x1000 0x80>;
96 clocks = <&dispcc 0x1>;
97 #clock-cells = <1>;
98 post-init-providers = <&dispcc>;
99 };
100 dispcc: clock-controller@2000 {
101 compatible = "vendor,soc4-dispcc", "vendor,soc1-dispcc";
102 reg = <0x2000 0x80>;
103 clocks = <&gcc 0xdd>;
104 #clock-cells = <1>;
105 };