Skip to contentSkip to conversation

pmdomain: bcm: bcm2835-power: check if the ASB register is equal to enable

PATCH Superseded Maíra Canal 3 participants 3 messages Oct 23, 2023 – Oct 24, 2023

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 pmdomain: bcm: bcm2835-power: check if the ASB register is equal to enable

The commit c494a447c14e ("soc: bcm: bcm2835-power: Refactor ASB control") refactored the ASB control by using a general function to handle both the enable and disable. But this patch introduced a subtle regression:
we need to check if !!(readl(base + reg) & ASB_ACK) == enable, not just check if (readl(base + reg) & ASB_ACK) == true.

Currently, this is causing an invalid register state in V3D when unloading and loading the driver, because bcm2835_asb_disable() will return -ETIMEDOUT and bcm2835_asb_power_off() will fail to disable the ASB slave for V3D.

Fixes c494a447c14e ("soc: bcm: bcm2835-power: Refactor ASB control")
---
 drivers/pmdomain/bcm/bcm2835-power.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pmdomain/bcm/bcm2835-power.c +1 -1
index 1a179d4e011c..d2f0233cb620 100644
@@ -175,7 +175,7 @@ static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable
 	}
 	writel(PM_PASSWORD | val, base + reg);
 
-	while (readl(base + reg) & ASB_ACK) {
+	while (!!(readl(base + reg) & ASB_ACK) == enable) {
 		cpu_relax();
 		if (ktime_get_ns() - start >= 1000)
 			return -ETIMEDOUT;

--
2.41.0

maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Maíra Canal

The commit c494a447c14e ("soc: bcm: bcm2835-power: Refactor ASB control") refactored the ASB control by using a general function to handle both the enable and disable. But this patch introduced a subtle regression:
we need to check if !!(readl(base + reg) & ASB_ACK) == enable, not just check if (readl(base + reg) & ASB_ACK) == true.

Quoted 7 lines

Currently, this is causing an invalid register state in V3D when unloading and loading the driver, because bcm2835_asb_disable() will return -ETIMEDOUT and bcm2835_asb_power_off() will fail to disable the ASB slave for V3D.

Fixes c494a447c14e ("soc: bcm: bcm2835-power: Refactor ASB control")

Good catch!

Signature · 1 line
Florian
Reviewed-by on v2 1/1
#2 lore raw
In reply to Maíra Canal

Hi Maíra,

Am 24.10.23 um 01:35 schrieb Maíra Canal:

Quoted 6 lines

The commit c494a447c14e ("soc: bcm: bcm2835-power: Refactor ASB control") refactored the ASB control by using a general function to handle both the enable and disable. But this patch introduced a subtle regression:
we need to check if !!(readl(base + reg) & ASB_ACK) == enable, not just check if (readl(base + reg) & ASB_ACK) == true.

Quoted 8 lines

Currently, this is causing an invalid register state in V3D when unloading and loading the driver, because bcm2835_asb_disable() will return -ETIMEDOUT and bcm2835_asb_power_off() will fail to disable the ASB slave for V3D.

Fixes c494a447c14e ("soc: bcm: bcm2835-power: Refactor ASB control")

---

could you please resubmit with a proper changelog (including the Reviewed-bys) of this patch?

Thanks

Quoted 19 lines
  drivers/pmdomain/bcm/bcm2835-power.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pmdomain/bcm/bcm2835-power.c +1 -2
index 1a179d4e011c..d2f0233cb620 100644
@@ -175,7 +175,7 @@ static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable
  	}
  	writel(PM_PASSWORD | val, base + reg);
 
-	while (readl(base + reg) & ASB_ACK) {
+	while (!!(readl(base + reg) & ASB_ACK) == enable) {
  		cpu_relax();
  		if (ktime_get_ns() - start >= 1000)
  			return -ETIMEDOUT;
--

2.41.0