of: property: fw_devlink misc fixes
v3 cover of: property: fw_devlink misc fixes
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(-)
Signature · 1 line
2.26.0
PATCH v3 1/2 of: property: Fix create device links for all child-supplier dependencies
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.
---
Changes since v1:
- Slightly reword description
drivers/of/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/property.c +1 -1
@@ -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 ;
Signature · 1 line
2.26.0
Re: [PATCH v3 1/2] of: property: Fix create device links for all child-supplier dependencies
Quoted 15 lines · 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 offor_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 <[email protected]>Reviewed-by Saravana Kannan <[email protected]>
Quoted 8 lines
---
Changes since v1:
- Slightly reword descriptiondrivers/of/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
Rob
PATCH v3 2/2 of: property: Do not link to disabled devices
In reply to Nicolas Saenz JulienneWhen 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.
---
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(-)
drivers/of/property.c +13 -1
@@ -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 ;
Signature · 1 line
2.26.0
Re: [PATCH v3 2/2] of: property: Do not link to disabled devices
Quoted 42 lines · 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 <[email protected]>---
Changes since v2:
- Correct code comment
- Use already available return handling codeChanges since v1:
- Move availability check into the compatible search code and stop if node disableddrivers/of/property.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)drivers/of/property.c +7
-1@@ -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 ; + }
drivers/of/property.c static int of_link_to_phandle(struct device *dev, struct device_node *sup_np, · line 1064
Quoted 10 lines
drivers/of/property.c +6
-0+ +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!
Re: [PATCH v3 2/2] of: property: Do not link to disabled devices
In reply to Nicolas Saenz JulienneQuoted 18 lines · 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 <[email protected]>---
Changes since v2:
- Correct code comment
- Use already available return handling code
Quoted 7 lines
Changes since v1:
- Move availability check into the compatible search code and stop if node disableddrivers/of/property.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
Applied, thanks.
Rob