Skip to content

Commit 70fb9a2

Browse files
rafaeljwgregkh
authored andcommitted
driver core: Document limitation related to DL_FLAG_RPM_ACTIVE
If device_link_add() is called twice in a row to create a stateless device link for the same consumer-supplier pair without an attempt to delete the link between these calls, and the second caller passes DL_FLAG_RPM_ACTIVE to it in flags, calling either device_link_del() or device_link_remove() immediately after that will leave the link's supplier device with nonzero PM-runtime usage counter, which may prevent the supplier from being runtime-suspended going forward until the link is deleted by another invocation of device_link_del() or device_link_remove() for it. Even though this is confusing and may lead to subtle issues, trying to avoid it in the framework also may cause problems to appear, so document it as a known limitation. Signed-off-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4080ab0 commit 70fb9a2

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Documentation/driver-api/device_link.rst

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ integration is desired.
8686

8787
Two other flags are specifically targeted at use cases where the device
8888
link is added from the consumer's ``->probe`` callback: ``DL_FLAG_RPM_ACTIVE``
89-
can be specified to runtime resume the supplier upon addition of the
90-
device link. ``DL_FLAG_AUTOREMOVE_CONSUMER`` causes the device link to be
91-
automatically purged when the consumer fails to probe or later unbinds.
89+
can be specified to runtime resume the supplier and prevent it from suspending
90+
before the consumer is runtime suspended. ``DL_FLAG_AUTOREMOVE_CONSUMER``
91+
causes the device link to be automatically purged when the consumer fails to
92+
probe or later unbinds.
9293

9394
Similarly, when the device link is added from supplier's ``->probe`` callback,
9495
``DL_FLAG_AUTOREMOVE_SUPPLIER`` causes the device link to be automatically
@@ -121,6 +122,20 @@ set) are expected to be removed by whoever called :c:func:`device_link_add()`
121122
to add them with the help of either :c:func:`device_link_del()` or
122123
:c:func:`device_link_remove()`.
123124

125+
Passing ``DL_FLAG_RPM_ACTIVE`` along with ``DL_FLAG_STATELESS`` to
126+
:c:func:`device_link_add()` may cause the PM-runtime usage counter of the
127+
supplier device to remain nonzero after a subsequent invocation of either
128+
:c:func:`device_link_del()` or :c:func:`device_link_remove()` to remove the
129+
device link returned by it. This happens if :c:func:`device_link_add()` is
130+
called twice in a row for the same consumer-supplier pair without removing the
131+
link between these calls, in which case allowing the PM-runtime usage counter
132+
of the supplier to drop on an attempt to remove the link may cause it to be
133+
suspended while the consumer is still PM-runtime-active and that has to be
134+
avoided. [To work around this limitation it is sufficient to let the consumer
135+
runtime suspend at least once, or call :c:func:`pm_runtime_set_suspended()` for
136+
it with PM-runtime disabled, between the :c:func:`device_link_add()` and
137+
:c:func:`device_link_del()` or :c:func:`device_link_remove()` calls.]
138+
124139
Sometimes drivers depend on optional resources. They are able to operate
125140
in a degraded mode (reduced feature set or performance) when those resources
126141
are not present. An example is an SPI controller that can use a DMA engine

0 commit comments

Comments
 (0)