From: Hans de Goede <hdegoede@redhat.com>
To: Mario Limonciello <mario.limonciello@amd.com>,
Mark Pearson <mpearson-lenovo@squebb.ca>
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86: thinkpad_acpi: Only update profile if successfully converted
Date: Mon, 19 Feb 2024 13:59:42 +0100 [thread overview]
Message-ID: <f0f64e2d-5e6f-4a3b-b57d-e617142eb08c@redhat.com> (raw)
In-Reply-To: <20240217022311.113879-1-mario.limonciello@amd.com>
Hi,
On 2/17/24 03:23, Mario Limonciello wrote:
> Randomly a Lenovo Z13 will trigger a kernel warning traceback from this
> condition:
>
> ```
> if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names))))
> ```
>
> This happens because thinkpad-acpi always assumes that
> convert_dytc_to_profile() successfully updated the profile. On the
> contrary a condition can occur that when dytc_profile_refresh() is called
> the profile doesn't get updated as there is a -EOPNOTSUPP branch.
>
> Catch this situation and avoid updating the profile. Also log this into
> dynamic debugging in case any other modes should be added in the future.
>
> Fixes: c3bfcd4c6762 ("platform/x86: thinkpad_acpi: Add platform profile support")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Thank you for your patch, I've applied this patch to my review-hans
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.
I will include this patch in my next fixes pull-req to Linus
for the current kernel development cycle.
Regards,
Hans
> ---
> BTW - This isn't new. I've been seeing this a long time, but I just finally
> got annoyed enough by it to find the code that triggered the sequence.
>
> drivers/platform/x86/thinkpad_acpi.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index c4895e9bc714..5ecd9d33250d 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -10308,6 +10308,7 @@ static int convert_dytc_to_profile(int funcmode, int dytcmode,
> return 0;
> default:
> /* Unknown function */
> + pr_debug("unknown function 0x%x\n", funcmode);
> return -EOPNOTSUPP;
> }
> return 0;
> @@ -10493,8 +10494,8 @@ static void dytc_profile_refresh(void)
> return;
>
> perfmode = (output >> DYTC_GET_MODE_BIT) & 0xF;
> - convert_dytc_to_profile(funcmode, perfmode, &profile);
> - if (profile != dytc_current_profile) {
> + err = convert_dytc_to_profile(funcmode, perfmode, &profile);
> + if (!err && profile != dytc_current_profile) {
> dytc_current_profile = profile;
> platform_profile_notify();
> }
next prev parent reply other threads:[~2024-02-19 12:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-17 2:23 [PATCH] platform/x86: thinkpad_acpi: Only update profile if successfully converted Mario Limonciello
2024-02-19 12:59 ` Hans de Goede [this message]
2024-02-19 15:13 ` Mark Pearson
2024-02-19 15:24 ` Mario Limonciello
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=f0f64e2d-5e6f-4a3b-b57d-e617142eb08c@redhat.com \
--to=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=mpearson-lenovo@squebb.ca \
--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