From: Mario Limonciello <mario.limonciello@amd.com>
To: Antheas Kapenekakis <lkml@antheas.dev>,
Derek John Clark <derekjohn.clark@gmail.com>
Cc: "Guenter Roeck" <linux@roeck-us.net>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
W_Armin@gmx.de, corbet@lwn.net, jdelvare@suse.com,
kuurtb@gmail.com, linux-doc@vger.kernel.org,
linux-hwmon@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH 1/6] platform/x86: msi-wmi-platform: Move guard out of switch in platform_write()
Date: Mon, 26 Oct 2026 10:25:41 -0500 [thread overview]
Message-ID: <baf91d42-13dd-41eb-88d7-d6311ee0d9f9@amd.com> (raw)
In-Reply-To: <CAGwozwGUAEb4Q9pfd_+aXMw2P3qY376F+usPHdUFO5Q6mV_ATQ@mail.gmail.com>
On 10/24/26 04:24, Antheas Kapenekakis wrote:
> On Wed, 21 Oct 2026 at 05:26, Derek John Clark
> <derekjohn.clark@gmail.com> wrote:
>>
>> On Tue, Oct 20, 2026 at 2:53 PM Antheas Kapenekakis <lkml@antheas.dev> wrote:
>>>
>>> On Tue, 18 Aug 2026 at 17:26, Antheas Kapenekakis <lkml@antheas.dev> wrote:
>>>>
>>>> On Tue, 18 Aug 2026 at 16:42, Guenter Roeck <linux@roeck-us.net> wrote:
>>>>>
>>>>> On 8/18/26 07:12, Ilpo Järvinen wrote:
>>>>>> On Mon, 3 Aug 2026, Derek J. Clark wrote:
>>>>>>
>>>>>>> The ML patch set uses a guard within a switch case that violates cleanup
>>>>>>> rules. Move the guard outside the switch so all return paths are covered.
>>>>>>>
>>>>>>> Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
>>>>>>> ---
>>>>>>> drivers/platform/x86/msi-wmi-platform.c | 2 +-
>>>>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>>>
>>>>>>> diff --git a/drivers/platform/x86/msi-wmi-platform.c b/drivers/platform/x86/msi-wmi-platform.c
>>>>>>> index dfb65ac8fbf6..33acd448f674 100644
>>>>>>> --- a/drivers/platform/x86/msi-wmi-platform.c
>>>>>>> +++ b/drivers/platform/x86/msi-wmi-platform.c
>>>>>>> @@ -675,11 +675,11 @@ static int msi_wmi_platform_write(struct device *dev, enum hwmon_sensor_types ty
>>>>>>> u8 buffer[32] = { };
>>>>>>> int ret;
>>>>>>>
>>>>>>> + guard(mutex)(&data->wmi_lock);
>>>>>>> switch (type) {
>>>>>>> case hwmon_pwm:
>>>>>>> switch (attr) {
>>>>>>> case hwmon_pwm_enable:
>>>>>>> - guard(mutex)(&data->wmi_lock);
>>>>>>
>>>>>> While I cannot see the code easily, one could also add braces to inside
>>>>>> the case to avoid this problem.
>>>>>>
>>>>>
>>>>> I don't see the code either, but wouldn't this be a use case for
>>>>> scoped_guard() ?
>>>>
>>>> Hi, not explicitly stated in the cover letter, but this is essentially
>>>> a series on top of the series I sent last year but I did not clean up
>>>> due to a variety of issues with MSI firmware that would have made the
>>>> driver unsuitable for upstreaming (to my standards at least). These
>>>> issues span Intel driver problems, HID controller instability, and
>>>> varying WMI implementations esp. in regards to PLx setting between AMD
>>>> / Intel variants, shift mode behavior not acting correctly, and fan
>>>> curve application / resetting being weird (the fan curve on off bit
>>>> does not seem to change whether an automatic curve is used but how
>>>> close the device alings to the set curve? requiring us to back up and
>>>> restore the original curve? half of the devices keep the curve during
>>>> sleep and half don't? but if the fan curve is so finicky do we really
>>>> want a resume handler for it? Perhaps we can kick the timing quirks to
>>>> userspace)
>>>>
>>>> For this reason, I focused on other manufacturers such as Ayaneo and
>>>> OneXPlayer. I will revisit this series per request from Derek as he
>>>> seems to want this for steamos and hid-msi is already queued for 7.3?
>>>> Although, to be honest, compared to the controller firmware issues,
>>>> the WMI implementation is pristine.
>>>>
>>>> So I will need to go through these issues 1 by 1 and see which can be
>>>> fixed and either drop certain features in the beginning.
>>>>
>>>> Particularly for the fan curves, if we say that resume handlers are
>>>> required to be in the kernel moving forward, I do not know how
>>>> realistic it is to make those reliable for this WMI device family.
>>>
>>> This driver still needs work. I am getting bug reports about
>>> inconsistent TDP application on the EX. A8 is broken as well. Even
>>> with your patches Derek. I need to grab a new version of center M and
>>> see what they are doing.
>>>
>>> Does this driver work in your experience? What is that SMT toggle you added
>>
>> I've got a few reports of some issues, but nothing with much detail. I
>> have the 8 AI+, 8 EX AI+, and A8 in hand and all three had effective
>> TDP changes in SteamOS with these patches applied and SteamOS Manager.
>> I haven't done extensive testing over multiple suspends or longer
>> sessions myself. I'm also not aware if there have been BIOS updates
>> since my testing.
>>
>> By SMT toggle i think you mean the STAPM toggle for the A8? It was
>> referenced in API_UserScenario.dll (setPowerLimit_AMDSTAMP) which I
>> reviewed using ILSpy. After toggling that TDP started reporting
>> correctly and being settable.
>>
>> Hope this helps. LMK if you need anything tested or additional info.
>
> Ok, I asked for more feedback. Yes, TDP changes do work, but they are
> not correct. Users AB testing with a Decky plugin called
> SimpleDeckyTDP report major divergence.
>
> SimpleDeckyTDP uses a combination of RyzenAdj for AMD and RAPL for
> Intel. When set to 7W, users report 25W power consumption when using
> the kernel driver and 15W when using simpledeckytdp on A8. 15W is the
> correct value for a 7W envelope on an X840u APU.
>
> STAPM should not be required to use or deviate from STT. Both of them
> should have equivalent behavior and match ryzenadj as the underlying
> DPTC hooks are the same, ryzenadj just accesses the mailbox directly.
> Using STAPM is a workaround for buggy vendor firmware that does not
> control boost values correctly (SPPT/FPPT) and is what the first
> generation Lenovo Legion Go did as well before they fixed it.
>
> STAPM as a workaround works because it uses timers to control boost
> values, so they decay after 2-3 minutes to the steady state TDP set by
> the firmware. STT boosts for as long as the device thermal envelope
> allows. STAPM is deprecated by AMD, only STT should be used going
> forward. +CC Mario
It's up to the OEM to decide whether they have programmed their firmware
to to use STT or STAPM. They should not be used at the same time.
If their BIOS/EC is using one and reverse engineered software is using
the other, you will expect problems.
>
> This points to a BIOS firmware issue. You should consider getting in
> touch with your MSI contact for feedback and to plan a fix. I do not
> have an MSI contact. And yes, I am not happy my users have to rely on
> third party unvetted plugins for basic power controls.
>
> But we cannot revisit this driver while basic behavior. does not work.
> If MSI does not fix this or there isn't a bug in this driver we can
> fix, the only viable way forward from our side is to move power
> controls to the DPTC RFC driver/RAPL for affected models and only
> retain fan curves on this driver. I do not want to do this, I have
> userspace integration for this driver already, but it is not
> functional to the standard expected by users.
>
> I checked the ACPI firmware and unlike other manufacturers, there is
> no EC independent control of the power envelope. We would still need
> to check a low battery hook in firmware but other than that it is a
> straight translation.
>
> Antheas
next prev parent reply other threads:[~2026-10-26 15:25 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-11 20:44 [PATCH v1 00/10] platform/x86: msi-wmi-platform: Add fan curves/platform profile/tdp/battery limiting Antheas Kapenekakis
2025-05-11 20:44 ` [PATCH v1 01/10] platform/x86: msi-wmi-platform: Use input buffer for returning result Antheas Kapenekakis
2025-05-11 23:31 ` Kurt Borja
2025-05-13 19:42 ` Armin Wolf
2025-05-11 20:44 ` [PATCH v1 02/10] platform/x86: msi-wmi-platform: Add unlocked msi_wmi_platform_query Antheas Kapenekakis
2025-05-12 19:21 ` Kurt Borja
2025-05-12 20:51 ` Antheas Kapenekakis
2025-05-12 21:23 ` Kurt Borja
2025-05-12 21:51 ` Antheas Kapenekakis
2025-05-13 19:45 ` Armin Wolf
2025-05-13 19:47 ` Armin Wolf
2025-05-11 20:44 ` [PATCH v1 03/10] platform/x86: msi-wmi-platform: Add quirk system Antheas Kapenekakis
2025-05-11 23:32 ` Kurt Borja
2025-05-13 20:43 ` Armin Wolf
2025-05-11 20:44 ` [PATCH v1 04/10] platform/x86: msi-wmi-platform: Add support for fan control Antheas Kapenekakis
2025-05-11 23:32 ` Kurt Borja
2025-05-13 20:58 ` Armin Wolf
2025-05-19 1:35 ` Armin Wolf
2025-05-11 20:44 ` [PATCH v1 05/10] platform/x86: msi-wmi-platform: Add platform profile through shift mode Antheas Kapenekakis
2025-05-11 23:33 ` Kurt Borja
2025-05-12 21:59 ` Antheas Kapenekakis
2025-05-19 1:51 ` Armin Wolf
2025-05-19 1:58 ` Armin Wolf
2025-05-11 20:44 ` [PATCH v1 06/10] platform/x86: msi-wmi-platform: Add PL1/PL2 support via firmware attributes Antheas Kapenekakis
2025-05-11 23:34 ` Kurt Borja
2025-05-12 10:22 ` Antheas Kapenekakis
2025-05-19 2:08 ` Armin Wolf
2025-05-11 20:44 ` [PATCH v1 07/10] platform/x86: msi-wmi-platform: Add charge_threshold support Antheas Kapenekakis
2025-05-11 23:34 ` Kurt Borja
2025-05-19 2:32 ` Armin Wolf
2025-05-11 20:44 ` [PATCH v1 08/10] platform/x86: msi-wmi-platform: Drop excess fans in dual fan devices Antheas Kapenekakis
2025-05-11 23:35 ` Kurt Borja
2025-05-11 20:44 ` [PATCH v1 09/10] platform/x86: msi-wmi-platform: Update header text Antheas Kapenekakis
2025-05-19 2:33 ` Armin Wolf
2025-05-11 20:44 ` [PATCH v1 10/10] platform/x86: msi-wmi-platform: Restore fan curves on PWM disable and unload Antheas Kapenekakis
2025-05-12 19:16 ` Kurt Borja
2025-05-12 20:50 ` Antheas Kapenekakis
2025-05-11 23:30 ` [PATCH v1 00/10] platform/x86: msi-wmi-platform: Add fan curves/platform profile/tdp/battery limiting Kurt Borja
2025-05-12 10:16 ` Antheas Kapenekakis
2025-05-12 19:05 ` Kurt Borja
2025-05-19 2:37 ` Armin Wolf
2025-05-30 20:50 ` Antheas Kapenekakis
2025-05-30 21:15 ` Armin Wolf
2025-05-30 21:28 ` Antheas Kapenekakis
2025-05-30 22:00 ` Armin Wolf
2026-05-08 18:41 ` Derek J. Clark
2026-05-09 17:25 ` Antheas Kapenekakis
2026-08-03 22:16 ` [PATCH 0/6] " Derek J. Clark
2026-08-03 22:16 ` [PATCH 1/6] platform/x86: msi-wmi-platform: Move guard out of switch in platform_write() Derek J. Clark
2026-08-18 14:12 ` Ilpo Järvinen
2026-08-18 14:42 ` Guenter Roeck
2026-08-18 15:20 ` Derek John Clark
2026-08-18 15:26 ` Antheas Kapenekakis
2026-10-20 21:52 ` Antheas Kapenekakis
2026-10-21 3:26 ` Derek John Clark
2026-10-24 9:24 ` Antheas Kapenekakis
2026-10-26 15:25 ` Mario Limonciello [this message]
2026-10-26 16:44 ` Antheas Kapenekakis
2026-10-26 16:49 ` Mario Limonciello
2026-08-03 22:16 ` [PATCH 2/6] platform/x86: msi-wmi-platform: fix: Remove unused err Derek J. Clark
2026-08-03 22:16 ` [PATCH 3/6] platform/x86: msi-wmi-platform: terminate msi_quirks DMI table Derek J. Clark
2026-08-03 22:16 ` [PATCH 4/6] platform/x86: msi-wmi-platform: Clean up devices Derek J. Clark
2026-08-03 22:16 ` [PATCH 5/6] platform/x86: wmi-msi-platform: Add MSI Claw A8 support Derek J. Clark
2026-08-03 22:16 ` [PATCH 6/6] platform-x86: msi-wmi-platform: Add Gen 4 device Derek J. Clark
2026-08-05 17:41 ` [PATCH 0/6] Re: [PATCH v1 00/10] platform/x86: msi-wmi-platform: Add fan curves/platform profile/tdp/battery limiting Antheas Kapenekakis
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=baf91d42-13dd-41eb-88d7-d6311ee0d9f9@amd.com \
--to=mario.limonciello@amd.com \
--cc=W_Armin@gmx.de \
--cc=corbet@lwn.net \
--cc=derekjohn.clark@gmail.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jdelvare@suse.com \
--cc=kuurtb@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lkml@antheas.dev \
--cc=platform-driver-x86@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®