[v3,4/4] of: property: fw_devlink: Add support for "post-init-providers" property

Message ID 20240221233026.2915061-5-saravanak@google.com
State New
Headers
Series Add post-init-providers binding to improve suspend/resume stability |

Commit Message

Saravana Kannan Feb. 21, 2024, 11:30 p.m. UTC
  Add support for this property so that dependency cycles can be broken and
fw_devlink can do better probe/suspend/resume ordering between devices in a
dependency cycle.

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

Comments

Andy Shevchenko Feb. 22, 2024, 1:32 p.m. UTC | #1
On Wed, Feb 21, 2024 at 03:30:24PM -0800, Saravana Kannan wrote:
> Add support for this property so that dependency cycles can be broken and
> fw_devlink can do better probe/suspend/resume ordering between devices in a
> dependency cycle.

..

> -	fwnode_link_add(of_fwnode_handle(con_np), of_fwnode_handle(sup_np), 0);
> +	fwnode_link_add(of_fwnode_handle(con_np), of_fwnode_handle(sup_np),
> +			flags);

I would leave it one line despite being 83 characters long.

..

> -			of_link_to_phandle(con_dev_np, phandle);
> +			of_link_to_phandle(con_dev_np, phandle,
> +					   s->fwlink_flags);

I would leave this on one line, it's only 81 characters.
  
Saravana Kannan Feb. 23, 2024, 12:03 a.m. UTC | #2
On Thu, Feb 22, 2024 at 5:32 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Wed, Feb 21, 2024 at 03:30:24PM -0800, Saravana Kannan wrote:
> > Add support for this property so that dependency cycles can be broken and
> > fw_devlink can do better probe/suspend/resume ordering between devices in a
> > dependency cycle.
>
> ...
>
> > -     fwnode_link_add(of_fwnode_handle(con_np), of_fwnode_handle(sup_np), 0);
> > +     fwnode_link_add(of_fwnode_handle(con_np), of_fwnode_handle(sup_np),
> > +                     flags);
>
> I would leave it one line despite being 83 characters long.
>
> ...
>
> > -                     of_link_to_phandle(con_dev_np, phandle);
> > +                     of_link_to_phandle(con_dev_np, phandle,
> > +                                        s->fwlink_flags);
>
> I would leave this on one line, it's only 81 characters.

I don't have a strong opinion either way. If I need to send another
revision out, I'll address this (if checkpatch doesn't complain).

-Saravana
  
Rob Herring Feb. 23, 2024, 5:37 p.m. UTC | #3
On Thu, Feb 22, 2024 at 5:04 PM Saravana Kannan <saravanak@google.com> wrote:
>
> On Thu, Feb 22, 2024 at 5:32 AM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > On Wed, Feb 21, 2024 at 03:30:24PM -0800, Saravana Kannan wrote:
> > > Add support for this property so that dependency cycles can be broken and
> > > fw_devlink can do better probe/suspend/resume ordering between devices in a
> > > dependency cycle.
> >
> > ...
> >
> > > -     fwnode_link_add(of_fwnode_handle(con_np), of_fwnode_handle(sup_np), 0);
> > > +     fwnode_link_add(of_fwnode_handle(con_np), of_fwnode_handle(sup_np),
> > > +                     flags);
> >
> > I would leave it one line despite being 83 characters long.
> >
> > ...
> >
> > > -                     of_link_to_phandle(con_dev_np, phandle);
> > > +                     of_link_to_phandle(con_dev_np, phandle,
> > > +                                        s->fwlink_flags);
> >
> > I would leave this on one line, it's only 81 characters.
>
> I don't have a strong opinion either way. If I need to send another
> revision out, I'll address this (if checkpatch doesn't complain).

My terminal is >80 chars, so 1 line is good.

Rob
  

Patch

diff --git a/drivers/of/property.c b/drivers/of/property.c
index bce849f21ae2..15ccad6cba4a 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -1066,7 +1066,8 @@  of_fwnode_device_get_match_data(const struct fwnode_handle *fwnode,
 }
 
 static void of_link_to_phandle(struct device_node *con_np,
-			      struct device_node *sup_np)
+			      struct device_node *sup_np,
+			      u8 flags)
 {
 	struct device_node *tmp_np = of_node_get(sup_np);
 
@@ -1085,7 +1086,8 @@  static void of_link_to_phandle(struct device_node *con_np,
 		tmp_np = of_get_next_parent(tmp_np);
 	}
 
-	fwnode_link_add(of_fwnode_handle(con_np), of_fwnode_handle(sup_np), 0);
+	fwnode_link_add(of_fwnode_handle(con_np), of_fwnode_handle(sup_np),
+			flags);
 }
 
 /**
@@ -1198,6 +1200,8 @@  static struct device_node *parse_##fname(struct device_node *np,	     \
  *		 to a struct device, implement this ops so fw_devlink can use it
  *		 to find the true consumer.
  * @optional: Describes whether a supplier is mandatory or not
+ * @fwlink_flags: Optional fwnode link flags to use when creating a fwnode link
+ *		  for this property.
  *
  * Returns:
  * parse_prop() return values are
@@ -1210,6 +1214,7 @@  struct supplier_bindings {
 					  const char *prop_name, int index);
 	struct device_node *(*get_con_dev)(struct device_node *np);
 	bool optional;
+	u8 fwlink_flags;
 };
 
 DEFINE_SIMPLE_PROP(clocks, "clocks", "#clock-cells")
@@ -1240,6 +1245,7 @@  DEFINE_SIMPLE_PROP(leds, "leds", NULL)
 DEFINE_SIMPLE_PROP(backlight, "backlight", NULL)
 DEFINE_SIMPLE_PROP(panel, "panel", NULL)
 DEFINE_SIMPLE_PROP(msi_parent, "msi-parent", "#msi-cells")
+DEFINE_SIMPLE_PROP(post_init_providers, "post-init-providers", NULL)
 DEFINE_SUFFIX_PROP(regulators, "-supply", NULL)
 DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells")
 
@@ -1349,6 +1355,10 @@  static const struct supplier_bindings of_supplier_bindings[] = {
 	{ .parse_prop = parse_regulators, },
 	{ .parse_prop = parse_gpio, },
 	{ .parse_prop = parse_gpios, },
+	{
+		.parse_prop = parse_post_init_providers,
+		.fwlink_flags = FWLINK_FLAG_IGNORE,
+	},
 	{}
 };
 
@@ -1393,7 +1403,8 @@  static int of_link_property(struct device_node *con_np, const char *prop_name)
 					: of_node_get(con_np);
 			matched = true;
 			i++;
-			of_link_to_phandle(con_dev_np, phandle);
+			of_link_to_phandle(con_dev_np, phandle,
+					   s->fwlink_flags);
 			of_node_put(phandle);
 			of_node_put(con_dev_np);
 		}