lkml.org 
[lkml]   [2020]   [Dec]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    Subject[PATCH v1 2/5] driver core: Add device link support for INFERRED flag
    From
    This flag can never be added to a device link that already exists and
    doesn't have the flag set. It can only be added when a device link is
    created for the first time or it can be maintained if the device link
    already has the it set.

    This flag will be used for marking device links created ONLY by
    inferring dependencies from data and NOT from explicit action by device
    drivers/frameworks. This will be useful in the future when we need to
    deal with cycles in dependencies inferred from firmware.

    Signed-off-by: Saravana Kannan <saravanak@google.com>
    ---
    drivers/base/core.c | 15 +++++++++++----
    include/linux/device.h | 2 ++
    2 files changed, 13 insertions(+), 4 deletions(-)

    diff --git a/drivers/base/core.c b/drivers/base/core.c
    index fe8601197b84..5827dbff7f21 100644
    --- a/drivers/base/core.c
    +++ b/drivers/base/core.c
    @@ -229,7 +229,8 @@ int device_is_dependent(struct device *dev, void *target)
    return ret;

    list_for_each_entry(link, &dev->links.consumers, s_node) {
    - if (link->flags == (DL_FLAG_SYNC_STATE_ONLY | DL_FLAG_MANAGED))
    + if ((link->flags & ~DL_FLAG_INFERRED) ==
    + (DL_FLAG_SYNC_STATE_ONLY | DL_FLAG_MANAGED))
    continue;

    if (link->consumer == target)
    @@ -302,7 +303,8 @@ static int device_reorder_to_tail(struct device *dev, void *not_used)

    device_for_each_child(dev, NULL, device_reorder_to_tail);
    list_for_each_entry(link, &dev->links.consumers, s_node) {
    - if (link->flags == (DL_FLAG_SYNC_STATE_ONLY | DL_FLAG_MANAGED))
    + if ((link->flags & ~DL_FLAG_INFERRED) ==
    + (DL_FLAG_SYNC_STATE_ONLY | DL_FLAG_MANAGED))
    continue;
    device_reorder_to_tail(link->consumer, NULL);
    }
    @@ -546,7 +548,8 @@ postcore_initcall(devlink_class_init);
    #define DL_MANAGED_LINK_FLAGS (DL_FLAG_AUTOREMOVE_CONSUMER | \
    DL_FLAG_AUTOREMOVE_SUPPLIER | \
    DL_FLAG_AUTOPROBE_CONSUMER | \
    - DL_FLAG_SYNC_STATE_ONLY)
    + DL_FLAG_SYNC_STATE_ONLY | \
    + DL_FLAG_INFERRED)

    #define DL_ADD_VALID_FLAGS (DL_MANAGED_LINK_FLAGS | DL_FLAG_STATELESS | \
    DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE)
    @@ -615,7 +618,7 @@ struct device_link *device_link_add(struct device *consumer,
    if (!consumer || !supplier || flags & ~DL_ADD_VALID_FLAGS ||
    (flags & DL_FLAG_STATELESS && flags & DL_MANAGED_LINK_FLAGS) ||
    (flags & DL_FLAG_SYNC_STATE_ONLY &&
    - flags != DL_FLAG_SYNC_STATE_ONLY) ||
    + (flags & ~DL_FLAG_INFERRED) != DL_FLAG_SYNC_STATE_ONLY) ||
    (flags & DL_FLAG_AUTOPROBE_CONSUMER &&
    flags & (DL_FLAG_AUTOREMOVE_CONSUMER |
    DL_FLAG_AUTOREMOVE_SUPPLIER)))
    @@ -671,6 +674,10 @@ struct device_link *device_link_add(struct device *consumer,
    if (link->consumer != consumer)
    continue;

    + if (link->flags & DL_FLAG_INFERRED &&
    + !(flags & DL_FLAG_INFERRED))
    + link->flags &= ~DL_FLAG_INFERRED;
    +
    if (flags & DL_FLAG_PM_RUNTIME) {
    if (!(link->flags & DL_FLAG_PM_RUNTIME)) {
    pm_runtime_new_link(consumer);
    diff --git a/include/linux/device.h b/include/linux/device.h
    index 89bb8b84173e..cb5eb2e58c25 100644
    --- a/include/linux/device.h
    +++ b/include/linux/device.h
    @@ -323,6 +323,7 @@ enum device_link_state {
    * AUTOPROBE_CONSUMER: Probe consumer driver automatically after supplier binds.
    * MANAGED: The core tracks presence of supplier/consumer drivers (internal).
    * SYNC_STATE_ONLY: Link only affects sync_state() behavior.
    + * INFERRED: Inferred from data (eg: firmware) and not from driver actions.
    */
    #define DL_FLAG_STATELESS BIT(0)
    #define DL_FLAG_AUTOREMOVE_CONSUMER BIT(1)
    @@ -332,6 +333,7 @@ enum device_link_state {
    #define DL_FLAG_AUTOPROBE_CONSUMER BIT(5)
    #define DL_FLAG_MANAGED BIT(6)
    #define DL_FLAG_SYNC_STATE_ONLY BIT(7)
    +#define DL_FLAG_INFERRED BIT(8)

    /**
    * enum dl_dev_state - Device driver presence tracking information.
    --
    2.29.2.684.gfbc64c5ab5-goog
    \
     
     \ /
      Last update: 2020-12-18 04:19    [W:4.591 / U:0.176 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site