Re: Regression, thermal: core: battery reading wrong after wake from S3 [Was: Bug Report according to thermal_core.c]

From: Rafael J. Wysocki
Date: Wed Jun 12 2024 - 13:23:45 EST


Restored list CCs.

On Wed, Jun 12, 2024 at 3:41 PM Rafael J. Wysocki <rafael@xxxxxxxxxx> wrote:
>
> On Wed, Jun 12, 2024 at 11:56 AM fhortner@xxxxxxxx <fhortner@xxxxxxxx> wrote:
> >
> > Am 11.06.24 um 16:42 schrieb Rafael J. Wysocki:
> >
> > This doesn't make them run in a different order, it just delays both
> > of them, because the notifiers are called sequentially.
> >
> > However, if you added the msleep() at the beginning of
> > thermal_zone_device_resume(), it would change the ordering of this
> > function with respect to the PM notifiers, so please try doing this.
> >
> > I did so and added msleep(1000) to thermal_core.c line 1634
> > I have also reverted the patch you sent me.
> >
> > The battery readings after resume from S3 sleep where fine.
> > I have tried 2 reboots with 4 sleep/wake cycles, respectively
>
> Thanks!
>
> This means that the two code paths in question somehow interfere
> destructively when they are running in parallel with each other.

One more thing to try is the attached patch (independent of the
previous one) to lower the priority of the thermal PM notifier to make
it run always after the ACPI battery one.

Please test this one too and let me know if it works for you.
---
drivers/thermal/thermal_core.c | 1 +
1 file changed, 1 insertion(+)

Index: linux-pm/drivers/thermal/thermal_core.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.c
+++ linux-pm/drivers/thermal/thermal_core.c
@@ -1712,6 +1712,7 @@ static int thermal_pm_notify(struct noti

static struct notifier_block thermal_pm_nb = {
.notifier_call = thermal_pm_notify,
+ .priority = -1,
};

static int __init thermal_init(void)