Revert "power-domain: Add refcounting"
PATCH 1/1 Revert "power-domain: Add refcounting"
Unfortunately this change breaks boot on K3 platform. U-Boot will hang after:
U-Boot SPL 2025.04-01050-ga40fc5afaec0 (Apr 14 2025 - 07:31:32 +0000) SYSFW ABI: 3.1 (firmware rev 0x0009 '9.2.7--v09.02.07 (Kool Koala)')
This reverts commit 197376fbf300e92afa0a1583815d9c9eb52d613a as suggested in [1].
[1] https://lists.denx.de/pipermail/u-boot/2025-April/587032.html
--- drivers/firmware/scmi/sandbox-scmi_devices.c | 1 - drivers/power/domain/power-domain-uclass.c | 40 ++----------- .../power/domain/sandbox-power-domain-test.c | 1 - include/power-domain.h | 60 +++---------------- test/dm/power-domain.c | 2 +- 5 files changed, 13 insertions(+), 91 deletions(-)
drivers/firmware/scmi/sandbox-scmi_devices.c +0 -1
@@ -163,5 +163,4 @@ U_BOOT_DRIVER(sandbox_scmi_devices) = { .priv_auto = sizeof(struct sandbox_scmi_device_priv), .remove = sandbox_scmi_devices_remove, .probe = sandbox_scmi_devices_probe, - .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF, };
drivers/power/domain/power-domain-uclass.c +4 -36
@@ -12,10 +12,6 @@#include <power-domain-uclass.h> #include <dm/device-internal.h> -struct power_domain_priv { -int on_count; -}; -static inline struct power_domain_ops *power_domain_dev_ops (struct udevice *dev) {return (struct power_domain_ops *)dev->driver->ops;
@@ -111,49 +107,22 @@ int power_domain_free(struct power_domain *power_domain)return ops->rfree ? ops->rfree (power_domain) :0 ; } -int power_domain_on_lowlevel (struct power_domain *power_domain) +int power_domain_on (struct power_domain *power_domain) { -struct power_domain_priv *priv =dev_get_uclass_priv (power_domain->dev);struct power_domain_ops *ops =power_domain_dev_ops (power_domain->dev); -int ret;debug ("%s(power_domain=%p)\n" , __func__, power_domain); -if (priv->on_count++ >0 ) -return -EALREADY ; - - ret = ops->on ? ops->on (power_domain) :0 ; -if (ret) { - priv->on_count--; -return ret; - } - -return 0 ; +return ops->on ? ops->on (power_domain) :0 ; } -int power_domain_off_lowlevel (struct power_domain *power_domain) +int power_domain_off (struct power_domain *power_domain) { -struct power_domain_priv *priv =dev_get_uclass_priv (power_domain->dev);struct power_domain_ops *ops =power_domain_dev_ops (power_domain->dev); -int ret;debug ("%s(power_domain=%p)\n" , __func__, power_domain); -if (priv->on_count <=0 ) { -debug ("Power domain %s already off.\n" , power_domain->dev->name); -return -EALREADY ; - } - -if (priv->on_count-- >1 ) -return -EBUSY ; - - ret = ops->off ? ops->off (power_domain) :0 ; -if (ret) { - priv->on_count++; -return ret; - } - -return 0 ; +return ops->off ? ops->off (power_domain) :0 ; }#if CONFIG_IS_ENABLED (OF_REAL )
@@ -211,5 +180,4 @@ int dev_power_domain_off(struct udevice *dev)UCLASS_DRIVER (power_domain) = { .id =UCLASS_POWER_DOMAIN , .name ="power_domain" , - .per_device_auto =sizeof (struct power_domain_priv ), };
drivers/power/domain/sandbox-power-domain-test.c +0 -1
@@ -51,5 +51,4 @@ U_BOOT_DRIVER(sandbox_power_domain_test) = { .id = UCLASS_MISC, .of_match = sandbox_power_domain_test_ids, .priv_auto = sizeof(struct sandbox_power_domain_test), - .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF, };
include/power-domain.h +8 -52
89 lines not on this page · raw message
test/dm/power-domain.c +1 -1
@@ -27,7 +27,7 @@ static int dm_test_power_domain(struct unit_test_state *uts)ut_assertok (uclass_get_device_by_name (UCLASS_MISC ,"power-domain-test" , &dev_test)); -ut_asserteq (0 ,sandbox_power_domain_query (dev_power_domain, +ut_asserteq (1 ,sandbox_power_domain_query (dev_power_domain,TEST_POWER_DOMAIN ));ut_assertok (sandbox_power_domain_test_get (dev_test));
Signature · 1 line
2.34.1
Hi Tom,
Quoted 6 lines · Wadim Egorov
Unfortunately this change breaks boot on K3 platform. U-Boot will hang after:
U-Boot SPL 2025.04-01050-ga40fc5afaec0 (Apr 14 2025 - 07:31:32 +0000) SYSFW ABI: 3.1 (firmware rev
0x0009'9.2.7--v09.02.07 (Kool Koala)')
Quoted 6 lines
This reverts commit
197376fbf300e92afa0a1583815d9c9eb52d613aas suggested in [1].[1] https://lists.denx.de/pipermail/u-boot/2025-April/587032.html
Signed-off-by Wadim Egorov <[email protected]>
This sadly needs to get in, there have been 3 or 4 reports already, as many boards are broken. We need to find another way to add refcounting (otherwise some imx8* features will stay broken), but it requires more thinking time.
Thanks,
Miquèl
Hi Miquel,
Quoted 16 lines · Miquel Raynal
Hi Tom,
Quoted 11 lines · Wadim Egorov
Unfortunately this change breaks boot on K3 platform. U-Boot will hang after:
U-Boot SPL 2025.04-01050-ga40fc5afaec0 (Apr 14 2025 - 07:31:32 +0000) SYSFW ABI: 3.1 (firmware rev
0x0009'9.2.7--v09.02.07 (Kool Koala)')This reverts commit
197376fbf300e92afa0a1583815d9c9eb52d613aas suggested in [1].[1] https://lists.denx.de/pipermail/u-boot/2025-April/587032.html
Quoted 8 lines
Quoted 1 line
Signed-off-by Wadim Egorov <[email protected]>This sadly needs to get in, there have been 3 or 4 reports already, as many boards are broken. We need to find another way to add refcounting (otherwise some imx8* features will stay broken), but it requires more thinking time.
Acked-by Miquel Raynal <[email protected]>
We had this discussion on your patch and you ended up with a 'low-level' function to provide the base functionality. But it would be easier if you retained the current behaviour and then added ref-counting to two new functions. Then people can migrate.
Of course, people perhaps won't migrate. This sort of thing is quite tricky. But I still think this would be an easier route. You could perhaps even add a Kconfig option like POWER_DOMAIN_NO_REF_COUNT which uses the current behaviour.
Regards,
Simon
Hi Simon,
Quoted 11 lines
Quoted 6 lines
This sadly needs to get in, there have been 3 or 4 reports already, as many boards are broken. We need to find another way to add refcounting (otherwise some imx8* features will stay broken), but it requires more thinking time.
Acked-by Miquel Raynal <[email protected]>We had this discussion on your patch and you ended up with a 'low-level' function to provide the base functionality. But it would be easier if you retained the current behaviour and then added ref-counting to two new functions. Then people can migrate.
It's not the fact that people are using refcounting which breaks. It is the fact that the device model does not support well the fact that one DT node might be used to picture several devices. The clock subsystem handles that by registering all clocks manually, and at some point abuses one of the uclass internal structures (there is a FIXME about that). It's not even the drivers that break.
Quoted 4 lines
Of course, people perhaps won't migrate. This sort of thing is quite tricky. But I still think this would be an easier route. You could perhaps even add a
Kconfigoption likePOWER_DOMAIN_NO_REF_COUNTwhich uses the current behaviour.
I now have an idea how to improve the power domain uclass to make it fit, let's see if that works, otherwise I might fallback to this solution indeed.
Thanks,
Miquèl
Quoted 10 lines · Wadim Egorov
Unfortunately this change breaks boot on K3 platform. U-Boot will hang after:
U-Boot SPL 2025.04-01050-ga40fc5afaec0 (Apr 14 2025 - 07:31:32 +0000) SYSFW ABI: 3.1 (firmware rev
0x0009'9.2.7--v09.02.07 (Kool Koala)')This reverts commit
197376fbf300e92afa0a1583815d9c9eb52d613aas suggested in [1].[...]
Applied to u-boot/master, thanks!
[1/1] Revert "power-domain: Add refcounting"
commit: 71f497a6d3908574a1b1c3813c2a1385910f76bd
Signature · 1 line
Tom