Skip to content

Commit bdd90e6

Browse files
jsun26inteljren1
authored andcommitted
DM Cx: code cleanup for getting cpu state cnt
Then we could use a common interface to get cx count. Signed-off-by: Victor Sun <victor.sun@intel.com> Acked-by: Kevin Tian <kevin.tian@intel.com>
1 parent 81cf3e1 commit bdd90e6

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

devicemodel/hw/acpi/acpi_pm.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,25 @@
3838
#include "dm.h"
3939
#include "acpi.h"
4040

41-
static uint8_t get_vcpu_px_cnt(struct vmctx *ctx, int vcpu_id)
41+
static inline int get_vcpu_pm_info(struct vmctx *ctx, int vcpu_id,
42+
uint64_t pm_type, uint64_t *pm_info)
4243
{
43-
uint64_t pm_ioctl_buf = 0;
44-
enum pm_cmd_type cmd_type = PMCMD_GET_PX_CNT;
45-
46-
pm_ioctl_buf = ((ctx->vmid << PMCMD_VMID_SHIFT) & PMCMD_VMID_MASK)
44+
*pm_info = ((ctx->vmid << PMCMD_VMID_SHIFT) & PMCMD_VMID_MASK)
4745
| ((vcpu_id << PMCMD_VCPUID_SHIFT) & PMCMD_VCPUID_MASK)
48-
| cmd_type;
46+
| (pm_type & PMCMD_TYPE_MASK);
47+
48+
return vm_get_cpu_state(ctx, pm_info);
49+
}
50+
51+
static inline uint8_t get_vcpu_px_cnt(struct vmctx *ctx, int vcpu_id)
52+
{
53+
uint64_t px_cnt;
4954

50-
if (vm_get_cpu_state(ctx, &pm_ioctl_buf)) {
55+
if (get_vcpu_pm_info(ctx, vcpu_id, PMCMD_GET_PX_CNT, &px_cnt)) {
5156
return 0;
5257
}
5358

54-
return (uint8_t)pm_ioctl_buf;
59+
return (uint8_t)px_cnt;
5560
}
5661

5762
static int get_vcpu_px_data(struct vmctx *ctx, int vcpu_id,

0 commit comments

Comments
 (0)