* [PATCH v3 0/2] of: property: fw_devlink misc fixes
@ 2020-04-20 12:00 Nicolas Saenz Julienne
2020-04-20 12:01 ` [PATCH v3 1/2] of: property: Fix create device links for all child-supplier dependencies Nicolas Saenz Julienne
2020-04-20 12:01 ` [PATCH v3 2/2] of: property: Do not link to disabled devices Nicolas Saenz Julienne
0 siblings, 2 replies; 6+ messages in thread
From: Nicolas Saenz Julienne @ 2020-04-20 12:00 UTC (permalink / raw)
To: saravanak, linux-kernel
Cc: frowand.list, robh+dt, devicetree, gregkh, Nicolas Saenz Julienne
As I'm interested in using this feature to fine-tune Raspberry Pi 4's
device probe dependencies, I tried to get the board to boot with
fw_devlink=on. As of today's linux-next the board won't boot with that
option. I tried to address the underlying issues.
---
Changes since v2:
- Address Saravana's comments
Changes since v1:
- Address Saravana's comments
- Drop patch #3 & #4
Nicolas Saenz Julienne (2):
of: property: Fix create device links for all child-supplier
dependencies
of: property: Do not link to disabled devices
drivers/of/property.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
--
2.26.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v3 1/2] of: property: Fix create device links for all child-supplier dependencies 2020-04-20 12:00 [PATCH v3 0/2] of: property: fw_devlink misc fixes Nicolas Saenz Julienne @ 2020-04-20 12:01 ` Nicolas Saenz Julienne 2020-04-28 17:45 ` Rob Herring 2020-04-20 12:01 ` [PATCH v3 2/2] of: property: Do not link to disabled devices Nicolas Saenz Julienne 1 sibling, 1 reply; 6+ messages in thread From: Nicolas Saenz Julienne @ 2020-04-20 12:01 UTC (permalink / raw) To: saravanak, linux-kernel, Rob Herring, Frank Rowand, Greg Kroah-Hartman Cc: devicetree, Nicolas Saenz Julienne Upon adding a new device from a DT node, we scan its properties and its children's properties in order to create a consumer/supplier relationship between the device and the property provider. That said, it's possible for some of the node's children to be disabled, which will create links that'll never be fulfilled. To get around this, use the for_each_available_child_of_node() function instead of for_each_available_node() when iterating over the node's children. Fixes: d4387cd11741 ("of: property: Create device links for all child-supplier depencencies") Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Reviewed-by: Saravana Kannan <saravanak@google.com> --- Changes since v1: - Slightly reword description drivers/of/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index 252e4f6001553..dc034eb45defd 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1298,7 +1298,7 @@ static int of_link_to_suppliers(struct device *dev, if (of_link_property(dev, con_np, p->name)) ret = -ENODEV; - for_each_child_of_node(con_np, child) + for_each_available_child_of_node(con_np, child) if (of_link_to_suppliers(dev, child) && !ret) ret = -EAGAIN; -- 2.26.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/2] of: property: Fix create device links for all child-supplier dependencies 2020-04-20 12:01 ` [PATCH v3 1/2] of: property: Fix create device links for all child-supplier dependencies Nicolas Saenz Julienne @ 2020-04-28 17:45 ` Rob Herring 0 siblings, 0 replies; 6+ messages in thread From: Rob Herring @ 2020-04-28 17:45 UTC (permalink / raw) To: Nicolas Saenz Julienne Cc: saravanak, linux-kernel, Frank Rowand, Greg Kroah-Hartman, devicetree, Nicolas Saenz Julienne On Mon, 20 Apr 2020 14:01:01 +0200, Nicolas Saenz Julienne wrote: > Upon adding a new device from a DT node, we scan its properties and its > children's properties in order to create a consumer/supplier > relationship between the device and the property provider. > > That said, it's possible for some of the node's children to be disabled, > which will create links that'll never be fulfilled. > > To get around this, use the for_each_available_child_of_node() function > instead of for_each_available_node() when iterating over the node's > children. > > Fixes: d4387cd11741 ("of: property: Create device links for all child-supplier depencencies") > Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> > Reviewed-by: Saravana Kannan <saravanak@google.com> > > --- > > Changes since v1: > - Slightly reword description > > drivers/of/property.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > Applied, thanks. Rob ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 2/2] of: property: Do not link to disabled devices 2020-04-20 12:00 [PATCH v3 0/2] of: property: fw_devlink misc fixes Nicolas Saenz Julienne 2020-04-20 12:01 ` [PATCH v3 1/2] of: property: Fix create device links for all child-supplier dependencies Nicolas Saenz Julienne @ 2020-04-20 12:01 ` Nicolas Saenz Julienne 2020-04-20 16:51 ` Saravana Kannan 2020-04-28 17:46 ` Rob Herring 1 sibling, 2 replies; 6+ messages in thread From: Nicolas Saenz Julienne @ 2020-04-20 12:01 UTC (permalink / raw) To: saravanak, linux-kernel, Rob Herring, Frank Rowand, Greg Kroah-Hartman Cc: devicetree, Nicolas Saenz Julienne When creating a consumer/supplier relationship between two devices, make sure the supplier node is actually active. Otherwise this will create a link relationship that will never be fulfilled. This, in the worst case scenario, will hang the system during boot. Note that, in practice, the fact that a device-tree represented consumer/supplier relationship isn't fulfilled will not prevent devices from successfully probing. Fixes: a3e1d1a7f5fc ("of: property: Add functional dependency link from DT bindings") Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> --- Changes since v2: - Correct code comment - Use already available return handling code Changes since v1: - Move availability check into the compatible search code and stop if node disabled drivers/of/property.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index dc034eb45defd..7bcf31ba717d8 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1045,8 +1045,20 @@ static int of_link_to_phandle(struct device *dev, struct device_node *sup_np, * Find the device node that contains the supplier phandle. It may be * @sup_np or it may be an ancestor of @sup_np. */ - while (sup_np && !of_find_property(sup_np, "compatible", NULL)) + while (sup_np) { + + /* Don't allow linking to a disabled supplier */ + if (!of_device_is_available(sup_np)) { + of_node_put(sup_np); + sup_np = NULL; + } + + if (of_find_property(sup_np, "compatible", NULL)) + break; + sup_np = of_get_next_parent(sup_np); + } + if (!sup_np) { dev_dbg(dev, "Not linking to %pOFP - No device\n", tmp_np); return -ENODEV; -- 2.26.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 2/2] of: property: Do not link to disabled devices 2020-04-20 12:01 ` [PATCH v3 2/2] of: property: Do not link to disabled devices Nicolas Saenz Julienne @ 2020-04-20 16:51 ` Saravana Kannan 2020-04-28 17:46 ` Rob Herring 1 sibling, 0 replies; 6+ messages in thread From: Saravana Kannan @ 2020-04-20 16:51 UTC (permalink / raw) To: Nicolas Saenz Julienne Cc: LKML, Rob Herring, Frank Rowand, Greg Kroah-Hartman, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS On Mon, Apr 20, 2020 at 5:02 AM Nicolas Saenz Julienne <nsaenzjulienne@suse.de> wrote: > > When creating a consumer/supplier relationship between two devices, > make sure the supplier node is actually active. Otherwise this will > create a link relationship that will never be fulfilled. This, in the > worst case scenario, will hang the system during boot. > > Note that, in practice, the fact that a device-tree represented > consumer/supplier relationship isn't fulfilled will not prevent devices > from successfully probing. > > Fixes: a3e1d1a7f5fc ("of: property: Add functional dependency link from DT bindings") > Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> > > --- > > Changes since v2: > - Correct code comment > - Use already available return handling code > > Changes since v1: > - Move availability check into the compatible search code and stop if > node disabled > > drivers/of/property.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/of/property.c b/drivers/of/property.c > index dc034eb45defd..7bcf31ba717d8 100644 > --- a/drivers/of/property.c > +++ b/drivers/of/property.c > @@ -1045,8 +1045,20 @@ static int of_link_to_phandle(struct device *dev, struct device_node *sup_np, > * Find the device node that contains the supplier phandle. It may be > * @sup_np or it may be an ancestor of @sup_np. > */ > - while (sup_np && !of_find_property(sup_np, "compatible", NULL)) > + while (sup_np) { > + > + /* Don't allow linking to a disabled supplier */ > + if (!of_device_is_available(sup_np)) { > + of_node_put(sup_np); > + sup_np = NULL; > + } > + > + if (of_find_property(sup_np, "compatible", NULL)) > + break; > + > sup_np = of_get_next_parent(sup_np); > + } > + > if (!sup_np) { > dev_dbg(dev, "Not linking to %pOFP - No device\n", tmp_np); > return -ENODEV; Thanks for the fix! Reviewed-by: Saravana Kannan <saravanak@google.com> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 2/2] of: property: Do not link to disabled devices 2020-04-20 12:01 ` [PATCH v3 2/2] of: property: Do not link to disabled devices Nicolas Saenz Julienne 2020-04-20 16:51 ` Saravana Kannan @ 2020-04-28 17:46 ` Rob Herring 1 sibling, 0 replies; 6+ messages in thread From: Rob Herring @ 2020-04-28 17:46 UTC (permalink / raw) To: Nicolas Saenz Julienne Cc: saravanak, linux-kernel, Frank Rowand, Greg Kroah-Hartman, devicetree, Nicolas Saenz Julienne On Mon, 20 Apr 2020 14:01:02 +0200, Nicolas Saenz Julienne wrote: > When creating a consumer/supplier relationship between two devices, > make sure the supplier node is actually active. Otherwise this will > create a link relationship that will never be fulfilled. This, in the > worst case scenario, will hang the system during boot. > > Note that, in practice, the fact that a device-tree represented > consumer/supplier relationship isn't fulfilled will not prevent devices > from successfully probing. > > Fixes: a3e1d1a7f5fc ("of: property: Add functional dependency link from DT bindings") > Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> > > --- > > Changes since v2: > - Correct code comment > - Use already available return handling code > > Changes since v1: > - Move availability check into the compatible search code and stop if > node disabled > > drivers/of/property.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > Applied, thanks. Rob ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-04-28 17:46 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-04-20 12:00 [PATCH v3 0/2] of: property: fw_devlink misc fixes Nicolas Saenz Julienne 2020-04-20 12:01 ` [PATCH v3 1/2] of: property: Fix create device links for all child-supplier dependencies Nicolas Saenz Julienne 2020-04-28 17:45 ` Rob Herring 2020-04-20 12:01 ` [PATCH v3 2/2] of: property: Do not link to disabled devices Nicolas Saenz Julienne 2020-04-20 16:51 ` Saravana Kannan 2020-04-28 17:46 ` Rob Herring
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).