All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v3 00/12]xen_cpufreq implementation in Xen hypervisor
@ 2014-10-23 15:07 Oleksandr Dmytryshyn
  2014-10-23 15:07 ` [RFC PATCH v3 01/12] cpufreq: move cpufreq.h file to the xen/include/xen location Oleksandr Dmytryshyn
                   ` (11 more replies)
  0 siblings, 12 replies; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-23 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Tim Deegan, Stefano Stabellini, Ian Campbell

Hi to all.

Next series of patches implements xen-cpufreq driver in Xen hypervisor.

Cpufreq core and registered cpufreq governors are located in xen. Dom0 has CPU
driver which can only change frequency of the physical CPUs. In addition this
driver can change CPUs regulator voltage. At start time xen-cpufreq driver
in kernel uploads to Xen information about physical cpus.
Xen notifies Dom0 kernel using VIRQ_CPUFREQ interrupt. Then xen-cpufreq driver
in kernel uses XEN_SYSCTL_cpufreq_op operation from HYPERVISOR_sysctl hypercall
to get some parameters from Xen (frequency, relation and cpu number).
Then xen-cpufreq changes frequency on physical cpu and uses the same
XEN_SYSCTL_cpufreq_op operation ti give the result to Xen.

Changed since v1:
 * use /xen/include/xen/ instead of the  /xen/include/cpufreq/
   for included files
 * move pmstat.c file to the xen/drivers/pm/stat.c instead of the
   xen/drivers/pm/pmstat.c
 * updated ./MAINTAINERS accordingly to new files location
 * introduce HAS_CPU_TURBO config and use it
 * move ACPI-specific pmstat functions under the CONFIG_ACPI config
   instead of the CONFIG_X86 config
 * correct info message in cpufreq_add_cpu() function (remove _PSD
   prefix for NON ACPI configuration)
 * dropped patch "[RFC PATCH 07/13] xen/arm: enable cpu hotplug"
 * dropped patch "[RFC PATCH 08/13] xen/dts: make the dt_find_property
   function to be global"
 * create PCPUs device tree node in /hypervisor/pcpus node instead
   of the /cpus/cpu@0/private_date/ node
 * reworked platform hypercall implementation (used XSM check
   for ARM architecture) and moved common code to the common
   place.
 * xen-cpufreq driver to the dom0-cpufreq

Changed since v2:
 * corrected comment in xen/drivers/pm/stat.c
 * restored blank line in xen/drivers/pm/stat.c
 * corrected #ifdef in xen/drivers/cpufreq/cpufreq.c
 * removed common file for platform_hypercall implementation
 * renamed dom0-cpufreq.c to hwdom-cpufreq.c
 * slightly reworked file hwdom-cpufreq.c
 * used VIRQ_CPUFREQ with number 14 instead of the 13

Oleksandr Dmytryshyn (12):
  cpufreq: move cpufreq.h file to the xen/include/xen location
  pm: move processor_perf.h file to the xen/include/xen location
  pmstat: move pmstat.c file to the xen/drivers/pm/stat.c location
  cpufreq: make turbo settings to be configurable
  pmstat: make pmstat functions more generalizable
  cpufreq: make cpufreq driver more generalizable
  arch/arm: create device tree nodes for hwdom cpufreq cpu driver
  xsm: enable xsm_platform_op hook for all architectures
  xen: arm: implement platform hypercall
  cpufreq: add hwdom-cpufreq driver
  xen: arm: implement XEN_SYSCTL_cpufreq_op
  xen/arm: enable cpufreq functionality for ARM

 MAINTAINERS                                        |   3 +-
 xen/Rules.mk                                       |   4 +
 xen/arch/arm/Makefile                              |   1 +
 xen/arch/arm/Rules.mk                              |   3 +
 xen/arch/arm/domain_build.c                        |  67 +++++
 xen/arch/arm/platform_hypercall.c                  |  84 +++++++
 xen/arch/arm/traps.c                               |   1 +
 xen/arch/x86/Rules.mk                              |   2 +
 xen/arch/x86/acpi/cpu_idle.c                       |   2 +-
 xen/arch/x86/acpi/cpufreq/cpufreq.c                |   2 +-
 xen/arch/x86/acpi/cpufreq/powernow.c               |   2 +-
 xen/arch/x86/acpi/power.c                          |   2 +-
 xen/arch/x86/cpu/mwait-idle.c                      |   2 +-
 xen/arch/x86/platform_hypercall.c                  |   2 +-
 xen/common/sysctl.c                                |  10 +-
 xen/drivers/Makefile                               |   1 +
 xen/drivers/acpi/Makefile                          |   1 -
 xen/drivers/cpufreq/Makefile                       |   1 +
 xen/drivers/cpufreq/cpufreq.c                      |  82 ++++++-
 xen/drivers/cpufreq/cpufreq_misc_governors.c       |   2 +-
 xen/drivers/cpufreq/cpufreq_ondemand.c             |   4 +-
 xen/drivers/cpufreq/hwdom-cpufreq.c                | 272 +++++++++++++++++++++
 xen/drivers/cpufreq/utility.c                      |  13 +-
 xen/drivers/pm/Makefile                            |   1 +
 xen/drivers/{acpi/pmstat.c => pm/stat.c}           |  16 +-
 xen/include/public/platform.h                      |   1 +
 xen/include/public/sysctl.h                        |  19 ++
 xen/include/public/xen.h                           |   1 +
 xen/include/{acpi/cpufreq => xen}/cpufreq.h        |  15 +-
 xen/include/{acpi/cpufreq => xen}/processor_perf.h |   7 +
 xen/include/xsm/dummy.h                            |  12 +-
 xen/include/xsm/xsm.h                              |  10 +-
 xen/xsm/flask/hooks.c                              |   3 +-
 33 files changed, 611 insertions(+), 37 deletions(-)
 create mode 100644 xen/arch/arm/platform_hypercall.c
 create mode 100644 xen/drivers/cpufreq/hwdom-cpufreq.c
 create mode 100644 xen/drivers/pm/Makefile
 rename xen/drivers/{acpi/pmstat.c => pm/stat.c} (97%)
 rename xen/include/{acpi/cpufreq => xen}/cpufreq.h (96%)
 rename xen/include/{acpi/cpufreq => xen}/processor_perf.h (95%)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [RFC PATCH v3 01/12] cpufreq: move cpufreq.h file to the xen/include/xen location
  2014-10-23 15:07 [RFC PATCH v3 00/12]xen_cpufreq implementation in Xen hypervisor Oleksandr Dmytryshyn
@ 2014-10-23 15:07 ` Oleksandr Dmytryshyn
  2014-10-23 15:07 ` [RFC PATCH v3 02/12] pm: move processor_perf.h " Oleksandr Dmytryshyn
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-23 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Tim Deegan, Stefano Stabellini, Ian Campbell

Cpufreq driver should be more generalizable (not ACPI-specific).
Thus this file should be placed to more convenient location.

Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
---
 MAINTAINERS                                  | 1 +
 xen/arch/x86/acpi/cpu_idle.c                 | 2 +-
 xen/arch/x86/acpi/cpufreq/cpufreq.c          | 2 +-
 xen/arch/x86/acpi/cpufreq/powernow.c         | 2 +-
 xen/arch/x86/acpi/power.c                    | 2 +-
 xen/arch/x86/cpu/mwait-idle.c                | 2 +-
 xen/drivers/acpi/pmstat.c                    | 2 +-
 xen/drivers/cpufreq/cpufreq.c                | 2 +-
 xen/drivers/cpufreq/cpufreq_misc_governors.c | 2 +-
 xen/drivers/cpufreq/cpufreq_ondemand.c       | 4 ++--
 xen/drivers/cpufreq/utility.c                | 2 +-
 xen/include/{acpi/cpufreq => xen}/cpufreq.h  | 7 +++++--
 12 files changed, 17 insertions(+), 13 deletions(-)
 rename xen/include/{acpi/cpufreq => xen}/cpufreq.h (98%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7757cdd..49f56a1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -235,6 +235,7 @@ X:	xen/arch/x86/acpi/boot.c
 X:	xen/arch/x86/acpi/lib.c
 F:	xen/drivers/cpufreq/
 F:	xen/include/acpi/cpufreq/
+F:	xen/include/xen/cpufreq.h
 
 QEMU-DM
 M:	Ian Jackson <ian.jackson@eu.citrix.com>
diff --git a/xen/arch/x86/acpi/cpu_idle.c b/xen/arch/x86/acpi/cpu_idle.c
index 597befa..d773955 100644
--- a/xen/arch/x86/acpi/cpu_idle.c
+++ b/xen/arch/x86/acpi/cpu_idle.c
@@ -51,7 +51,7 @@
 #include <xen/softirq.h>
 #include <public/platform.h>
 #include <public/sysctl.h>
-#include <acpi/cpufreq/cpufreq.h>
+#include <xen/cpufreq.h>
 #include <asm/apic.h>
 #include <asm/cpuidle.h>
 #include <asm/mwait.h>
diff --git a/xen/arch/x86/acpi/cpufreq/cpufreq.c b/xen/arch/x86/acpi/cpufreq/cpufreq.c
index 4a6aeb3..5d22257 100644
--- a/xen/arch/x86/acpi/cpufreq/cpufreq.c
+++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c
@@ -42,7 +42,7 @@
 #include <asm/percpu.h>
 #include <asm/cpufeature.h>
 #include <acpi/acpi.h>
-#include <acpi/cpufreq/cpufreq.h>
+#include <xen/cpufreq.h>
 
 enum {
     UNDEFINED_CAPABLE = 0,
diff --git a/xen/arch/x86/acpi/cpufreq/powernow.c b/xen/arch/x86/acpi/cpufreq/powernow.c
index 2c9fea2..4961d55 100644
--- a/xen/arch/x86/acpi/cpufreq/powernow.c
+++ b/xen/arch/x86/acpi/cpufreq/powernow.c
@@ -36,7 +36,7 @@
 #include <asm/percpu.h>
 #include <asm/cpufeature.h>
 #include <acpi/acpi.h>
-#include <acpi/cpufreq/cpufreq.h>
+#include <xen/cpufreq.h>
 
 #define CPUID_6_ECX_APERFMPERF_CAPABILITY       (0x1)
 #define CPUID_FREQ_VOLT_CAPABILITIES    0x80000007
diff --git a/xen/arch/x86/acpi/power.c b/xen/arch/x86/acpi/power.c
index f41f0de..f4a87e3 100644
--- a/xen/arch/x86/acpi/power.c
+++ b/xen/arch/x86/acpi/power.c
@@ -29,7 +29,7 @@
 #include <asm/tboot.h>
 #include <asm/apic.h>
 #include <asm/io_apic.h>
-#include <acpi/cpufreq/cpufreq.h>
+#include <xen/cpufreq.h>
 
 uint32_t system_reset_counter = 1;
 
diff --git a/xen/arch/x86/cpu/mwait-idle.c b/xen/arch/x86/cpu/mwait-idle.c
index 85179f2..c72219a 100644
--- a/xen/arch/x86/cpu/mwait-idle.c
+++ b/xen/arch/x86/cpu/mwait-idle.c
@@ -59,7 +59,7 @@
 #include <asm/hpet.h>
 #include <asm/mwait.h>
 #include <asm/msr.h>
-#include <acpi/cpufreq/cpufreq.h>
+#include <xen/cpufreq.h>
 
 #define MWAIT_IDLE_VERSION "0.4"
 #undef PREFIX
diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/acpi/pmstat.c
index daac2da..3486148 100644
--- a/xen/drivers/acpi/pmstat.c
+++ b/xen/drivers/acpi/pmstat.c
@@ -40,7 +40,7 @@
 #include <xen/acpi.h>
 
 #include <public/sysctl.h>
-#include <acpi/cpufreq/cpufreq.h>
+#include <xen/cpufreq.h>
 #include <xen/pmstat.h>
 
 DEFINE_PER_CPU_READ_MOSTLY(struct pm_px *, cpufreq_statistic_data);
diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c
index ab66884..f5f4d75 100644
--- a/xen/drivers/cpufreq/cpufreq.c
+++ b/xen/drivers/cpufreq/cpufreq.c
@@ -44,7 +44,7 @@
 #include <asm/processor.h>
 #include <asm/percpu.h>
 #include <acpi/acpi.h>
-#include <acpi/cpufreq/cpufreq.h>
+#include <xen/cpufreq.h>
 
 static unsigned int __read_mostly usr_min_freq;
 static unsigned int __read_mostly usr_max_freq;
diff --git a/xen/drivers/cpufreq/cpufreq_misc_governors.c b/xen/drivers/cpufreq/cpufreq_misc_governors.c
index 746bbcd..4a5510c 100644
--- a/xen/drivers/cpufreq/cpufreq_misc_governors.c
+++ b/xen/drivers/cpufreq/cpufreq_misc_governors.c
@@ -18,7 +18,7 @@
 #include <xen/init.h>
 #include <xen/percpu.h>
 #include <xen/sched.h>
-#include <acpi/cpufreq/cpufreq.h>
+#include <xen/cpufreq.h>
 
 /*
  * cpufreq userspace governor
diff --git a/xen/drivers/cpufreq/cpufreq_ondemand.c b/xen/drivers/cpufreq/cpufreq_ondemand.c
index 7fdba03..d490c8a 100644
--- a/xen/drivers/cpufreq/cpufreq_ondemand.c
+++ b/xen/drivers/cpufreq/cpufreq_ondemand.c
@@ -1,5 +1,5 @@
 /*
- *  xen/arch/x86/acpi/cpufreq/cpufreq_ondemand.c
+ *  xen/drivers/cpufreq/cpufreq_ondemand.c
  *
  *  Copyright (C)  2001 Russell King
  *            (C)  2003 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>.
@@ -18,7 +18,7 @@
 #include <xen/types.h>
 #include <xen/sched.h>
 #include <xen/timer.h>
-#include <acpi/cpufreq/cpufreq.h>
+#include <xen/cpufreq.h>
 
 #define DEF_FREQUENCY_UP_THRESHOLD              (80)
 #define MIN_FREQUENCY_UP_THRESHOLD              (11)
diff --git a/xen/drivers/cpufreq/utility.c b/xen/drivers/cpufreq/utility.c
index 519f862..3cb0b3e 100644
--- a/xen/drivers/cpufreq/utility.c
+++ b/xen/drivers/cpufreq/utility.c
@@ -28,7 +28,7 @@
 #include <xen/sched.h>
 #include <xen/timer.h>
 #include <xen/trace.h>
-#include <acpi/cpufreq/cpufreq.h>
+#include <xen/cpufreq.h>
 #include <public/sysctl.h>
 
 struct cpufreq_driver   *cpufreq_driver;
diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/xen/cpufreq.h
similarity index 98%
rename from xen/include/acpi/cpufreq/cpufreq.h
rename to xen/include/xen/cpufreq.h
index f96c3e4..fa653ef 100644
--- a/xen/include/acpi/cpufreq/cpufreq.h
+++ b/xen/include/xen/cpufreq.h
@@ -1,5 +1,5 @@
 /*
- *  xen/include/acpi/cpufreq/cpufreq.h
+ *  xen/include/xen/cpufreq.h
  *
  *  Copyright (C) 2001 Russell King
  *            (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
@@ -16,9 +16,12 @@
 
 #include <xen/types.h>
 #include <xen/list.h>
+#include <xen/percpu.h>
+#include <xen/spinlock.h>
+#include <xen/errno.h>
 #include <xen/cpumask.h>
 
-#include "processor_perf.h"
+#include <acpi/cpufreq/processor_perf.h>
 
 DECLARE_PER_CPU(spinlock_t, cpufreq_statistic_lock);
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [RFC PATCH v3 02/12] pm: move processor_perf.h file to the xen/include/xen location
  2014-10-23 15:07 [RFC PATCH v3 00/12]xen_cpufreq implementation in Xen hypervisor Oleksandr Dmytryshyn
  2014-10-23 15:07 ` [RFC PATCH v3 01/12] cpufreq: move cpufreq.h file to the xen/include/xen location Oleksandr Dmytryshyn
@ 2014-10-23 15:07 ` Oleksandr Dmytryshyn
  2014-10-23 15:07 ` [RFC PATCH v3 03/12] pmstat: move pmstat.c file to the xen/drivers/pm/stat.c location Oleksandr Dmytryshyn
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-23 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Tim Deegan, Stefano Stabellini, Ian Campbell

Cpufreq driver should be more generalizable (not ACPI-specific).
Thus this file should be placed to more convenient location.

Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
---
 MAINTAINERS                                        | 2 +-
 xen/arch/x86/platform_hypercall.c                  | 2 +-
 xen/include/xen/cpufreq.h                          | 2 +-
 xen/include/{acpi/cpufreq => xen}/processor_perf.h | 0
 4 files changed, 3 insertions(+), 3 deletions(-)
 rename xen/include/{acpi/cpufreq => xen}/processor_perf.h (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 49f56a1..f4d916e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -234,8 +234,8 @@ F:	xen/arch/x86/acpi/
 X:	xen/arch/x86/acpi/boot.c
 X:	xen/arch/x86/acpi/lib.c
 F:	xen/drivers/cpufreq/
-F:	xen/include/acpi/cpufreq/
 F:	xen/include/xen/cpufreq.h
+F:	xen/include/xen/processor_perf.h
 
 QEMU-DM
 M:	Ian Jackson <ian.jackson@eu.citrix.com>
diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hypercall.c
index 2162811..7ce8592 100644
--- a/xen/arch/x86/platform_hypercall.c
+++ b/xen/arch/x86/platform_hypercall.c
@@ -25,7 +25,7 @@
 #include <xen/irq.h>
 #include <asm/current.h>
 #include <public/platform.h>
-#include <acpi/cpufreq/processor_perf.h>
+#include <xen/processor_perf.h>
 #include <asm/edd.h>
 #include <asm/mtrr.h>
 #include <asm/io_apic.h>
diff --git a/xen/include/xen/cpufreq.h b/xen/include/xen/cpufreq.h
index fa653ef..82dc4dc 100644
--- a/xen/include/xen/cpufreq.h
+++ b/xen/include/xen/cpufreq.h
@@ -21,7 +21,7 @@
 #include <xen/errno.h>
 #include <xen/cpumask.h>
 
-#include <acpi/cpufreq/processor_perf.h>
+#include <xen/processor_perf.h>
 
 DECLARE_PER_CPU(spinlock_t, cpufreq_statistic_lock);
 
diff --git a/xen/include/acpi/cpufreq/processor_perf.h b/xen/include/xen/processor_perf.h
similarity index 100%
rename from xen/include/acpi/cpufreq/processor_perf.h
rename to xen/include/xen/processor_perf.h
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [RFC PATCH v3 03/12] pmstat: move pmstat.c file to the xen/drivers/pm/stat.c location
  2014-10-23 15:07 [RFC PATCH v3 00/12]xen_cpufreq implementation in Xen hypervisor Oleksandr Dmytryshyn
  2014-10-23 15:07 ` [RFC PATCH v3 01/12] cpufreq: move cpufreq.h file to the xen/include/xen location Oleksandr Dmytryshyn
  2014-10-23 15:07 ` [RFC PATCH v3 02/12] pm: move processor_perf.h " Oleksandr Dmytryshyn
@ 2014-10-23 15:07 ` Oleksandr Dmytryshyn
  2014-10-23 15:07 ` [RFC PATCH v3 04/12] cpufreq: make turbo settings to be configurable Oleksandr Dmytryshyn
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-23 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Tim Deegan, Stefano Stabellini, Ian Campbell

Cpufreq driver should be more generalizable (not ACPI-specific).
Thus this file should be placed to more convenient location.

Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
---
 xen/Rules.mk                             | 1 +
 xen/arch/x86/Rules.mk                    | 1 +
 xen/common/sysctl.c                      | 2 +-
 xen/drivers/Makefile                     | 1 +
 xen/drivers/acpi/Makefile                | 1 -
 xen/drivers/pm/Makefile                  | 1 +
 xen/drivers/{acpi/pmstat.c => pm/stat.c} | 0
 7 files changed, 5 insertions(+), 2 deletions(-)
 create mode 100644 xen/drivers/pm/Makefile
 rename xen/drivers/{acpi/pmstat.c => pm/stat.c} (100%)

diff --git a/xen/Rules.mk b/xen/Rules.mk
index 3a6cec5..b7caab6 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -55,6 +55,7 @@ CFLAGS-$(perfc)         += -DPERF_COUNTERS
 CFLAGS-$(perfc_arrays)  += -DPERF_ARRAYS
 CFLAGS-$(lock_profile)  += -DLOCK_PROFILE
 CFLAGS-$(HAS_ACPI)      += -DHAS_ACPI
+CFLAGS-$(HAS_PM)        += -DHAS_PM
 CFLAGS-$(HAS_GDBSX)     += -DHAS_GDBSX
 CFLAGS-$(HAS_PASSTHROUGH) += -DHAS_PASSTHROUGH
 CFLAGS-$(HAS_DEVICE_TREE) += -DHAS_DEVICE_TREE
diff --git a/xen/arch/x86/Rules.mk b/xen/arch/x86/Rules.mk
index 576985e..9e9fbf1 100644
--- a/xen/arch/x86/Rules.mk
+++ b/xen/arch/x86/Rules.mk
@@ -3,6 +3,7 @@
 
 HAS_IOPORTS := y
 HAS_ACPI := y
+HAS_PM := y
 HAS_VGA  := y
 HAS_VIDEO  := y
 HAS_CPUFREQ := y
diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index 0cb6ee1..0dcf06a 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -170,7 +170,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
         op->u.availheap.avail_bytes <<= PAGE_SHIFT;
         break;
 
-#ifdef HAS_ACPI
+#ifdef HAS_PM
     case XEN_SYSCTL_get_pmstat:
         ret = do_get_pm_info(&op->u.get_pmstat);
         break;
diff --git a/xen/drivers/Makefile b/xen/drivers/Makefile
index 9c70f20..ee4fd4d 100644
--- a/xen/drivers/Makefile
+++ b/xen/drivers/Makefile
@@ -4,3 +4,4 @@ subdir-$(HAS_PCI) += pci
 subdir-$(HAS_PASSTHROUGH) += passthrough
 subdir-$(HAS_ACPI) += acpi
 subdir-$(HAS_VIDEO) += video
+subdir-$(HAS_PM) += pm
diff --git a/xen/drivers/acpi/Makefile b/xen/drivers/acpi/Makefile
index bbb06a7..0505742 100644
--- a/xen/drivers/acpi/Makefile
+++ b/xen/drivers/acpi/Makefile
@@ -5,7 +5,6 @@ subdir-$(x86) += apei
 obj-bin-y += tables.init.o
 obj-y += numa.o
 obj-y += osl.o
-obj-y += pmstat.o
 
 obj-$(x86) += hwregs.o
 obj-$(x86) += reboot.o
diff --git a/xen/drivers/pm/Makefile b/xen/drivers/pm/Makefile
new file mode 100644
index 0000000..2073683
--- /dev/null
+++ b/xen/drivers/pm/Makefile
@@ -0,0 +1 @@
+obj-y += stat.o
diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/pm/stat.c
similarity index 100%
rename from xen/drivers/acpi/pmstat.c
rename to xen/drivers/pm/stat.c
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [RFC PATCH v3 04/12] cpufreq: make turbo settings to be configurable
  2014-10-23 15:07 [RFC PATCH v3 00/12]xen_cpufreq implementation in Xen hypervisor Oleksandr Dmytryshyn
                   ` (2 preceding siblings ...)
  2014-10-23 15:07 ` [RFC PATCH v3 03/12] pmstat: move pmstat.c file to the xen/drivers/pm/stat.c location Oleksandr Dmytryshyn
@ 2014-10-23 15:07 ` Oleksandr Dmytryshyn
  2014-10-23 15:07 ` [RFC PATCH v3 05/12] pmstat: make pmstat functions more generalizable Oleksandr Dmytryshyn
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-23 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Tim Deegan, Stefano Stabellini, Ian Campbell

This settings is not needed for some architectures.
So make it to be configurable and use it for x86
architecture.

Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
---
 xen/Rules.mk                  |  1 +
 xen/arch/x86/Rules.mk         |  1 +
 xen/drivers/cpufreq/utility.c | 11 ++++++++++-
 xen/drivers/pm/stat.c         |  6 ++++++
 xen/include/xen/cpufreq.h     |  6 ++++++
 5 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/xen/Rules.mk b/xen/Rules.mk
index b7caab6..5953152 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -56,6 +56,7 @@ CFLAGS-$(perfc_arrays)  += -DPERF_ARRAYS
 CFLAGS-$(lock_profile)  += -DLOCK_PROFILE
 CFLAGS-$(HAS_ACPI)      += -DHAS_ACPI
 CFLAGS-$(HAS_PM)        += -DHAS_PM
+CFLAGS-$(HAS_CPU_TURBO) += -DHAS_CPU_TURBO
 CFLAGS-$(HAS_GDBSX)     += -DHAS_GDBSX
 CFLAGS-$(HAS_PASSTHROUGH) += -DHAS_PASSTHROUGH
 CFLAGS-$(HAS_DEVICE_TREE) += -DHAS_DEVICE_TREE
diff --git a/xen/arch/x86/Rules.mk b/xen/arch/x86/Rules.mk
index 9e9fbf1..cfe4f90 100644
--- a/xen/arch/x86/Rules.mk
+++ b/xen/arch/x86/Rules.mk
@@ -4,6 +4,7 @@
 HAS_IOPORTS := y
 HAS_ACPI := y
 HAS_PM := y
+HAS_CPU_TURBO := y
 HAS_VGA  := y
 HAS_VIDEO  := y
 HAS_CPUFREQ := y
diff --git a/xen/drivers/cpufreq/utility.c b/xen/drivers/cpufreq/utility.c
index 3cb0b3e..e92cf17 100644
--- a/xen/drivers/cpufreq/utility.c
+++ b/xen/drivers/cpufreq/utility.c
@@ -209,7 +209,9 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
 {
     unsigned int min_freq = ~0;
     unsigned int max_freq = 0;
+#ifdef HAS_CPU_TURBO
     unsigned int second_max_freq = 0;
+#endif
     unsigned int i;
 
     for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
@@ -221,6 +223,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
         if (freq > max_freq)
             max_freq = freq;
     }
+#ifdef HAS_CPU_TURBO
     for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
         unsigned int freq = table[i].frequency;
         if (freq == CPUFREQ_ENTRY_INVALID || freq == max_freq)
@@ -234,9 +237,13 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
         printk("max_freq: %u    second_max_freq: %u\n",
                max_freq, second_max_freq);
 
+    policy->cpuinfo.second_max_freq = second_max_freq;
+#else
+    if (cpufreq_verbose)
+        printk("max_freq: %u\n", max_freq);
+#endif
     policy->min = policy->cpuinfo.min_freq = min_freq;
     policy->max = policy->cpuinfo.max_freq = max_freq;
-    policy->cpuinfo.second_max_freq = second_max_freq;
 
     if (policy->min == ~0)
         return -EINVAL;
@@ -390,6 +397,7 @@ int cpufreq_driver_getavg(unsigned int cpu, unsigned int flag)
     return policy->cur;
 }
 
+#ifdef HAS_CPU_TURBO
 int cpufreq_update_turbo(int cpuid, int new_state)
 {
     struct cpufreq_policy *policy;
@@ -430,6 +438,7 @@ int cpufreq_get_turbo_status(int cpuid)
     policy = per_cpu(cpufreq_cpu_policy, cpuid);
     return policy && policy->turbo == CPUFREQ_TURBO_ENABLED;
 }
+#endif /* HAS_CPU_TURBO */
 
 /*********************************************************************
  *                 POLICY                                            *
diff --git a/xen/drivers/pm/stat.c b/xen/drivers/pm/stat.c
index 3486148..3154051 100644
--- a/xen/drivers/pm/stat.c
+++ b/xen/drivers/pm/stat.c
@@ -292,7 +292,11 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op)
             &op->u.get_para.u.ondemand.sampling_rate,
             &op->u.get_para.u.ondemand.up_threshold);
     }
+#ifdef HAS_CPU_TURBO
     op->u.get_para.turbo_enabled = cpufreq_get_turbo_status(op->cpuid);
+#else
+    op->u.get_para.turbo_enabled = 0;
+#endif
 
     return ret;
 }
@@ -475,6 +479,7 @@ int do_pm_op(struct xen_sysctl_pm_op *op)
         break;
     }
 
+#ifdef HAS_CPU_TURBO
     case XEN_SYSCTL_pm_op_enable_turbo:
     {
         ret = cpufreq_update_turbo(op->cpuid, CPUFREQ_TURBO_ENABLED);
@@ -486,6 +491,7 @@ int do_pm_op(struct xen_sysctl_pm_op *op)
         ret = cpufreq_update_turbo(op->cpuid, CPUFREQ_TURBO_DISABLED);
         break;
     }
+#endif /* HAS_CPU_TURBO */
 
     default:
         printk("not defined sub-hypercall @ do_pm_op\n");
diff --git a/xen/include/xen/cpufreq.h b/xen/include/xen/cpufreq.h
index 82dc4dc..d7b6c34 100644
--- a/xen/include/xen/cpufreq.h
+++ b/xen/include/xen/cpufreq.h
@@ -39,7 +39,9 @@ extern struct acpi_cpufreq_data *cpufreq_drv_data[NR_CPUS];
 
 struct cpufreq_cpuinfo {
     unsigned int        max_freq;
+#ifdef HAS_CPU_TURBO
     unsigned int        second_max_freq;    /* P1 if Turbo Mode is on */
+#endif
     unsigned int        min_freq;
     unsigned int        transition_latency; /* in 10^(-9) s = nanoseconds */
 };
@@ -59,10 +61,12 @@ struct cpufreq_policy {
 
     bool_t              resume; /* flag for cpufreq 1st run
                                  * S3 wakeup, hotplug cpu, etc */
+#ifdef HAS_CPU_TURBO
     s8                  turbo;  /* tristate flag: 0 for unsupported
                                  * -1 for disable, 1 for enabled
                                  * See CPUFREQ_TURBO_* below for defines */
     bool_t              aperf_mperf; /* CPU has APERF/MPERF MSRs */
+#endif
 };
 DECLARE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_policy);
 
@@ -127,8 +131,10 @@ extern int cpufreq_driver_getavg(unsigned int cpu, unsigned int flag);
 #define CPUFREQ_TURBO_UNSUPPORTED   0
 #define CPUFREQ_TURBO_ENABLED       1
 
+#ifdef HAS_CPU_TURBO
 extern int cpufreq_update_turbo(int cpuid, int new_state);
 extern int cpufreq_get_turbo_status(int cpuid);
+#endif
 
 static __inline__ int 
 __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [RFC PATCH v3 05/12] pmstat: make pmstat functions more generalizable
  2014-10-23 15:07 [RFC PATCH v3 00/12]xen_cpufreq implementation in Xen hypervisor Oleksandr Dmytryshyn
                   ` (3 preceding siblings ...)
  2014-10-23 15:07 ` [RFC PATCH v3 04/12] cpufreq: make turbo settings to be configurable Oleksandr Dmytryshyn
@ 2014-10-23 15:07 ` Oleksandr Dmytryshyn
  2014-10-23 15:07 ` [RFC PATCH v3 06/12] cpufreq: make cpufreq driver " Oleksandr Dmytryshyn
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-23 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Tim Deegan, Stefano Stabellini, Ian Campbell

ACPI-specific parts are moved under appropriate ifdefs.
Now pmstat functions can be used in ARM platform.

Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
---
 xen/drivers/pm/stat.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/pm/stat.c b/xen/drivers/pm/stat.c
index 3154051..1d13805 100644
--- a/xen/drivers/pm/stat.c
+++ b/xen/drivers/pm/stat.c
@@ -37,7 +37,6 @@
 #include <asm/processor.h>
 #include <xen/percpu.h>
 #include <xen/domain.h>
-#include <xen/acpi.h>
 
 #include <public/sysctl.h>
 #include <xen/cpufreq.h>
@@ -134,6 +133,8 @@ int do_get_pm_info(struct xen_sysctl_get_pmstat *op)
         break;
     }
 
+/* For now those operations can be used only when ACPI is enabled */
+#ifdef CONFIG_ACPI
     case PMSTAT_get_max_cx:
     {
         op->u.getcx.nr = pmstat_get_cx_nr(op->cpuid);
@@ -152,6 +153,7 @@ int do_get_pm_info(struct xen_sysctl_get_pmstat *op)
         ret = pmstat_reset_cx_stat(op->cpuid);
         break;
     }
+#endif /* CONFIG_ACPI */
 
     default:
         printk("not defined sub-hypercall @ do_get_pm_info\n");
@@ -467,6 +469,7 @@ int do_pm_op(struct xen_sysctl_pm_op *op)
         break;
     }
 
+#ifdef CONFIG_ACPI
     case XEN_SYSCTL_pm_op_get_max_cstate:
     {
         op->u.get_max_cstate = acpi_get_cstate_limit();
@@ -478,6 +481,7 @@ int do_pm_op(struct xen_sysctl_pm_op *op)
         acpi_set_cstate_limit(op->u.set_max_cstate);
         break;
     }
+#endif /* CONFIG_ACPI */
 
 #ifdef HAS_CPU_TURBO
     case XEN_SYSCTL_pm_op_enable_turbo:
@@ -502,6 +506,7 @@ int do_pm_op(struct xen_sysctl_pm_op *op)
     return ret;
 }
 
+#ifdef CONFIG_ACPI
 int acpi_set_pdc_bits(u32 acpi_id, XEN_GUEST_HANDLE_PARAM(uint32) pdc)
 {
     u32 bits[3];
@@ -532,3 +537,4 @@ int acpi_set_pdc_bits(u32 acpi_id, XEN_GUEST_HANDLE_PARAM(uint32) pdc)
 
     return ret;
 }
+#endif /* CONFIG_ACPI */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [RFC PATCH v3 06/12] cpufreq: make cpufreq driver more generalizable
  2014-10-23 15:07 [RFC PATCH v3 00/12]xen_cpufreq implementation in Xen hypervisor Oleksandr Dmytryshyn
                   ` (4 preceding siblings ...)
  2014-10-23 15:07 ` [RFC PATCH v3 05/12] pmstat: make pmstat functions more generalizable Oleksandr Dmytryshyn
@ 2014-10-23 15:07 ` Oleksandr Dmytryshyn
  2014-10-23 15:07 ` [RFC PATCH v3 07/12] arch/arm: create device tree nodes for hwdom cpufreq cpu driver Oleksandr Dmytryshyn
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-23 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Tim Deegan, Stefano Stabellini, Ian Campbell

First implementation of the cpufreq driver has been
written with x86 in mind. This patch makes possible
the cpufreq driver be working on both x86 and arm
architectures.

Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
---
 xen/Rules.mk                     |  1 +
 xen/drivers/cpufreq/cpufreq.c    | 80 +++++++++++++++++++++++++++++++++++++---
 xen/include/public/platform.h    |  1 +
 xen/include/xen/processor_perf.h |  7 ++++
 4 files changed, 83 insertions(+), 6 deletions(-)

diff --git a/xen/Rules.mk b/xen/Rules.mk
index 5953152..3b0b89b 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -55,6 +55,7 @@ CFLAGS-$(perfc)         += -DPERF_COUNTERS
 CFLAGS-$(perfc_arrays)  += -DPERF_ARRAYS
 CFLAGS-$(lock_profile)  += -DLOCK_PROFILE
 CFLAGS-$(HAS_ACPI)      += -DHAS_ACPI
+CFLAGS-$(HAS_CPUFREQ)   += -DHAS_CPUFREQ
 CFLAGS-$(HAS_PM)        += -DHAS_PM
 CFLAGS-$(HAS_CPU_TURBO) += -DHAS_CPU_TURBO
 CFLAGS-$(HAS_GDBSX)     += -DHAS_GDBSX
diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c
index f5f4d75..1644096 100644
--- a/xen/drivers/cpufreq/cpufreq.c
+++ b/xen/drivers/cpufreq/cpufreq.c
@@ -43,7 +43,6 @@
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <asm/percpu.h>
-#include <acpi/acpi.h>
 #include <xen/cpufreq.h>
 
 static unsigned int __read_mostly usr_min_freq;
@@ -192,6 +191,7 @@ int cpufreq_add_cpu(unsigned int cpu)
     } else {
         /* domain sanity check under whatever coordination type */
         firstcpu = cpumask_first(cpufreq_dom->map);
+#ifdef CONFIG_ACPI
         if ((perf->domain_info.coord_type !=
             processor_pminfo[firstcpu]->perf.domain_info.coord_type) ||
             (perf->domain_info.num_processors !=
@@ -207,6 +207,18 @@ int cpufreq_add_cpu(unsigned int cpu)
                 );
             return -EINVAL;
         }
+#else /* CONFIG_ACPI */
+        if ((perf->domain_info.num_processors !=
+            processor_pminfo[firstcpu]->perf.domain_info.num_processors)) {
+
+            printk(KERN_WARNING "cpufreq fail to add CPU%d:"
+                   "incorrect num processors (%"PRIu64"), expect(%"PRIu64")\n",
+                   cpu, perf->domain_info.num_processors,
+                   processor_pminfo[firstcpu]->perf.domain_info.num_processors
+                );
+            return -EINVAL;
+        }
+#endif /* CONFIG_ACPI */
     }
 
     if (!domexist || hw_all) {
@@ -363,6 +375,7 @@ int cpufreq_del_cpu(unsigned int cpu)
     return 0;
 }
 
+#ifdef CONFIG_ACPI
 static void print_PCT(struct xen_pct_register *ptr)
 {
     printk("\t_PCT: descriptor=%d, length=%d, space_id=%d, "
@@ -370,12 +383,14 @@ static void print_PCT(struct xen_pct_register *ptr)
            ptr->descriptor, ptr->length, ptr->space_id, ptr->bit_width,
            ptr->bit_offset, ptr->reserved, ptr->address);
 }
+#endif
 
 static void print_PSS(struct xen_processor_px *ptr, int count)
 {
     int i;
     printk("\t_PSS: state_count=%d\n", count);
     for (i=0; i<count; i++){
+#ifdef CONFIG_ACPI
         printk("\tState%d: %"PRId64"MHz %"PRId64"mW %"PRId64"us "
                "%"PRId64"us %#"PRIx64" %#"PRIx64"\n",
                i,
@@ -385,15 +400,26 @@ static void print_PSS(struct xen_processor_px *ptr, int count)
                ptr[i].bus_master_latency,
                ptr[i].control,
                ptr[i].status);
+#else /* CONFIG_ACPI */
+        printk("\tState%d: %"PRId64"MHz %"PRId64"us\n",
+               i,
+               ptr[i].core_frequency,
+               ptr[i].transition_latency);
+#endif /* CONFIG_ACPI */
     }
 }
 
 static void print_PSD( struct xen_psd_package *ptr)
 {
+#ifdef CONFIG_ACPI
     printk("\t_PSD: num_entries=%"PRId64" rev=%"PRId64
            " domain=%"PRId64" coord_type=%"PRId64" num_processors=%"PRId64"\n",
            ptr->num_entries, ptr->revision, ptr->domain, ptr->coord_type,
            ptr->num_processors);
+#else /* CONFIG_ACPI */
+    printk("\t_PSD:  domain=%"PRId64" num_processors=%"PRId64"\n",
+           ptr->domain, ptr->num_processors);
+#endif /* CONFIG_ACPI */
 }
 
 static void print_PPC(unsigned int platform_limit)
@@ -401,13 +427,53 @@ static void print_PPC(unsigned int platform_limit)
     printk("\t_PPC: %d\n", platform_limit);
 }
 
+static inline uint32_t is_pss_data(struct xen_processor_performance *px)
+{
+#ifdef CONFIG_ACPI
+    return px->flags & XEN_PX_PSS;
+#else
+    return px->flags == XEN_PX_DATA;
+#endif
+}
+
+static inline uint32_t is_psd_data(struct xen_processor_performance *px)
+{
+#ifdef CONFIG_ACPI
+    return px->flags & XEN_PX_PSD;
+#else
+    return px->flags == XEN_PX_DATA;
+#endif
+}
+
+static inline uint32_t is_ppc_data(struct xen_processor_performance *px)
+{
+#ifdef CONFIG_ACPI
+    return px->flags & XEN_PX_PPC;
+#else
+    return px->flags == XEN_PX_DATA;
+#endif
+}
+
+static inline uint32_t is_all_data(struct xen_processor_performance *px)
+{
+#ifdef CONFIG_ACPI
+    return px->flags == ( XEN_PX_PCT | XEN_PX_PSS | XEN_PX_PSD | XEN_PX_PPC );
+#else
+    return px->flags == XEN_PX_DATA;
+#endif
+}
+
 int set_px_pminfo(uint32_t acpi_id, struct xen_processor_performance *dom0_px_info)
 {
     int ret=0, cpuid;
     struct processor_pminfo *pmpt;
     struct processor_performance *pxpt;
 
+#ifdef CONFIG_ACPI
     cpuid = get_cpu_id(acpi_id);
+#else
+    cpuid = acpi_id;
+#endif
     if ( cpuid < 0 || !dom0_px_info)
     {
         ret = -EINVAL;
@@ -429,6 +495,8 @@ int set_px_pminfo(uint32_t acpi_id, struct xen_processor_performance *dom0_px_in
         processor_pminfo[cpuid] = pmpt;
     }
     pxpt = &pmpt->perf;
+
+#ifdef CONFIG_ACPI
     pmpt->acpi_id = acpi_id;
     pmpt->id = cpuid;
 
@@ -455,8 +523,9 @@ int set_px_pminfo(uint32_t acpi_id, struct xen_processor_performance *dom0_px_in
             print_PCT(&pxpt->status_register);
         }
     }
+#endif /* CONFIG_ACPI */
 
-    if ( dom0_px_info->flags & XEN_PX_PSS ) 
+    if ( is_pss_data(dom0_px_info) )
     {
         /* capability check */
         if (dom0_px_info->state_count <= 1)
@@ -483,7 +552,7 @@ int set_px_pminfo(uint32_t acpi_id, struct xen_processor_performance *dom0_px_in
             print_PSS(pxpt->states,pxpt->state_count);
     }
 
-    if ( dom0_px_info->flags & XEN_PX_PSD )
+    if ( is_psd_data(dom0_px_info) )
     {
         /* check domain coordination */
         if (dom0_px_info->shared_type != CPUFREQ_SHARED_TYPE_ALL &&
@@ -503,7 +572,7 @@ int set_px_pminfo(uint32_t acpi_id, struct xen_processor_performance *dom0_px_in
             print_PSD(&pxpt->domain_info);
     }
 
-    if ( dom0_px_info->flags & XEN_PX_PPC )
+    if ( is_ppc_data(dom0_px_info) )
     {
         pxpt->platform_limit = dom0_px_info->platform_limit;
 
@@ -517,8 +586,7 @@ int set_px_pminfo(uint32_t acpi_id, struct xen_processor_performance *dom0_px_in
         }
     }
 
-    if ( dom0_px_info->flags == ( XEN_PX_PCT | XEN_PX_PSS |
-                XEN_PX_PSD | XEN_PX_PPC ) )
+    if ( is_all_data(dom0_px_info) )
     {
         pxpt->init = XEN_PX_INIT;
 
diff --git a/xen/include/public/platform.h b/xen/include/public/platform.h
index 4341f54..ccb7969 100644
--- a/xen/include/public/platform.h
+++ b/xen/include/public/platform.h
@@ -358,6 +358,7 @@ DEFINE_XEN_GUEST_HANDLE(xenpf_getidletime_t);
 #define XEN_PX_PSS   2
 #define XEN_PX_PPC   4
 #define XEN_PX_PSD   8
+#define XEN_PX_DATA  16
 
 struct xen_power_register {
     uint32_t     space_id;
diff --git a/xen/include/xen/processor_perf.h b/xen/include/xen/processor_perf.h
index d8a1ba6..6c1279d 100644
--- a/xen/include/xen/processor_perf.h
+++ b/xen/include/xen/processor_perf.h
@@ -3,7 +3,10 @@
 
 #include <public/platform.h>
 #include <public/sysctl.h>
+
+#ifdef CONFIG_ACPI
 #include <xen/acpi.h>
+#endif
 
 #define XEN_PX_INIT 0x80000000
 
@@ -24,8 +27,10 @@ int  cpufreq_del_cpu(unsigned int);
 struct processor_performance {
     uint32_t state;
     uint32_t platform_limit;
+#ifdef CONFIG_ACPI
     struct xen_pct_register control_register;
     struct xen_pct_register status_register;
+#endif
     uint32_t state_count;
     struct xen_processor_px *states;
     struct xen_psd_package domain_info;
@@ -35,8 +40,10 @@ struct processor_performance {
 };
 
 struct processor_pminfo {
+#ifdef CONFIG_ACPI
     uint32_t acpi_id;
     uint32_t id;
+#endif
     struct processor_performance    perf;
 };
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [RFC PATCH v3 07/12] arch/arm: create device tree nodes for hwdom cpufreq cpu driver
  2014-10-23 15:07 [RFC PATCH v3 00/12]xen_cpufreq implementation in Xen hypervisor Oleksandr Dmytryshyn
                   ` (5 preceding siblings ...)
  2014-10-23 15:07 ` [RFC PATCH v3 06/12] cpufreq: make cpufreq driver " Oleksandr Dmytryshyn
@ 2014-10-23 15:07 ` Oleksandr Dmytryshyn
  2014-10-23 15:49   ` Julien Grall
  2014-10-23 15:07 ` [RFC PATCH v3 08/12] xsm: enable xsm_platform_op hook for all architectures Oleksandr Dmytryshyn
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-23 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Tim Deegan, Stefano Stabellini, Ian Campbell

This patch copies all cpu@0..cpu@N nodes (from input
device tree) with properties to /hypervisor/pcpus
node (device tree for hwdom). Thus we can give all
information about all physical CPUs in the pcpus node.
Driver in hwdom should parse /hypervisor/pcpus path
instead of the /cpus path in the device tree.

Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
---
 xen/arch/arm/domain_build.c | 67 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 2db0236..2186514 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -326,6 +326,69 @@ static int make_memory_node(const struct domain *d,
     return res;
 }
 
+#ifdef HAS_CPUFREQ
+static int fdt_copy_phys_cpus_nodes(void *fdt)
+{
+    int res;
+    const struct dt_device_node *cpus = dt_find_node_by_path("/cpus");
+    const struct dt_device_node *npcpu;
+    const struct dt_property *pp;
+    char *node_name;
+
+    if ( !cpus )
+    {
+        dprintk(XENLOG_ERR, "Missing /cpus node in the device tree?\n");
+        return -ENOENT;
+    }
+
+    /*
+     * create pcpus node and copy to it
+     * original cpu@0..cpu@N nodes with its properties.
+     * This is needed for the cpufreq cpu driver in Dom0
+     */
+    DPRINT("Create pcpus node\n");
+
+    res = fdt_begin_node(fdt, "pcpus");
+    if ( res )
+        return res;
+
+    dt_for_each_child_node( cpus, npcpu )
+    {
+        if ( dt_device_type_is_equal(npcpu, "cpu") )
+        {
+            node_name = strrchr(dt_node_full_name(npcpu), '/');
+            node_name++;
+
+            ASSERT(node_name && *node_name);
+
+            DPRINT("Copy %s node to the pcpus\n", node_name);
+
+            res = fdt_begin_node(fdt, node_name);
+            if ( res )
+                return res;
+
+            dt_for_each_property_node( npcpu, pp )
+            {
+                if ( pp->length )
+                {
+                    res = fdt_property(fdt, pp->name, pp->value,
+                                        pp->length);
+                    if ( res )
+                        return res;
+                }
+            }
+
+            res = fdt_end_node(fdt);
+            if ( res )
+                return res;
+        }
+    }
+
+    res = fdt_end_node(fdt);
+    return res;
+}
+#endif /* HAS_CPUFREQ */
+
 static int make_hypervisor_node(struct domain *d,
                                 void *fdt, const struct dt_device_node *parent)
 {
@@ -386,6 +449,10 @@ static int make_hypervisor_node(struct domain *d,
     if ( res )
         return res;
 
+    #ifdef HAS_CPUFREQ
+    fdt_copy_phys_cpus_nodes(fdt);
+    #endif
+
     res = fdt_end_node(fdt);
 
     return res;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [RFC PATCH v3 08/12] xsm: enable xsm_platform_op hook for all architectures
  2014-10-23 15:07 [RFC PATCH v3 00/12]xen_cpufreq implementation in Xen hypervisor Oleksandr Dmytryshyn
                   ` (6 preceding siblings ...)
  2014-10-23 15:07 ` [RFC PATCH v3 07/12] arch/arm: create device tree nodes for hwdom cpufreq cpu driver Oleksandr Dmytryshyn
@ 2014-10-23 15:07 ` Oleksandr Dmytryshyn
  2014-10-23 16:11   ` Julien Grall
  2014-10-23 15:07 ` [RFC PATCH v3 09/12] xen: arm: implement platform hypercall Oleksandr Dmytryshyn
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-23 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Tim Deegan, Stefano Stabellini, Ian Campbell

This hook is used by platform hypercall which will
be implemented for all architectures.

Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
---
 xen/include/xsm/dummy.h | 12 ++++++------
 xen/include/xsm/xsm.h   | 10 +++++-----
 xen/xsm/flask/hooks.c   |  3 ++-
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h
index eb9e1a1..911fb5d 100644
--- a/xen/include/xsm/dummy.h
+++ b/xen/include/xsm/dummy.h
@@ -491,6 +491,12 @@ static XSM_INLINE int xsm_hvm_param_nested(XSM_DEFAULT_ARG struct domain *d)
     return xsm_default_action(action, current->domain, d);
 }
 
+static XSM_INLINE int xsm_platform_op(XSM_DEFAULT_ARG uint32_t op)
+{
+    XSM_ASSERT_ACTION(XSM_PRIV);
+    return xsm_default_action(action, current->domain, NULL);
+}
+
 #ifdef CONFIG_X86
 static XSM_INLINE int xsm_shadow_control(XSM_DEFAULT_ARG struct domain *d, uint32_t op)
 {
@@ -546,12 +552,6 @@ static XSM_INLINE int xsm_apic(XSM_DEFAULT_ARG struct domain *d, int cmd)
     return xsm_default_action(action, d, NULL);
 }
 
-static XSM_INLINE int xsm_platform_op(XSM_DEFAULT_ARG uint32_t op)
-{
-    XSM_ASSERT_ACTION(XSM_PRIV);
-    return xsm_default_action(action, current->domain, NULL);
-}
-
 static XSM_INLINE int xsm_machine_memory_map(XSM_DEFAULT_VOID)
 {
     XSM_ASSERT_ACTION(XSM_PRIV);
diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
index 1939453..5cb1e0d 100644
--- a/xen/include/xsm/xsm.h
+++ b/xen/include/xsm/xsm.h
@@ -509,6 +509,11 @@ static inline int xsm_hvm_param_nested (xsm_default_t def, struct domain *d)
     return xsm_ops->hvm_param_nested(d);
 }
 
+static inline int xsm_platform_op (xsm_default_t def, uint32_t op)
+{
+    return xsm_ops->platform_op(op);
+}
+
 #ifdef CONFIG_X86
 static inline int xsm_shadow_control (xsm_default_t def, struct domain *d, uint32_t op)
 {
@@ -560,11 +565,6 @@ static inline int xsm_memtype (xsm_default_t def, uint32_t access)
     return xsm_ops->memtype(access);
 }
 
-static inline int xsm_platform_op (xsm_default_t def, uint32_t op)
-{
-    return xsm_ops->platform_op(op);
-}
-
 static inline int xsm_machine_memory_map(xsm_default_t def)
 {
     return xsm_ops->machine_memory_map();
diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
index d94ab77..29126ec 100644
--- a/xen/xsm/flask/hooks.c
+++ b/xen/xsm/flask/hooks.c
@@ -1542,6 +1542,8 @@ static struct xsm_operations flask_ops = {
     .add_to_physmap = flask_add_to_physmap,
     .remove_from_physmap = flask_remove_from_physmap,
 
+    .platform_op = flask_platform_op,
+
 #ifdef CONFIG_X86
     .shadow_control = flask_shadow_control,
     .hvm_set_pci_intx_level = flask_hvm_set_pci_intx_level,
@@ -1552,7 +1554,6 @@ static struct xsm_operations flask_ops = {
     .mem_event_op = flask_mem_event_op,
     .mem_sharing_op = flask_mem_sharing_op,
     .apic = flask_apic,
-    .platform_op = flask_platform_op,
     .machine_memory_map = flask_machine_memory_map,
     .domain_memory_map = flask_domain_memory_map,
     .mmu_update = flask_mmu_update,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [RFC PATCH v3 09/12] xen: arm: implement platform hypercall
  2014-10-23 15:07 [RFC PATCH v3 00/12]xen_cpufreq implementation in Xen hypervisor Oleksandr Dmytryshyn
                   ` (7 preceding siblings ...)
  2014-10-23 15:07 ` [RFC PATCH v3 08/12] xsm: enable xsm_platform_op hook for all architectures Oleksandr Dmytryshyn
@ 2014-10-23 15:07 ` Oleksandr Dmytryshyn
  2014-10-23 15:07 ` [RFC PATCH v3 10/12] cpufreq: add hwdom-cpufreq driver Oleksandr Dmytryshyn
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-23 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Tim Deegan, Stefano Stabellini, Ian Campbell

Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
---
 xen/arch/arm/Makefile             |  1 +
 xen/arch/arm/platform_hypercall.c | 84 +++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/traps.c              |  1 +
 3 files changed, 86 insertions(+)
 create mode 100644 xen/arch/arm/platform_hypercall.c

diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index d70f6d5..54d8258 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -32,6 +32,7 @@ obj-y += vuart.o
 obj-y += hvm.o
 obj-y += device.o
 obj-y += decode.o
+obj-y += platform_hypercall.o
 
 #obj-bin-y += ....o
 
diff --git a/xen/arch/arm/platform_hypercall.c b/xen/arch/arm/platform_hypercall.c
new file mode 100644
index 0000000..f14641b
--- /dev/null
+++ b/xen/arch/arm/platform_hypercall.c
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * platform_hypercall.c
+ *
+ * Hardware platform operations. Intended for use by domain-0 kernel.
+ *
+ * Copyright (c) 2014 GlobalLogic Inc.
+ */
+
+#include <xen/config.h>
+#include <xen/types.h>
+#include <xen/sched.h>
+#include <xen/event.h>
+#include <xen/guest_access.h>
+#include <xen/pmstat.h>
+#include <xen/irq.h>
+#include <public/platform.h>
+#include <xsm/xsm.h>
+
+static DEFINE_SPINLOCK(xenpf_lock);
+
+long do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)
+{
+    long ret = 0;
+    struct xen_platform_op curop, *op = &curop;
+
+    if ( copy_from_guest(op, u_xenpf_op, 1) )
+        return -EFAULT;
+
+    if ( op->interface_version != XENPF_INTERFACE_VERSION )
+        return -EACCES;
+
+    ret = xsm_platform_op(XSM_PRIV, op->cmd);
+    if ( ret )
+        return ret;
+
+    /*
+     * Trylock here avoids deadlock with an existing platform critical section
+     * which might (for some current or future reason) want to synchronise
+     * with this vcpu.
+     */
+    while ( !spin_trylock(&xenpf_lock) )
+        if ( hypercall_preempt_check() )
+            return hypercall_create_continuation(
+                __HYPERVISOR_platform_op, "h", u_xenpf_op);
+
+    switch ( op->cmd )
+    {
+    case XENPF_set_processor_pminfo:
+        switch ( op->u.set_pminfo.type )
+        {
+        case XEN_PM_PX:
+            if ( !(xen_processor_pmbits & XEN_PROCESSOR_PM_PX) )
+            {
+                ret = -ENOSYS;
+                break;
+           }
+#ifdef HAS_CPUFREQ
+            ret = set_px_pminfo(op->u.set_pminfo.id, &op->u.set_pminfo.u.perf);
+#else
+            ret = -EINVAL;
+#endif
+            break;
+
+        default:
+            ret = -EINVAL;
+            break;
+        }
+        break;
+    }
+
+    spin_unlock(&xenpf_lock);
+
+    return ret;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 21c7b26..d1b0014 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -1012,6 +1012,7 @@ static arm_hypercall_t arm_hypercall_table[] = {
     HYPERCALL(hvm_op, 2),
     HYPERCALL(grant_table_op, 3),
     HYPERCALL_ARM(vcpu_op, 3),
+    HYPERCALL(platform_op, 1),
 };
 
 typedef int (*arm_psci_fn_t)(uint32_t, register_t);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [RFC PATCH v3 10/12] cpufreq: add hwdom-cpufreq driver
  2014-10-23 15:07 [RFC PATCH v3 00/12]xen_cpufreq implementation in Xen hypervisor Oleksandr Dmytryshyn
                   ` (8 preceding siblings ...)
  2014-10-23 15:07 ` [RFC PATCH v3 09/12] xen: arm: implement platform hypercall Oleksandr Dmytryshyn
@ 2014-10-23 15:07 ` Oleksandr Dmytryshyn
  2014-10-23 16:42   ` Julien Grall
  2014-10-23 15:07 ` [RFC PATCH v3 11/12] xen: arm: implement XEN_SYSCTL_cpufreq_op Oleksandr Dmytryshyn
  2014-10-23 15:07 ` [RFC PATCH v3 12/12] xen/arm: enable cpufreq functionality for ARM Oleksandr Dmytryshyn
  11 siblings, 1 reply; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-23 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Tim Deegan, Stefano Stabellini, Ian Campbell

This driver uses hwdom to change frequencies on CPUs

Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
---
 xen/Rules.mk                        |   1 +
 xen/drivers/cpufreq/Makefile        |   1 +
 xen/drivers/cpufreq/hwdom-cpufreq.c | 220 ++++++++++++++++++++++++++++++++++++
 xen/include/public/xen.h            |   1 +
 4 files changed, 223 insertions(+)
 create mode 100644 xen/drivers/cpufreq/hwdom-cpufreq.c

diff --git a/xen/Rules.mk b/xen/Rules.mk
index 3b0b89b..cccbc72 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -56,6 +56,7 @@ CFLAGS-$(perfc_arrays)  += -DPERF_ARRAYS
 CFLAGS-$(lock_profile)  += -DLOCK_PROFILE
 CFLAGS-$(HAS_ACPI)      += -DHAS_ACPI
 CFLAGS-$(HAS_CPUFREQ)   += -DHAS_CPUFREQ
+CFLAGS-$(HAS_HWDOM_CPUFREQ) += -DHAS_HWDOM_CPUFREQ
 CFLAGS-$(HAS_PM)        += -DHAS_PM
 CFLAGS-$(HAS_CPU_TURBO) += -DHAS_CPU_TURBO
 CFLAGS-$(HAS_GDBSX)     += -DHAS_GDBSX
diff --git a/xen/drivers/cpufreq/Makefile b/xen/drivers/cpufreq/Makefile
index b87d127..891997c 100644
--- a/xen/drivers/cpufreq/Makefile
+++ b/xen/drivers/cpufreq/Makefile
@@ -2,3 +2,4 @@ obj-y += cpufreq.o
 obj-y += cpufreq_ondemand.o
 obj-y += cpufreq_misc_governors.o
 obj-y += utility.o
+obj-$(HAS_HWDOM_CPUFREQ) += hwdom-cpufreq.o
diff --git a/xen/drivers/cpufreq/hwdom-cpufreq.c b/xen/drivers/cpufreq/hwdom-cpufreq.c
new file mode 100644
index 0000000..67c9e1d
--- /dev/null
+++ b/xen/drivers/cpufreq/hwdom-cpufreq.c
@@ -0,0 +1,220 @@
+/*
+ *  Copyright (C) 2014 GlobalLogic Inc.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or (at
+ *  your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+#include <xen/types.h>
+#include <xen/errno.h>
+#include <xen/sched.h>
+#include <xen/event.h>
+#include <xen/irq.h>
+#include <xen/spinlock.h>
+#include <xen/cpufreq.h>
+#include <asm/current.h>
+
+struct hwdom_cpufreq_data {
+    struct processor_performance *perf_data;
+    struct cpufreq_frequency_table *freq_table;
+};
+
+static struct hwdom_cpufreq_data *hwdom_cpufreq_drv_data[NR_CPUS];
+
+int cpufreq_cpu_init(unsigned int cpuid)
+{
+    return cpufreq_add_cpu(cpuid);
+}
+
+static int hwdom_cpufreq_verify(struct cpufreq_policy *policy)
+{
+    struct hwdom_cpufreq_data *data;
+    struct processor_performance *perf;
+
+    if ( !policy || !(data = hwdom_cpufreq_drv_data[policy->cpu]) ||
+         !processor_pminfo[policy->cpu] )
+        return -EINVAL;
+
+    perf = &processor_pminfo[policy->cpu]->perf;
+
+    cpufreq_verify_within_limits(policy, 0,
+        perf->states[perf->platform_limit].core_frequency * 1000);
+
+    return cpufreq_frequency_table_verify(policy, data->freq_table);
+}
+
+static int hwdom_cpufreq_target(struct cpufreq_policy *policy,
+                               unsigned int target_freq, unsigned int relation)
+{
+    struct hwdom_cpufreq_data *data = hwdom_cpufreq_drv_data[policy->cpu];
+    struct processor_performance *perf;
+    struct cpufreq_freqs freqs;
+    cpumask_t online_policy_cpus;
+    unsigned int next_state = 0; /* Index into freq_table */
+    unsigned int next_perf_state = 0; /* Index into perf table */
+    unsigned int j;
+    int ret = 0;
+
+    if ( unlikely(data == NULL ||
+         data->perf_data == NULL || data->freq_table == NULL) )
+    {
+        return -ENODEV;
+    }
+
+    perf = data->perf_data;
+    ret = cpufreq_frequency_table_target(policy,
+                                            data->freq_table,
+                                            target_freq,
+                                            relation, &next_state);
+    if ( unlikely(ret) )
+        return -ENODEV;
+
+    cpumask_and(&online_policy_cpus, &cpu_online_map, policy->cpus);
+
+    next_perf_state = data->freq_table[next_state].index;
+    if ( perf->state == next_perf_state )
+    {
+        if ( unlikely(policy->resume) )
+            policy->resume = 0;
+        else
+            return 0;
+    }
+
+    freqs.old = perf->states[perf->state].core_frequency * 1000;
+    freqs.new = data->freq_table[next_state].frequency;
+
+    for_each_cpu( j, &online_policy_cpus )
+        cpufreq_statistic_update(j, perf->state, next_perf_state);
+
+    perf->state = next_perf_state;
+    policy->cur = freqs.new;
+
+    return ret;
+}
+
+static int
+hwdom_cpufreq_cpu_init(struct cpufreq_policy *policy)
+{
+    struct processor_performance *perf;
+    struct hwdom_cpufreq_data *data;
+    unsigned int cpu = policy->cpu;
+    unsigned int valid_states = 0;
+    int i;
+    int ret = 0;
+
+    data = xzalloc(struct hwdom_cpufreq_data);
+    if ( !data )
+        return -ENOMEM;
+
+    hwdom_cpufreq_drv_data[cpu] = data;
+
+    data->perf_data = &processor_pminfo[cpu]->perf;
+
+    perf = data->perf_data;
+    policy->shared_type = perf->shared_type;
+
+    data->freq_table = xmalloc_array(struct cpufreq_frequency_table,
+                                    (perf->state_count+1));
+    if ( !data->freq_table )
+    {
+        ret = -ENOMEM;
+        goto err_unreg;
+    }
+
+    /* detect transition latency */
+    policy->cpuinfo.transition_latency = 0;
+    for ( i=0; i<perf->state_count; i++ )
+    {
+        if ( (perf->states[i].transition_latency * 1000) >
+             policy->cpuinfo.transition_latency )
+            policy->cpuinfo.transition_latency =
+                perf->states[i].transition_latency * 1000;
+    }
+
+    policy->governor = cpufreq_opt_governor ? : CPUFREQ_DEFAULT_GOVERNOR;
+
+    /* table init */
+    for ( i=0; i<perf->state_count; i++ )
+    {
+        if ( i>0 && perf->states[i].core_frequency >=
+            data->freq_table[valid_states-1].frequency / 1000 )
+            continue;
+
+        data->freq_table[valid_states].index = i;
+        data->freq_table[valid_states].frequency =
+            perf->states[i].core_frequency * 1000;
+        valid_states++;
+    }
+    data->freq_table[valid_states].frequency = CPUFREQ_TABLE_END;
+    perf->state = 0;
+
+    ret = cpufreq_frequency_table_cpuinfo(policy, data->freq_table);
+    if ( ret )
+        goto err_freqfree;
+
+
+    /*
+     * the first call to ->target() should result in us actually
+     * send command to the Dom0 to set frequency.
+     */
+    policy->resume = 1;
+
+    /* Set the minimal frequency */
+    return hwdom_cpufreq_target(policy, policy->min, CPUFREQ_RELATION_L);
+
+ err_freqfree:
+    xfree(data->freq_table);
+ err_unreg:
+    xfree(data);
+    hwdom_cpufreq_drv_data[cpu] = NULL;
+
+    return ret;
+}
+
+static int hwdom_cpufreq_cpu_exit(struct cpufreq_policy *policy)
+{
+    struct hwdom_cpufreq_data *data = hwdom_cpufreq_drv_data[policy->cpu];
+
+    if ( data )
+    {
+        hwdom_cpufreq_drv_data[policy->cpu] = NULL;
+        xfree(data->freq_table);
+        xfree(data);
+    }
+
+    return 0;
+}
+
+static struct cpufreq_driver hwdom_cpufreq_driver = {
+    .name   = "hwdom-cpufreq",
+    .verify = hwdom_cpufreq_verify,
+    .target = hwdom_cpufreq_target,
+    .init   = hwdom_cpufreq_cpu_init,
+    .exit   = hwdom_cpufreq_cpu_exit,
+};
+
+int __init hwdom_cpufreq_driver_init(void)
+{
+    int ret = 0;
+
+    if ( cpufreq_controller == FREQCTL_xen )
+        ret = cpufreq_register_driver(&hwdom_cpufreq_driver);
+
+    return ret;
+}
+
+__initcall(hwdom_cpufreq_driver_init);
diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h
index 8c5697e..abd8438 100644
--- a/xen/include/public/xen.h
+++ b/xen/include/public/xen.h
@@ -160,6 +160,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t);
 #define VIRQ_MEM_EVENT  10 /* G. (DOM0) A memory event has occured           */
 #define VIRQ_XC_RESERVED 11 /* G. Reserved for XenClient                     */
 #define VIRQ_ENOMEM     12 /* G. (DOM0) Low on heap memory       */
+#define VIRQ_CPUFREQ    14 /* G. (DOM0) Notify cpufreq driver                */
 
 /* Architecture-specific VIRQ definitions. */
 #define VIRQ_ARCH_0    16
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [RFC PATCH v3 11/12] xen: arm: implement XEN_SYSCTL_cpufreq_op
  2014-10-23 15:07 [RFC PATCH v3 00/12]xen_cpufreq implementation in Xen hypervisor Oleksandr Dmytryshyn
                   ` (9 preceding siblings ...)
  2014-10-23 15:07 ` [RFC PATCH v3 10/12] cpufreq: add hwdom-cpufreq driver Oleksandr Dmytryshyn
@ 2014-10-23 15:07 ` Oleksandr Dmytryshyn
  2014-10-23 16:27   ` Julien Grall
  2014-10-26 17:41   ` Stefano Stabellini
  2014-10-23 15:07 ` [RFC PATCH v3 12/12] xen/arm: enable cpufreq functionality for ARM Oleksandr Dmytryshyn
  11 siblings, 2 replies; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-23 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Tim Deegan, Stefano Stabellini, Ian Campbell

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

Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
---
 xen/common/sysctl.c                 |  8 ++++++
 xen/drivers/cpufreq/hwdom-cpufreq.c | 52 +++++++++++++++++++++++++++++++++++++
 xen/include/public/sysctl.h         | 19 ++++++++++++++
 xen/include/xen/cpufreq.h           |  2 ++
 4 files changed, 81 insertions(+)

diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index 0dcf06a..fd0cd0d 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_HWDOM_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/hwdom-cpufreq.c b/xen/drivers/cpufreq/hwdom-cpufreq.c
index 67c9e1d..cc97f37 100644
--- a/xen/drivers/cpufreq/hwdom-cpufreq.c
+++ b/xen/drivers/cpufreq/hwdom-cpufreq.c
@@ -34,12 +34,53 @@ struct hwdom_cpufreq_data {
 };
 
 static struct hwdom_cpufreq_data *hwdom_cpufreq_drv_data[NR_CPUS];
+static DEFINE_SPINLOCK(sysctl_cpufreq_lock);
+
+struct sysctl_cpufreq_data {
+    uint32_t cpu;
+    uint32_t freq;
+    uint32_t relation;
+    int32_t result;
+};
+
+static struct sysctl_cpufreq_data sysctl_cpufreq_data;
 
 int cpufreq_cpu_init(unsigned int cpuid)
 {
     return cpufreq_add_cpu(cpuid);
 }
 
+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 -EOPNOTSUPP;
+        break;
+    }
+    return ret;
+}
+
 static int hwdom_cpufreq_verify(struct cpufreq_policy *policy)
 {
     struct hwdom_cpufreq_data *data;
@@ -97,6 +138,17 @@ static int hwdom_cpufreq_target(struct cpufreq_policy *policy,
     freqs.old = perf->states[perf->state].core_frequency * 1000;
     freqs.new = data->freq_table[next_state].frequency;
 
+    /* Do send cmd for Dom0 */
+    spin_lock(&sysctl_cpufreq_lock);
+    /* return previous result */
+    ret = sysctl_cpufreq_data.result;
+
+    sysctl_cpufreq_data.cpu = policy->cpu;
+    sysctl_cpufreq_data.freq = freqs.new;
+    sysctl_cpufreq_data.relation = (uint32_t)relation;
+    spin_unlock(&sysctl_cpufreq_lock);
+    notify_cpufreq_domains();
+
     for_each_cpu( j, &online_policy_cpus )
         cpufreq_statistic_update(j, perf->state, next_perf_state);
 
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..0c8c19d 100644
--- a/xen/include/xen/cpufreq.h
+++ b/xen/include/xen/cpufreq.h
@@ -264,4 +264,6 @@ int write_userspace_scaling_setspeed(unsigned int cpu, unsigned int freq);
 void cpufreq_dbs_timer_suspend(void);
 void cpufreq_dbs_timer_resume(void);
 
+int sysctl_cpufreq_op(xen_sysctl_cpufreq_op_t *op);
+
 #endif /* __XEN_CPUFREQ_PM_H__ */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [RFC PATCH v3 12/12] xen/arm: enable cpufreq functionality for ARM
  2014-10-23 15:07 [RFC PATCH v3 00/12]xen_cpufreq implementation in Xen hypervisor Oleksandr Dmytryshyn
                   ` (10 preceding siblings ...)
  2014-10-23 15:07 ` [RFC PATCH v3 11/12] xen: arm: implement XEN_SYSCTL_cpufreq_op Oleksandr Dmytryshyn
@ 2014-10-23 15:07 ` Oleksandr Dmytryshyn
  11 siblings, 0 replies; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-23 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Tim Deegan, Stefano Stabellini, Ian Campbell

Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
---
 xen/arch/arm/Rules.mk | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk
index 718cd8a..1484b55 100644
--- a/xen/arch/arm/Rules.mk
+++ b/xen/arch/arm/Rules.mk
@@ -9,6 +9,9 @@
 HAS_DEVICE_TREE := y
 HAS_VIDEO := y
 HAS_ARM_HDLCD := y
+HAS_CPUFREQ := y
+HAS_HWDOM_CPUFREQ := y
+HAS_PM := y
 
 CFLAGS += -I$(BASEDIR)/include
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 07/12] arch/arm: create device tree nodes for hwdom cpufreq cpu driver
  2014-10-23 15:07 ` [RFC PATCH v3 07/12] arch/arm: create device tree nodes for hwdom cpufreq cpu driver Oleksandr Dmytryshyn
@ 2014-10-23 15:49   ` Julien Grall
  2014-10-24 10:24     ` Oleksandr Dmytryshyn
  0 siblings, 1 reply; 32+ messages in thread
From: Julien Grall @ 2014-10-23 15:49 UTC (permalink / raw)
  To: Oleksandr Dmytryshyn, xen-devel
  Cc: Stefano Stabellini, Tim Deegan, Ian Campbell

Hi Oleksandr,

On 10/23/2014 04:07 PM, Oleksandr Dmytryshyn wrote:
> This patch copies all cpu@0..cpu@N nodes (from input
> device tree) with properties to /hypervisor/pcpus
> node (device tree for hwdom). Thus we can give all
> information about all physical CPUs in the pcpus node.
> Driver in hwdom should parse /hypervisor/pcpus path
> instead of the /cpus path in the device tree.
> 
> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
> ---
>  xen/arch/arm/domain_build.c | 67 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 67 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 2db0236..2186514 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -326,6 +326,69 @@ static int make_memory_node(const struct domain *d,
>      return res;
>  }
>  
> +#ifdef HAS_CPUFREQ
> +static int fdt_copy_phys_cpus_nodes(void *fdt)
> +{
> +    int res;
> +    const struct dt_device_node *cpus = dt_find_node_by_path("/cpus");
> +    const struct dt_device_node *npcpu;
> +    const struct dt_property *pp;
> +    char *node_name;
> +
> +    if ( !cpus )
> +    {
> +        dprintk(XENLOG_ERR, "Missing /cpus node in the device tree?\n");
> +        return -ENOENT;
> +    }
> +
> +    /*
> +     * create pcpus node and copy to it
> +     * original cpu@0..cpu@N nodes with its properties.
> +     * This is needed for the cpufreq cpu driver in Dom0
> +     */
> +    DPRINT("Create pcpus node\n");
> +
> +    res = fdt_begin_node(fdt, "pcpus");

This new bindings has to be documented somewhere. The best places would
be in Documentation/devicetree/bindins/arm/xen.txt (see Linux repo).

> +    if ( res )
> +        return res;
> +
> +    dt_for_each_child_node( cpus, npcpu )
> +    {
> +        if ( dt_device_type_is_equal(npcpu, "cpu") )
> +        {
> +            node_name = strrchr(dt_node_full_name(npcpu), '/');
> +            node_name++;
> +
> +            ASSERT(node_name && *node_name);

The first check on node_name is pointless because of the node_name++ above.

I would divide the ASSERT in 2 parts, and do the first check before
node_name++;

> +
> +            DPRINT("Copy %s node to the pcpus\n", node_name);
> +
> +            res = fdt_begin_node(fdt, node_name);
> +            if ( res )
> +                return res;
> +
> +            dt_for_each_property_node( npcpu, pp )
> +            {
> +                if ( pp->length )
> +                {
> +                    res = fdt_property(fdt, pp->name, pp->value,
> +                                        pp->length);
> +                    if ( res )
> +                        return res;
> +                }
> +            }
> +

You can use write_properties to replace this loop.

> +            res = fdt_end_node(fdt);
> +            if ( res )
> +                return res;
> +        }
> +    }
> +
> +    res = fdt_end_node(fdt);
> +    return res;
> +}
> +#endif /* HAS_CPUFREQ */
> +
>  static int make_hypervisor_node(struct domain *d,
>                                  void *fdt, const struct dt_device_node *parent)
>  {
> @@ -386,6 +449,10 @@ static int make_hypervisor_node(struct domain *d,
>      if ( res )
>          return res;
>  
> +    #ifdef HAS_CPUFREQ
> +    fdt_copy_phys_cpus_nodes(fdt);

You forgot to check the return value of the function.

Regards,

-- 
Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 08/12] xsm: enable xsm_platform_op hook for all architectures
  2014-10-23 15:07 ` [RFC PATCH v3 08/12] xsm: enable xsm_platform_op hook for all architectures Oleksandr Dmytryshyn
@ 2014-10-23 16:11   ` Julien Grall
  2014-10-24 10:24     ` Oleksandr Dmytryshyn
  0 siblings, 1 reply; 32+ messages in thread
From: Julien Grall @ 2014-10-23 16:11 UTC (permalink / raw)
  To: Oleksandr Dmytryshyn, xen-devel
  Cc: Stefano Stabellini, Daniel De Graaf, Tim Deegan, Ian Campbell

Hi Oleksandr,

You forgot to CC Daniel (CCed him) who is the XSM maintainers.

On 10/23/2014 04:07 PM, Oleksandr Dmytryshyn wrote:
> This hook is used by platform hypercall which will
> be implemented for all architectures.

I don't think it's necessary to have a separate patch for XSM. I would
fold it in #9.

Otherwise, this change looks good to me.

> 
> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
> ---
>  xen/include/xsm/dummy.h | 12 ++++++------
>  xen/include/xsm/xsm.h   | 10 +++++-----
>  xen/xsm/flask/hooks.c   |  3 ++-
>  3 files changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h
> index eb9e1a1..911fb5d 100644
> --- a/xen/include/xsm/dummy.h
> +++ b/xen/include/xsm/dummy.h
> @@ -491,6 +491,12 @@ static XSM_INLINE int xsm_hvm_param_nested(XSM_DEFAULT_ARG struct domain *d)
>      return xsm_default_action(action, current->domain, d);
>  }
>  
> +static XSM_INLINE int xsm_platform_op(XSM_DEFAULT_ARG uint32_t op)
> +{
> +    XSM_ASSERT_ACTION(XSM_PRIV);
> +    return xsm_default_action(action, current->domain, NULL);
> +}
> +
>  #ifdef CONFIG_X86
>  static XSM_INLINE int xsm_shadow_control(XSM_DEFAULT_ARG struct domain *d, uint32_t op)
>  {
> @@ -546,12 +552,6 @@ static XSM_INLINE int xsm_apic(XSM_DEFAULT_ARG struct domain *d, int cmd)
>      return xsm_default_action(action, d, NULL);
>  }
>  
> -static XSM_INLINE int xsm_platform_op(XSM_DEFAULT_ARG uint32_t op)
> -{
> -    XSM_ASSERT_ACTION(XSM_PRIV);
> -    return xsm_default_action(action, current->domain, NULL);
> -}
> -
>  static XSM_INLINE int xsm_machine_memory_map(XSM_DEFAULT_VOID)
>  {
>      XSM_ASSERT_ACTION(XSM_PRIV);
> diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
> index 1939453..5cb1e0d 100644
> --- a/xen/include/xsm/xsm.h
> +++ b/xen/include/xsm/xsm.h
> @@ -509,6 +509,11 @@ static inline int xsm_hvm_param_nested (xsm_default_t def, struct domain *d)
>      return xsm_ops->hvm_param_nested(d);
>  }
>  
> +static inline int xsm_platform_op (xsm_default_t def, uint32_t op)
> +{
> +    return xsm_ops->platform_op(op);
> +}
> +
>  #ifdef CONFIG_X86
>  static inline int xsm_shadow_control (xsm_default_t def, struct domain *d, uint32_t op)
>  {
> @@ -560,11 +565,6 @@ static inline int xsm_memtype (xsm_default_t def, uint32_t access)
>      return xsm_ops->memtype(access);
>  }
>  
> -static inline int xsm_platform_op (xsm_default_t def, uint32_t op)
> -{
> -    return xsm_ops->platform_op(op);
> -}
> -
>  static inline int xsm_machine_memory_map(xsm_default_t def)
>  {
>      return xsm_ops->machine_memory_map();
> diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
> index d94ab77..29126ec 100644
> --- a/xen/xsm/flask/hooks.c
> +++ b/xen/xsm/flask/hooks.c
> @@ -1542,6 +1542,8 @@ static struct xsm_operations flask_ops = {
>      .add_to_physmap = flask_add_to_physmap,
>      .remove_from_physmap = flask_remove_from_physmap,
>  
> +    .platform_op = flask_platform_op,
> +
>  #ifdef CONFIG_X86
>      .shadow_control = flask_shadow_control,
>      .hvm_set_pci_intx_level = flask_hvm_set_pci_intx_level,
> @@ -1552,7 +1554,6 @@ static struct xsm_operations flask_ops = {
>      .mem_event_op = flask_mem_event_op,
>      .mem_sharing_op = flask_mem_sharing_op,
>      .apic = flask_apic,
> -    .platform_op = flask_platform_op,
>      .machine_memory_map = flask_machine_memory_map,
>      .domain_memory_map = flask_domain_memory_map,
>      .mmu_update = flask_mmu_update,
> 


-- 
Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 11/12] xen: arm: implement XEN_SYSCTL_cpufreq_op
  2014-10-23 15:07 ` [RFC PATCH v3 11/12] xen: arm: implement XEN_SYSCTL_cpufreq_op Oleksandr Dmytryshyn
@ 2014-10-23 16:27   ` Julien Grall
  2014-10-24 10:37     ` Oleksandr Dmytryshyn
  2014-10-26 17:41   ` Stefano Stabellini
  1 sibling, 1 reply; 32+ messages in thread
From: Julien Grall @ 2014-10-23 16:27 UTC (permalink / raw)
  To: Oleksandr Dmytryshyn, xen-devel
  Cc: Stefano Stabellini, Tim Deegan, Ian Campbell

Hi Oleksandr,

On 10/23/2014 04:07 PM, Oleksandr Dmytryshyn wrote:
> Kernel uses this op to get some parameters for the
> xen-cpufreq driver to change CPUs frequency.

The XSM bit is missing for this new sysctl (see flask_sysctl).

> diff --git a/xen/drivers/cpufreq/hwdom-cpufreq.c b/xen/drivers/cpufreq/hwdom-cpufreq.c
> index 67c9e1d..cc97f37 100644
> --- a/xen/drivers/cpufreq/hwdom-cpufreq.c
> +++ b/xen/drivers/cpufreq/hwdom-cpufreq.c
> @@ -34,12 +34,53 @@ struct hwdom_cpufreq_data {
>  };
>  
>  static struct hwdom_cpufreq_data *hwdom_cpufreq_drv_data[NR_CPUS];
> +static DEFINE_SPINLOCK(sysctl_cpufreq_lock);
> +
> +struct sysctl_cpufreq_data {
> +    uint32_t cpu;
> +    uint32_t freq;
> +    uint32_t relation;
> +    int32_t result;
> +};
> +
> +static struct sysctl_cpufreq_data sysctl_cpufreq_data;
>  
>  int cpufreq_cpu_init(unsigned int cpuid)
>  {
>      return cpufreq_add_cpu(cpuid);
>  }
>  
> +static void notify_cpufreq_domains(void)
> +{
> +    send_global_virq(VIRQ_CPUFREQ);
> +}
> +
> +int sysctl_cpufreq_op(xen_sysctl_cpufreq_op_t *op)
> +{
> +    int ret = 0;

AFAIU, the cpufreq will always run in the hardware domain. Therefore,
shouldn't you check that the sysctl is effectively executed by this domain?

>  static int hwdom_cpufreq_verify(struct cpufreq_policy *policy)
>  {
>      struct hwdom_cpufreq_data *data;
> @@ -97,6 +138,17 @@ static int hwdom_cpufreq_target(struct cpufreq_policy *policy,
>      freqs.old = perf->states[perf->state].core_frequency * 1000;
>      freqs.new = data->freq_table[next_state].frequency;
>  
> +    /* Do send cmd for Dom0 */

s/Dom0/Hardware domain/

> +    spin_lock(&sysctl_cpufreq_lock);
> +    /* return previous result */
> +    ret = sysctl_cpufreq_data.result;
> +
> +    sysctl_cpufreq_data.cpu = policy->cpu;
> +    sysctl_cpufreq_data.freq = freqs.new;
> +    sysctl_cpufreq_data.relation = (uint32_t)relation;
> +    spin_unlock(&sysctl_cpufreq_lock);
> +    notify_cpufreq_domains();
> +
>      for_each_cpu( j, &online_policy_cpus )
>          cpufreq_statistic_update(j, perf->state, next_perf_state);
>  
> 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;
> +};

Can you document this structure?

Regards,

-- 
Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 10/12] cpufreq: add hwdom-cpufreq driver
  2014-10-23 15:07 ` [RFC PATCH v3 10/12] cpufreq: add hwdom-cpufreq driver Oleksandr Dmytryshyn
@ 2014-10-23 16:42   ` Julien Grall
  2014-10-24 10:30     ` Oleksandr Dmytryshyn
  0 siblings, 1 reply; 32+ messages in thread
From: Julien Grall @ 2014-10-23 16:42 UTC (permalink / raw)
  To: Oleksandr Dmytryshyn, xen-devel
  Cc: Stefano Stabellini, Tim Deegan, Ian Campbell

Hi Oleksandr,

On 10/23/2014 04:07 PM, Oleksandr Dmytryshyn wrote:
> This driver uses hwdom to change frequencies on CPUs
> 
> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
> ---
>  xen/Rules.mk                        |   1 +
>  xen/drivers/cpufreq/Makefile        |   1 +
>  xen/drivers/cpufreq/hwdom-cpufreq.c | 220 ++++++++++++++++++++++++++++++++++++
>  xen/include/public/xen.h            |   1 +
>  4 files changed, 223 insertions(+)
>  create mode 100644 xen/drivers/cpufreq/hwdom-cpufreq.c
> 
> diff --git a/xen/Rules.mk b/xen/Rules.mk
> index 3b0b89b..cccbc72 100644
> --- a/xen/Rules.mk
> +++ b/xen/Rules.mk
> @@ -56,6 +56,7 @@ CFLAGS-$(perfc_arrays)  += -DPERF_ARRAYS
>  CFLAGS-$(lock_profile)  += -DLOCK_PROFILE
>  CFLAGS-$(HAS_ACPI)      += -DHAS_ACPI
>  CFLAGS-$(HAS_CPUFREQ)   += -DHAS_CPUFREQ
> +CFLAGS-$(HAS_HWDOM_CPUFREQ) += -DHAS_HWDOM_CPUFREQ
>  CFLAGS-$(HAS_PM)        += -DHAS_PM
>  CFLAGS-$(HAS_CPU_TURBO) += -DHAS_CPU_TURBO
>  CFLAGS-$(HAS_GDBSX)     += -DHAS_GDBSX
> diff --git a/xen/drivers/cpufreq/Makefile b/xen/drivers/cpufreq/Makefile
> index b87d127..891997c 100644
> --- a/xen/drivers/cpufreq/Makefile
> +++ b/xen/drivers/cpufreq/Makefile
> @@ -2,3 +2,4 @@ obj-y += cpufreq.o
>  obj-y += cpufreq_ondemand.o
>  obj-y += cpufreq_misc_governors.o
>  obj-y += utility.o
> +obj-$(HAS_HWDOM_CPUFREQ) += hwdom-cpufreq.o
> diff --git a/xen/drivers/cpufreq/hwdom-cpufreq.c b/xen/drivers/cpufreq/hwdom-cpufreq.c
> new file mode 100644
> index 0000000..67c9e1d
> --- /dev/null
> +++ b/xen/drivers/cpufreq/hwdom-cpufreq.c
> @@ -0,0 +1,220 @@
> +/*
> + *  Copyright (C) 2014 GlobalLogic Inc.

A part of this file has been copied from xen/arch/x86/acpi/cpufreq.c. I
would keep the copyright from this file and add yours.

Maybe we could share the initialization code (and others parts?) with
this file? For instance the structure looks the same...

> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or (at
> + *  your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful, but
> + *  WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + *  General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License along
> + *  with this program; if not, write to the Free Software Foundation, Inc.,
> + *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + */
> +#include <xen/types.h>
> +#include <xen/errno.h>
> +#include <xen/sched.h>
> +#include <xen/event.h>
> +#include <xen/irq.h>
> +#include <xen/spinlock.h>
> +#include <xen/cpufreq.h>
> +#include <asm/current.h>
> +
> +struct hwdom_cpufreq_data {
> +    struct processor_performance *perf_data;
> +    struct cpufreq_frequency_table *freq_table;
> +};
> +
> +static struct hwdom_cpufreq_data *hwdom_cpufreq_drv_data[NR_CPUS];
> +
> +int cpufreq_cpu_init(unsigned int cpuid)
> +{
> +    return cpufreq_add_cpu(cpuid);
> +}
> +
> +static int hwdom_cpufreq_verify(struct cpufreq_policy *policy)
> +{
> +    struct hwdom_cpufreq_data *data;
> +    struct processor_performance *perf;
> +
> +    if ( !policy || !(data = hwdom_cpufreq_drv_data[policy->cpu]) ||
> +         !processor_pminfo[policy->cpu] )
> +        return -EINVAL;
> +
> +    perf = &processor_pminfo[policy->cpu]->perf;
> +
> +    cpufreq_verify_within_limits(policy, 0,
> +        perf->states[perf->platform_limit].core_frequency * 1000);

NIT: Missing space after the comma.

> +
> +    return cpufreq_frequency_table_verify(policy, data->freq_table);
> +}
> +
> +static int hwdom_cpufreq_target(struct cpufreq_policy *policy,
> +                               unsigned int target_freq, unsigned int relation)
> +{
> +    struct hwdom_cpufreq_data *data = hwdom_cpufreq_drv_data[policy->cpu];
> +    struct processor_performance *perf;
> +    struct cpufreq_freqs freqs;
> +    cpumask_t online_policy_cpus;
> +    unsigned int next_state = 0; /* Index into freq_table */
> +    unsigned int next_perf_state = 0; /* Index into perf table */
> +    unsigned int j;
> +    int ret = 0;
> +
> +    if ( unlikely(data == NULL ||
> +         data->perf_data == NULL || data->freq_table == NULL) )
> +    {
> +        return -ENODEV;
> +    }

NIT: The braces are not necessary.

> +
> +    perf = data->perf_data;
> +    ret = cpufreq_frequency_table_target(policy,
> +                                            data->freq_table,
> +                                            target_freq,
> +                                            relation, &next_state);

NIT: The alignment of the parameters don't look good.

> +    if ( unlikely(ret) )
> +        return -ENODEV;
> +
> +    cpumask_and(&online_policy_cpus, &cpu_online_map, policy->cpus);
> +
> +    next_perf_state = data->freq_table[next_state].index;
> +    if ( perf->state == next_perf_state )
> +    {
> +        if ( unlikely(policy->resume) )
> +            policy->resume = 0;
> +        else
> +            return 0;
> +    }
> +
> +    freqs.old = perf->states[perf->state].core_frequency * 1000;
> +    freqs.new = data->freq_table[next_state].frequency;
> +
> +    for_each_cpu( j, &online_policy_cpus )
> +        cpufreq_statistic_update(j, perf->state, next_perf_state);
> +
> +    perf->state = next_perf_state;
> +    policy->cur = freqs.new;
> +
> +    return ret;
> +}
> +
> +static int
> +hwdom_cpufreq_cpu_init(struct cpufreq_policy *policy)
> +{
> +    struct processor_performance *perf;
> +    struct hwdom_cpufreq_data *data;
> +    unsigned int cpu = policy->cpu;
> +    unsigned int valid_states = 0;
> +    int i;
> +    int ret = 0;
> +
> +    data = xzalloc(struct hwdom_cpufreq_data);
> +    if ( !data )
> +        return -ENOMEM;
> +
> +    hwdom_cpufreq_drv_data[cpu] = data;
> +
> +    data->perf_data = &processor_pminfo[cpu]->perf;
> +
> +    perf = data->perf_data;
> +    policy->shared_type = perf->shared_type;
> +
> +    data->freq_table = xmalloc_array(struct cpufreq_frequency_table,
> +                                    (perf->state_count+1));

NIT: Misaligned

> +    if ( !data->freq_table )
> +    {
> +        ret = -ENOMEM;
> +        goto err_unreg;
> +    }
> +
> +    /* detect transition latency */
> +    policy->cpuinfo.transition_latency = 0;
> +    for ( i=0; i<perf->state_count; i++ )

NIT: i < perf...

> +    {
> +        if ( (perf->states[i].transition_latency * 1000) >
> +             policy->cpuinfo.transition_latency )
> +            policy->cpuinfo.transition_latency =
> +                perf->states[i].transition_latency * 1000;
> +    }
> +
> +    policy->governor = cpufreq_opt_governor ? : CPUFREQ_DEFAULT_GOVERNOR;
> +
> +    /* table init */
> +    for ( i=0; i<perf->state_count; i++ )

Ditto

> +    {
> +        if ( i>0 && perf->states[i].core_frequency >=
> +            data->freq_table[valid_states-1].frequency / 1000 )
> +            continue;
> +
> +        data->freq_table[valid_states].index = i;
> +        data->freq_table[valid_states].frequency =
> +            perf->states[i].core_frequency * 1000;
> +        valid_states++;
> +    }
> +    data->freq_table[valid_states].frequency = CPUFREQ_TABLE_END;
> +    perf->state = 0;
> +
> +    ret = cpufreq_frequency_table_cpuinfo(policy, data->freq_table);
> +    if ( ret )
> +        goto err_freqfree;
> +
> +
> +    /*
> +     * the first call to ->target() should result in us actually
> +     * send command to the Dom0 to set frequency.
> +     */
> +    policy->resume = 1;
> +
> +    /* Set the minimal frequency */
> +    return hwdom_cpufreq_target(policy, policy->min, CPUFREQ_RELATION_L);
> +
> + err_freqfree:
> +    xfree(data->freq_table);
> + err_unreg:
> +    xfree(data);
> +    hwdom_cpufreq_drv_data[cpu] = NULL;
> +
> +    return ret;
> +}
> +
> +static int hwdom_cpufreq_cpu_exit(struct cpufreq_policy *policy)
> +{
> +    struct hwdom_cpufreq_data *data = hwdom_cpufreq_drv_data[policy->cpu];
> +
> +    if ( data )
> +    {
> +        hwdom_cpufreq_drv_data[policy->cpu] = NULL;
> +        xfree(data->freq_table);
> +        xfree(data);
> +    }
> +
> +    return 0;
> +}
> +
> +static struct cpufreq_driver hwdom_cpufreq_driver = {
> +    .name   = "hwdom-cpufreq",
> +    .verify = hwdom_cpufreq_verify,
> +    .target = hwdom_cpufreq_target,
> +    .init   = hwdom_cpufreq_cpu_init,
> +    .exit   = hwdom_cpufreq_cpu_exit,
> +};
> +
> +int __init hwdom_cpufreq_driver_init(void)

It looks like this function is only used for the __initcall. I would put
a static before.

Regards,

-- 
Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 07/12] arch/arm: create device tree nodes for hwdom cpufreq cpu driver
  2014-10-23 15:49   ` Julien Grall
@ 2014-10-24 10:24     ` Oleksandr Dmytryshyn
  2014-10-27 10:52       ` Oleksandr Dmytryshyn
  0 siblings, 1 reply; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-24 10:24 UTC (permalink / raw)
  To: Julien Grall; +Cc: Stefano Stabellini, Tim Deegan, Ian Campbell, xen-devel

On Thu, Oct 23, 2014 at 6:49 PM, Julien Grall <julien.grall@linaro.org> wrote:
> Hi Oleksandr,
>
> On 10/23/2014 04:07 PM, Oleksandr Dmytryshyn wrote:
>> This patch copies all cpu@0..cpu@N nodes (from input
>> device tree) with properties to /hypervisor/pcpus
>> node (device tree for hwdom). Thus we can give all
>> information about all physical CPUs in the pcpus node.
>> Driver in hwdom should parse /hypervisor/pcpus path
>> instead of the /cpus path in the device tree.
>>
>> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
>> ---
>>  xen/arch/arm/domain_build.c | 67 +++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 67 insertions(+)
>>
>> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>> index 2db0236..2186514 100644
>> --- a/xen/arch/arm/domain_build.c
>> +++ b/xen/arch/arm/domain_build.c
>> @@ -326,6 +326,69 @@ static int make_memory_node(const struct domain *d,
>>      return res;
>>  }
>>
>> +#ifdef HAS_CPUFREQ
>> +static int fdt_copy_phys_cpus_nodes(void *fdt)
>> +{
>> +    int res;
>> +    const struct dt_device_node *cpus = dt_find_node_by_path("/cpus");
>> +    const struct dt_device_node *npcpu;
>> +    const struct dt_property *pp;
>> +    char *node_name;
>> +
>> +    if ( !cpus )
>> +    {
>> +        dprintk(XENLOG_ERR, "Missing /cpus node in the device tree?\n");
>> +        return -ENOENT;
>> +    }
>> +
>> +    /*
>> +     * create pcpus node and copy to it
>> +     * original cpu@0..cpu@N nodes with its properties.
>> +     * This is needed for the cpufreq cpu driver in Dom0
>> +     */
>> +    DPRINT("Create pcpus node\n");
>> +
>> +    res = fdt_begin_node(fdt, "pcpus");
>
> This new bindings has to be documented somewhere. The best places would
> be in Documentation/devicetree/bindins/arm/xen.txt (see Linux repo).
I'll do this in the next patch-set.

>> +    if ( res )
>> +        return res;
>> +
>> +    dt_for_each_child_node( cpus, npcpu )
>> +    {
>> +        if ( dt_device_type_is_equal(npcpu, "cpu") )
>> +        {
>> +            node_name = strrchr(dt_node_full_name(npcpu), '/');
>> +            node_name++;
>> +
>> +            ASSERT(node_name && *node_name);
>
> The first check on node_name is pointless because of the node_name++ above.
>
> I would divide the ASSERT in 2 parts, and do the first check before
> node_name++;
I'll do this in the next patch-set.

>> +
>> +            DPRINT("Copy %s node to the pcpus\n", node_name);
>> +
>> +            res = fdt_begin_node(fdt, node_name);
>> +            if ( res )
>> +                return res;
>> +
>> +            dt_for_each_property_node( npcpu, pp )
>> +            {
>> +                if ( pp->length )
>> +                {
>> +                    res = fdt_property(fdt, pp->name, pp->value,
>> +                                        pp->length);
>> +                    if ( res )
>> +                        return res;
>> +                }
>> +            }
>> +
>
> You can use write_properties to replace this loop.
I'll try to do this in the next patch set.

>> +            res = fdt_end_node(fdt);
>> +            if ( res )
>> +                return res;
>> +        }
>> +    }
>> +
>> +    res = fdt_end_node(fdt);
>> +    return res;
>> +}
>> +#endif /* HAS_CPUFREQ */
>> +
>>  static int make_hypervisor_node(struct domain *d,
>>                                  void *fdt, const struct dt_device_node *parent)
>>  {
>> @@ -386,6 +449,10 @@ static int make_hypervisor_node(struct domain *d,
>>      if ( res )
>>          return res;
>>
>> +    #ifdef HAS_CPUFREQ
>> +    fdt_copy_phys_cpus_nodes(fdt);
>
> You forgot to check the return value of the function.
I'll add checking in the next patch-set.

> Regards,
>
> --
> Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 08/12] xsm: enable xsm_platform_op hook for all architectures
  2014-10-23 16:11   ` Julien Grall
@ 2014-10-24 10:24     ` Oleksandr Dmytryshyn
  2014-10-24 10:27       ` Oleksandr Dmytryshyn
  0 siblings, 1 reply; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-24 10:24 UTC (permalink / raw)
  To: Julien Grall
  Cc: Stefano Stabellini, Daniel De Graaf, Tim Deegan, Ian Campbell, xen-devel

On Thu, Oct 23, 2014 at 7:11 PM, Julien Grall <julien.grall@linaro.org> wrote:
> Hi Oleksandr,
>
> You forgot to CC Daniel (CCed him) who is the XSM maintainers.
>
> On 10/23/2014 04:07 PM, Oleksandr Dmytryshyn wrote:
>> This hook is used by platform hypercall which will
>> be implemented for all architectures.
>
> I don't think it's necessary to have a separate patch for XSM. I would
> fold it in #9.
I'll do this in the next patch-set.

> Otherwise, this change looks good to me.
>
>>
>> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
>> ---
>>  xen/include/xsm/dummy.h | 12 ++++++------
>>  xen/include/xsm/xsm.h   | 10 +++++-----
>>  xen/xsm/flask/hooks.c   |  3 ++-
>>  3 files changed, 13 insertions(+), 12 deletions(-)
>>
>> diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h
>> index eb9e1a1..911fb5d 100644
>> --- a/xen/include/xsm/dummy.h
>> +++ b/xen/include/xsm/dummy.h
>> @@ -491,6 +491,12 @@ static XSM_INLINE int xsm_hvm_param_nested(XSM_DEFAULT_ARG struct domain *d)
>>      return xsm_default_action(action, current->domain, d);
>>  }
>>
>> +static XSM_INLINE int xsm_platform_op(XSM_DEFAULT_ARG uint32_t op)
>> +{
>> +    XSM_ASSERT_ACTION(XSM_PRIV);
>> +    return xsm_default_action(action, current->domain, NULL);
>> +}
>> +
>>  #ifdef CONFIG_X86
>>  static XSM_INLINE int xsm_shadow_control(XSM_DEFAULT_ARG struct domain *d, uint32_t op)
>>  {
>> @@ -546,12 +552,6 @@ static XSM_INLINE int xsm_apic(XSM_DEFAULT_ARG struct domain *d, int cmd)
>>      return xsm_default_action(action, d, NULL);
>>  }
>>
>> -static XSM_INLINE int xsm_platform_op(XSM_DEFAULT_ARG uint32_t op)
>> -{
>> -    XSM_ASSERT_ACTION(XSM_PRIV);
>> -    return xsm_default_action(action, current->domain, NULL);
>> -}
>> -
>>  static XSM_INLINE int xsm_machine_memory_map(XSM_DEFAULT_VOID)
>>  {
>>      XSM_ASSERT_ACTION(XSM_PRIV);
>> diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
>> index 1939453..5cb1e0d 100644
>> --- a/xen/include/xsm/xsm.h
>> +++ b/xen/include/xsm/xsm.h
>> @@ -509,6 +509,11 @@ static inline int xsm_hvm_param_nested (xsm_default_t def, struct domain *d)
>>      return xsm_ops->hvm_param_nested(d);
>>  }
>>
>> +static inline int xsm_platform_op (xsm_default_t def, uint32_t op)
>> +{
>> +    return xsm_ops->platform_op(op);
>> +}
>> +
>>  #ifdef CONFIG_X86
>>  static inline int xsm_shadow_control (xsm_default_t def, struct domain *d, uint32_t op)
>>  {
>> @@ -560,11 +565,6 @@ static inline int xsm_memtype (xsm_default_t def, uint32_t access)
>>      return xsm_ops->memtype(access);
>>  }
>>
>> -static inline int xsm_platform_op (xsm_default_t def, uint32_t op)
>> -{
>> -    return xsm_ops->platform_op(op);
>> -}
>> -
>>  static inline int xsm_machine_memory_map(xsm_default_t def)
>>  {
>>      return xsm_ops->machine_memory_map();
>> diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
>> index d94ab77..29126ec 100644
>> --- a/xen/xsm/flask/hooks.c
>> +++ b/xen/xsm/flask/hooks.c
>> @@ -1542,6 +1542,8 @@ static struct xsm_operations flask_ops = {
>>      .add_to_physmap = flask_add_to_physmap,
>>      .remove_from_physmap = flask_remove_from_physmap,
>>
>> +    .platform_op = flask_platform_op,
>> +
>>  #ifdef CONFIG_X86
>>      .shadow_control = flask_shadow_control,
>>      .hvm_set_pci_intx_level = flask_hvm_set_pci_intx_level,
>> @@ -1552,7 +1554,6 @@ static struct xsm_operations flask_ops = {
>>      .mem_event_op = flask_mem_event_op,
>>      .mem_sharing_op = flask_mem_sharing_op,
>>      .apic = flask_apic,
>> -    .platform_op = flask_platform_op,
>>      .machine_memory_map = flask_machine_memory_map,
>>      .domain_memory_map = flask_domain_memory_map,
>>      .mmu_update = flask_mmu_update,
>>
>
>
> --
> Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 08/12] xsm: enable xsm_platform_op hook for all architectures
  2014-10-24 10:24     ` Oleksandr Dmytryshyn
@ 2014-10-24 10:27       ` Oleksandr Dmytryshyn
  2014-10-24 11:38         ` Julien Grall
  0 siblings, 1 reply; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-24 10:27 UTC (permalink / raw)
  To: Julien Grall
  Cc: Stefano Stabellini, Daniel De Graaf, Tim Deegan, Ian Campbell, xen-devel

On Fri, Oct 24, 2014 at 1:24 PM, Oleksandr Dmytryshyn
<oleksandr.dmytryshyn@globallogic.com> wrote:
> On Thu, Oct 23, 2014 at 7:11 PM, Julien Grall <julien.grall@linaro.org> wrote:
>> Hi Oleksandr,
>>
>> You forgot to CC Daniel (CCed him) who is the XSM maintainers.
I'll CC Daniel in the future.

>> On 10/23/2014 04:07 PM, Oleksandr Dmytryshyn wrote:
>>> This hook is used by platform hypercall which will
>>> be implemented for all architectures.
>>
>> I don't think it's necessary to have a separate patch for XSM. I would
>> fold it in #9.
> I'll do this in the next patch-set.
>
>> Otherwise, this change looks good to me.
>>
>>>
>>> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
>>> ---
>>>  xen/include/xsm/dummy.h | 12 ++++++------
>>>  xen/include/xsm/xsm.h   | 10 +++++-----
>>>  xen/xsm/flask/hooks.c   |  3 ++-
>>>  3 files changed, 13 insertions(+), 12 deletions(-)
>>>
>>> diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h
>>> index eb9e1a1..911fb5d 100644
>>> --- a/xen/include/xsm/dummy.h
>>> +++ b/xen/include/xsm/dummy.h
>>> @@ -491,6 +491,12 @@ static XSM_INLINE int xsm_hvm_param_nested(XSM_DEFAULT_ARG struct domain *d)
>>>      return xsm_default_action(action, current->domain, d);
>>>  }
>>>
>>> +static XSM_INLINE int xsm_platform_op(XSM_DEFAULT_ARG uint32_t op)
>>> +{
>>> +    XSM_ASSERT_ACTION(XSM_PRIV);
>>> +    return xsm_default_action(action, current->domain, NULL);
>>> +}
>>> +
>>>  #ifdef CONFIG_X86
>>>  static XSM_INLINE int xsm_shadow_control(XSM_DEFAULT_ARG struct domain *d, uint32_t op)
>>>  {
>>> @@ -546,12 +552,6 @@ static XSM_INLINE int xsm_apic(XSM_DEFAULT_ARG struct domain *d, int cmd)
>>>      return xsm_default_action(action, d, NULL);
>>>  }
>>>
>>> -static XSM_INLINE int xsm_platform_op(XSM_DEFAULT_ARG uint32_t op)
>>> -{
>>> -    XSM_ASSERT_ACTION(XSM_PRIV);
>>> -    return xsm_default_action(action, current->domain, NULL);
>>> -}
>>> -
>>>  static XSM_INLINE int xsm_machine_memory_map(XSM_DEFAULT_VOID)
>>>  {
>>>      XSM_ASSERT_ACTION(XSM_PRIV);
>>> diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
>>> index 1939453..5cb1e0d 100644
>>> --- a/xen/include/xsm/xsm.h
>>> +++ b/xen/include/xsm/xsm.h
>>> @@ -509,6 +509,11 @@ static inline int xsm_hvm_param_nested (xsm_default_t def, struct domain *d)
>>>      return xsm_ops->hvm_param_nested(d);
>>>  }
>>>
>>> +static inline int xsm_platform_op (xsm_default_t def, uint32_t op)
>>> +{
>>> +    return xsm_ops->platform_op(op);
>>> +}
>>> +
>>>  #ifdef CONFIG_X86
>>>  static inline int xsm_shadow_control (xsm_default_t def, struct domain *d, uint32_t op)
>>>  {
>>> @@ -560,11 +565,6 @@ static inline int xsm_memtype (xsm_default_t def, uint32_t access)
>>>      return xsm_ops->memtype(access);
>>>  }
>>>
>>> -static inline int xsm_platform_op (xsm_default_t def, uint32_t op)
>>> -{
>>> -    return xsm_ops->platform_op(op);
>>> -}
>>> -
>>>  static inline int xsm_machine_memory_map(xsm_default_t def)
>>>  {
>>>      return xsm_ops->machine_memory_map();
>>> diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
>>> index d94ab77..29126ec 100644
>>> --- a/xen/xsm/flask/hooks.c
>>> +++ b/xen/xsm/flask/hooks.c
>>> @@ -1542,6 +1542,8 @@ static struct xsm_operations flask_ops = {
>>>      .add_to_physmap = flask_add_to_physmap,
>>>      .remove_from_physmap = flask_remove_from_physmap,
>>>
>>> +    .platform_op = flask_platform_op,
>>> +
>>>  #ifdef CONFIG_X86
>>>      .shadow_control = flask_shadow_control,
>>>      .hvm_set_pci_intx_level = flask_hvm_set_pci_intx_level,
>>> @@ -1552,7 +1554,6 @@ static struct xsm_operations flask_ops = {
>>>      .mem_event_op = flask_mem_event_op,
>>>      .mem_sharing_op = flask_mem_sharing_op,
>>>      .apic = flask_apic,
>>> -    .platform_op = flask_platform_op,
>>>      .machine_memory_map = flask_machine_memory_map,
>>>      .domain_memory_map = flask_domain_memory_map,
>>>      .mmu_update = flask_mmu_update,
>>>
>>
>>
>> --
>> Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 10/12] cpufreq: add hwdom-cpufreq driver
  2014-10-23 16:42   ` Julien Grall
@ 2014-10-24 10:30     ` Oleksandr Dmytryshyn
  2014-10-24 11:45       ` Julien Grall
  0 siblings, 1 reply; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-24 10:30 UTC (permalink / raw)
  To: Julien Grall; +Cc: Stefano Stabellini, Tim Deegan, Ian Campbell, xen-devel

On Thu, Oct 23, 2014 at 7:42 PM, Julien Grall <julien.grall@linaro.org> wrote:
> Hi Oleksandr,
>
> On 10/23/2014 04:07 PM, Oleksandr Dmytryshyn wrote:
>> This driver uses hwdom to change frequencies on CPUs
>>
>> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
>> ---
>>  xen/Rules.mk                        |   1 +
>>  xen/drivers/cpufreq/Makefile        |   1 +
>>  xen/drivers/cpufreq/hwdom-cpufreq.c | 220 ++++++++++++++++++++++++++++++++++++
>>  xen/include/public/xen.h            |   1 +
>>  4 files changed, 223 insertions(+)
>>  create mode 100644 xen/drivers/cpufreq/hwdom-cpufreq.c
>>
>> diff --git a/xen/Rules.mk b/xen/Rules.mk
>> index 3b0b89b..cccbc72 100644
>> --- a/xen/Rules.mk
>> +++ b/xen/Rules.mk
>> @@ -56,6 +56,7 @@ CFLAGS-$(perfc_arrays)  += -DPERF_ARRAYS
>>  CFLAGS-$(lock_profile)  += -DLOCK_PROFILE
>>  CFLAGS-$(HAS_ACPI)      += -DHAS_ACPI
>>  CFLAGS-$(HAS_CPUFREQ)   += -DHAS_CPUFREQ
>> +CFLAGS-$(HAS_HWDOM_CPUFREQ) += -DHAS_HWDOM_CPUFREQ
>>  CFLAGS-$(HAS_PM)        += -DHAS_PM
>>  CFLAGS-$(HAS_CPU_TURBO) += -DHAS_CPU_TURBO
>>  CFLAGS-$(HAS_GDBSX)     += -DHAS_GDBSX
>> diff --git a/xen/drivers/cpufreq/Makefile b/xen/drivers/cpufreq/Makefile
>> index b87d127..891997c 100644
>> --- a/xen/drivers/cpufreq/Makefile
>> +++ b/xen/drivers/cpufreq/Makefile
>> @@ -2,3 +2,4 @@ obj-y += cpufreq.o
>>  obj-y += cpufreq_ondemand.o
>>  obj-y += cpufreq_misc_governors.o
>>  obj-y += utility.o
>> +obj-$(HAS_HWDOM_CPUFREQ) += hwdom-cpufreq.o
>> diff --git a/xen/drivers/cpufreq/hwdom-cpufreq.c b/xen/drivers/cpufreq/hwdom-cpufreq.c
>> new file mode 100644
>> index 0000000..67c9e1d
>> --- /dev/null
>> +++ b/xen/drivers/cpufreq/hwdom-cpufreq.c
>> @@ -0,0 +1,220 @@
>> +/*
>> + *  Copyright (C) 2014 GlobalLogic Inc.
>
> A part of this file has been copied from xen/arch/x86/acpi/cpufreq.c. I
> would keep the copyright from this file and add yours.
I'll do this in the next patch-set.

> Maybe we could share the initialization code (and others parts?) with
> this file? For instance the structure looks the same...
I don't think that we could simple share the initialization code and
others parts.
A lot of code looks the same. But I've introduced a new structure
hwdom_cpufreq_data which has different field names (non-ACPI meaning).

>> + *
>> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> + *
>> + *  This program is free software; you can redistribute it and/or modify
>> + *  it under the terms of the GNU General Public License as published by
>> + *  the Free Software Foundation; either version 2 of the License, or (at
>> + *  your option) any later version.
>> + *
>> + *  This program is distributed in the hope that it will be useful, but
>> + *  WITHOUT ANY WARRANTY; without even the implied warranty of
>> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + *  General Public License for more details.
>> + *
>> + *  You should have received a copy of the GNU General Public License along
>> + *  with this program; if not, write to the Free Software Foundation, Inc.,
>> + *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
>> + *
>> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> + */
>> +#include <xen/types.h>
>> +#include <xen/errno.h>
>> +#include <xen/sched.h>
>> +#include <xen/event.h>
>> +#include <xen/irq.h>
>> +#include <xen/spinlock.h>
>> +#include <xen/cpufreq.h>
>> +#include <asm/current.h>
>> +
>> +struct hwdom_cpufreq_data {
>> +    struct processor_performance *perf_data;
>> +    struct cpufreq_frequency_table *freq_table;
>> +};
>> +
>> +static struct hwdom_cpufreq_data *hwdom_cpufreq_drv_data[NR_CPUS];
>> +
>> +int cpufreq_cpu_init(unsigned int cpuid)
>> +{
>> +    return cpufreq_add_cpu(cpuid);
>> +}
>> +
>> +static int hwdom_cpufreq_verify(struct cpufreq_policy *policy)
>> +{
>> +    struct hwdom_cpufreq_data *data;
>> +    struct processor_performance *perf;
>> +
>> +    if ( !policy || !(data = hwdom_cpufreq_drv_data[policy->cpu]) ||
>> +         !processor_pminfo[policy->cpu] )
>> +        return -EINVAL;
>> +
>> +    perf = &processor_pminfo[policy->cpu]->perf;
>> +
>> +    cpufreq_verify_within_limits(policy, 0,
>> +        perf->states[perf->platform_limit].core_frequency * 1000);
>
> NIT: Missing space after the comma.
I'll fix this in the next patch-set.

>> +
>> +    return cpufreq_frequency_table_verify(policy, data->freq_table);
>> +}
>> +
>> +static int hwdom_cpufreq_target(struct cpufreq_policy *policy,
>> +                               unsigned int target_freq, unsigned int relation)
>> +{
>> +    struct hwdom_cpufreq_data *data = hwdom_cpufreq_drv_data[policy->cpu];
>> +    struct processor_performance *perf;
>> +    struct cpufreq_freqs freqs;
>> +    cpumask_t online_policy_cpus;
>> +    unsigned int next_state = 0; /* Index into freq_table */
>> +    unsigned int next_perf_state = 0; /* Index into perf table */
>> +    unsigned int j;
>> +    int ret = 0;
>> +
>> +    if ( unlikely(data == NULL ||
>> +         data->perf_data == NULL || data->freq_table == NULL) )
>> +    {
>> +        return -ENODEV;
>> +    }
>
> NIT: The braces are not necessary.
I'll fix this in the next patch-set.

>> +
>> +    perf = data->perf_data;
>> +    ret = cpufreq_frequency_table_target(policy,
>> +                                            data->freq_table,
>> +                                            target_freq,
>> +                                            relation, &next_state);
>
> NIT: The alignment of the parameters don't look good.
I'll fix this in the next patch-set.

>> +    if ( unlikely(ret) )
>> +        return -ENODEV;
>> +
>> +    cpumask_and(&online_policy_cpus, &cpu_online_map, policy->cpus);
>> +
>> +    next_perf_state = data->freq_table[next_state].index;
>> +    if ( perf->state == next_perf_state )
>> +    {
>> +        if ( unlikely(policy->resume) )
>> +            policy->resume = 0;
>> +        else
>> +            return 0;
>> +    }
>> +
>> +    freqs.old = perf->states[perf->state].core_frequency * 1000;
>> +    freqs.new = data->freq_table[next_state].frequency;
>> +
>> +    for_each_cpu( j, &online_policy_cpus )
>> +        cpufreq_statistic_update(j, perf->state, next_perf_state);
>> +
>> +    perf->state = next_perf_state;
>> +    policy->cur = freqs.new;
>> +
>> +    return ret;
>> +}
>> +
>> +static int
>> +hwdom_cpufreq_cpu_init(struct cpufreq_policy *policy)
>> +{
>> +    struct processor_performance *perf;
>> +    struct hwdom_cpufreq_data *data;
>> +    unsigned int cpu = policy->cpu;
>> +    unsigned int valid_states = 0;
>> +    int i;
>> +    int ret = 0;
>> +
>> +    data = xzalloc(struct hwdom_cpufreq_data);
>> +    if ( !data )
>> +        return -ENOMEM;
>> +
>> +    hwdom_cpufreq_drv_data[cpu] = data;
>> +
>> +    data->perf_data = &processor_pminfo[cpu]->perf;
>> +
>> +    perf = data->perf_data;
>> +    policy->shared_type = perf->shared_type;
>> +
>> +    data->freq_table = xmalloc_array(struct cpufreq_frequency_table,
>> +                                    (perf->state_count+1));
>
> NIT: Misaligned
I'll fix this in the next patch-set.

>> +    if ( !data->freq_table )
>> +    {
>> +        ret = -ENOMEM;
>> +        goto err_unreg;
>> +    }
>> +
>> +    /* detect transition latency */
>> +    policy->cpuinfo.transition_latency = 0;
>> +    for ( i=0; i<perf->state_count; i++ )
>
> NIT: i < perf...
I'll fix this in the next patch-set.

>> +    {
>> +        if ( (perf->states[i].transition_latency * 1000) >
>> +             policy->cpuinfo.transition_latency )
>> +            policy->cpuinfo.transition_latency =
>> +                perf->states[i].transition_latency * 1000;
>> +    }
>> +
>> +    policy->governor = cpufreq_opt_governor ? : CPUFREQ_DEFAULT_GOVERNOR;
>> +
>> +    /* table init */
>> +    for ( i=0; i<perf->state_count; i++ )
>
> Ditto
I'll fix this in the next patch-set.

>> +    {
>> +        if ( i>0 && perf->states[i].core_frequency >=
>> +            data->freq_table[valid_states-1].frequency / 1000 )
>> +            continue;
>> +
>> +        data->freq_table[valid_states].index = i;
>> +        data->freq_table[valid_states].frequency =
>> +            perf->states[i].core_frequency * 1000;
>> +        valid_states++;
>> +    }
>> +    data->freq_table[valid_states].frequency = CPUFREQ_TABLE_END;
>> +    perf->state = 0;
>> +
>> +    ret = cpufreq_frequency_table_cpuinfo(policy, data->freq_table);
>> +    if ( ret )
>> +        goto err_freqfree;
>> +
>> +
>> +    /*
>> +     * the first call to ->target() should result in us actually
>> +     * send command to the Dom0 to set frequency.
>> +     */
>> +    policy->resume = 1;
>> +
>> +    /* Set the minimal frequency */
>> +    return hwdom_cpufreq_target(policy, policy->min, CPUFREQ_RELATION_L);
>> +
>> + err_freqfree:
>> +    xfree(data->freq_table);
>> + err_unreg:
>> +    xfree(data);
>> +    hwdom_cpufreq_drv_data[cpu] = NULL;
>> +
>> +    return ret;
>> +}
>> +
>> +static int hwdom_cpufreq_cpu_exit(struct cpufreq_policy *policy)
>> +{
>> +    struct hwdom_cpufreq_data *data = hwdom_cpufreq_drv_data[policy->cpu];
>> +
>> +    if ( data )
>> +    {
>> +        hwdom_cpufreq_drv_data[policy->cpu] = NULL;
>> +        xfree(data->freq_table);
>> +        xfree(data);
>> +    }
>> +
>> +    return 0;
>> +}
>> +
>> +static struct cpufreq_driver hwdom_cpufreq_driver = {
>> +    .name   = "hwdom-cpufreq",
>> +    .verify = hwdom_cpufreq_verify,
>> +    .target = hwdom_cpufreq_target,
>> +    .init   = hwdom_cpufreq_cpu_init,
>> +    .exit   = hwdom_cpufreq_cpu_exit,
>> +};
>> +
>> +int __init hwdom_cpufreq_driver_init(void)
>
> It looks like this function is only used for the __initcall. I would put
> a static before.
I'll fix this in the next patch-set.

> Regards,
>
> --
> Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 11/12] xen: arm: implement XEN_SYSCTL_cpufreq_op
  2014-10-23 16:27   ` Julien Grall
@ 2014-10-24 10:37     ` Oleksandr Dmytryshyn
  0 siblings, 0 replies; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-24 10:37 UTC (permalink / raw)
  To: Julien Grall; +Cc: Stefano Stabellini, Tim Deegan, Ian Campbell, xen-devel

On Thu, Oct 23, 2014 at 7:27 PM, Julien Grall <julien.grall@linaro.org> wrote:
> Hi Oleksandr,
>
> On 10/23/2014 04:07 PM, Oleksandr Dmytryshyn wrote:
>> Kernel uses this op to get some parameters for the
>> xen-cpufreq driver to change CPUs frequency.
>
> The XSM bit is missing for this new sysctl (see flask_sysctl).
I'll introduce the XSM bit for this new sysctl. But I see that file
xen/xsm/flask/hooks.c is not compiled for x86 and ARM architectures.
It uses bits (for example XEN__PHYSINFO) which are not defined anywhere.

>> diff --git a/xen/drivers/cpufreq/hwdom-cpufreq.c b/xen/drivers/cpufreq/hwdom-cpufreq.c
>> index 67c9e1d..cc97f37 100644
>> --- a/xen/drivers/cpufreq/hwdom-cpufreq.c
>> +++ b/xen/drivers/cpufreq/hwdom-cpufreq.c
>> @@ -34,12 +34,53 @@ struct hwdom_cpufreq_data {
>>  };
>>
>>  static struct hwdom_cpufreq_data *hwdom_cpufreq_drv_data[NR_CPUS];
>> +static DEFINE_SPINLOCK(sysctl_cpufreq_lock);
>> +
>> +struct sysctl_cpufreq_data {
>> +    uint32_t cpu;
>> +    uint32_t freq;
>> +    uint32_t relation;
>> +    int32_t result;
>> +};
>> +
>> +static struct sysctl_cpufreq_data sysctl_cpufreq_data;
>>
>>  int cpufreq_cpu_init(unsigned int cpuid)
>>  {
>>      return cpufreq_add_cpu(cpuid);
>>  }
>>
>> +static void notify_cpufreq_domains(void)
>> +{
>> +    send_global_virq(VIRQ_CPUFREQ);
>> +}
>> +
>> +int sysctl_cpufreq_op(xen_sysctl_cpufreq_op_t *op)
>> +{
>> +    int ret = 0;
>
> AFAIU, the cpufreq will always run in the hardware domain. Therefore,
> shouldn't you check that the sysctl is effectively executed by this domain?
I'll try to do this in the next patch set.

>>  static int hwdom_cpufreq_verify(struct cpufreq_policy *policy)
>>  {
>>      struct hwdom_cpufreq_data *data;
>> @@ -97,6 +138,17 @@ static int hwdom_cpufreq_target(struct cpufreq_policy *policy,
>>      freqs.old = perf->states[perf->state].core_frequency * 1000;
>>      freqs.new = data->freq_table[next_state].frequency;
>>
>> +    /* Do send cmd for Dom0 */
>
> s/Dom0/Hardware domain/
I'll fix this in the next patch set.

>> +    spin_lock(&sysctl_cpufreq_lock);
>> +    /* return previous result */
>> +    ret = sysctl_cpufreq_data.result;
>> +
>> +    sysctl_cpufreq_data.cpu = policy->cpu;
>> +    sysctl_cpufreq_data.freq = freqs.new;
>> +    sysctl_cpufreq_data.relation = (uint32_t)relation;
>> +    spin_unlock(&sysctl_cpufreq_lock);
>> +    notify_cpufreq_domains();
>> +
>>      for_each_cpu( j, &online_policy_cpus )
>>          cpufreq_statistic_update(j, perf->state, next_perf_state);
>>
>> 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;
>> +};
>
> Can you document this structure?
I'll do this in the next patch set.

> Regards,
>
> --
> Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 08/12] xsm: enable xsm_platform_op hook for all architectures
  2014-10-24 10:27       ` Oleksandr Dmytryshyn
@ 2014-10-24 11:38         ` Julien Grall
  0 siblings, 0 replies; 32+ messages in thread
From: Julien Grall @ 2014-10-24 11:38 UTC (permalink / raw)
  To: Oleksandr Dmytryshyn
  Cc: Stefano Stabellini, Daniel De Graaf, Tim Deegan, Ian Campbell, xen-devel

On 10/24/2014 11:27 AM, Oleksandr Dmytryshyn wrote:
> On Fri, Oct 24, 2014 at 1:24 PM, Oleksandr Dmytryshyn
> <oleksandr.dmytryshyn@globallogic.com> wrote:
>> On Thu, Oct 23, 2014 at 7:11 PM, Julien Grall <julien.grall@linaro.org> wrote:
>>> Hi Oleksandr,
>>>
>>> You forgot to CC Daniel (CCed him) who is the XSM maintainers.
> I'll CC Daniel in the future.

A good way to not forget maintainers is to use scripts/get_maintainers.pl.

Regards,

>>> On 10/23/2014 04:07 PM, Oleksandr Dmytryshyn wrote:
>>>> This hook is used by platform hypercall which will
>>>> be implemented for all architectures.
>>>
>>> I don't think it's necessary to have a separate patch for XSM. I would
>>> fold it in #9.
>> I'll do this in the next patch-set.
>>
>>> Otherwise, this change looks good to me.
>>>
>>>>
>>>> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
>>>> ---
>>>>  xen/include/xsm/dummy.h | 12 ++++++------
>>>>  xen/include/xsm/xsm.h   | 10 +++++-----
>>>>  xen/xsm/flask/hooks.c   |  3 ++-
>>>>  3 files changed, 13 insertions(+), 12 deletions(-)
>>>>
>>>> diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h
>>>> index eb9e1a1..911fb5d 100644
>>>> --- a/xen/include/xsm/dummy.h
>>>> +++ b/xen/include/xsm/dummy.h
>>>> @@ -491,6 +491,12 @@ static XSM_INLINE int xsm_hvm_param_nested(XSM_DEFAULT_ARG struct domain *d)
>>>>      return xsm_default_action(action, current->domain, d);
>>>>  }
>>>>
>>>> +static XSM_INLINE int xsm_platform_op(XSM_DEFAULT_ARG uint32_t op)
>>>> +{
>>>> +    XSM_ASSERT_ACTION(XSM_PRIV);
>>>> +    return xsm_default_action(action, current->domain, NULL);
>>>> +}
>>>> +
>>>>  #ifdef CONFIG_X86
>>>>  static XSM_INLINE int xsm_shadow_control(XSM_DEFAULT_ARG struct domain *d, uint32_t op)
>>>>  {
>>>> @@ -546,12 +552,6 @@ static XSM_INLINE int xsm_apic(XSM_DEFAULT_ARG struct domain *d, int cmd)
>>>>      return xsm_default_action(action, d, NULL);
>>>>  }
>>>>
>>>> -static XSM_INLINE int xsm_platform_op(XSM_DEFAULT_ARG uint32_t op)
>>>> -{
>>>> -    XSM_ASSERT_ACTION(XSM_PRIV);
>>>> -    return xsm_default_action(action, current->domain, NULL);
>>>> -}
>>>> -
>>>>  static XSM_INLINE int xsm_machine_memory_map(XSM_DEFAULT_VOID)
>>>>  {
>>>>      XSM_ASSERT_ACTION(XSM_PRIV);
>>>> diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
>>>> index 1939453..5cb1e0d 100644
>>>> --- a/xen/include/xsm/xsm.h
>>>> +++ b/xen/include/xsm/xsm.h
>>>> @@ -509,6 +509,11 @@ static inline int xsm_hvm_param_nested (xsm_default_t def, struct domain *d)
>>>>      return xsm_ops->hvm_param_nested(d);
>>>>  }
>>>>
>>>> +static inline int xsm_platform_op (xsm_default_t def, uint32_t op)
>>>> +{
>>>> +    return xsm_ops->platform_op(op);
>>>> +}
>>>> +
>>>>  #ifdef CONFIG_X86
>>>>  static inline int xsm_shadow_control (xsm_default_t def, struct domain *d, uint32_t op)
>>>>  {
>>>> @@ -560,11 +565,6 @@ static inline int xsm_memtype (xsm_default_t def, uint32_t access)
>>>>      return xsm_ops->memtype(access);
>>>>  }
>>>>
>>>> -static inline int xsm_platform_op (xsm_default_t def, uint32_t op)
>>>> -{
>>>> -    return xsm_ops->platform_op(op);
>>>> -}
>>>> -
>>>>  static inline int xsm_machine_memory_map(xsm_default_t def)
>>>>  {
>>>>      return xsm_ops->machine_memory_map();
>>>> diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
>>>> index d94ab77..29126ec 100644
>>>> --- a/xen/xsm/flask/hooks.c
>>>> +++ b/xen/xsm/flask/hooks.c
>>>> @@ -1542,6 +1542,8 @@ static struct xsm_operations flask_ops = {
>>>>      .add_to_physmap = flask_add_to_physmap,
>>>>      .remove_from_physmap = flask_remove_from_physmap,
>>>>
>>>> +    .platform_op = flask_platform_op,
>>>> +
>>>>  #ifdef CONFIG_X86
>>>>      .shadow_control = flask_shadow_control,
>>>>      .hvm_set_pci_intx_level = flask_hvm_set_pci_intx_level,
>>>> @@ -1552,7 +1554,6 @@ static struct xsm_operations flask_ops = {
>>>>      .mem_event_op = flask_mem_event_op,
>>>>      .mem_sharing_op = flask_mem_sharing_op,
>>>>      .apic = flask_apic,
>>>> -    .platform_op = flask_platform_op,
>>>>      .machine_memory_map = flask_machine_memory_map,
>>>>      .domain_memory_map = flask_domain_memory_map,
>>>>      .mmu_update = flask_mmu_update,
>>>>
>>>
>>>
>>> --
>>> Julien Grall


-- 
Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 10/12] cpufreq: add hwdom-cpufreq driver
  2014-10-24 10:30     ` Oleksandr Dmytryshyn
@ 2014-10-24 11:45       ` Julien Grall
  2014-10-24 13:05         ` Oleksandr Dmytryshyn
  0 siblings, 1 reply; 32+ messages in thread
From: Julien Grall @ 2014-10-24 11:45 UTC (permalink / raw)
  To: Oleksandr Dmytryshyn
  Cc: Stefano Stabellini, Tim Deegan, Ian Campbell, xen-devel

On 10/24/2014 11:30 AM, Oleksandr Dmytryshyn wrote:
> On Thu, Oct 23, 2014 at 7:42 PM, Julien Grall <julien.grall@linaro.org> wrote:
>> Hi Oleksandr,
>>
>> On 10/23/2014 04:07 PM, Oleksandr Dmytryshyn wrote:
>>> This driver uses hwdom to change frequencies on CPUs
>>>
>>> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
>>> ---
>>>  xen/Rules.mk                        |   1 +
>>>  xen/drivers/cpufreq/Makefile        |   1 +
>>>  xen/drivers/cpufreq/hwdom-cpufreq.c | 220 ++++++++++++++++++++++++++++++++++++
>>>  xen/include/public/xen.h            |   1 +
>>>  4 files changed, 223 insertions(+)
>>>  create mode 100644 xen/drivers/cpufreq/hwdom-cpufreq.c
>>>
>>> diff --git a/xen/Rules.mk b/xen/Rules.mk
>>> index 3b0b89b..cccbc72 100644
>>> --- a/xen/Rules.mk
>>> +++ b/xen/Rules.mk
>>> @@ -56,6 +56,7 @@ CFLAGS-$(perfc_arrays)  += -DPERF_ARRAYS
>>>  CFLAGS-$(lock_profile)  += -DLOCK_PROFILE
>>>  CFLAGS-$(HAS_ACPI)      += -DHAS_ACPI
>>>  CFLAGS-$(HAS_CPUFREQ)   += -DHAS_CPUFREQ
>>> +CFLAGS-$(HAS_HWDOM_CPUFREQ) += -DHAS_HWDOM_CPUFREQ
>>>  CFLAGS-$(HAS_PM)        += -DHAS_PM
>>>  CFLAGS-$(HAS_CPU_TURBO) += -DHAS_CPU_TURBO
>>>  CFLAGS-$(HAS_GDBSX)     += -DHAS_GDBSX
>>> diff --git a/xen/drivers/cpufreq/Makefile b/xen/drivers/cpufreq/Makefile
>>> index b87d127..891997c 100644
>>> --- a/xen/drivers/cpufreq/Makefile
>>> +++ b/xen/drivers/cpufreq/Makefile
>>> @@ -2,3 +2,4 @@ obj-y += cpufreq.o
>>>  obj-y += cpufreq_ondemand.o
>>>  obj-y += cpufreq_misc_governors.o
>>>  obj-y += utility.o
>>> +obj-$(HAS_HWDOM_CPUFREQ) += hwdom-cpufreq.o
>>> diff --git a/xen/drivers/cpufreq/hwdom-cpufreq.c b/xen/drivers/cpufreq/hwdom-cpufreq.c
>>> new file mode 100644
>>> index 0000000..67c9e1d
>>> --- /dev/null
>>> +++ b/xen/drivers/cpufreq/hwdom-cpufreq.c
>>> @@ -0,0 +1,220 @@
>>> +/*
>>> + *  Copyright (C) 2014 GlobalLogic Inc.
>>
>> A part of this file has been copied from xen/arch/x86/acpi/cpufreq.c. I
>> would keep the copyright from this file and add yours.
> I'll do this in the next patch-set.
> 
>> Maybe we could share the initialization code (and others parts?) with
>> this file? For instance the structure looks the same...
> I don't think that we could simple share the initialization code and
> others parts.
> A lot of code looks the same. But I've introduced a new structure
> hwdom_cpufreq_data which has different field names (non-ACPI meaning).

Except the name, the type of each fields are the same (except the third
one which doesn't exist here).

IHMO, those names could be renamed if it could avoid to duplicate tens
lines of code.

It would be easier for maintaining the code later.

Regards,

-- 
Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 10/12] cpufreq: add hwdom-cpufreq driver
  2014-10-24 11:45       ` Julien Grall
@ 2014-10-24 13:05         ` Oleksandr Dmytryshyn
  2014-10-24 13:08           ` Julien Grall
  0 siblings, 1 reply; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-24 13:05 UTC (permalink / raw)
  To: Julien Grall; +Cc: Stefano Stabellini, Tim Deegan, Ian Campbell, xen-devel

On Fri, Oct 24, 2014 at 2:45 PM, Julien Grall <julien.grall@linaro.org> wrote:
> On 10/24/2014 11:30 AM, Oleksandr Dmytryshyn wrote:
>> On Thu, Oct 23, 2014 at 7:42 PM, Julien Grall <julien.grall@linaro.org> wrote:
>>> Hi Oleksandr,
>>>
>>> On 10/23/2014 04:07 PM, Oleksandr Dmytryshyn wrote:
>>>> This driver uses hwdom to change frequencies on CPUs
>>>>
>>>> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
>>>> ---
>>>>  xen/Rules.mk                        |   1 +
>>>>  xen/drivers/cpufreq/Makefile        |   1 +
>>>>  xen/drivers/cpufreq/hwdom-cpufreq.c | 220 ++++++++++++++++++++++++++++++++++++
>>>>  xen/include/public/xen.h            |   1 +
>>>>  4 files changed, 223 insertions(+)
>>>>  create mode 100644 xen/drivers/cpufreq/hwdom-cpufreq.c
>>>>
>>>> diff --git a/xen/Rules.mk b/xen/Rules.mk
>>>> index 3b0b89b..cccbc72 100644
>>>> --- a/xen/Rules.mk
>>>> +++ b/xen/Rules.mk
>>>> @@ -56,6 +56,7 @@ CFLAGS-$(perfc_arrays)  += -DPERF_ARRAYS
>>>>  CFLAGS-$(lock_profile)  += -DLOCK_PROFILE
>>>>  CFLAGS-$(HAS_ACPI)      += -DHAS_ACPI
>>>>  CFLAGS-$(HAS_CPUFREQ)   += -DHAS_CPUFREQ
>>>> +CFLAGS-$(HAS_HWDOM_CPUFREQ) += -DHAS_HWDOM_CPUFREQ
>>>>  CFLAGS-$(HAS_PM)        += -DHAS_PM
>>>>  CFLAGS-$(HAS_CPU_TURBO) += -DHAS_CPU_TURBO
>>>>  CFLAGS-$(HAS_GDBSX)     += -DHAS_GDBSX
>>>> diff --git a/xen/drivers/cpufreq/Makefile b/xen/drivers/cpufreq/Makefile
>>>> index b87d127..891997c 100644
>>>> --- a/xen/drivers/cpufreq/Makefile
>>>> +++ b/xen/drivers/cpufreq/Makefile
>>>> @@ -2,3 +2,4 @@ obj-y += cpufreq.o
>>>>  obj-y += cpufreq_ondemand.o
>>>>  obj-y += cpufreq_misc_governors.o
>>>>  obj-y += utility.o
>>>> +obj-$(HAS_HWDOM_CPUFREQ) += hwdom-cpufreq.o
>>>> diff --git a/xen/drivers/cpufreq/hwdom-cpufreq.c b/xen/drivers/cpufreq/hwdom-cpufreq.c
>>>> new file mode 100644
>>>> index 0000000..67c9e1d
>>>> --- /dev/null
>>>> +++ b/xen/drivers/cpufreq/hwdom-cpufreq.c
>>>> @@ -0,0 +1,220 @@
>>>> +/*
>>>> + *  Copyright (C) 2014 GlobalLogic Inc.
>>>
>>> A part of this file has been copied from xen/arch/x86/acpi/cpufreq.c. I
>>> would keep the copyright from this file and add yours.
>> I'll do this in the next patch-set.
>>
>>> Maybe we could share the initialization code (and others parts?) with
>>> this file? For instance the structure looks the same...
>> I don't think that we could simple share the initialization code and
>> others parts.
>> A lot of code looks the same. But I've introduced a new structure
>> hwdom_cpufreq_data which has different field names (non-ACPI meaning).
>
> Except the name, the type of each fields are the same (except the third
> one which doesn't exist here).
>
> IHMO, those names could be renamed if it could avoid to duplicate tens
> lines of code.
>
> It would be easier for maintaining the code later.
In this case I'll back to the 'acpi_cpufreq_data' structure and I'll try
to create an additional file with common code for those drivers.

> Regards,
>
> --
> Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 10/12] cpufreq: add hwdom-cpufreq driver
  2014-10-24 13:05         ` Oleksandr Dmytryshyn
@ 2014-10-24 13:08           ` Julien Grall
  2014-10-27 13:29             ` Oleksandr Dmytryshyn
  0 siblings, 1 reply; 32+ messages in thread
From: Julien Grall @ 2014-10-24 13:08 UTC (permalink / raw)
  To: Oleksandr Dmytryshyn
  Cc: Stefano Stabellini, Tim Deegan, Ian Campbell, xen-devel

On 10/24/2014 02:05 PM, Oleksandr Dmytryshyn wrote:
> On Fri, Oct 24, 2014 at 2:45 PM, Julien Grall <julien.grall@linaro.org> wrote:
>> On 10/24/2014 11:30 AM, Oleksandr Dmytryshyn wrote:
>>> On Thu, Oct 23, 2014 at 7:42 PM, Julien Grall <julien.grall@linaro.org> wrote:
>>>> Hi Oleksandr,
>>>>
>>>> On 10/23/2014 04:07 PM, Oleksandr Dmytryshyn wrote:
>>>>> This driver uses hwdom to change frequencies on CPUs
>>>>>
>>>>> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
>>>>> ---
>>>>>  xen/Rules.mk                        |   1 +
>>>>>  xen/drivers/cpufreq/Makefile        |   1 +
>>>>>  xen/drivers/cpufreq/hwdom-cpufreq.c | 220 ++++++++++++++++++++++++++++++++++++
>>>>>  xen/include/public/xen.h            |   1 +
>>>>>  4 files changed, 223 insertions(+)
>>>>>  create mode 100644 xen/drivers/cpufreq/hwdom-cpufreq.c
>>>>>
>>>>> diff --git a/xen/Rules.mk b/xen/Rules.mk
>>>>> index 3b0b89b..cccbc72 100644
>>>>> --- a/xen/Rules.mk
>>>>> +++ b/xen/Rules.mk
>>>>> @@ -56,6 +56,7 @@ CFLAGS-$(perfc_arrays)  += -DPERF_ARRAYS
>>>>>  CFLAGS-$(lock_profile)  += -DLOCK_PROFILE
>>>>>  CFLAGS-$(HAS_ACPI)      += -DHAS_ACPI
>>>>>  CFLAGS-$(HAS_CPUFREQ)   += -DHAS_CPUFREQ
>>>>> +CFLAGS-$(HAS_HWDOM_CPUFREQ) += -DHAS_HWDOM_CPUFREQ
>>>>>  CFLAGS-$(HAS_PM)        += -DHAS_PM
>>>>>  CFLAGS-$(HAS_CPU_TURBO) += -DHAS_CPU_TURBO
>>>>>  CFLAGS-$(HAS_GDBSX)     += -DHAS_GDBSX
>>>>> diff --git a/xen/drivers/cpufreq/Makefile b/xen/drivers/cpufreq/Makefile
>>>>> index b87d127..891997c 100644
>>>>> --- a/xen/drivers/cpufreq/Makefile
>>>>> +++ b/xen/drivers/cpufreq/Makefile
>>>>> @@ -2,3 +2,4 @@ obj-y += cpufreq.o
>>>>>  obj-y += cpufreq_ondemand.o
>>>>>  obj-y += cpufreq_misc_governors.o
>>>>>  obj-y += utility.o
>>>>> +obj-$(HAS_HWDOM_CPUFREQ) += hwdom-cpufreq.o
>>>>> diff --git a/xen/drivers/cpufreq/hwdom-cpufreq.c b/xen/drivers/cpufreq/hwdom-cpufreq.c
>>>>> new file mode 100644
>>>>> index 0000000..67c9e1d
>>>>> --- /dev/null
>>>>> +++ b/xen/drivers/cpufreq/hwdom-cpufreq.c
>>>>> @@ -0,0 +1,220 @@
>>>>> +/*
>>>>> + *  Copyright (C) 2014 GlobalLogic Inc.
>>>>
>>>> A part of this file has been copied from xen/arch/x86/acpi/cpufreq.c. I
>>>> would keep the copyright from this file and add yours.
>>> I'll do this in the next patch-set.
>>>
>>>> Maybe we could share the initialization code (and others parts?) with
>>>> this file? For instance the structure looks the same...
>>> I don't think that we could simple share the initialization code and
>>> others parts.
>>> A lot of code looks the same. But I've introduced a new structure
>>> hwdom_cpufreq_data which has different field names (non-ACPI meaning).
>>
>> Except the name, the type of each fields are the same (except the third
>> one which doesn't exist here).
>>
>> IHMO, those names could be renamed if it could avoid to duplicate tens
>> lines of code.
>>
>> It would be easier for maintaining the code later.
> In this case I'll back to the 'acpi_cpufreq_data' structure and I'll try
> to create an additional file with common code for those drivers.

I'm not the maintainers, so I would wait any input from maintainers
before doing a such big change :).

Regards,

-- 
Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 11/12] xen: arm: implement XEN_SYSCTL_cpufreq_op
  2014-10-23 15:07 ` [RFC PATCH v3 11/12] xen: arm: implement XEN_SYSCTL_cpufreq_op Oleksandr Dmytryshyn
  2014-10-23 16:27   ` Julien Grall
@ 2014-10-26 17:41   ` Stefano Stabellini
  2014-10-27 16:27     ` Oleksandr Dmytryshyn
  1 sibling, 1 reply; 32+ messages in thread
From: Stefano Stabellini @ 2014-10-26 17:41 UTC (permalink / raw)
  To: Oleksandr Dmytryshyn
  Cc: Stefano Stabellini, Tim Deegan, Ian Campbell, xen-devel

On Thu, 23 Oct 2014, Oleksandr Dmytryshyn wrote:
> Kernel uses this op to get some parameters for the
> xen-cpufreq driver to change CPUs frequency.

The commit message doesn't describe many of the changes introduced by
this patch.
For example it fails to mention that it is
introducing notify_cpufreq_domains.

We need a better commit message.

Also doesn't notify_cpufreq_domains belong to the previous patch anyway?

> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
> ---
>  xen/common/sysctl.c                 |  8 ++++++
>  xen/drivers/cpufreq/hwdom-cpufreq.c | 52 +++++++++++++++++++++++++++++++++++++
>  xen/include/public/sysctl.h         | 19 ++++++++++++++
>  xen/include/xen/cpufreq.h           |  2 ++
>  4 files changed, 81 insertions(+)
> 
> diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
> index 0dcf06a..fd0cd0d 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_HWDOM_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/hwdom-cpufreq.c b/xen/drivers/cpufreq/hwdom-cpufreq.c
> index 67c9e1d..cc97f37 100644
> --- a/xen/drivers/cpufreq/hwdom-cpufreq.c
> +++ b/xen/drivers/cpufreq/hwdom-cpufreq.c
> @@ -34,12 +34,53 @@ struct hwdom_cpufreq_data {
>  };
>  
>  static struct hwdom_cpufreq_data *hwdom_cpufreq_drv_data[NR_CPUS];
> +static DEFINE_SPINLOCK(sysctl_cpufreq_lock);
> +
> +struct sysctl_cpufreq_data {
> +    uint32_t cpu;
> +    uint32_t freq;
> +    uint32_t relation;
> +    int32_t result;
> +};
> +
> +static struct sysctl_cpufreq_data sysctl_cpufreq_data;
>  
>  int cpufreq_cpu_init(unsigned int cpuid)
>  {
>      return cpufreq_add_cpu(cpuid);
>  }
>  
> +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 -EOPNOTSUPP;
> +        break;
> +    }
> +    return ret;
> +}
> +
>  static int hwdom_cpufreq_verify(struct cpufreq_policy *policy)
>  {
>      struct hwdom_cpufreq_data *data;
> @@ -97,6 +138,17 @@ static int hwdom_cpufreq_target(struct cpufreq_policy *policy,
>      freqs.old = perf->states[perf->state].core_frequency * 1000;
>      freqs.new = data->freq_table[next_state].frequency;
>  
> +    /* Do send cmd for Dom0 */
> +    spin_lock(&sysctl_cpufreq_lock);
> +    /* return previous result */
> +    ret = sysctl_cpufreq_data.result;
> +
> +    sysctl_cpufreq_data.cpu = policy->cpu;
> +    sysctl_cpufreq_data.freq = freqs.new;
> +    sysctl_cpufreq_data.relation = (uint32_t)relation;
> +    spin_unlock(&sysctl_cpufreq_lock);
> +    notify_cpufreq_domains();
> +
>      for_each_cpu( j, &online_policy_cpus )
>          cpufreq_statistic_update(j, perf->state, next_perf_state);
>  
> 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..0c8c19d 100644
> --- a/xen/include/xen/cpufreq.h
> +++ b/xen/include/xen/cpufreq.h
> @@ -264,4 +264,6 @@ int write_userspace_scaling_setspeed(unsigned int cpu, unsigned int freq);
>  void cpufreq_dbs_timer_suspend(void);
>  void cpufreq_dbs_timer_resume(void);
>  
> +int sysctl_cpufreq_op(xen_sysctl_cpufreq_op_t *op);
> +
>  #endif /* __XEN_CPUFREQ_PM_H__ */
> -- 
> 1.9.1
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 07/12] arch/arm: create device tree nodes for hwdom cpufreq cpu driver
  2014-10-24 10:24     ` Oleksandr Dmytryshyn
@ 2014-10-27 10:52       ` Oleksandr Dmytryshyn
  2014-10-27 13:15         ` Julien Grall
  0 siblings, 1 reply; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-27 10:52 UTC (permalink / raw)
  To: Julien Grall; +Cc: Stefano Stabellini, Tim Deegan, Ian Campbell, xen-devel

On Fri, Oct 24, 2014 at 1:24 PM, Oleksandr Dmytryshyn
<oleksandr.dmytryshyn@globallogic.com> wrote:
> On Thu, Oct 23, 2014 at 6:49 PM, Julien Grall <julien.grall@linaro.org> wrote:
>> Hi Oleksandr,
>>
>> On 10/23/2014 04:07 PM, Oleksandr Dmytryshyn wrote:
>>> This patch copies all cpu@0..cpu@N nodes (from input
>>> device tree) with properties to /hypervisor/pcpus
>>> node (device tree for hwdom). Thus we can give all
>>> information about all physical CPUs in the pcpus node.
>>> Driver in hwdom should parse /hypervisor/pcpus path
>>> instead of the /cpus path in the device tree.
>>>
>>> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
>>> ---
>>>  xen/arch/arm/domain_build.c | 67 +++++++++++++++++++++++++++++++++++++++++++++
>>>  1 file changed, 67 insertions(+)
>>>
>>> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>>> index 2db0236..2186514 100644
>>> --- a/xen/arch/arm/domain_build.c
>>> +++ b/xen/arch/arm/domain_build.c
>>> @@ -326,6 +326,69 @@ static int make_memory_node(const struct domain *d,
>>>      return res;
>>>  }
>>>
>>> +#ifdef HAS_CPUFREQ
>>> +static int fdt_copy_phys_cpus_nodes(void *fdt)
>>> +{
>>> +    int res;
>>> +    const struct dt_device_node *cpus = dt_find_node_by_path("/cpus");
>>> +    const struct dt_device_node *npcpu;
>>> +    const struct dt_property *pp;
>>> +    char *node_name;
>>> +
>>> +    if ( !cpus )
>>> +    {
>>> +        dprintk(XENLOG_ERR, "Missing /cpus node in the device tree?\n");
>>> +        return -ENOENT;
>>> +    }
>>> +
>>> +    /*
>>> +     * create pcpus node and copy to it
>>> +     * original cpu@0..cpu@N nodes with its properties.
>>> +     * This is needed for the cpufreq cpu driver in Dom0
>>> +     */
>>> +    DPRINT("Create pcpus node\n");
>>> +
>>> +    res = fdt_begin_node(fdt, "pcpus");
>>
>> This new bindings has to be documented somewhere. The best places would
>> be in Documentation/devicetree/bindins/arm/xen.txt (see Linux repo).
> I'll do this in the next patch-set.
>
>>> +    if ( res )
>>> +        return res;
>>> +
>>> +    dt_for_each_child_node( cpus, npcpu )
>>> +    {
>>> +        if ( dt_device_type_is_equal(npcpu, "cpu") )
>>> +        {
>>> +            node_name = strrchr(dt_node_full_name(npcpu), '/');
>>> +            node_name++;
>>> +
>>> +            ASSERT(node_name && *node_name);
>>
>> The first check on node_name is pointless because of the node_name++ above.
>>
>> I would divide the ASSERT in 2 parts, and do the first check before
>> node_name++;
> I'll do this in the next patch-set.
>
>>> +
>>> +            DPRINT("Copy %s node to the pcpus\n", node_name);
>>> +
>>> +            res = fdt_begin_node(fdt, node_name);
>>> +            if ( res )
>>> +                return res;
>>> +
>>> +            dt_for_each_property_node( npcpu, pp )
>>> +            {
>>> +                if ( pp->length )
>>> +                {
>>> +                    res = fdt_property(fdt, pp->name, pp->value,
>>> +                                        pp->length);
>>> +                    if ( res )
>>> +                        return res;
>>> +                }
>>> +            }
>>> +
>>
>> You can use write_properties to replace this loop.
> I'll try to do this in the next patch set.
It is better to keep this loop because write_properties() replaces only loop
and this function contains additional checkings. Also this function passes
kernel_info * parameter which is absent in the function make_hypervisor_node().
kinfo->fdt is passed as the parameter to the  the function
make_hypervisor_node().

>>> +            res = fdt_end_node(fdt);
>>> +            if ( res )
>>> +                return res;
>>> +        }
>>> +    }
>>> +
>>> +    res = fdt_end_node(fdt);
>>> +    return res;
>>> +}
>>> +#endif /* HAS_CPUFREQ */
>>> +
>>>  static int make_hypervisor_node(struct domain *d,
>>>                                  void *fdt, const struct dt_device_node *parent)
>>>  {
>>> @@ -386,6 +449,10 @@ static int make_hypervisor_node(struct domain *d,
>>>      if ( res )
>>>          return res;
>>>
>>> +    #ifdef HAS_CPUFREQ
>>> +    fdt_copy_phys_cpus_nodes(fdt);
>>
>> You forgot to check the return value of the function.
> I'll add checking in the next patch-set.
>
>> Regards,
>>
>> --
>> Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 07/12] arch/arm: create device tree nodes for hwdom cpufreq cpu driver
  2014-10-27 10:52       ` Oleksandr Dmytryshyn
@ 2014-10-27 13:15         ` Julien Grall
  2014-10-27 13:32           ` Oleksandr Dmytryshyn
  0 siblings, 1 reply; 32+ messages in thread
From: Julien Grall @ 2014-10-27 13:15 UTC (permalink / raw)
  To: Oleksandr Dmytryshyn
  Cc: Stefano Stabellini, Tim Deegan, Ian Campbell, xen-devel

Hi Oleksandr,

On 10/27/2014 10:52 AM, Oleksandr Dmytryshyn wrote:
> On Fri, Oct 24, 2014 at 1:24 PM, Oleksandr Dmytryshyn
> <oleksandr.dmytryshyn@globallogic.com> wrote:
>> On Thu, Oct 23, 2014 at 6:49 PM, Julien Grall <julien.grall@linaro.org> wrote:
>>>> +
>>>> +            DPRINT("Copy %s node to the pcpus\n", node_name);
>>>> +
>>>> +            res = fdt_begin_node(fdt, node_name);
>>>> +            if ( res )
>>>> +                return res;
>>>> +
>>>> +            dt_for_each_property_node( npcpu, pp )
>>>> +            {
>>>> +                if ( pp->length )
>>>> +                {
>>>> +                    res = fdt_property(fdt, pp->name, pp->value,
>>>> +                                        pp->length);
>>>> +                    if ( res )
>>>> +                        return res;
>>>> +                }
>>>> +            }
>>>> +
>>>
>>> You can use write_properties to replace this loop.
>> I'll try to do this in the next patch set.
> It is better to keep this loop because write_properties() replaces only loop
> and this function contains additional checkings.

Those checking are only for the "chosen" node. This function is used in
place where we have to copy properties in DOM0 DT. Not sure why you
think it would not fit here?

BTW, we plan to rework this function for Xen 4.6. The function will
likely look like to your open loop.

> Also this function passes
> kernel_info * parameter which is absent in the function make_hypervisor_node().
> kinfo->fdt is passed as the parameter to the  the function
> make_hypervisor_node().

The prototype of make_hypervisor_node is not set in stone :).
It's perfectly fine to pass kinfo in parameter.

Regards,

-- 
Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 10/12] cpufreq: add hwdom-cpufreq driver
  2014-10-24 13:08           ` Julien Grall
@ 2014-10-27 13:29             ` Oleksandr Dmytryshyn
  0 siblings, 0 replies; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-27 13:29 UTC (permalink / raw)
  To: Julien Grall; +Cc: Stefano Stabellini, Tim Deegan, Ian Campbell, xen-devel

On Fri, Oct 24, 2014 at 4:08 PM, Julien Grall <julien.grall@linaro.org> wrote:
> On 10/24/2014 02:05 PM, Oleksandr Dmytryshyn wrote:
>> On Fri, Oct 24, 2014 at 2:45 PM, Julien Grall <julien.grall@linaro.org> wrote:
>>> On 10/24/2014 11:30 AM, Oleksandr Dmytryshyn wrote:
>>>> On Thu, Oct 23, 2014 at 7:42 PM, Julien Grall <julien.grall@linaro.org> wrote:
>>>>> Hi Oleksandr,
>>>>>
>>>>> On 10/23/2014 04:07 PM, Oleksandr Dmytryshyn wrote:
>>>>>> This driver uses hwdom to change frequencies on CPUs
>>>>>>
>>>>>> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
>>>>>> ---
>>>>>>  xen/Rules.mk                        |   1 +
>>>>>>  xen/drivers/cpufreq/Makefile        |   1 +
>>>>>>  xen/drivers/cpufreq/hwdom-cpufreq.c | 220 ++++++++++++++++++++++++++++++++++++
>>>>>>  xen/include/public/xen.h            |   1 +
>>>>>>  4 files changed, 223 insertions(+)
>>>>>>  create mode 100644 xen/drivers/cpufreq/hwdom-cpufreq.c
>>>>>>
>>>>>> diff --git a/xen/Rules.mk b/xen/Rules.mk
>>>>>> index 3b0b89b..cccbc72 100644
>>>>>> --- a/xen/Rules.mk
>>>>>> +++ b/xen/Rules.mk
>>>>>> @@ -56,6 +56,7 @@ CFLAGS-$(perfc_arrays)  += -DPERF_ARRAYS
>>>>>>  CFLAGS-$(lock_profile)  += -DLOCK_PROFILE
>>>>>>  CFLAGS-$(HAS_ACPI)      += -DHAS_ACPI
>>>>>>  CFLAGS-$(HAS_CPUFREQ)   += -DHAS_CPUFREQ
>>>>>> +CFLAGS-$(HAS_HWDOM_CPUFREQ) += -DHAS_HWDOM_CPUFREQ
>>>>>>  CFLAGS-$(HAS_PM)        += -DHAS_PM
>>>>>>  CFLAGS-$(HAS_CPU_TURBO) += -DHAS_CPU_TURBO
>>>>>>  CFLAGS-$(HAS_GDBSX)     += -DHAS_GDBSX
>>>>>> diff --git a/xen/drivers/cpufreq/Makefile b/xen/drivers/cpufreq/Makefile
>>>>>> index b87d127..891997c 100644
>>>>>> --- a/xen/drivers/cpufreq/Makefile
>>>>>> +++ b/xen/drivers/cpufreq/Makefile
>>>>>> @@ -2,3 +2,4 @@ obj-y += cpufreq.o
>>>>>>  obj-y += cpufreq_ondemand.o
>>>>>>  obj-y += cpufreq_misc_governors.o
>>>>>>  obj-y += utility.o
>>>>>> +obj-$(HAS_HWDOM_CPUFREQ) += hwdom-cpufreq.o
>>>>>> diff --git a/xen/drivers/cpufreq/hwdom-cpufreq.c b/xen/drivers/cpufreq/hwdom-cpufreq.c
>>>>>> new file mode 100644
>>>>>> index 0000000..67c9e1d
>>>>>> --- /dev/null
>>>>>> +++ b/xen/drivers/cpufreq/hwdom-cpufreq.c
>>>>>> @@ -0,0 +1,220 @@
>>>>>> +/*
>>>>>> + *  Copyright (C) 2014 GlobalLogic Inc.
>>>>>
>>>>> A part of this file has been copied from xen/arch/x86/acpi/cpufreq.c. I
>>>>> would keep the copyright from this file and add yours.
>>>> I'll do this in the next patch-set.
>>>>
>>>>> Maybe we could share the initialization code (and others parts?) with
>>>>> this file? For instance the structure looks the same...
>>>> I don't think that we could simple share the initialization code and
>>>> others parts.
>>>> A lot of code looks the same. But I've introduced a new structure
>>>> hwdom_cpufreq_data which has different field names (non-ACPI meaning).
>>>
>>> Except the name, the type of each fields are the same (except the third
>>> one which doesn't exist here).
>>>
>>> IHMO, those names could be renamed if it could avoid to duplicate tens
>>> lines of code.
>>>
>>> It would be easier for maintaining the code later.
>> In this case I'll back to the 'acpi_cpufreq_data' structure and I'll try
>> to create an additional file with common code for those drivers.
>
> I'm not the maintainers, so I would wait any input from maintainers
> before doing a such big change :).
In this case, I'll leave a separate file (without sharing of the code).
If there will be any input from maintainers I'll rework this patch.

> Regards,
>
> --
> Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 07/12] arch/arm: create device tree nodes for hwdom cpufreq cpu driver
  2014-10-27 13:15         ` Julien Grall
@ 2014-10-27 13:32           ` Oleksandr Dmytryshyn
  0 siblings, 0 replies; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-27 13:32 UTC (permalink / raw)
  To: Julien Grall; +Cc: Stefano Stabellini, Tim Deegan, Ian Campbell, xen-devel

On Mon, Oct 27, 2014 at 3:15 PM, Julien Grall <julien.grall@linaro.org> wrote:
> Hi Oleksandr,
>
> On 10/27/2014 10:52 AM, Oleksandr Dmytryshyn wrote:
>> On Fri, Oct 24, 2014 at 1:24 PM, Oleksandr Dmytryshyn
>> <oleksandr.dmytryshyn@globallogic.com> wrote:
>>> On Thu, Oct 23, 2014 at 6:49 PM, Julien Grall <julien.grall@linaro.org> wrote:
>>>>> +
>>>>> +            DPRINT("Copy %s node to the pcpus\n", node_name);
>>>>> +
>>>>> +            res = fdt_begin_node(fdt, node_name);
>>>>> +            if ( res )
>>>>> +                return res;
>>>>> +
>>>>> +            dt_for_each_property_node( npcpu, pp )
>>>>> +            {
>>>>> +                if ( pp->length )
>>>>> +                {
>>>>> +                    res = fdt_property(fdt, pp->name, pp->value,
>>>>> +                                        pp->length);
>>>>> +                    if ( res )
>>>>> +                        return res;
>>>>> +                }
>>>>> +            }
>>>>> +
>>>>
>>>> You can use write_properties to replace this loop.
>>> I'll try to do this in the next patch set.
>> It is better to keep this loop because write_properties() replaces only loop
>> and this function contains additional checkings.
>
> Those checking are only for the "chosen" node. This function is used in
> place where we have to copy properties in DOM0 DT. Not sure why you
> think it would not fit here?
>
> BTW, we plan to rework this function for Xen 4.6. The function will
> likely look like to your open loop.
>
>> Also this function passes
>> kernel_info * parameter which is absent in the function make_hypervisor_node().
>> kinfo->fdt is passed as the parameter to the  the function
>> make_hypervisor_node().
>
> The prototype of make_hypervisor_node is not set in stone :).
> It's perfectly fine to pass kinfo in parameter.
OK. I'll use this function to replace the loop.

> Regards,
>
> --
> Julien Grall

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [RFC PATCH v3 11/12] xen: arm: implement XEN_SYSCTL_cpufreq_op
  2014-10-26 17:41   ` Stefano Stabellini
@ 2014-10-27 16:27     ` Oleksandr Dmytryshyn
  0 siblings, 0 replies; 32+ messages in thread
From: Oleksandr Dmytryshyn @ 2014-10-27 16:27 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: Stefano Stabellini, Tim Deegan, Ian Campbell, xen-devel

On Sun, Oct 26, 2014 at 7:41 PM, Stefano Stabellini
<stefano.stabellini@eu.citrix.com> wrote:
> On Thu, 23 Oct 2014, Oleksandr Dmytryshyn wrote:
>> Kernel uses this op to get some parameters for the
>> xen-cpufreq driver to change CPUs frequency.
>
> The commit message doesn't describe many of the changes introduced by
> this patch.
> For example it fails to mention that it is
> introducing notify_cpufreq_domains.
>
> We need a better commit message.
I'll extend a commit message in the next patch-set.

> Also doesn't notify_cpufreq_domains belong to the previous patch anyway?
I'll move this function to the previous patch in the next patch-set.

>> Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
>> ---
>>  xen/common/sysctl.c                 |  8 ++++++
>>  xen/drivers/cpufreq/hwdom-cpufreq.c | 52 +++++++++++++++++++++++++++++++++++++
>>  xen/include/public/sysctl.h         | 19 ++++++++++++++
>>  xen/include/xen/cpufreq.h           |  2 ++
>>  4 files changed, 81 insertions(+)
>>
>> diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
>> index 0dcf06a..fd0cd0d 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_HWDOM_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/hwdom-cpufreq.c b/xen/drivers/cpufreq/hwdom-cpufreq.c
>> index 67c9e1d..cc97f37 100644
>> --- a/xen/drivers/cpufreq/hwdom-cpufreq.c
>> +++ b/xen/drivers/cpufreq/hwdom-cpufreq.c
>> @@ -34,12 +34,53 @@ struct hwdom_cpufreq_data {
>>  };
>>
>>  static struct hwdom_cpufreq_data *hwdom_cpufreq_drv_data[NR_CPUS];
>> +static DEFINE_SPINLOCK(sysctl_cpufreq_lock);
>> +
>> +struct sysctl_cpufreq_data {
>> +    uint32_t cpu;
>> +    uint32_t freq;
>> +    uint32_t relation;
>> +    int32_t result;
>> +};
>> +
>> +static struct sysctl_cpufreq_data sysctl_cpufreq_data;
>>
>>  int cpufreq_cpu_init(unsigned int cpuid)
>>  {
>>      return cpufreq_add_cpu(cpuid);
>>  }
>>
>> +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 -EOPNOTSUPP;
>> +        break;
>> +    }
>> +    return ret;
>> +}
>> +
>>  static int hwdom_cpufreq_verify(struct cpufreq_policy *policy)
>>  {
>>      struct hwdom_cpufreq_data *data;
>> @@ -97,6 +138,17 @@ static int hwdom_cpufreq_target(struct cpufreq_policy *policy,
>>      freqs.old = perf->states[perf->state].core_frequency * 1000;
>>      freqs.new = data->freq_table[next_state].frequency;
>>
>> +    /* Do send cmd for Dom0 */
>> +    spin_lock(&sysctl_cpufreq_lock);
>> +    /* return previous result */
>> +    ret = sysctl_cpufreq_data.result;
>> +
>> +    sysctl_cpufreq_data.cpu = policy->cpu;
>> +    sysctl_cpufreq_data.freq = freqs.new;
>> +    sysctl_cpufreq_data.relation = (uint32_t)relation;
>> +    spin_unlock(&sysctl_cpufreq_lock);
>> +    notify_cpufreq_domains();
>> +
>>      for_each_cpu( j, &online_policy_cpus )
>>          cpufreq_statistic_update(j, perf->state, next_perf_state);
>>
>> 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..0c8c19d 100644
>> --- a/xen/include/xen/cpufreq.h
>> +++ b/xen/include/xen/cpufreq.h
>> @@ -264,4 +264,6 @@ int write_userspace_scaling_setspeed(unsigned int cpu, unsigned int freq);
>>  void cpufreq_dbs_timer_suspend(void);
>>  void cpufreq_dbs_timer_resume(void);
>>
>> +int sysctl_cpufreq_op(xen_sysctl_cpufreq_op_t *op);
>> +
>>  #endif /* __XEN_CPUFREQ_PM_H__ */
>> --
>> 1.9.1
>>
>>
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel@lists.xen.org
>> http://lists.xen.org/xen-devel
>>

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2014-10-27 16:27 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-23 15:07 [RFC PATCH v3 00/12]xen_cpufreq implementation in Xen hypervisor Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 01/12] cpufreq: move cpufreq.h file to the xen/include/xen location Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 02/12] pm: move processor_perf.h " Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 03/12] pmstat: move pmstat.c file to the xen/drivers/pm/stat.c location Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 04/12] cpufreq: make turbo settings to be configurable Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 05/12] pmstat: make pmstat functions more generalizable Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 06/12] cpufreq: make cpufreq driver " Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 07/12] arch/arm: create device tree nodes for hwdom cpufreq cpu driver Oleksandr Dmytryshyn
2014-10-23 15:49   ` Julien Grall
2014-10-24 10:24     ` Oleksandr Dmytryshyn
2014-10-27 10:52       ` Oleksandr Dmytryshyn
2014-10-27 13:15         ` Julien Grall
2014-10-27 13:32           ` Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 08/12] xsm: enable xsm_platform_op hook for all architectures Oleksandr Dmytryshyn
2014-10-23 16:11   ` Julien Grall
2014-10-24 10:24     ` Oleksandr Dmytryshyn
2014-10-24 10:27       ` Oleksandr Dmytryshyn
2014-10-24 11:38         ` Julien Grall
2014-10-23 15:07 ` [RFC PATCH v3 09/12] xen: arm: implement platform hypercall Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 10/12] cpufreq: add hwdom-cpufreq driver Oleksandr Dmytryshyn
2014-10-23 16:42   ` Julien Grall
2014-10-24 10:30     ` Oleksandr Dmytryshyn
2014-10-24 11:45       ` Julien Grall
2014-10-24 13:05         ` Oleksandr Dmytryshyn
2014-10-24 13:08           ` Julien Grall
2014-10-27 13:29             ` Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 11/12] xen: arm: implement XEN_SYSCTL_cpufreq_op Oleksandr Dmytryshyn
2014-10-23 16:27   ` Julien Grall
2014-10-24 10:37     ` Oleksandr Dmytryshyn
2014-10-26 17:41   ` Stefano Stabellini
2014-10-27 16:27     ` Oleksandr Dmytryshyn
2014-10-23 15:07 ` [RFC PATCH v3 12/12] xen/arm: enable cpufreq functionality for ARM Oleksandr Dmytryshyn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.