ia64/xen-unstable

changeset 19441:fa8dc6e43ec8

cpuidle: export max_cstate access via libxc

Signed-off-by: Wei Gang <gang.wei@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 31 11:19:26 2009 +0100 (2009-03-31)
parents 0f53202cb132
children 687376c92188
files tools/libxc/xc_pm.c tools/libxc/xenctrl.h xen/drivers/acpi/pmstat.c xen/include/public/sysctl.h
line diff
     1.1 --- a/tools/libxc/xc_pm.c	Tue Mar 31 11:17:51 2009 +0100
     1.2 +++ b/tools/libxc/xc_pm.c	Tue Mar 31 11:19:26 2009 +0100
     1.3 @@ -362,3 +362,36 @@ int xc_set_sched_opt_smt(int xc_handle, 
     1.4     return rc;
     1.5  }
     1.6  
     1.7 +int xc_get_cpuidle_max_cstate(int xc_handle, uint32_t *value)
     1.8 +{
     1.9 +    int rc;
    1.10 +    DECLARE_SYSCTL;
    1.11 +
    1.12 +    if ( xc_handle < 0 || !value )
    1.13 +        return -EINVAL;
    1.14 +
    1.15 +    sysctl.cmd = XEN_SYSCTL_pm_op;
    1.16 +    sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_get_max_cstate;
    1.17 +    sysctl.u.pm_op.cpuid = 0;
    1.18 +    sysctl.u.pm_op.get_max_cstate = 0;
    1.19 +    rc = do_sysctl(xc_handle, &sysctl);
    1.20 +    *value = sysctl.u.pm_op.get_max_cstate;
    1.21 +
    1.22 +    return rc;
    1.23 +}
    1.24 +
    1.25 +int xc_set_cpuidle_max_cstate(int xc_handle, uint32_t value)
    1.26 +{
    1.27 +    DECLARE_SYSCTL;
    1.28 +
    1.29 +    if ( xc_handle < 0 )
    1.30 +        return -EINVAL;
    1.31 +
    1.32 +    sysctl.cmd = XEN_SYSCTL_pm_op;
    1.33 +    sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_set_max_cstate;
    1.34 +    sysctl.u.pm_op.cpuid = 0;
    1.35 +    sysctl.u.pm_op.set_max_cstate = value;
    1.36 +
    1.37 +    return do_sysctl(xc_handle, &sysctl);
    1.38 +}
    1.39 +
     2.1 --- a/tools/libxc/xenctrl.h	Tue Mar 31 11:17:51 2009 +0100
     2.2 +++ b/tools/libxc/xenctrl.h	Tue Mar 31 11:19:26 2009 +0100
     2.3 @@ -1262,4 +1262,7 @@ int xc_get_cputopo(int xc_handle, struct
     2.4  
     2.5  int xc_set_sched_opt_smt(int xc_handle, uint32_t value);
     2.6  
     2.7 +int xc_get_cpuidle_max_cstate(int xc_handle, uint32_t *value);
     2.8 +int xc_set_cpuidle_max_cstate(int xc_handle, uint32_t value);
     2.9 +
    2.10  #endif /* XENCTRL_H */
     3.1 --- a/xen/drivers/acpi/pmstat.c	Tue Mar 31 11:17:51 2009 +0100
     3.2 +++ b/xen/drivers/acpi/pmstat.c	Tue Mar 31 11:19:26 2009 +0100
     3.3 @@ -37,6 +37,7 @@
     3.4  #include <asm/processor.h>
     3.5  #include <xen/percpu.h>
     3.6  #include <xen/domain.h>
     3.7 +#include <xen/acpi.h>
     3.8  
     3.9  #include <public/sysctl.h>
    3.10  #include <acpi/cpufreq/cpufreq.h>
    3.11 @@ -527,6 +528,18 @@ int do_pm_op(struct xen_sysctl_pm_op *op
    3.12          break;
    3.13      }
    3.14  
    3.15 +    case XEN_SYSCTL_pm_op_get_max_cstate:
    3.16 +    {
    3.17 +        op->get_max_cstate = max_cstate;
    3.18 +        break;
    3.19 +    }
    3.20 +
    3.21 +    case XEN_SYSCTL_pm_op_set_max_cstate:
    3.22 +    {
    3.23 +        max_cstate = op->set_max_cstate;
    3.24 +        break;
    3.25 +    }
    3.26 +
    3.27      default:
    3.28          printk("not defined sub-hypercall @ do_pm_op\n");
    3.29          ret = -ENOSYS;
     4.1 --- a/xen/include/public/sysctl.h	Tue Mar 31 11:17:51 2009 +0100
     4.2 +++ b/xen/include/public/sysctl.h	Tue Mar 31 11:19:26 2009 +0100
     4.3 @@ -382,6 +382,10 @@ struct xen_sysctl_pm_op {
     4.4      /* set/reset scheduler power saving option */
     4.5      #define XEN_SYSCTL_pm_op_set_sched_opt_smt    0x21
     4.6  
     4.7 +    /* cpuidle max_cstate access command */
     4.8 +    #define XEN_SYSCTL_pm_op_get_max_cstate       0x22
     4.9 +    #define XEN_SYSCTL_pm_op_set_max_cstate       0x23
    4.10 +
    4.11      uint32_t cmd;
    4.12      uint32_t cpuid;
    4.13      union {
    4.14 @@ -391,6 +395,8 @@ struct xen_sysctl_pm_op {
    4.15          uint64_t get_avgfreq;
    4.16          struct xen_get_cputopo      get_topo;
    4.17          uint32_t                    set_sched_opt_smt;
    4.18 +        uint32_t                    get_max_cstate;
    4.19 +        uint32_t                    set_max_cstate;
    4.20      };
    4.21  };
    4.22