Skip to content

Commit 373a828

Browse files
jsun26inteljren1
authored andcommitted
HV Cx: load cx data to boot_cpu_data when boot
The cx data is hardcoded within HV, load it to boot_cpu_data when HV boot. The patch provide a3960 soc cx data for example. Signed-off-by: Victor Sun <victor.sun@intel.com> Acked-by: Kevin Tian <kevin.tian@intel.com>
1 parent d63b900 commit 373a828

File tree

3 files changed

+56
-4
lines changed

3 files changed

+56
-4
lines changed

hypervisor/arch/x86/cpu_state_tbl.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ struct cpu_px_data px_a3960[] = {
5353
{0x320, 0, 0xA, 0xA, 0x0800, 0x0800} /* P16 */
5454
};
5555

56+
/* The table includes cpu cx info of Intel A3960 SoC */
57+
struct cpu_cx_data cx_a3960[] = {
58+
{{SPACE_FFixedHW, 0x0, 0, 0, 0}, 0x1, 0x1, 0x3E8}, /* C1 */
59+
{{SPACE_SYSTEM_IO, 0x8, 0, 0, 0x415}, 0x2, 0x32, 0x0A}, /* C2 */
60+
{{SPACE_SYSTEM_IO, 0x8, 0, 0, 0x419}, 0x3, 0x96, 0x0A} /* C3 */
61+
};
62+
5663
/* The table includes cpu px info of Intel J3455 SoC */
5764
struct cpu_px_data px_j3455[] = {
5865
{0x5DD, 0, 0xA, 0xA, 0x1700, 0x1700}, /* P0 */
@@ -71,10 +78,12 @@ struct cpu_state_table {
7178
struct cpu_state_info state_info;
7279
} cpu_state_tbl[] = {
7380
{"Intel(R) Atom(TM) Processor A3960 @ 1.90GHz",
74-
{ARRAY_SIZE(px_a3960), px_a3960}
81+
{ARRAY_SIZE(px_a3960), px_a3960,
82+
ARRAY_SIZE(cx_a3960), cx_a3960}
7583
},
7684
{"Intel(R) Celeron(R) CPU J3455 @ 1.50GHz",
77-
{ARRAY_SIZE(px_j3455), px_j3455}
85+
{ARRAY_SIZE(px_j3455), px_j3455,
86+
0, NULL}
7887
}
7988
};
8089

@@ -122,4 +131,15 @@ void load_cpu_state_data(void)
122131

123132
boot_cpu_data.state_info.px_data = state_info->px_data;
124133
}
134+
135+
if (state_info->cx_cnt && state_info->cx_data) {
136+
if (state_info->cx_cnt > MAX_CX_ENTRY) {
137+
boot_cpu_data.state_info.cx_cnt = MAX_CX_ENTRY;
138+
} else {
139+
boot_cpu_data.state_info.cx_cnt = state_info->cx_cnt;
140+
}
141+
142+
boot_cpu_data.state_info.cx_data = state_info->cx_data;
143+
}
144+
125145
}

hypervisor/include/arch/x86/cpu.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,10 @@ enum feature_word {
236236
};
237237

238238
struct cpu_state_info {
239-
uint8_t px_cnt;
239+
uint8_t px_cnt; /* count of all Px states */
240240
struct cpu_px_data *px_data;
241+
uint8_t cx_cnt; /* count of all Cx entries */
242+
struct cpu_cx_data *cx_data;
241243
};
242244

243245
struct cpuinfo_x86 {
@@ -254,7 +256,13 @@ struct cpuinfo_x86 {
254256

255257
extern struct cpuinfo_x86 boot_cpu_data;
256258

257-
#define MAX_PSTATE 20
259+
#define MAX_PSTATE 20 /* max num of supported Px count */
260+
#define MAX_CSTATE 8 /* max num of supported Cx count */
261+
262+
/* We support MAX_CSTATE num of Cx, means have (MAX_CSTATE - 1) Cx entries,
263+
* i.e. supported Cx entry index range from 1 to MAX_CX_ENTRY.
264+
*/
265+
#define MAX_CX_ENTRY (MAX_CSTATE - 1)
258266

259267
/* Function prototypes */
260268
void cpu_dead(uint32_t logical_id);

hypervisor/include/public/acrn_common.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,30 @@ struct acrn_vm_pci_msix_remap {
292292
* @brief Info The power state data of a VCPU.
293293
*
294294
*/
295+
296+
#define SPACE_SYSTEM_MEMORY 0
297+
#define SPACE_SYSTEM_IO 1
298+
#define SPACE_PCI_CONFIG 2
299+
#define SPACE_Embedded_Control 3
300+
#define SPACE_SMBUS 4
301+
#define SPACE_PLATFORM_COMM 10
302+
#define SPACE_FFixedHW 0x7F
303+
304+
struct acrn_register {
305+
uint8_t space_id;
306+
uint8_t bit_width;
307+
uint8_t bit_offset;
308+
uint8_t access_size;
309+
uint64_t address;
310+
} __attribute__((aligned(8)));
311+
312+
struct cpu_cx_data {
313+
struct acrn_register cx_reg;
314+
uint8_t type;
315+
uint32_t latency;
316+
uint64_t power;
317+
} __attribute__((aligned(8)));
318+
295319
struct cpu_px_data {
296320
uint64_t core_frequency; /* megahertz */
297321
uint64_t power; /* milliWatts */

0 commit comments

Comments
 (0)