mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: johannes.goede@oss.qualcomm.com
To: "Rafael J. Wysocki (Intel)" <rafael@kernel.org>
Cc: "Ali Ahmet Memiş" <aliamemis@disroot.org>,
	"Len Brown" <lenb@kernel.org>, "Armin Wolf" <W_Armin@gmx.de>,
	"Charis Stratakis" <c.stratakis@proton.me>,
	linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org,
	regressions@lists.linux.dev,
	"Mark Pearson" <mpearson-lenovo@squebb.ca>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] ACPI: battery: Re-read battery information in the complete callback
Date: Wed, 14 Oct 2026 11:58:17 +0200	[thread overview]
Message-ID: <b64b8092-93d7-4873-a55f-422b8e70cc04@oss.qualcomm.com> (raw)
In-Reply-To: <CAJZ5v0isCM3K3U6HSdDnvXzBX41AgQMFYxqLx3KvMA0W_91-ew@mail.gmail.com>

Hi Rafael,

On 13-Oct-26 19:20, Rafael J. Wysocki (Intel) wrote:
> Hi Hans,
> 
> On Tue, Oct 13, 2026 at 3:36 PM <johannes.goede@oss.qualcomm.com> wrote:
>>
>> Hi Rafael,
>>
>> On 13-Oct-26 13:58, Rafael J. Wysocki (Intel) wrote:
>>> On Tue, Oct 13, 2026 at 11:33 AM <johannes.goede@oss.qualcomm.com> wrote:
>>>>
>>>> Hi,
>>>>
>>>> On 13-Oct-26 00:46, Ali Ahmet Memiş wrote:
>>>>> Since commit d33e89d12295 ("thermal: core: Suspend thermal zones later
>>>>> and resume them earlier"), thermal zones are resumed from dpm_complete(),
>>>>> before the PM_POST_SUSPEND notifier that re-reads _BIX and _BST. On
>>>>> ThinkPad P1 Gen2 and P53, INT3403 _TMP calls \GTST which switches the EC
>>>>> page selector (HIID) without taking the BATM mutex used by the battery
>>>>> methods. ACPICA releases the interpreter lock around EC accesses
>>>>
>>>> I'm wondering if this "ACPICA releases the interpreter lock around EC
>>>> accesses" is not the real problem here.
>>>
>>> Yes, it most likely is.
>>>
>>> What actually happens is that ACPICA drops the interpreter lock and
>>> the namespace lock in several cases listed in the
>>> acpi_ex_exit_interpreter() documentation comment, the majority of
>>> which involve having to wait.
>>>
>>> The bottom line though is that the interpreter and namespace locks
>>> cannot be expected to be held throughout AML evaluation because it is
>>> not known in advance if any of the cases in question will appear.
>>>
>>>> Recently I've learned / heard
>>>> from a trusted source that Windows ACPI subsystem is very much single
>>>> threaded. So it is nice that ACPI has these mutexes and other stuff
>>>> to support multi-threading but as long as Windows ACPI interpreter is
>>>> not multi-threaded I think we may need to consider to copy Windows
>>>> behavior.
>>>
>>> This is also my conclusion, at least to some extent.
>>>
>>> The problem with it though is that in some cases parallel evaluation
>>> of AML is actually useful.  For example, say two PCI devices are
>>> powered up at the same time and AML waits for each of them.  The async
>>> suspend/resume aligns those waits to take place simultaneously instead
>>> of serializing them which allows some time to be saved.
>>>
>>>> So maybe the EC accesses should keep the interpreter lock locked during
>>>> EC accesses.
>>>
>>> The problem here is that it is hard to say in advance whether or not
>>> _BIX or _BST will access the EC and whether or not that will clash
>>> with _TMP evaluation for a seemingly unrelated thermal zone.
>>>
>>>> And even go further and maybe we need to introduce a big-acpi-lock,
>>>> which I guess the interpreter lock more or less is? And just serialize
>>>> all ACPI accesses since most ACPI tables clearly do not handle
>>>> multi-threaded access to ACPI methods well ?
>>>
>>> I would be inclined to do so except for device power management
>>> methods, that is _ON, _OFF, and _PSx, that are not the problematic
>>> ones, at least as far as I know.
>>
>> That sounds like a reasonable compromise which should fix both
>> this case as well as help with bko221065 .
>>
>>>> Another example of multi-threaded ACPI calls causing problems is:
>>>>
>>>> https://bugzilla.kernel.org/show_bug.cgi?id=221065
>>>
>>> Right.
>>>
>>> So I guess the idea would be to add locking to acpi_evaluate_object()?
>>
>> Yes that seems like a nice single point of entry to do this where
>> all the various helpers eventually end up.
> 
> That, of course, would require updating ACPICA code and I'm not sure
> if doing it upstream is useful.  For example, if some hosts already
> use locking around acpi_evaluate_object(), this modification won't
> help them and it will certainly be a change in behavior.
> 
> This means that we'll likely end up with a Linux-specific divergence
> from the upstream which can be lived with, but it won't be nice.

Ah, I see.

>>> An alternative might be to introduce an "exclusive" variant of
>>> acpi_evaluate_object() with built-in locking and use it in the cases
>>> that are known-problematic.
>>
>> So here we have _TMP and _BIX / _BST and in bko221065 we have
>> a bunch of again batteyr methods + UCSI racing. I'm afraid if
>> we add something like acpi_evaluate_object_exclusive() we'll end
>> up eventually using that almost everywhere.
> 
> While I think that your concern is valid, this can be done without
> touching the ACPICA code at all.

Not needing to touch ACPICA is a valid concern. So I agree lets go
with a wrapper for paths which we know need to be serialized for now.

And then add that around the battery methods + _TMP + UCSI methods
for starters I guess ?

###

Should we also stop releasing the interpreter lock in the EC code?

All these things (battery, _TMP, UCSI) seem to have in common that
they might talk to the EC in some cases?

Where as e.g. your powering-up of PCI slots example is unlikely to
talk to the EC ?

Regards,

Hans



  parent reply	other threads:[~2026-10-14  9:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <37N_jFulf7n-Z55NfKfE71C_wVPxYvZ0xD_iRUg2fXu7TypDiF5PStQ6siSfVBih6fThg5WoPes8U5ZQpfVm_teMFcUGXFxz2DdMbfSWuws=@proton.me>
2026-10-12 22:46 ` Ali Ahmet Memiş
2026-10-12 22:58   ` Ali Ahmet Memiş
2026-10-13  1:40     ` Charis Stratakis
2026-10-13  5:34       ` Ali Ahmet Memiş
2026-10-13  9:33   ` johannes.goede
2026-10-13 11:58     ` Rafael J. Wysocki (Intel)
2026-10-13 12:30       ` Ali Ahmet Memiş
2026-10-13 13:12         ` Rafael J. Wysocki (Intel)
2026-10-13 13:36       ` johannes.goede
2026-10-13 17:20         ` Rafael J. Wysocki (Intel)
2026-10-13 21:05           ` Ali Ahmet Memiş
2026-10-14 10:01             ` johannes.goede
2026-10-14 13:32               ` Ali Ahmet Memiş
2026-10-14 14:00                 ` johannes.goede
2026-10-14  9:58           ` johannes.goede [this message]
2026-10-14 15:06             ` Rafael J. Wysocki (Intel)
2026-10-14 19:34               ` johannes.goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b64b8092-93d7-4873-a55f-422b8e70cc04@oss.qualcomm.com \
    --to=johannes.goede@oss.qualcomm.com \
    --cc=W_Armin@gmx.de \
    --cc=aliamemis@disroot.org \
    --cc=c.stratakis@proton.me \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=rafael@kernel.org \
    --cc=regressions@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®