diff mbox series

[v1,09/18] driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links

Message ID 20201104232356.4038506-10-saravanak@google.com
State Accepted
Commit ac66c5bbb4371073dcace77e47c234d2e36a006b
Headers show
Series [v1,01/18] Revert "driver core: Avoid deferred probe due to fw_devlink_pause/resume()" | expand

Commit Message

Saravana Kannan Nov. 4, 2020, 11:23 p.m. UTC
SYNC_STATE_ONLY device links only affect the behavior of sync_state()
callbacks. Specifically, they prevent sync_state() only callbacks from
being called on a device if one or more of its consumers haven't probed.

So, creating a SYNC_STATE_ONLY device link from an already probed
consumer is useless. So, don't allow creating such device links.

Signed-off-by: Saravana Kannan <saravanak@google.com>
---
 drivers/base/core.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Rafael J. Wysocki Nov. 16, 2020, 3:57 p.m. UTC | #1
On Thu, Nov 5, 2020 at 12:24 AM Saravana Kannan <saravanak@google.com> wrote:
>
> SYNC_STATE_ONLY device links only affect the behavior of sync_state()
> callbacks. Specifically, they prevent sync_state() only callbacks from
> being called on a device if one or more of its consumers haven't probed.
>
> So, creating a SYNC_STATE_ONLY device link from an already probed
> consumer is useless. So, don't allow creating such device links.

I'm wondering why this needs to be part of the series?

It looks like it could go in separately, couldn't it?

>
> Signed-off-by: Saravana Kannan <saravanak@google.com>
> ---
>  drivers/base/core.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 1a1d9a55645c..4a0907574646 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -646,6 +646,17 @@ struct device_link *device_link_add(struct device *consumer,
>                 goto out;
>         }
>
> +       /*
> +        * SYNC_STATE_ONLY links are useless once a consumer device has probed.
> +        * So, only create it if the consumer hasn't probed yet.
> +        */
> +       if (flags & DL_FLAG_SYNC_STATE_ONLY &&
> +           consumer->links.status != DL_DEV_NO_DRIVER &&
> +           consumer->links.status != DL_DEV_PROBING) {
> +               link = NULL;
> +               goto out;
> +       }

Returning NULL at this point may be confusing if there is a link
between these devices already.

> +
>         /*
>          * DL_FLAG_AUTOREMOVE_SUPPLIER indicates that the link will be needed
>          * longer than for DL_FLAG_AUTOREMOVE_CONSUMER and setting them both
> --
> 2.29.1.341.ge80a0c044ae-goog
>
diff mbox series

Patch

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 1a1d9a55645c..4a0907574646 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -646,6 +646,17 @@  struct device_link *device_link_add(struct device *consumer,
 		goto out;
 	}
 
+	/*
+	 * SYNC_STATE_ONLY links are useless once a consumer device has probed.
+	 * So, only create it if the consumer hasn't probed yet.
+	 */
+	if (flags & DL_FLAG_SYNC_STATE_ONLY &&
+	    consumer->links.status != DL_DEV_NO_DRIVER &&
+	    consumer->links.status != DL_DEV_PROBING) {
+		link = NULL;
+		goto out;
+	}
+
 	/*
 	 * DL_FLAG_AUTOREMOVE_SUPPLIER indicates that the link will be needed
 	 * longer than for DL_FLAG_AUTOREMOVE_CONSUMER and setting them both