2022-08-16 20:46:27 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2022 Advanced Micro Devices, Inc.
|
|
|
|
*
|
|
|
|
* Author: Meng Li <li.meng@amd.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LINUX_AMD_PSTATE_H
|
|
|
|
#define _LINUX_AMD_PSTATE_H
|
|
|
|
|
|
|
|
#include <linux/pm_qos.h>
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* AMD P-state INTERFACE *
|
|
|
|
*********************************************************************/
|
|
|
|
/**
|
|
|
|
* struct amd_aperf_mperf
|
|
|
|
* @aperf: actual performance frequency clock count
|
|
|
|
* @mperf: maximum performance frequency clock count
|
|
|
|
* @tsc: time stamp counter
|
|
|
|
*/
|
|
|
|
struct amd_aperf_mperf {
|
|
|
|
u64 aperf;
|
|
|
|
u64 mperf;
|
|
|
|
u64 tsc;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct amd_cpudata - private CPU data for AMD P-State
|
|
|
|
* @cpu: CPU number
|
|
|
|
* @req: constraint request to apply
|
|
|
|
* @cppc_req_cached: cached performance request hints
|
|
|
|
* @highest_perf: the maximum performance an individual processor may reach,
|
|
|
|
* assuming ideal conditions
|
2024-01-19 02:05:00 -07:00
|
|
|
* For platforms that do not support the preferred core feature, the
|
|
|
|
* highest_pef may be configured with 166 or 255, to avoid max frequency
|
|
|
|
* calculated wrongly. we take the fixed value as the highest_perf.
|
2022-08-16 20:46:27 -07:00
|
|
|
* @nominal_perf: the maximum sustained performance level of the processor,
|
|
|
|
* assuming ideal operating conditions
|
|
|
|
* @lowest_nonlinear_perf: the lowest performance level at which nonlinear power
|
|
|
|
* savings are achieved
|
|
|
|
* @lowest_perf: the absolute lowest performance level of the processor
|
2024-01-19 02:05:00 -07:00
|
|
|
* @prefcore_ranking: the preferred core ranking, the higher value indicates a higher
|
|
|
|
* priority.
|
2024-04-25 01:07:51 -07:00
|
|
|
* @min_limit_perf: Cached value of the performance corresponding to policy->min
|
|
|
|
* @max_limit_perf: Cached value of the performance corresponding to policy->max
|
2024-04-25 01:07:52 -07:00
|
|
|
* @min_limit_freq: Cached value of policy->min (in khz)
|
|
|
|
* @max_limit_freq: Cached value of policy->max (in khz)
|
|
|
|
* @max_freq: the frequency (in khz) that mapped to highest_perf
|
|
|
|
* @min_freq: the frequency (in khz) that mapped to lowest_perf
|
|
|
|
* @nominal_freq: the frequency (in khz) that mapped to nominal_perf
|
|
|
|
* @lowest_nonlinear_freq: the frequency (in khz) that mapped to lowest_nonlinear_perf
|
2022-08-16 20:46:27 -07:00
|
|
|
* @cur: Difference of Aperf/Mperf/tsc count between last and current sample
|
|
|
|
* @prev: Last Aperf/Mperf/tsc count value read from register
|
2024-04-25 01:07:52 -07:00
|
|
|
* @freq: current cpu frequency value (in khz)
|
2022-08-16 20:46:27 -07:00
|
|
|
* @boost_supported: check whether the Processor or SBIOS supports boost mode
|
2024-01-19 02:04:58 -07:00
|
|
|
* @hw_prefcore: check whether HW supports preferred core featue.
|
|
|
|
* Only when hw_prefcore and early prefcore param are true,
|
|
|
|
* AMD P-State driver supports preferred core featue.
|
2023-01-31 02:00:09 -07:00
|
|
|
* @epp_policy: Last saved policy used to set energy-performance preference
|
|
|
|
* @epp_cached: Cached CPPC energy-performance preference value
|
|
|
|
* @policy: Cpufreq policy value
|
|
|
|
* @cppc_cap1_cached Cached MSR_AMD_CPPC_CAP1 register value
|
2022-08-16 20:46:27 -07:00
|
|
|
*
|
|
|
|
* The amd_cpudata is key private data for each CPU thread in AMD P-State, and
|
|
|
|
* represents all the attributes and goals that AMD P-State requests at runtime.
|
|
|
|
*/
|
|
|
|
struct amd_cpudata {
|
|
|
|
int cpu;
|
|
|
|
|
|
|
|
struct freq_qos_request req[2];
|
|
|
|
u64 cppc_req_cached;
|
|
|
|
|
|
|
|
u32 highest_perf;
|
|
|
|
u32 nominal_perf;
|
|
|
|
u32 lowest_nonlinear_perf;
|
|
|
|
u32 lowest_perf;
|
2024-01-19 02:05:00 -07:00
|
|
|
u32 prefcore_ranking;
|
2023-11-16 23:38:39 -07:00
|
|
|
u32 min_limit_perf;
|
|
|
|
u32 max_limit_perf;
|
|
|
|
u32 min_limit_freq;
|
|
|
|
u32 max_limit_freq;
|
2022-08-16 20:46:27 -07:00
|
|
|
|
|
|
|
u32 max_freq;
|
|
|
|
u32 min_freq;
|
|
|
|
u32 nominal_freq;
|
|
|
|
u32 lowest_nonlinear_freq;
|
|
|
|
|
|
|
|
struct amd_aperf_mperf cur;
|
|
|
|
struct amd_aperf_mperf prev;
|
|
|
|
|
|
|
|
u64 freq;
|
|
|
|
bool boost_supported;
|
2024-01-19 02:04:58 -07:00
|
|
|
bool hw_prefcore;
|
2023-01-31 02:00:09 -07:00
|
|
|
|
|
|
|
/* EPP feature related attributes*/
|
|
|
|
s16 epp_policy;
|
|
|
|
s16 epp_cached;
|
|
|
|
u32 policy;
|
|
|
|
u64 cppc_cap1_cached;
|
2023-01-31 02:00:10 -07:00
|
|
|
bool suspended;
|
2024-06-12 07:20:49 -07:00
|
|
|
s16 epp_default;
|
cpufreq: amd-pstate: initialize core precision boost state
The "Core Performance Boost (CPB) feature, when enabled in the BIOS,
allows the OS to control the highest performance for each individual
core. The active, passive and the guided modes of the amd-pstate driver
do support controlling the core frequency boost when this BIOS feature
is enabled. Additionally, the amd-pstate driver provides a sysfs
interface allowing the user to activate/deactivate this core performance
boost feature at runtime.
Add support for the set_boost callback in the active mode driver to
enable boost control via the cpufreq core. This ensures a consistent
boost control interface across all pstate modes, including passive
mode, guided mode, and active mode.
With this addition, all three pstate modes can support the same boost
control interface with unique interface and global CPB control. Each
CPU also supports individual boost control, allowing global CPB to
change all cores' boost states simultaneously. Specific CPUs can
update their boost states separately, ensuring all cores' boost
states are synchronized.
Cc: Oleksandr Natalenko <oleksandr@natalenko.name>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217931
Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
Co-developed-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
Link: https://lore.kernel.org/r/20240626042733.3747-3-mario.limonciello@amd.com
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
2024-06-25 21:27:31 -07:00
|
|
|
bool boost_state;
|
2022-08-16 20:46:27 -07:00
|
|
|
};
|
|
|
|
|
2024-08-31 19:49:11 -07:00
|
|
|
/*
|
|
|
|
* enum amd_pstate_mode - driver working mode of amd pstate
|
|
|
|
*/
|
|
|
|
enum amd_pstate_mode {
|
|
|
|
AMD_PSTATE_UNDEFINED = 0,
|
|
|
|
AMD_PSTATE_DISABLE,
|
|
|
|
AMD_PSTATE_PASSIVE,
|
|
|
|
AMD_PSTATE_ACTIVE,
|
|
|
|
AMD_PSTATE_GUIDED,
|
|
|
|
AMD_PSTATE_MAX,
|
|
|
|
};
|
|
|
|
const char *amd_pstate_get_mode_string(enum amd_pstate_mode mode);
|
|
|
|
int amd_pstate_update_status(const char *buf, size_t size);
|
|
|
|
|
2022-08-16 20:46:27 -07:00
|
|
|
#endif /* _LINUX_AMD_PSTATE_H */
|