treewide: Fix probing of devices in DT overlays
commit1a50d9403f
upstream. When loading a DT overlay that creates a device, the device is not probed, unless the DT overlay is unloaded and reloaded again. After the recent refactoring to improve fw_devlink, it no longer depends on the "compatible" property to identify which device tree nodes will become struct devices. fw_devlink now picks up dangling consumers (consumers pointing to descendent device tree nodes of a device that aren't converted to child devices) when a device is successfully bound to a driver. See __fw_devlink_pickup_dangling_consumers(). However, during DT overlay, a device's device tree node can have sub-nodes added/removed without unbinding/rebinding the driver. This difference in behavior between the normal device instantiation and probing flow vs. the DT overlay flow has a bunch of implications that are pointed out elsewhere[1]. One of them is that the fw_devlink logic to pick up dangling consumers is never exercised. This patch solves the fw_devlink issue by marking all DT nodes added by DT overlays with FWNODE_FLAG_NOT_DEVICE (fwnode that won't become device), and by clearing the flag when a struct device is actually created for the DT node. This way, fw_devlink knows not to have consumers waiting on these newly added DT nodes, and to propagate the dependency to an ancestor DT node that has the corresponding struct device. Based on a patch by Saravana Kannan, which covered only platform and spi devices. [1] https://lore.kernel.org/r/CAGETcx_bkuFaLCiPrAWCPQz+w79ccDp6=9e881qmK=vx3hBMyg@mail.gmail.com Fixes:4a032827da
("of: property: Simplify of_link_to_phandle()") Link: https://lore.kernel.org/r/CAGETcx_+rhHvaC_HJXGrr5_WAd2+k5f=rWYnkCZ6z5bGX-wj4w@mail.gmail.com Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Mark Brown <broonie@kernel.org> Acked-by: Wolfram Sang <wsa@kernel.org> # for I2C Acked-by: Shawn Guo <shawnguo@kernel.org> Acked-by: Saravana Kannan <saravanak@google.com> Tested-by: Ivan Bornyakov <i.bornyakov@metrotek.ru> Link: https://lore.kernel.org/r/e1fa546682ea4c8474ff997ab6244c5e11b6f8bc.1680182615.git.geert+renesas@glider.be Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
abb597c85a
commit
59e0dd5bef
|
@ -331,6 +331,12 @@ static int of_weim_notify(struct notifier_block *nb, unsigned long action,
|
||||||
"Failed to setup timing for '%pOF'\n", rd->dn);
|
"Failed to setup timing for '%pOF'\n", rd->dn);
|
||||||
|
|
||||||
if (!of_node_check_flag(rd->dn, OF_POPULATED)) {
|
if (!of_node_check_flag(rd->dn, OF_POPULATED)) {
|
||||||
|
/*
|
||||||
|
* Clear the flag before adding the device so that
|
||||||
|
* fw_devlink doesn't skip adding consumers to this
|
||||||
|
* device.
|
||||||
|
*/
|
||||||
|
rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE;
|
||||||
if (!of_platform_device_create(rd->dn, NULL, &pdev->dev)) {
|
if (!of_platform_device_create(rd->dn, NULL, &pdev->dev)) {
|
||||||
dev_err(&pdev->dev,
|
dev_err(&pdev->dev,
|
||||||
"Failed to create child device '%pOF'\n",
|
"Failed to create child device '%pOF'\n",
|
||||||
|
|
|
@ -244,6 +244,11 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action,
|
||||||
return NOTIFY_OK;
|
return NOTIFY_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Clear the flag before adding the device so that fw_devlink
|
||||||
|
* doesn't skip adding consumers to this device.
|
||||||
|
*/
|
||||||
|
rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE;
|
||||||
client = of_i2c_register_device(adap, rd->dn);
|
client = of_i2c_register_device(adap, rd->dn);
|
||||||
if (IS_ERR(client)) {
|
if (IS_ERR(client)) {
|
||||||
dev_err(&adap->dev, "failed to create client for '%pOF'\n",
|
dev_err(&adap->dev, "failed to create client for '%pOF'\n",
|
||||||
|
|
|
@ -225,6 +225,7 @@ static void __of_attach_node(struct device_node *np)
|
||||||
np->sibling = np->parent->child;
|
np->sibling = np->parent->child;
|
||||||
np->parent->child = np;
|
np->parent->child = np;
|
||||||
of_node_clear_flag(np, OF_DETACHED);
|
of_node_clear_flag(np, OF_DETACHED);
|
||||||
|
np->fwnode.flags |= FWNODE_FLAG_NOT_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -741,6 +741,11 @@ static int of_platform_notify(struct notifier_block *nb,
|
||||||
if (of_node_check_flag(rd->dn, OF_POPULATED))
|
if (of_node_check_flag(rd->dn, OF_POPULATED))
|
||||||
return NOTIFY_OK;
|
return NOTIFY_OK;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Clear the flag before adding the device so that fw_devlink
|
||||||
|
* doesn't skip adding consumers to this device.
|
||||||
|
*/
|
||||||
|
rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE;
|
||||||
/* pdev_parent may be NULL when no bus platform device */
|
/* pdev_parent may be NULL when no bus platform device */
|
||||||
pdev_parent = of_find_device_by_node(rd->dn->parent);
|
pdev_parent = of_find_device_by_node(rd->dn->parent);
|
||||||
pdev = of_platform_device_create(rd->dn, NULL,
|
pdev = of_platform_device_create(rd->dn, NULL,
|
||||||
|
|
|
@ -4370,6 +4370,11 @@ static int of_spi_notify(struct notifier_block *nb, unsigned long action,
|
||||||
return NOTIFY_OK;
|
return NOTIFY_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Clear the flag before adding the device so that fw_devlink
|
||||||
|
* doesn't skip adding consumers to this device.
|
||||||
|
*/
|
||||||
|
rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE;
|
||||||
spi = of_register_spi_device(ctlr, rd->dn);
|
spi = of_register_spi_device(ctlr, rd->dn);
|
||||||
put_device(&ctlr->dev);
|
put_device(&ctlr->dev);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue