linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of: platform: Destroy child devices symmetrically
@ 2020-08-06 15:36 Thierry Reding
  2020-08-17 21:53 ` Rob Herring
  0 siblings, 1 reply; 2+ messages in thread
From: Thierry Reding @ 2020-08-06 15:36 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand; +Cc: devicetree, linux-kernel

From: Thierry Reding <treding@nvidia.com>

Iterate over child devices in reverse when unpopulating a platform
device to make this step symmetrical with the population step. This
fixes an issue in the Tegra DRM driver where upon module unload the
DPAUX controller tries to unregister an I2C controller but will end
up waiting indefinitely because one of the SOR devices is keeping a
reference to it. Since the SOR devices are instantiated after the
DPAUX devices, they would only be removed (and hence release their
reference to the I2C controller) after the DPAUX devices have been
removed.

While destroying the child devices in reverse order helps in this
situation, it isn't fully safe to do so either. An even better way
would be for the child devices to be reordered to match the probe
order, which would work irrespective of the instantiation order.

However, reordering by probe order would be fairly complicated and
doesn't fix any known issues, so we'll go with the simpler fix for
now.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/of/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 071f04da32c8..b557a0fcd4ba 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -590,7 +590,7 @@ EXPORT_SYMBOL_GPL(of_platform_device_destroy);
 void of_platform_depopulate(struct device *parent)
 {
 	if (parent->of_node && of_node_check_flag(parent->of_node, OF_POPULATED_BUS)) {
-		device_for_each_child(parent, NULL, of_platform_device_destroy);
+		device_for_each_child_reverse(parent, NULL, of_platform_device_destroy);
 		of_node_clear_flag(parent->of_node, OF_POPULATED_BUS);
 	}
 }
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] of: platform: Destroy child devices symmetrically
  2020-08-06 15:36 [PATCH] of: platform: Destroy child devices symmetrically Thierry Reding
@ 2020-08-17 21:53 ` Rob Herring
  0 siblings, 0 replies; 2+ messages in thread
From: Rob Herring @ 2020-08-17 21:53 UTC (permalink / raw)
  To: Thierry Reding; +Cc: devicetree, Frank Rowand, Rob Herring, linux-kernel

On Thu, 06 Aug 2020 17:36:50 +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> Iterate over child devices in reverse when unpopulating a platform
> device to make this step symmetrical with the population step. This
> fixes an issue in the Tegra DRM driver where upon module unload the
> DPAUX controller tries to unregister an I2C controller but will end
> up waiting indefinitely because one of the SOR devices is keeping a
> reference to it. Since the SOR devices are instantiated after the
> DPAUX devices, they would only be removed (and hence release their
> reference to the I2C controller) after the DPAUX devices have been
> removed.
> 
> While destroying the child devices in reverse order helps in this
> situation, it isn't fully safe to do so either. An even better way
> would be for the child devices to be reordered to match the probe
> order, which would work irrespective of the instantiation order.
> 
> However, reordering by probe order would be fairly complicated and
> doesn't fix any known issues, so we'll go with the simpler fix for
> now.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/of/platform.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Applied, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-17 21:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-06 15:36 [PATCH] of: platform: Destroy child devices symmetrically Thierry Reding
2020-08-17 21:53 ` 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).