* [PATCH v5 1/3] driver core: Adds flags param to fwnode_link_add()
2024-03-05 5:04 [PATCH v5 0/3] Add post-init-providers binding to improve suspend/resume stability Saravana Kannan
@ 2024-03-05 5:04 ` Saravana Kannan
2024-03-05 5:04 ` [PATCH v5 2/3] driver core: Add FWLINK_FLAG_IGNORE to completely ignore a fwnode link Saravana Kannan
2024-03-05 5:04 ` [PATCH v5 3/3] of: property: fw_devlink: Add support for "post-init-providers" property Saravana Kannan
2 siblings, 0 replies; 4+ messages in thread
From: Saravana Kannan @ 2024-03-05 5:04 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Ard Biesheuvel,
Rob Herring, Frank Rowand, Andy Shevchenko, Daniel Scally,
Heikki Krogerus, Sakari Ailus, Len Brown
Cc: Saravana Kannan, kernel-team, linux-kernel, linux-efi,
devicetree, linux-acpi, Rob Herring
Allow the callers to set fwnode link flags when adding fwnode links.
Signed-off-by: Saravana Kannan <saravanak@google.com>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
---
drivers/base/core.c | 5 +++--
drivers/firmware/efi/sysfb_efi.c | 2 +-
drivers/of/property.c | 2 +-
include/linux/fwnode.h | 3 ++-
4 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 9828da9b933c..adeff041d472 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -92,12 +92,13 @@ static int __fwnode_link_add(struct fwnode_handle *con,
return 0;
}
-int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup)
+int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup,
+ u8 flags)
{
int ret;
mutex_lock(&fwnode_link_lock);
- ret = __fwnode_link_add(con, sup, 0);
+ ret = __fwnode_link_add(con, sup, flags);
mutex_unlock(&fwnode_link_lock);
return ret;
}
diff --git a/drivers/firmware/efi/sysfb_efi.c b/drivers/firmware/efi/sysfb_efi.c
index 456d0e5eaf78..cc807ed35aed 100644
--- a/drivers/firmware/efi/sysfb_efi.c
+++ b/drivers/firmware/efi/sysfb_efi.c
@@ -336,7 +336,7 @@ static int efifb_add_links(struct fwnode_handle *fwnode)
if (!sup_np)
return 0;
- fwnode_link_add(fwnode, of_fwnode_handle(sup_np));
+ fwnode_link_add(fwnode, of_fwnode_handle(sup_np), 0);
of_node_put(sup_np);
return 0;
diff --git a/drivers/of/property.c b/drivers/of/property.c
index b71267c6667c..bce849f21ae2 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -1085,7 +1085,7 @@ 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));
+ fwnode_link_add(of_fwnode_handle(con_np), of_fwnode_handle(sup_np), 0);
}
/**
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 2a72f55d26eb..c964749953e3 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -210,7 +210,8 @@ static inline void fwnode_dev_initialized(struct fwnode_handle *fwnode,
}
extern bool fw_devlink_is_strict(void);
-int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup);
+int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup,
+ u8 flags);
void fwnode_links_purge(struct fwnode_handle *fwnode);
void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode);
--
2.44.0.278.ge034bb2e1d-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v5 2/3] driver core: Add FWLINK_FLAG_IGNORE to completely ignore a fwnode link
2024-03-05 5:04 [PATCH v5 0/3] Add post-init-providers binding to improve suspend/resume stability Saravana Kannan
2024-03-05 5:04 ` [PATCH v5 1/3] driver core: Adds flags param to fwnode_link_add() Saravana Kannan
@ 2024-03-05 5:04 ` Saravana Kannan
2024-03-05 5:04 ` [PATCH v5 3/3] of: property: fw_devlink: Add support for "post-init-providers" property Saravana Kannan
2 siblings, 0 replies; 4+ messages in thread
From: Saravana Kannan @ 2024-03-05 5:04 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Ard Biesheuvel,
Rob Herring, Frank Rowand, Andy Shevchenko, Daniel Scally,
Heikki Krogerus, Sakari Ailus, Len Brown
Cc: Saravana Kannan, kernel-team, linux-kernel, linux-efi,
devicetree, linux-acpi, Rob Herring
A fwnode link between specific supplier-consumer fwnodes can be added
multiple times for multiple reasons. If that dependency doesn't exist,
deleting the fwnode link once doesn't guarantee that it won't get created
again.
So, add FWLINK_FLAG_IGNORE flag to mark a fwnode link as one that needs to
be completely ignored. Since a fwnode link's flags is an OR of all the
flags passed to all the fwnode_link_add() calls to create that specific
fwnode link, the FWLINK_FLAG_IGNORE flag is preserved and can be used to
mark a fwnode link as on that need to be completely ignored until it is
deleted.
Signed-off-by: Saravana Kannan <saravanak@google.com>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
---
drivers/base/core.c | 9 ++++++++-
include/linux/fwnode.h | 2 ++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index adeff041d472..fac017657d25 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1012,7 +1012,8 @@ static struct fwnode_handle *fwnode_links_check_suppliers(
return NULL;
list_for_each_entry(link, &fwnode->suppliers, c_hook)
- if (!(link->flags & FWLINK_FLAG_CYCLE))
+ if (!(link->flags &
+ (FWLINK_FLAG_CYCLE | FWLINK_FLAG_IGNORE)))
return link->supplier;
return NULL;
@@ -1963,6 +1964,9 @@ static bool __fw_devlink_relax_cycles(struct device *con,
}
list_for_each_entry(link, &sup_handle->suppliers, c_hook) {
+ if (link->flags & FWLINK_FLAG_IGNORE)
+ continue;
+
if (__fw_devlink_relax_cycles(con, link->supplier)) {
__fwnode_link_cycle(link);
ret = true;
@@ -2041,6 +2045,9 @@ static int fw_devlink_create_devlink(struct device *con,
int ret = 0;
u32 flags;
+ if (link->flags & FWLINK_FLAG_IGNORE)
+ return 0;
+
if (con->fwnode == link->consumer)
flags = fw_devlink_get_flags(link->flags);
else
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index c964749953e3..21699eee9641 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -53,8 +53,10 @@ struct fwnode_handle {
* fwnode link flags
*
* CYCLE: The fwnode link is part of a cycle. Don't defer probe.
+ * IGNORE: Completely ignore this link, even during cycle detection.
*/
#define FWLINK_FLAG_CYCLE BIT(0)
+#define FWLINK_FLAG_IGNORE BIT(1)
struct fwnode_link {
struct fwnode_handle *supplier;
--
2.44.0.278.ge034bb2e1d-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v5 3/3] of: property: fw_devlink: Add support for "post-init-providers" property
2024-03-05 5:04 [PATCH v5 0/3] Add post-init-providers binding to improve suspend/resume stability Saravana Kannan
2024-03-05 5:04 ` [PATCH v5 1/3] driver core: Adds flags param to fwnode_link_add() Saravana Kannan
2024-03-05 5:04 ` [PATCH v5 2/3] driver core: Add FWLINK_FLAG_IGNORE to completely ignore a fwnode link Saravana Kannan
@ 2024-03-05 5:04 ` Saravana Kannan
2 siblings, 0 replies; 4+ messages in thread
From: Saravana Kannan @ 2024-03-05 5:04 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Ard Biesheuvel,
Rob Herring, Frank Rowand, Andy Shevchenko, Daniel Scally,
Heikki Krogerus, Sakari Ailus, Len Brown
Cc: Saravana Kannan, kernel-team, linux-kernel, linux-efi,
devicetree, linux-acpi, Rob Herring
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>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
---
drivers/of/property.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/of/property.c b/drivers/of/property.c
index bce849f21ae2..b517a92dabca 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,7 @@ 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 +1199,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 +1213,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 +1244,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 +1354,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 +1402,7 @@ 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);
}
--
2.44.0.278.ge034bb2e1d-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread