linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] pmdomain: bcm: bcm2835-power: check if the ASB register is equal to enable
@ 2023-10-24 10:10 Maíra Canal
  2023-10-24 10:43 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Maíra Canal @ 2023-10-24 10:10 UTC (permalink / raw)
  To: Ulf Hansson, Florian Fainelli, Ray Jui, Scott Branden,
	Nick Alcock, Peter Robinson, Lee Jones, Stefan Wahren,
	Melissa Wen
  Cc: bcm-kernel-feedback-list, linux-pm, linux-rpi-kernel,
	linux-arm-kernel, kernel-dev, 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.

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.

[v2]:
    * Use the !! operator to assure the correct assertion (Stefan Wahren)

[v3]:
    * Include a changelog (Stefan Wahren)
    * Include Florian's and Stefan's Reviewed-by

Fixes: c494a447c14e ("soc: bcm: bcm2835-power: Refactor ASB control")
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/pmdomain/bcm/bcm2835-power.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pmdomain/bcm/bcm2835-power.c b/drivers/pmdomain/bcm/bcm2835-power.c
index 1a179d4e011c..d2f0233cb620 100644
--- a/drivers/pmdomain/bcm/bcm2835-power.c
+++ b/drivers/pmdomain/bcm/bcm2835-power.c
@@ -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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3] pmdomain: bcm: bcm2835-power: check if the ASB register is equal to enable
  2023-10-24 10:10 [PATCH v3] pmdomain: bcm: bcm2835-power: check if the ASB register is equal to enable Maíra Canal
@ 2023-10-24 10:43 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2023-10-24 10:43 UTC (permalink / raw)
  To: Maíra Canal
  Cc: Florian Fainelli, Ray Jui, Scott Branden, Nick Alcock,
	Peter Robinson, Lee Jones, Stefan Wahren, Melissa Wen,
	bcm-kernel-feedback-list, linux-pm, linux-rpi-kernel,
	linux-arm-kernel, kernel-dev

On Tue, 24 Oct 2023 at 12:13, Maíra Canal <mcanal@igalia.com> wrote:
>
> 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.
>
> [v2]:
>     * Use the !! operator to assure the correct assertion (Stefan Wahren)
>
> [v3]:
>     * Include a changelog (Stefan Wahren)
>     * Include Florian's and Stefan's Reviewed-by

The version information belongs a few lines below.

>
> Fixes: c494a447c14e ("soc: bcm: bcm2835-power: Refactor ASB control")
> Signed-off-by: Maíra Canal <mcanal@igalia.com>
> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
> Reviewed-by: Stefan Wahren <stefan.wahren@i2se.com>

No need to resend this time. I have amended the patch to remove the
version information from the commit message, applied it for fixes and
added a stable tag!

Kind regards
Uffe

> ---

This is where you manually need to edit the format patch-file to add
the version information.

End the section with three dashes and a newline, like below:

---
>  drivers/pmdomain/bcm/bcm2835-power.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pmdomain/bcm/bcm2835-power.c b/drivers/pmdomain/bcm/bcm2835-power.c
> index 1a179d4e011c..d2f0233cb620 100644
> --- a/drivers/pmdomain/bcm/bcm2835-power.c
> +++ b/drivers/pmdomain/bcm/bcm2835-power.c
> @@ -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
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2023-10-24 10:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-24 10:10 [PATCH v3] pmdomain: bcm: bcm2835-power: check if the ASB register is equal to enable Maíra Canal
2023-10-24 10:43 ` Ulf Hansson

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).