[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC PATCH v2 11/12] xen: arm: implement XEN_SYSCTL_cpufreq_op



Kernel uses this op to get some parameters for the
xen-cpufreq driver to change CPUs frequency.

Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@xxxxxxxxxxxxxxx>
---
 xen/common/sysctl.c                |  8 ++++++++
 xen/drivers/cpufreq/dom0-cpufreq.c | 26 ++++++++++++++++++++++++++
 xen/include/public/sysctl.h        | 19 +++++++++++++++++++
 xen/include/xen/cpufreq.h          |  5 +++++
 4 files changed, 58 insertions(+)

diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index 0dcf06a..d90b3c0 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -27,6 +27,7 @@
 #include <xsm/xsm.h>
 #include <xen/pmstat.h>
 #include <xen/gcov.h>
+#include <xen/cpufreq.h>
 
 long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
 {
@@ -362,6 +363,13 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
         break;
 #endif
 
+#ifdef HAS_DOM0_CPUFREQ
+    case XEN_SYSCTL_cpufreq_op:
+        ret = sysctl_cpufreq_op(&op->u.cpufreq_op);
+        copyback = 1;
+        break;
+#endif
+
     default:
         ret = arch_do_sysctl(op, u_sysctl);
         copyback = 0;
diff --git a/xen/drivers/cpufreq/dom0-cpufreq.c 
b/xen/drivers/cpufreq/dom0-cpufreq.c
index f4274d7..a55cd64 100644
--- a/xen/drivers/cpufreq/dom0-cpufreq.c
+++ b/xen/drivers/cpufreq/dom0-cpufreq.c
@@ -50,6 +50,32 @@ static void notify_cpufreq_domains(void)
     send_global_virq(VIRQ_CPUFREQ);
 }
 
+int sysctl_cpufreq_op(xen_sysctl_cpufreq_op_t *op)
+{
+    int ret = 0;
+    switch ( op->cmd )
+    {
+    case XEN_SYSCTL_CPUFREQ_get_target:
+        spin_lock(&sysctl_cpufreq_lock);
+        op->u.target.cpu = sysctl_cpufreq_data.cpu;
+        op->u.target.freq = sysctl_cpufreq_data.freq;
+        op->u.target.relation = sysctl_cpufreq_data.relation;
+        spin_unlock(&sysctl_cpufreq_lock);
+        break;
+
+    case XEN_SYSCTL_CPUFREQ_set_result:
+        spin_lock(&sysctl_cpufreq_lock);
+        sysctl_cpufreq_data.result = op->u.result;
+        spin_unlock(&sysctl_cpufreq_lock);
+        break;
+
+    default:
+        return -ENOSYS;
+        break;
+    }
+    return ret;
+}
+
 static int dom0_cpufreq_verify(struct cpufreq_policy *policy)
 {
     struct acpi_cpufreq_data *data;
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index 8437d31..ecd4674 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -632,6 +632,23 @@ struct xen_sysctl_coverage_op {
 typedef struct xen_sysctl_coverage_op xen_sysctl_coverage_op_t;
 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_coverage_op_t);
 
+#define XEN_SYSCTL_CPUFREQ_get_target      0
+#define XEN_SYSCTL_CPUFREQ_set_result      1
+
+struct xen_sysctl_cpufreq_op {
+    uint32_t cmd;
+    union {
+        struct {
+            uint32_t cpu;
+            uint32_t freq;
+            uint32_t relation;
+        } target;
+        uint32_t result;
+    } u;
+};
+typedef struct xen_sysctl_cpufreq_op xen_sysctl_cpufreq_op_t;
+DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpufreq_op_t);
+
 
 struct xen_sysctl {
     uint32_t cmd;
@@ -654,6 +671,7 @@ struct xen_sysctl {
 #define XEN_SYSCTL_cpupool_op                    18
 #define XEN_SYSCTL_scheduler_op                  19
 #define XEN_SYSCTL_coverage_op                   20
+#define XEN_SYSCTL_cpufreq_op                    21
     uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
     union {
         struct xen_sysctl_readconsole       readconsole;
@@ -675,6 +693,7 @@ struct xen_sysctl {
         struct xen_sysctl_cpupool_op        cpupool_op;
         struct xen_sysctl_scheduler_op      scheduler_op;
         struct xen_sysctl_coverage_op       coverage_op;
+        struct xen_sysctl_cpufreq_op        cpufreq_op;
         uint8_t                             pad[128];
     } u;
 };
diff --git a/xen/include/xen/cpufreq.h b/xen/include/xen/cpufreq.h
index d7b6c34..2094b29 100644
--- a/xen/include/xen/cpufreq.h
+++ b/xen/include/xen/cpufreq.h
@@ -20,6 +20,7 @@
 #include <xen/spinlock.h>
 #include <xen/errno.h>
 #include <xen/cpumask.h>
+#include <public/sysctl.h>
 
 #include <xen/processor_perf.h>
 
@@ -264,4 +265,8 @@ int write_userspace_scaling_setspeed(unsigned int cpu, 
unsigned int freq);
 void cpufreq_dbs_timer_suspend(void);
 void cpufreq_dbs_timer_resume(void);
 
+#ifdef HAS_DOM0_CPUFREQ
+int sysctl_cpufreq_op(xen_sysctl_cpufreq_op_t *op);
+#endif
+
 #endif /* __XEN_CPUFREQ_PM_H__ */
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.