* [PATCH v1] driver core: Fix handling of SYNC_STATE_ONLY + STATELESS device links
@ 2020-05-20 4:36 Saravana Kannan
2020-05-20 4:38 ` Saravana Kannan
2020-05-20 9:13 ` Rafael J. Wysocki
0 siblings, 2 replies; 3+ messages in thread
From: Saravana Kannan @ 2020-05-20 4:36 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Saravana Kannan
Cc: kernel-team, Rafael J. Wysocki, linux-kernel
Commit 21c27f06587d ("driver core: Fix SYNC_STATE_ONLY device link
implementation") didn't completely fix STATELESS + SYNC_STATE_ONLY
handling.
What looks like an optimization in that commit is actually a bug that
causes an if condition to always take the else path. This prevents
reordering of devices in the dpm_list when a DL_FLAG_STATELESS device
link is create on top of an existing DL_FLAG_SYNC_STATE_ONLY device
link.
Fixes: 21c27f06587d ("driver core: Fix SYNC_STATE_ONLY device link implementation")
Signed-off-by: Saravana Kannan <saravanak@google.com>
---
Sigh... device links are tricky and hard! Sorry about the endless fixes :(
Also, how was this not caught by the compiler as a warning?
-Saravana
drivers/base/core.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 83a3e0b62ce3..dfd4e94ef790 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -543,12 +543,14 @@ struct device_link *device_link_add(struct device *consumer,
if (flags & DL_FLAG_STATELESS) {
kref_get(&link->kref);
- link->flags |= DL_FLAG_STATELESS;
if (link->flags & DL_FLAG_SYNC_STATE_ONLY &&
- !(link->flags & DL_FLAG_STATELESS))
+ !(link->flags & DL_FLAG_STATELESS)) {
+ link->flags |= DL_FLAG_STATELESS;
goto reorder;
- else
+ } else {
+ link->flags |= DL_FLAG_STATELESS;
goto out;
+ }
}
/*
--
2.26.2.761.g0e0b3e54be-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] driver core: Fix handling of SYNC_STATE_ONLY + STATELESS device links
2020-05-20 4:36 [PATCH v1] driver core: Fix handling of SYNC_STATE_ONLY + STATELESS device links Saravana Kannan
@ 2020-05-20 4:38 ` Saravana Kannan
2020-05-20 9:13 ` Rafael J. Wysocki
1 sibling, 0 replies; 3+ messages in thread
From: Saravana Kannan @ 2020-05-20 4:38 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Saravana Kannan
Cc: Android Kernel Team, Rafael J. Wysocki, LKML, stable
On Tue, May 19, 2020 at 9:36 PM Saravana Kannan <saravanak@google.com> wrote:
>
> Commit 21c27f06587d ("driver core: Fix SYNC_STATE_ONLY device link
> implementation") didn't completely fix STATELESS + SYNC_STATE_ONLY
> handling.
>
> What looks like an optimization in that commit is actually a bug that
> causes an if condition to always take the else path. This prevents
> reordering of devices in the dpm_list when a DL_FLAG_STATELESS device
> link is create on top of an existing DL_FLAG_SYNC_STATE_ONLY device
> link.
>
> Fixes: 21c27f06587d ("driver core: Fix SYNC_STATE_ONLY device link implementation")
> Signed-off-by: Saravana Kannan <saravanak@google.com>
> ---
> Sigh... device links are tricky and hard! Sorry about the endless fixes :(
> Also, how was this not caught by the compiler as a warning?
>
> -Saravana
>
> drivers/base/core.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 83a3e0b62ce3..dfd4e94ef790 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -543,12 +543,14 @@ struct device_link *device_link_add(struct device *consumer,
>
> if (flags & DL_FLAG_STATELESS) {
> kref_get(&link->kref);
> - link->flags |= DL_FLAG_STATELESS;
> if (link->flags & DL_FLAG_SYNC_STATE_ONLY &&
> - !(link->flags & DL_FLAG_STATELESS))
> + !(link->flags & DL_FLAG_STATELESS)) {
> + link->flags |= DL_FLAG_STATELESS;
> goto reorder;
> - else
> + } else {
> + link->flags |= DL_FLAG_STATELESS;
> goto out;
> + }
> }
>
> /*
Forgot to add stable@vger.kernel.org. Doing that now.
-Saravana
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] driver core: Fix handling of SYNC_STATE_ONLY + STATELESS device links
2020-05-20 4:36 [PATCH v1] driver core: Fix handling of SYNC_STATE_ONLY + STATELESS device links Saravana Kannan
2020-05-20 4:38 ` Saravana Kannan
@ 2020-05-20 9:13 ` Rafael J. Wysocki
1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2020-05-20 9:13 UTC (permalink / raw)
To: Saravana Kannan
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Cc: Android Kernel,
Rafael J. Wysocki, Linux Kernel Mailing List
On Wed, May 20, 2020 at 6:36 AM Saravana Kannan <saravanak@google.com> wrote:
>
> Commit 21c27f06587d ("driver core: Fix SYNC_STATE_ONLY device link
> implementation") didn't completely fix STATELESS + SYNC_STATE_ONLY
> handling.
>
> What looks like an optimization in that commit is actually a bug that
> causes an if condition to always take the else path. This prevents
> reordering of devices in the dpm_list when a DL_FLAG_STATELESS device
> link is create on top of an existing DL_FLAG_SYNC_STATE_ONLY device
> link.
>
> Fixes: 21c27f06587d ("driver core: Fix SYNC_STATE_ONLY device link implementation")
> Signed-off-by: Saravana Kannan <saravanak@google.com>
> ---
> Sigh... device links are tricky and hard! Sorry about the endless fixes :(
> Also, how was this not caught by the compiler as a warning?
Well, I haven't spotted this either ...
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> drivers/base/core.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 83a3e0b62ce3..dfd4e94ef790 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -543,12 +543,14 @@ struct device_link *device_link_add(struct device *consumer,
>
> if (flags & DL_FLAG_STATELESS) {
> kref_get(&link->kref);
> - link->flags |= DL_FLAG_STATELESS;
> if (link->flags & DL_FLAG_SYNC_STATE_ONLY &&
> - !(link->flags & DL_FLAG_STATELESS))
> + !(link->flags & DL_FLAG_STATELESS)) {
> + link->flags |= DL_FLAG_STATELESS;
> goto reorder;
> - else
> + } else {
> + link->flags |= DL_FLAG_STATELESS;
> goto out;
> + }
> }
>
> /*
> --
> 2.26.2.761.g0e0b3e54be-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-20 9:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20 4:36 [PATCH v1] driver core: Fix handling of SYNC_STATE_ONLY + STATELESS device links Saravana Kannan
2020-05-20 4:38 ` Saravana Kannan
2020-05-20 9:13 ` Rafael J. Wysocki
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.