All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC v2] driver core: Fix repeated device_is_dependent check for same link
@ 2022-07-06 15:53 Abel Vesa
  2022-07-06 15:56 ` Greg Kroah-Hartman
  2022-07-07  4:51 ` Saravana Kannan
  0 siblings, 2 replies; 4+ messages in thread
From: Abel Vesa @ 2022-07-06 15:53 UTC (permalink / raw)
  To: Saravana Kannan, Greg Kroah-Hartman, Rafael J. Wysocki
  Cc: linux-arm-msm, Linux Kernel Mailing List, Abel Vesa

In case of a cyclic dependency, if the supplier is not yet available,
the parent of the supplier is checked for dependency. But if there are
more than one suppliers with the same parent, the first check returns
true while the next ones skip that specific link entirely because of
having DL_FLAG_MANAGED and DL_FLAG_SYNC_STATE_ONLY set, which is what
the relaxing of the link does. But if we check for the target being
a consumer before the check for those flags, we can check as many
times as needed the same link and it will always return true, This is
safe to do, since the relaxing of the link will be done only once
because those flags will be set and it will bail early.

Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
---
 drivers/base/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 753e7cca0f40..2c3b860dfe80 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -297,13 +297,13 @@ int device_is_dependent(struct device *dev, void *target)
 		return ret;

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

-		if (link->consumer == target)
-			return 1;
-
 		ret = device_is_dependent(link->consumer, target);
 		if (ret)
 			break;
--
2.34.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC v2] driver core: Fix repeated device_is_dependent check for same link
  2022-07-06 15:53 [RFC v2] driver core: Fix repeated device_is_dependent check for same link Abel Vesa
@ 2022-07-06 15:56 ` Greg Kroah-Hartman
  2022-07-07  4:51 ` Saravana Kannan
  1 sibling, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2022-07-06 15:56 UTC (permalink / raw)
  To: Abel Vesa
  Cc: Saravana Kannan, Rafael J. Wysocki, linux-arm-msm,
	Linux Kernel Mailing List

On Wed, Jul 06, 2022 at 06:53:47PM +0300, Abel Vesa wrote:
> In case of a cyclic dependency, if the supplier is not yet available,
> the parent of the supplier is checked for dependency. But if there are
> more than one suppliers with the same parent, the first check returns
> true while the next ones skip that specific link entirely because of
> having DL_FLAG_MANAGED and DL_FLAG_SYNC_STATE_ONLY set, which is what
> the relaxing of the link does. But if we check for the target being
> a consumer before the check for those flags, we can check as many
> times as needed the same link and it will always return true, This is
> safe to do, since the relaxing of the link will be done only once
> because those flags will be set and it will bail early.
> 
> Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
> ---
>  drivers/base/core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 753e7cca0f40..2c3b860dfe80 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -297,13 +297,13 @@ int device_is_dependent(struct device *dev, void *target)
>  		return ret;
> 
>  	list_for_each_entry(link, &dev->links.consumers, s_node) {
> +		if (link->consumer == target)
> +			return 1;
> +
>  		if ((link->flags & ~DL_FLAG_INFERRED) ==
>  		    (DL_FLAG_SYNC_STATE_ONLY | DL_FLAG_MANAGED))
>  			continue;
> 
> -		if (link->consumer == target)
> -			return 1;
> -
>  		ret = device_is_dependent(link->consumer, target);
>  		if (ret)
>  			break;
> --
> 2.34.3
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- This looks like a new version of a previously submitted patch, but you
  did not list below the --- line any changes from the previous version.
  Please read the section entitled "The canonical patch format" in the
  kernel file, Documentation/SubmittingPatches for what needs to be done
  here to properly describe this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC v2] driver core: Fix repeated device_is_dependent check for same link
  2022-07-06 15:53 [RFC v2] driver core: Fix repeated device_is_dependent check for same link Abel Vesa
  2022-07-06 15:56 ` Greg Kroah-Hartman
@ 2022-07-07  4:51 ` Saravana Kannan
  2022-07-07 10:41   ` Abel Vesa
  1 sibling, 1 reply; 4+ messages in thread
From: Saravana Kannan @ 2022-07-07  4:51 UTC (permalink / raw)
  To: Abel Vesa
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, linux-arm-msm,
	Linux Kernel Mailing List

On Wed, Jul 6, 2022 at 8:54 AM Abel Vesa <abel.vesa@linaro.org> wrote:
>
> In case of a cyclic dependency, if the supplier is not yet available,
> the parent of the supplier is checked for dependency. But if there are
> more than one suppliers with the same parent, the first check returns
> true while the next ones skip that specific link entirely because of
> having DL_FLAG_MANAGED and DL_FLAG_SYNC_STATE_ONLY set, which is what
> the relaxing of the link does. But if we check for the target being
> a consumer before the check for those flags, we can check as many
> times as needed the same link and it will always return true, This is
> safe to do, since the relaxing of the link will be done only once
> because those flags will be set and it will bail early.
>
> Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
> ---
>  drivers/base/core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 753e7cca0f40..2c3b860dfe80 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -297,13 +297,13 @@ int device_is_dependent(struct device *dev, void *target)
>                 return ret;
>
>         list_for_each_entry(link, &dev->links.consumers, s_node) {
> +               if (link->consumer == target)
> +                       return 1;
> +
>                 if ((link->flags & ~DL_FLAG_INFERRED) ==
>                     (DL_FLAG_SYNC_STATE_ONLY | DL_FLAG_MANAGED))
>                         continue;

Thanks for trying to fix this issue, but I'll have to Nack this patch.

The whole point of the SYNC_STATE_ONLY flag is to allow cycles. It's
needed to maintain correctness of sync_state(). I think I described
those in the commit text that added the SYNC_STATE_ONLY flag. Check it
out if you are interested. So this change of yours will break
sync_state() functionality.

There's a bunch of nuance to fixing the dual cycle issue and I don't
mind fixing this myself in a week or two if you can wait.

Thanks,
Saravana

>
> -               if (link->consumer == target)
> -                       return 1;
> -
>                 ret = device_is_dependent(link->consumer, target);
>                 if (ret)
>                         break;
> --
> 2.34.3
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC v2] driver core: Fix repeated device_is_dependent check for same link
  2022-07-07  4:51 ` Saravana Kannan
@ 2022-07-07 10:41   ` Abel Vesa
  0 siblings, 0 replies; 4+ messages in thread
From: Abel Vesa @ 2022-07-07 10:41 UTC (permalink / raw)
  To: Saravana Kannan
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, linux-arm-msm,
	Linux Kernel Mailing List

On 22-07-06 21:51:34, Saravana Kannan wrote:
> On Wed, Jul 6, 2022 at 8:54 AM Abel Vesa <abel.vesa@linaro.org> wrote:
> >
> > In case of a cyclic dependency, if the supplier is not yet available,
> > the parent of the supplier is checked for dependency. But if there are
> > more than one suppliers with the same parent, the first check returns
> > true while the next ones skip that specific link entirely because of
> > having DL_FLAG_MANAGED and DL_FLAG_SYNC_STATE_ONLY set, which is what
> > the relaxing of the link does. But if we check for the target being
> > a consumer before the check for those flags, we can check as many
> > times as needed the same link and it will always return true, This is
> > safe to do, since the relaxing of the link will be done only once
> > because those flags will be set and it will bail early.
> >
> > Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
> > ---
> >  drivers/base/core.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/base/core.c b/drivers/base/core.c
> > index 753e7cca0f40..2c3b860dfe80 100644
> > --- a/drivers/base/core.c
> > +++ b/drivers/base/core.c
> > @@ -297,13 +297,13 @@ int device_is_dependent(struct device *dev, void *target)
> >                 return ret;
> >
> >         list_for_each_entry(link, &dev->links.consumers, s_node) {
> > +               if (link->consumer == target)
> > +                       return 1;
> > +
> >                 if ((link->flags & ~DL_FLAG_INFERRED) ==
> >                     (DL_FLAG_SYNC_STATE_ONLY | DL_FLAG_MANAGED))
> >                         continue;
>
> Thanks for trying to fix this issue, but I'll have to Nack this patch.
>
> The whole point of the SYNC_STATE_ONLY flag is to allow cycles. It's
> needed to maintain correctness of sync_state(). I think I described
> those in the commit text that added the SYNC_STATE_ONLY flag. Check it
> out if you are interested. So this change of yours will break
> sync_state() functionality.
>

Fair enough.

> There's a bunch of nuance to fixing the dual cycle issue and I don't
> mind fixing this myself in a week or two if you can wait.
>

Please cc me on it.

> Thanks,
> Saravana
>
> >
> > -               if (link->consumer == target)
> > -                       return 1;
> > -
> >                 ret = device_is_dependent(link->consumer, target);
> >                 if (ret)
> >                         break;
> > --
> > 2.34.3
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-07 10:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-06 15:53 [RFC v2] driver core: Fix repeated device_is_dependent check for same link Abel Vesa
2022-07-06 15:56 ` Greg Kroah-Hartman
2022-07-07  4:51 ` Saravana Kannan
2022-07-07 10:41   ` Abel Vesa

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.