linux-stable/drivers/of
Geert Uytterhoeven 59e0dd5bef treewide: Fix probing of devices in DT overlays
commit 1a50d9403f 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>
2023-09-13 09:43:05 +02:00
..
unittest-data of: overlay: unittest: add tests for overlay notifiers 2022-05-03 11:53:15 -05:00
address.c of/address: Return an error when no valid dma-ranges are found 2023-02-14 19:11:42 +01:00
base.c Devicetree updates for v6.1: 2022-10-10 13:13:51 -07:00
device.c of: Fix modalias string generation 2023-05-11 23:03:28 +09:00
dynamic.c treewide: Fix probing of devices in DT overlays 2023-09-13 09:43:05 +02:00
fdt.c Revert "mm: kmemleak: alloc gray object for reserved region with direct map" 2023-02-09 11:28:20 +01:00
fdt_address.c
irq.c of: irq: Report individual failures in of_irq_init() 2022-09-07 10:54:55 -05:00
Kconfig
kexec.c mm,ima,kexec,of: use memblock_free_late from ima_free_kexec_buffer 2023-08-30 16:11:06 +02:00
kobj.c
Makefile
of_numa.c
of_private.h of: Fix "dma-ranges" handling for bus controllers 2022-09-30 14:35:43 -05:00
of_reserved_mem.c of: reserved_mem: Have kmemleak ignore dynamically allocated reserved mem 2023-02-22 12:59:46 +01:00
overlay.c of: overlay: Call of_changeset_init() early 2023-09-13 09:42:44 +02:00
pdt.c
platform.c treewide: Fix probing of devices in DT overlays 2023-09-13 09:43:05 +02:00
property.c of: property: fw_devlink: Add a devlink for panel followers 2023-09-13 09:43:04 +02:00
resolver.c
unittest.c of: unittest: Fix overlay type in apply/revert check 2023-09-13 09:42:44 +02:00