// SPDX-License-Identifier: GPL-2.0-or-later /* * AMD Processor P-state Frequency Driver Unit Test * * Copyright (C) 2022 Advanced Micro Devices, Inc. All Rights Reserved. * * Author: Meng Li <li.meng@amd.com> * * The AMD P-State Unit Test is a test module for testing the amd-pstate * driver. 1) It can help all users to verify their processor support * (SBIOS/Firmware or Hardware). 2) Kernel can have a basic function * test to avoid the kernel regression during the update. 3) We can * introduce more functional or performance tests to align the result * together, it will benefit power and performance scale optimization. * * This driver implements basic framework with plans to enhance it with * additional test cases to improve the depth and coverage of the test. * * See Documentation/admin-guide/pm/amd-pstate.rst Unit Tests for * amd-pstate to get more detail.
*/
staticbool get_shared_mem(void)
{ bool result = false;
if (!boot_cpu_has(X86_FEATURE_CPPC))
result = true;
return result;
}
/* * check the _CPC object is present in SBIOS.
*/ staticint amd_pstate_ut_acpi_cpc_valid(u32 index)
{ if (!acpi_cpc_valid()) {
pr_err("%s the _CPC object is not present in SBIOS!\n", __func__); return -EINVAL;
}
return 0;
}
/* * check if amd pstate is enabled
*/ staticint amd_pstate_ut_check_enabled(u32 index)
{
u64 cppc_enable = 0; int ret;
if (get_shared_mem()) return 0;
ret = rdmsrq_safe(MSR_AMD_CPPC_ENABLE, &cppc_enable); if (ret) {
pr_err("%s rdmsrq_safe MSR_AMD_CPPC_ENABLE ret=%d error!\n", __func__, ret); return ret;
}
if (!cppc_enable) {
pr_err("%s amd pstate must be enabled!\n", __func__); return -EINVAL;
}
return 0;
}
/* * check if performance values are reasonable. * highest_perf >= nominal_perf > lowest_nonlinear_perf > lowest_perf > 0
*/ staticint amd_pstate_ut_check_perf(u32 index)
{ int cpu = 0, ret = 0;
u32 highest_perf = 0, nominal_perf = 0, lowest_nonlinear_perf = 0, lowest_perf = 0;
u64 cap1 = 0; struct cppc_perf_caps cppc_perf; union perf_cached cur_perf;
/* * Check if frequency values are reasonable. * max_freq >= nominal_freq > lowest_nonlinear_freq > min_freq > 0 * check max freq when set support boost mode.
*/ staticint amd_pstate_ut_check_freq(u32 index)
{ int cpu = 0;
if (cpudata->lowest_nonlinear_freq != policy->min) {
pr_err("%s cpu%d cpudata_lowest_nonlinear_freq=%d policy_min=%d, they should be equal!\n",
__func__, cpu, cpudata->lowest_nonlinear_freq, policy->min); return -EINVAL;
}
if (cpudata->boost_supported) { if ((policy->max != policy->cpuinfo.max_freq) &&
(policy->max != cpudata->nominal_freq)) {
pr_err("%s cpu%d policy_max=%d should be equal cpu_max=%d or cpu_nominal=%d !\n",
__func__, cpu, policy->max, policy->cpuinfo.max_freq,
cpudata->nominal_freq); return -EINVAL;
}
} else {
pr_err("%s cpu%d must support boost!\n", __func__, cpu); return -EINVAL;
}
}
for (mode1 = AMD_PSTATE_DISABLE; mode1 < AMD_PSTATE_MAX; mode1++) {
ret = amd_pstate_set_mode(mode1); if (ret) return ret; for (mode2 = AMD_PSTATE_DISABLE; mode2 < AMD_PSTATE_MAX; mode2++) { if (mode1 == mode2) continue;
ret = amd_pstate_set_mode(mode2); if (ret) goto out;
}
}
out: if (ret)
pr_warn("%s: failed to update status for %s->%s: %d\n", __func__,
amd_pstate_get_mode_string(mode1),
amd_pstate_get_mode_string(mode2), ret);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.