On Wed, Mar 25, 2026 at 03:35:39PM +0100, Herve Codina wrote:
> Device-tree node can be created when CONFIG_PCI_DYNAMIC_OF_NODES. Those
> node are created and filled based on PCI core information but the
> fwnode device field is not set.
s/Those node are/Those nodes are/
> When later an overlay is applied, this confuses fw_devlink. Indeed,
> without any device attached to the node, fw_devlink considers that this
> node will never become a device. When this node is pointed as a
> supplier, devlink looks at its ancestors in order to find a node with a
> device that could be used as the supplier.
>
> In the PCI use case, this leads to links that wrongly use the PCI root
> bridge device as the supplier instead of the expected PCI device.
>
> Setting the fwnode device to the device of the PCI device allows devlink
> to use this device as a supplier and so, correct links are created.
>
> Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
> drivers/pci/of.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/pci/of.c b/drivers/pci/of.c
> index 5fb7f501fd35..b694fcda16b1 100644
> --- a/drivers/pci/of.c
> +++ b/drivers/pci/of.c
> @@ -709,6 +709,13 @@ void of_pci_make_dev_node(struct pci_dev *pdev)
> if (ret)
> goto out_free_node;
>
> + /*
> + * Set the fwnode device in order to have fw_devlink creating links
> + * pointing to this PCI device instead of walking up to the PCI host
> + * bridge.
> + */
> + fw_devlink_set_device(&np->fwnode, &pdev->dev);
> +
> ret = of_changeset_apply(cset);
> if (ret)
> goto out_free_node;
> --
> 2.53.0
>