[v1,4/5] of: property: Make sure child dependencies don't block probing of parent
diff mbox series

Message ID 20191028220027.251605-5-saravanak@google.com
State Accepted
Commit 0ff5cc1ec33b4b7540c4bc09f50123befc6ed947
Headers show
Series
  • Improve of_devlink to handle "proxy cycles"
Related show

Commit Message

Saravana Kannan Oct. 28, 2019, 10 p.m. UTC
When creating device links to proxy the sync_state() needs of child
dependencies, create SYNC_STATE_ONLY device links so that children
dependencies don't block probing of the parent.

Also, differentiate between missing suppliers of parent device vs
missing suppliers of child devices so that driver core doesn't block
parent device probing when only child supplier dependencies are missing.

Signed-off-by: Saravana Kannan <saravanak@google.com>
---
 drivers/of/property.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

Comments

Rob Herring Nov. 4, 2019, 5:01 p.m. UTC | #1
On Mon, Oct 28, 2019 at 5:00 PM Saravana Kannan <saravanak@google.com> wrote:
>
> When creating device links to proxy the sync_state() needs of child
> dependencies, create SYNC_STATE_ONLY device links so that children
> dependencies don't block probing of the parent.
>
> Also, differentiate between missing suppliers of parent device vs
> missing suppliers of child devices so that driver core doesn't block
> parent device probing when only child supplier dependencies are missing.
>
> Signed-off-by: Saravana Kannan <saravanak@google.com>
> ---
>  drivers/of/property.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)

Reviewed-by: Rob Herring <robh@kernel.org>

One nit below:

>
> diff --git a/drivers/of/property.c b/drivers/of/property.c
> index 2808832b2e86..f16f85597ccc 100644
> --- a/drivers/of/property.c
> +++ b/drivers/of/property.c
> @@ -1032,10 +1032,10 @@ static bool of_is_ancestor_of(struct device_node *test_ancestor,
>   * - -EINVAL if the supplier link is invalid and should not be created
>   * - -ENODEV if there is no device that corresponds to the supplier phandle
>   */
> -static int of_link_to_phandle(struct device *dev, struct device_node *sup_np)
> +static int of_link_to_phandle(struct device *dev, struct device_node *sup_np,
> +                             u32 dl_flags)
>  {
>         struct device *sup_dev;
> -       u32 dl_flags = DL_FLAG_AUTOPROBE_CONSUMER;
>         int ret = 0;
>         struct device_node *tmp_np = sup_np;
>
> @@ -1195,13 +1195,20 @@ static int of_link_property(struct device *dev, struct device_node *con_np,
>         unsigned int i = 0;
>         bool matched = false;
>         int ret = 0;
> +       u32 dl_flags;
> +
> +       if (dev->of_node == con_np)
> +               dl_flags = DL_FLAG_AUTOPROBE_CONSUMER;
> +       else
> +               dl_flags = DL_FLAG_SYNC_STATE_ONLY;
>
>         /* Do not stop at first failed link, link all available suppliers. */
>         while (!matched && s->parse_prop) {
>                 while ((phandle = s->parse_prop(con_np, prop_name, i))) {
>                         matched = true;
>                         i++;
> -                       if (of_link_to_phandle(dev, phandle) == -EAGAIN)
> +                       if (of_link_to_phandle(dev, phandle, dl_flags)
> +                                                               == -EAGAIN)

nit: I'd just keep this one line or at least move '==' up.

>                                 ret = -EAGAIN;
>                         of_node_put(phandle);
>                 }
> @@ -1219,10 +1226,10 @@ static int of_link_to_suppliers(struct device *dev,
>
>         for_each_property_of_node(con_np, p)
>                 if (of_link_property(dev, con_np, p->name))
> -                       ret = -EAGAIN;
> +                       ret = -ENODEV;
>
>         for_each_child_of_node(con_np, child)
> -               if (of_link_to_suppliers(dev, child))
> +               if (of_link_to_suppliers(dev, child) && !ret)
>                         ret = -EAGAIN;
>
>         return ret;
> --
> 2.24.0.rc0.303.g954a862665-goog
>
Saravana Kannan Nov. 4, 2019, 7:04 p.m. UTC | #2
On Mon, Nov 4, 2019 at 9:01 AM Rob Herring <robh+dt@kernel.org> wrote:
>
> On Mon, Oct 28, 2019 at 5:00 PM Saravana Kannan <saravanak@google.com> wrote:
> >
> > When creating device links to proxy the sync_state() needs of child
> > dependencies, create SYNC_STATE_ONLY device links so that children
> > dependencies don't block probing of the parent.
> >
> > Also, differentiate between missing suppliers of parent device vs
> > missing suppliers of child devices so that driver core doesn't block
> > parent device probing when only child supplier dependencies are missing.
> >
> > Signed-off-by: Saravana Kannan <saravanak@google.com>
> > ---
> >  drivers/of/property.c | 17 ++++++++++++-----
> >  1 file changed, 12 insertions(+), 5 deletions(-)
>
> Reviewed-by: Rob Herring <robh@kernel.org>

Thank you!

> One nit below:
>
> >
> > diff --git a/drivers/of/property.c b/drivers/of/property.c
> > index 2808832b2e86..f16f85597ccc 100644
> > --- a/drivers/of/property.c
> > +++ b/drivers/of/property.c
> > @@ -1032,10 +1032,10 @@ static bool of_is_ancestor_of(struct device_node *test_ancestor,
> >   * - -EINVAL if the supplier link is invalid and should not be created
> >   * - -ENODEV if there is no device that corresponds to the supplier phandle
> >   */
> > -static int of_link_to_phandle(struct device *dev, struct device_node *sup_np)
> > +static int of_link_to_phandle(struct device *dev, struct device_node *sup_np,
> > +                             u32 dl_flags)
> >  {
> >         struct device *sup_dev;
> > -       u32 dl_flags = DL_FLAG_AUTOPROBE_CONSUMER;
> >         int ret = 0;
> >         struct device_node *tmp_np = sup_np;
> >
> > @@ -1195,13 +1195,20 @@ static int of_link_property(struct device *dev, struct device_node *con_np,
> >         unsigned int i = 0;
> >         bool matched = false;
> >         int ret = 0;
> > +       u32 dl_flags;
> > +
> > +       if (dev->of_node == con_np)
> > +               dl_flags = DL_FLAG_AUTOPROBE_CONSUMER;
> > +       else
> > +               dl_flags = DL_FLAG_SYNC_STATE_ONLY;
> >
> >         /* Do not stop at first failed link, link all available suppliers. */
> >         while (!matched && s->parse_prop) {
> >                 while ((phandle = s->parse_prop(con_np, prop_name, i))) {
> >                         matched = true;
> >                         i++;
> > -                       if (of_link_to_phandle(dev, phandle) == -EAGAIN)
> > +                       if (of_link_to_phandle(dev, phandle, dl_flags)
> > +                                                               == -EAGAIN)
>
> nit: I'd just keep this one line or at least move '==' up.

You'd keep it one line even if it's > 80 cols? Ok, I'll move the "==" up.


-Saravana

Patch
diff mbox series

diff --git a/drivers/of/property.c b/drivers/of/property.c
index 2808832b2e86..f16f85597ccc 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -1032,10 +1032,10 @@  static bool of_is_ancestor_of(struct device_node *test_ancestor,
  * - -EINVAL if the supplier link is invalid and should not be created
  * - -ENODEV if there is no device that corresponds to the supplier phandle
  */
-static int of_link_to_phandle(struct device *dev, struct device_node *sup_np)
+static int of_link_to_phandle(struct device *dev, struct device_node *sup_np,
+			      u32 dl_flags)
 {
 	struct device *sup_dev;
-	u32 dl_flags = DL_FLAG_AUTOPROBE_CONSUMER;
 	int ret = 0;
 	struct device_node *tmp_np = sup_np;
 
@@ -1195,13 +1195,20 @@  static int of_link_property(struct device *dev, struct device_node *con_np,
 	unsigned int i = 0;
 	bool matched = false;
 	int ret = 0;
+	u32 dl_flags;
+
+	if (dev->of_node == con_np)
+		dl_flags = DL_FLAG_AUTOPROBE_CONSUMER;
+	else
+		dl_flags = DL_FLAG_SYNC_STATE_ONLY;
 
 	/* Do not stop at first failed link, link all available suppliers. */
 	while (!matched && s->parse_prop) {
 		while ((phandle = s->parse_prop(con_np, prop_name, i))) {
 			matched = true;
 			i++;
-			if (of_link_to_phandle(dev, phandle) == -EAGAIN)
+			if (of_link_to_phandle(dev, phandle, dl_flags)
+								== -EAGAIN)
 				ret = -EAGAIN;
 			of_node_put(phandle);
 		}
@@ -1219,10 +1226,10 @@  static int of_link_to_suppliers(struct device *dev,
 
 	for_each_property_of_node(con_np, p)
 		if (of_link_property(dev, con_np, p->name))
-			ret = -EAGAIN;
+			ret = -ENODEV;
 
 	for_each_child_of_node(con_np, child)
-		if (of_link_to_suppliers(dev, child))
+		if (of_link_to_suppliers(dev, child) && !ret)
 			ret = -EAGAIN;
 
 	return ret;