aboutsummaryrefslogtreecommitdiff
path: root/drivers/power/domain
diff options
context:
space:
mode:
authorAnatolij Gustschin <agust@denx.de>2020-02-17 09:42:11 +0100
committerTom Rini <trini@konsulko.com>2020-03-10 16:29:38 -0400
commit3e4fcfa4bcd74fee409694d24ee580a2826bbe9a (patch)
tree248e496480646b0b3d8a9308efff9fdb8a74ffeb /drivers/power/domain
parent3a1cb953085ecca1dd2f87288375801ebd580bab (diff)
downloadu-boot-3e4fcfa4bcd74fee409694d24ee580a2826bbe9a.zip
u-boot-3e4fcfa4bcd74fee409694d24ee580a2826bbe9a.tar.gz
u-boot-3e4fcfa4bcd74fee409694d24ee580a2826bbe9a.tar.bz2
power-domain: fix hang in endless loop on i.MX8
Currently when booting the kernel on i.MX8 U-Boot hangs in an endless loop when switching off dma, connectivity or lsio power domains during device removal. It hapens first when removing gpio0 (gpio@5d080000) device, here its power domain device 'lsio_gpio0' is obtained for switching off power. Since the obtained 'lsio_gpio0' device is removed afterwards, its power domain is also switched off and here the parent power domain device 'lsio_power_domain' is optained for switching off the power. Thereafter, when the obtained 'lsio_power_domain' is removed, device_remove() removes its first child 'lsio_gpio0'. During this child removal the 'lsio_power_domain' device is obtained again for switching and when removing it later, the same child removal is repeated, so we are stuck in an endless loop. Below is a snippet from dm tree on i.MX8QXP for better illustration of the DM devices relationship: Class Index Probed Driver Name ----------------------------------------------------------- root 0 [ + ] root_driver root_driver ... simple_bus 0 [ + ] generic_simple_bus |-- imx8qx-pm power_doma 0 [ + ] imx8_power_domain | |-- lsio_power_domain power_doma 1 [ + ] imx8_power_domain | | |-- lsio_gpio0 power_doma 2 [ + ] imx8_power_domain | | |-- lsio_gpio1 Do not remove a power domain device if it is a parent of the currently controlled device. Fixes: 52edfed65de9 ("dm: core: device: switch off power domain after device removal") Signed-off-by: Anatolij Gustschin <agust@denx.de> Reported-by: Oliver Graute <oliver.graute@gmail.com> Reported-by: Fabio Estevam <festevam@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com> Tested-by: Fabio Estevam <festevam@gmail.com>
Diffstat (limited to 'drivers/power/domain')
-rw-r--r--drivers/power/domain/power-domain-uclass.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/power/domain/power-domain-uclass.c b/drivers/power/domain/power-domain-uclass.c
index d9c623b..2b7a1cb 100644
--- a/drivers/power/domain/power-domain-uclass.c
+++ b/drivers/power/domain/power-domain-uclass.c
@@ -128,6 +128,17 @@ static int dev_power_domain_ctrl(struct udevice *dev, bool on)
}
/*
+ * For platforms with parent and child power-domain devices
+ * we may not run device_remove() on the power-domain parent
+ * because it will result in removing its children and switching
+ * off their power-domain parent. So we will get here again and
+ * again and will be stuck in an endless loop.
+ */
+ if (!on && dev_get_parent(dev) == pd.dev &&
+ device_get_uclass_id(dev) == UCLASS_POWER_DOMAIN)
+ return ret;
+
+ /*
* power_domain_get() bound the device, thus
* we must remove it again to prevent unbinding
* active devices (which would result in unbind