Re: [PATCH v4 0/5] Functional dependencies between devices

From: Marek Szyprowski
Date: Thu Sep 29 2016 - 02:59:04 EST

Hi Rafael,

On 2016-09-29 02:24, Rafael J. Wysocki wrote:
Hi Everyone,

On Thursday, September 08, 2016 11:25:44 PM Rafael J. Wysocki wrote:
Hi Everyone,

This is a refresh of the functional dependencies series that I posted last
year and which has picked up by Marek quite recently. For reference,
appended is my introductory message sent previously (which may be
slightly outdated now).

As last time, the first patch rearranges the code around
__device_release_driver() a bit to prepare it for the next one (it
actually hasn't changed AFAICS).

The second patch introduces the actual device links mechanics, but without
system suspend/resume and runtime PM support which are added by the
subsequent patches.

Some bugs found by Marek during his work on these patches should be fixed
here. In particular, the endless recursion in device_reorder_to_tail()
which simply was broken before.

There are two additional patches to address the issue with runtime PM
that occured when runtime PM was disabled for some suppliers due to a PM
sleep transition in progress. Those patches simply make runtime PM
return 0 in that case which may be controversial, so please let me know if
there are concerns about those.

The way device_link_add() works is a bit different, as it takes an
status argument now. That makes it possible to create a link in any
with extra care of course, and should address the problem pointed to by
during the previous discussion.

Also some comments from Tomeu have been addressed.
An update here.

The first patch hasn't changed, so I'm resending it.

The majority of changes in the other patches are in order to address Lukas'

First off, I added a DEVICE_LINK_STATELESS flag that will prevent the driver
core from trying to maintain device links having it set.

Also, the DEVICE_LINK_PERSISTENT flag was dropped (as link "persistence" is
the default behavior now) and there's a new one, DEVICE_LINK_AUTOREMOVE,
that will cause the driver core to remove the link on the consumer driver

Moreover, the code checks attempts to create a link between a parent and a
child device now and actively prevents that from happening.

The changelog of the second patch has been updated as requested by Ulf.

The third patch was updated to fix a bug related to the (previously missing)
clearing of power.direct_complete for supplier devices having consumers that
don't use direct_complete.

The next two (runtime PM) patches turned out to be unnecessary, so I've
dropped them.

The runtime PM patch [4/5] was reorganized somewhat to reduce the
level in there, but the code flow introduced by it is essentially the same
and the last patch was simply rebased on top of the new series.
Time for another update. :-)

Fewer changes this time, mostly to address issues found by Lukas and Marek.

The most significant one is to make device_link_add() cope with the case when
the consumer device has not been registered yet when it is called. The
supplier device still is required to be registered and the function will return
NULL if that is not the case.

Another significant change is in patch [4/5] that now makes the core apply
pm_runtime_get_sync()/pm_runtime_put() to supplier devices around the probing
of a consumer one (in analogy with the parent).

Thanks for the update! Updated version fixes all the remaining issues.

Tested-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>

Best regards
Marek Szyprowski, PhD
Samsung R&D Institute Poland