From: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
To: Qianheng Peng <pengqh1@chinatelecom.cn>,
ray.huang@amd.com, mario.limonciello@amd.com, perry.yuan@amd.com,
kprateek.nayak@amd.com, rafael@kernel.org,
viresh.kumar@linaro.org, skhan@linuxfoundation.org,
li.meng@amd.com
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
wangxb12@chinatelecom.cn, xiongl24@chinatelecom.cn,
zhangar@chinatelecom.cn, zhongqiu.han@oss.qualcomm.com
Subject: Re: [PATCH v3] cpufreq: amd-pstate-ut: bail out early on non-AMD platform
Date: Thu, 16 Jul 2026 22:11:02 +0800 [thread overview]
Message-ID: <09b4f56e-0bc7-4b5e-8d97-a0c924be67f7@oss.qualcomm.com> (raw)
In-Reply-To: <1784191899-28957-1-git-send-email-pengqh1@chinatelecom.cn>
Hi Qianheng,
Thank you for your patience. It looks good to me overall, just a few
nits inline.
On 7/16/2026 4:51 PM, Qianheng Peng wrote:
> The crash issue may occur when modprobe amd_pstate_ut on intel platform.
>
It is better to start with:
"Loading the amd-pstate-ut module on a non-AMD platform triggers a NULL
pointer dereference:"
or
"A kernel NULL pointer dereference occurs when loading the amd-pstate-ut
module on a non-AMD (e.g. Intel) platform"
> amd_pstate_ut: 1 amd_pstate_ut_acpi_cpc_valid success!
> amd_pstate_ut: 2 amd_pstate_ut_check_enabled success!
> BUG: kernel NULL pointer dereference, address: 0000000000000080
> #PF: supervisor read access in kernel mode
> #PF: error_code(0x0000) - not-present page
> PGD 0 P4D 0
> Oops: 0000 [#1] SMP NOPTI
> CPU: 0 PID: 20300 Comm: modprobe
> Kdump: loaded Tainted: G O 6.6.0-0010.rc1.ctl4.x86_64 #1
> Hardware name: FiberHome R2200 V5/Xeon Boards, BIOS 3.1a 02/24/2020
> RIP: 0010:amd_pstate_ut_check_perf+0x141/0x280 [amd_pstate_ut]
> Call Trace:
> <TASK>
> amd_pstate_ut_init+0x1b/0xff0 [amd_pstate_ut]
> ? __pfx_amd_pstate_ut_init+0x10/0x10 [amd_pstate_ut]
> do_one_initcall+0x42/0x2e0
> ? kmalloc_trace+0x26/0x90
> do_init_module+0x60/0x240
> __se_sys_init_module+0x185/0x1c0
> do_syscall_64+0x62/0x190
> entry_SYSCALL_64_after_hwframe+0x76/0x7e
> </TASK>
>
> Add state detection to amd pstate driver to prevent amd_pstate_ut driver
This change fixes the amd-pstate-ut module rather than the amd-pstate
driver itself. Maybe something like:
"Add driver-state detection to the amd-pstate-ut module ..."
> from testing on non-AMD platforms.
It also covers the AMD_PSTATE_DISABLE case but not only non-AMD platforms.
And likewise, the subject may be changed as well, for example:
"cpufreq: amd-pstate-ut: Bail out early if the amd-pstate driver is not
running"
or
"cpufreq: amd-pstate-ut: Skip tests when amd-pstate driver is not
active"
>
> Fixes: 14eb1c96e3a3 ("cpufreq: amd-pstate: Add test module for amd-pstate driver")
> Suggested-by: Li Xiong <xiongl24@chinatelecom.cn>
> Suggested-by: Xibo Wang <wangxb12@chinatelecom.cn>
> Signed-off-by: Qianheng Peng <pengqh1@chinatelecom.cn>
>
> ---
> v3:
> - Remove unnecessary NULL check
> - Add detection to driver state instead of driver name
>
> v2: https://lore.kernel.org/all/1784108124-19988-1-git-send-email-pengqh1@chinatelecom.cn
> - Print policy->cpu instead of policy->kboj.name
> - Add cpufreq driver name detection to amd_pstate_ut
>
> v1: https://lore.kernel.org/all/1784015941-26535-1-git-send-email-pengqh1@chinatelecom.cn
> ---
> drivers/cpufreq/amd-pstate-ut.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/cpufreq/amd-pstate-ut.c b/drivers/cpufreq/amd-pstate-ut.c
> index 735b29f..2142838 100644
> --- a/drivers/cpufreq/amd-pstate-ut.c
> +++ b/drivers/cpufreq/amd-pstate-ut.c
> @@ -560,6 +560,11 @@ static int amd_pstate_ut_check_freq_attrs(u32 index)
> static int __init amd_pstate_ut_init(void)
> {
> u32 i = 0, arr_size = ARRAY_SIZE(amd_pstate_ut_cases);
> + enum amd_pstate_mode mode = amd_pstate_get_status();
> +
> + /* don't test if no running amd-pstate driver */
How about:
"/* Do not run tests when the amd-pstate driver is not active. */"
> + if (mode == AMD_PSTATE_UNDEFINED || mode == AMD_PSTATE_DISABLE)
> + return -EOPNOTSUPP;
>
> for (i = 0; i < arr_size; i++) {
> int ret;
Anyone, please feel free to correct or ignore any of the nits above.
Regardless, the patch code looks good to me.
Reviewed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
--
Thx and BRs,
Zhongqiu Han
prev parent reply other threads:[~2026-07-16 14:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 8:51 [PATCH v3] cpufreq: amd-pstate-ut: bail out early on non-AMD platform Qianheng Peng
2026-07-16 14:11 ` Zhongqiu Han [this message]
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=09b4f56e-0bc7-4b5e-8d97-a0c924be67f7@oss.qualcomm.com \
--to=zhongqiu.han@oss.qualcomm.com \
--cc=kprateek.nayak@amd.com \
--cc=li.meng@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=pengqh1@chinatelecom.cn \
--cc=perry.yuan@amd.com \
--cc=rafael@kernel.org \
--cc=ray.huang@amd.com \
--cc=skhan@linuxfoundation.org \
--cc=viresh.kumar@linaro.org \
--cc=wangxb12@chinatelecom.cn \
--cc=xiongl24@chinatelecom.cn \
--cc=zhangar@chinatelecom.cn \
/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