mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-03 01:06:53 +00:00
hv:Move pm state structure to pm.h
-- move structure 'cpu_state_info' from cpu_caps.h to host_pm.h -- add get_cpu_pm_state_info() api Tracked-On: #1842 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com> Reviewed-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
ef0ef6ba52
commit
7c4dd0d277
@ -102,6 +102,8 @@ static const struct cpu_state_table {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct cpu_state_info cpu_pm_state_info;
|
||||||
|
|
||||||
static int32_t get_state_tbl_idx(const char *cpuname)
|
static int32_t get_state_tbl_idx(const char *cpuname)
|
||||||
{
|
{
|
||||||
int32_t i;
|
int32_t i;
|
||||||
@ -120,12 +122,17 @@ static int32_t get_state_tbl_idx(const char *cpuname)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct cpu_state_info *get_cpu_pm_state_info(void)
|
||||||
|
{
|
||||||
|
return &cpu_pm_state_info;
|
||||||
|
}
|
||||||
|
|
||||||
void load_cpu_state_data(void)
|
void load_cpu_state_data(void)
|
||||||
{
|
{
|
||||||
int32_t tbl_idx;
|
int32_t tbl_idx;
|
||||||
const struct cpu_state_info *state_info;
|
const struct cpu_state_info *state_info;
|
||||||
|
|
||||||
(void)memset(&boot_cpu_data.state_info, 0U, sizeof(struct cpu_state_info));
|
(void)memset(&cpu_pm_state_info, 0U, sizeof(struct cpu_state_info));
|
||||||
|
|
||||||
tbl_idx = get_state_tbl_idx(boot_cpu_data.model_name);
|
tbl_idx = get_state_tbl_idx(boot_cpu_data.model_name);
|
||||||
|
|
||||||
@ -136,22 +143,22 @@ void load_cpu_state_data(void)
|
|||||||
|
|
||||||
if ((state_info->px_cnt != 0U) && (state_info->px_data != NULL)) {
|
if ((state_info->px_cnt != 0U) && (state_info->px_data != NULL)) {
|
||||||
if (state_info->px_cnt > MAX_PSTATE) {
|
if (state_info->px_cnt > MAX_PSTATE) {
|
||||||
boot_cpu_data.state_info.px_cnt = MAX_PSTATE;
|
cpu_pm_state_info.px_cnt = MAX_PSTATE;
|
||||||
} else {
|
} else {
|
||||||
boot_cpu_data.state_info.px_cnt = state_info->px_cnt;
|
cpu_pm_state_info.px_cnt = state_info->px_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
boot_cpu_data.state_info.px_data = state_info->px_data;
|
cpu_pm_state_info.px_data = state_info->px_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((state_info->cx_cnt != 0U) && (state_info->cx_data != NULL)) {
|
if ((state_info->cx_cnt != 0U) && (state_info->cx_data != NULL)) {
|
||||||
if (state_info->cx_cnt > MAX_CX_ENTRY) {
|
if (state_info->cx_cnt > MAX_CX_ENTRY) {
|
||||||
boot_cpu_data.state_info.cx_cnt = MAX_CX_ENTRY;
|
cpu_pm_state_info.cx_cnt = MAX_CX_ENTRY;
|
||||||
} else {
|
} else {
|
||||||
boot_cpu_data.state_info.cx_cnt = state_info->cx_cnt;
|
cpu_pm_state_info.cx_cnt = state_info->cx_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
boot_cpu_data.state_info.cx_data = state_info->cx_data;
|
cpu_pm_state_info.cx_data = state_info->cx_data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,36 +33,38 @@ int32_t validate_pstate(const struct acrn_vm *vm, uint64_t perf_ctl)
|
|||||||
static void vm_setup_cpu_px(struct acrn_vm *vm)
|
static void vm_setup_cpu_px(struct acrn_vm *vm)
|
||||||
{
|
{
|
||||||
uint32_t px_data_size;
|
uint32_t px_data_size;
|
||||||
|
struct cpu_state_info *pm_state_info = get_cpu_pm_state_info();
|
||||||
|
|
||||||
vm->pm.px_cnt = 0U;
|
vm->pm.px_cnt = 0U;
|
||||||
(void)memset(vm->pm.px_data, 0U, MAX_PSTATE * sizeof(struct cpu_px_data));
|
(void)memset(vm->pm.px_data, 0U, MAX_PSTATE * sizeof(struct cpu_px_data));
|
||||||
|
|
||||||
if ((boot_cpu_data.state_info.px_cnt != 0U) && (boot_cpu_data.state_info.px_data != NULL)) {
|
if ((pm_state_info->px_cnt != 0U) && (pm_state_info->px_data != NULL)) {
|
||||||
ASSERT((boot_cpu_data.state_info.px_cnt <= MAX_PSTATE), "failed to setup cpu px");
|
ASSERT((pm_state_info->px_cnt <= MAX_PSTATE), "failed to setup cpu px");
|
||||||
|
|
||||||
vm->pm.px_cnt = boot_cpu_data.state_info.px_cnt;
|
vm->pm.px_cnt = pm_state_info->px_cnt;
|
||||||
px_data_size = ((uint32_t)vm->pm.px_cnt) * sizeof(struct cpu_px_data);
|
px_data_size = ((uint32_t)vm->pm.px_cnt) * sizeof(struct cpu_px_data);
|
||||||
(void)memcpy_s(vm->pm.px_data, px_data_size, boot_cpu_data.state_info.px_data, px_data_size);
|
(void)memcpy_s(vm->pm.px_data, px_data_size, pm_state_info->px_data, px_data_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vm_setup_cpu_cx(struct acrn_vm *vm)
|
static void vm_setup_cpu_cx(struct acrn_vm *vm)
|
||||||
{
|
{
|
||||||
uint32_t cx_data_size;
|
uint32_t cx_data_size;
|
||||||
|
struct cpu_state_info *pm_state_info = get_cpu_pm_state_info();
|
||||||
|
|
||||||
vm->pm.cx_cnt = 0U;
|
vm->pm.cx_cnt = 0U;
|
||||||
(void)memset(vm->pm.cx_data, 0U, MAX_CSTATE * sizeof(struct cpu_cx_data));
|
(void)memset(vm->pm.cx_data, 0U, MAX_CSTATE * sizeof(struct cpu_cx_data));
|
||||||
|
|
||||||
if ((boot_cpu_data.state_info.cx_cnt != 0U) && (boot_cpu_data.state_info.cx_data != NULL)) {
|
if ((pm_state_info->cx_cnt != 0U) && (pm_state_info->cx_data != NULL)) {
|
||||||
ASSERT((boot_cpu_data.state_info.cx_cnt <= MAX_CX_ENTRY), "failed to setup cpu cx");
|
ASSERT((pm_state_info->cx_cnt <= MAX_CX_ENTRY), "failed to setup cpu cx");
|
||||||
|
|
||||||
vm->pm.cx_cnt = boot_cpu_data.state_info.cx_cnt;
|
vm->pm.cx_cnt = pm_state_info->cx_cnt;
|
||||||
cx_data_size = ((uint32_t)vm->pm.cx_cnt) * sizeof(struct cpu_cx_data);
|
cx_data_size = ((uint32_t)vm->pm.cx_cnt) * sizeof(struct cpu_cx_data);
|
||||||
|
|
||||||
/* please note pm.cx_data[0] is a empty space holder,
|
/* please note pm.cx_data[0] is a empty space holder,
|
||||||
* pm.cx_data[1...MAX_CX_ENTRY] would be used to store cx entry datas.
|
* pm.cx_data[1...MAX_CX_ENTRY] would be used to store cx entry datas.
|
||||||
*/
|
*/
|
||||||
(void)memcpy_s(vm->pm.cx_data + 1, cx_data_size, boot_cpu_data.state_info.cx_data, cx_data_size);
|
(void)memcpy_s(vm->pm.cx_data + 1, cx_data_size, pm_state_info->cx_data, cx_data_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,13 +7,6 @@
|
|||||||
#ifndef CPUINFO_H
|
#ifndef CPUINFO_H
|
||||||
#define CPUINFO_H
|
#define CPUINFO_H
|
||||||
|
|
||||||
struct cpu_state_info {
|
|
||||||
uint8_t px_cnt; /* count of all Px states */
|
|
||||||
const struct cpu_px_data *px_data;
|
|
||||||
uint8_t cx_cnt; /* count of all Cx entries */
|
|
||||||
const struct cpu_cx_data *cx_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define MAX_PSTATE 20U /* max num of supported Px count */
|
#define MAX_PSTATE 20U /* max num of supported Px count */
|
||||||
#define MAX_CSTATE 8U /* max num of supported Cx count */
|
#define MAX_CSTATE 8U /* max num of supported Cx count */
|
||||||
/* We support MAX_CSTATE num of Cx, means have (MAX_CSTATE - 1) Cx entries,
|
/* We support MAX_CSTATE num of Cx, means have (MAX_CSTATE - 1) Cx entries,
|
||||||
@ -41,7 +34,6 @@ struct cpuinfo_x86 {
|
|||||||
uint64_t physical_address_mask;
|
uint64_t physical_address_mask;
|
||||||
uint32_t cpuid_leaves[FEATURE_WORDS];
|
uint32_t cpuid_leaves[FEATURE_WORDS];
|
||||||
char model_name[64];
|
char model_name[64];
|
||||||
struct cpu_state_info state_info;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct cpuinfo_x86 boot_cpu_data;
|
extern struct cpuinfo_x86 boot_cpu_data;
|
||||||
|
@ -10,11 +10,19 @@
|
|||||||
#define BIT_SLP_EN 13U
|
#define BIT_SLP_EN 13U
|
||||||
#define BIT_WAK_STS 15U
|
#define BIT_WAK_STS 15U
|
||||||
|
|
||||||
|
struct cpu_state_info {
|
||||||
|
uint8_t px_cnt; /* count of all Px states */
|
||||||
|
const struct cpu_px_data *px_data;
|
||||||
|
uint8_t cx_cnt; /* count of all Cx entries */
|
||||||
|
const struct cpu_cx_data *cx_data;
|
||||||
|
};
|
||||||
|
|
||||||
void set_host_wake_vectors(void *vector_32, void *vector_64);
|
void set_host_wake_vectors(void *vector_32, void *vector_64);
|
||||||
struct pm_s_state_data *get_host_sstate_data(void);
|
struct pm_s_state_data *get_host_sstate_data(void);
|
||||||
|
|
||||||
void host_enter_s3(struct pm_s_state_data *sstate_data, uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val);
|
void host_enter_s3(struct pm_s_state_data *sstate_data, uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val);
|
||||||
extern void asm_enter_s3(struct pm_s_state_data *sstate_data, uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val);
|
extern void asm_enter_s3(struct pm_s_state_data *sstate_data, uint32_t pm1a_cnt_val, uint32_t pm1b_cnt_val);
|
||||||
extern void restore_s3_context(void);
|
extern void restore_s3_context(void);
|
||||||
|
struct cpu_state_info *get_cpu_pm_state_info(void);
|
||||||
|
|
||||||
#endif /* HOST_PM_H */
|
#endif /* HOST_PM_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user