From patchwork Thu Nov 9 17:09:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 10051395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5AC7260381 for ; Thu, 9 Nov 2017 17:13:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F1992B050 for ; Thu, 9 Nov 2017 17:13:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33DC82B04F; Thu, 9 Nov 2017 17:13:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6E3032B050 for ; Thu, 9 Nov 2017 17:13:44 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCqLb-0003w9-Mt; Thu, 09 Nov 2017 17:10:35 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCqLa-0003vh-6X for xen-devel@lists.xenproject.org; Thu, 09 Nov 2017 17:10:34 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id 9F/C2-00431-90C840A5; Thu, 09 Nov 2017 17:10:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOIsWRWlGSWpSXmKPExsVyMfS6oy5HD0u Uwel3chbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8a23pnsBT37GSsufNjI0sD4cipjFyMXh5DA DEaJuz8eMIM4LAIvWSS+fG5gAnEkBPpZJf7N2MDWxcgJ5GRJXNuwlgnCTpO49fwnC4RdLrHyx HRWEFtIQEni9c7NTBBjZzNJdN+Yww6SYBMwkNj/7gmYLQJUdG/VZLAiZpCi+3s+giWEBcIl3j z5BGazCKhKzHz+BGwbr4CzxN5DF5khtslJ3DzXCWZzCrhIvPl4nQ1is7PExdfH2SYwCi5gZFj FqF6cWlSWWqRrppdUlJmeUZKbmJmja2hgrJebWlycmJ6ak5hUrJecn7uJERh49QwMjDsYr7Q5 H2KU5GBSEuWVsmSJEuJLyk+pzEgszogvKs1JLT7EKMPBoSTB690NlBMsSk1PrUjLzAHGAExag oNHSYT3XRdQmre4IDG3ODMdInWK0ZXjwp1Lf5g4jm26DCQP7LkFJJ/NfN3AzDHtamsTsxBLXn 5eqpQ4rxXIbAGQ5ozSPLjRsPi9xCgrJczLyMDAIMRTkFqUm1mCKv+KUZyDUUmYdzvICTyZeSV wF7wCOo4J6LhodrDjShIRUlINjEtLzhusyubYNXmJ5ZuknhtRBi9LmmRyNi6R97lWXM18KUzd osohKouH6UpW96VINa7Io7JPeyv5Lj9vbA65Wc6+f3Hv07yJnv2LHJb6nvtyWEbmSI7NtfXve Ys/bEn8aOA+keFaCPfRzbzvJ7dV17hqhb4v+rq7atmmnmX8v4LlGbcvMt9bqsRSnJFoqMVcVJ wIAJumkZTaAgAA X-Env-Sender: olekstysh@gmail.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1510247432!97475236!1 X-Originating-IP: [209.85.215.65] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10813 invoked from network); 9 Nov 2017 17:10:32 -0000 Received: from mail-lf0-f65.google.com (HELO mail-lf0-f65.google.com) (209.85.215.65) by server-12.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 9 Nov 2017 17:10:32 -0000 Received: by mail-lf0-f65.google.com with SMTP id a132so8046369lfa.7 for ; Thu, 09 Nov 2017 09:10:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QudqFaJuntpmPEhqSbFMxdMuinxbNDCYAwq8X8ARCqg=; b=buyn5g6AQ2SehO8oL8Hf/w6zNWii6MozYMNosNMejjn9rHy+1c520IbTD/x2hX7i5K xd4J57wB94480QGpOz5ynFrR2YMxRJB+0y5SiotygEmuhXYqpGtG1KMntlpbyDR31NFS znO3bK/x0oX+je+ZO29YJfIzbzHbNVjLOdclPikJTucN52QhNMKl+PsUejKJ4yJlN6dX f6xHg/I55e0pTzJ0cnDCXO1PTfBh6lb+6M6VBllS9G7Kd5MA2iNJz3IBrnvwk6PEtAE/ xcYnO+hlVX3BscT8awKMUBgM2XBX9gXuC5UhaolDAiRignnTwyssM2CrR8L7lfbcX3H6 Mo+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QudqFaJuntpmPEhqSbFMxdMuinxbNDCYAwq8X8ARCqg=; b=VWTzeJ6wzOfnno9onNKh8V3EkHydgJIZnlfnrIgSdXBWqvZF90HqZT5tcMtgb9hlxR /dHSPqRrqUGN2XJ4G83tOCIOkkCKMSu+b4uNgXG1E1NOH1KLzMVgEqmdsRaeDTnrljXk GlOepHdYpFccyse7E3zW6dOt0TnQtRkXev7OIe6z9k5G/QgSnOoNzilKn2JvKy8hHbXZ bruPBm7LNcC0yxbZnEoATb5PRSBFGa4PK2Qna5aLQ7yiUkOfLVs49a6DZx7sQCrZOvaV KKkvN8FJS8IBF7o0ar8kj3ISomrcYVg7zYv32/qhNj2m+AnAFS46HYChMChdYfp+KMIl ycmw== X-Gm-Message-State: AJaThX5ewNlqG5/yRWk9etqmmMhNiaY66wJyzgtfflnvAcgbvU33927E h7TVSsJwoQWVkW/V50o0dNsyqg== X-Google-Smtp-Source: ABhQp+TMX6yUOyPkVVTlPSy/dIIktiLxOvrif6AEs8DLgvSzJRFzY2RsWypjQl0a85lJAV8UHfUw6w== X-Received: by 10.46.33.86 with SMTP id h83mr501700ljh.193.1510247431506; Thu, 09 Nov 2017 09:10:31 -0800 (PST) Received: from otyshchenko.kyiv.epam.com (ll-53.209.223.85.sovam.net.ua. [85.223.209.53]) by smtp.gmail.com with ESMTPSA id x90sm1394299ljb.86.2017.11.09.09.10.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Nov 2017 09:10:30 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Thu, 9 Nov 2017 19:09:51 +0200 Message-Id: <1510247421-24094-2-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510247421-24094-1-git-send-email-olekstysh@gmail.com> References: <1510247421-24094-1-git-send-email-olekstysh@gmail.com> Cc: Stefano Stabellini , Andrew Cooper , Oleksandr Dmytryshyn , Julien Grall , Oleksandr Tyshchenko , Jan Beulich Subject: [Xen-devel] [RFC PATCH 01/31] cpufreq: move cpufreq.h file to the xen/include/xen location X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Dmytryshyn Cpufreq driver should be more generalizable (not ACPI-specific). Thus this file should be placed to more convenient location. This is a rebased version of the original patch: https://lists.xen.org/archives/html/xen-devel/2014-11/msg00938.html Signed-off-by: Oleksandr Dmytryshyn Signed-off-by: Oleksandr Tyshchenko CC: Jan Beulich CC: Andrew Cooper CC: Stefano Stabellini CC: Julien Grall --- 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/cpufreq.h | 245 -------------------------- xen/include/xen/cpufreq.h | 248 +++++++++++++++++++++++++++ 13 files changed, 260 insertions(+), 256 deletions(-) delete mode 100644 xen/include/acpi/cpufreq/cpufreq.h create mode 100644 xen/include/xen/cpufreq.h diff --git a/MAINTAINERS b/MAINTAINERS index 5b9e123..524e067 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -295,6 +295,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 PUBLIC I/O INTERFACES AND PV DRIVERS DESIGNS M: Konrad Rzeszutek Wilk diff --git a/xen/arch/x86/acpi/cpu_idle.c b/xen/arch/x86/acpi/cpu_idle.c index 482b8a7..c66622e 100644 --- a/xen/arch/x86/acpi/cpu_idle.c +++ b/xen/arch/x86/acpi/cpu_idle.c @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/xen/arch/x86/acpi/cpufreq/cpufreq.c b/xen/arch/x86/acpi/cpufreq/cpufreq.c index 1f8d02a..bd82025 100644 --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c @@ -41,7 +41,7 @@ #include #include #include -#include +#include enum { UNDEFINED_CAPABLE = 0, diff --git a/xen/arch/x86/acpi/cpufreq/powernow.c b/xen/arch/x86/acpi/cpufreq/powernow.c index 8f1ac74..79f55a3 100644 --- a/xen/arch/x86/acpi/cpufreq/powernow.c +++ b/xen/arch/x86/acpi/cpufreq/powernow.c @@ -35,7 +35,7 @@ #include #include #include -#include +#include #define CPUID_FREQ_VOLT_CAPABILITIES 0x80000007 #define CPB_CAPABLE 0x00000200 diff --git a/xen/arch/x86/acpi/power.c b/xen/arch/x86/acpi/power.c index 1e4e568..beebd5a 100644 --- a/xen/arch/x86/acpi/power.c +++ b/xen/arch/x86/acpi/power.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include 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 762dff1..29f0286 100644 --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -58,7 +58,7 @@ #include #include #include -#include +#include #define MWAIT_IDLE_VERSION "0.4.1" #undef PREFIX diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/acpi/pmstat.c index 2a6c4c7..2dbde1c 100644 --- a/xen/drivers/acpi/pmstat.c +++ b/xen/drivers/acpi/pmstat.c @@ -38,7 +38,7 @@ #include #include -#include +#include #include 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 212f48f..ab909e2 100644 --- a/xen/drivers/cpufreq/cpufreq.c +++ b/xen/drivers/cpufreq/cpufreq.c @@ -43,7 +43,7 @@ #include #include #include -#include +#include 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 #include #include -#include +#include /* * cpufreq userspace governor diff --git a/xen/drivers/cpufreq/cpufreq_ondemand.c b/xen/drivers/cpufreq/cpufreq_ondemand.c index fe6c63d..1c384ec 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 . @@ -18,7 +18,7 @@ #include #include #include -#include +#include #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 53879fe..a687e5a 100644 --- a/xen/drivers/cpufreq/utility.c +++ b/xen/drivers/cpufreq/utility.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include struct cpufreq_driver *cpufreq_driver; diff --git a/xen/include/acpi/cpufreq/cpufreq.h b/xen/include/acpi/cpufreq/cpufreq.h deleted file mode 100644 index a5cd7d0..0000000 --- a/xen/include/acpi/cpufreq/cpufreq.h +++ /dev/null @@ -1,245 +0,0 @@ -/* - * xen/include/acpi/cpufreq/cpufreq.h - * - * Copyright (C) 2001 Russell King - * (C) 2002 - 2003 Dominik Brodowski - * - * $Id: cpufreq.h,v 1.36 2003/01/20 17:31:48 db Exp $ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef __XEN_CPUFREQ_PM_H__ -#define __XEN_CPUFREQ_PM_H__ - -#include -#include -#include - -#include "processor_perf.h" - -DECLARE_PER_CPU(spinlock_t, cpufreq_statistic_lock); - -extern bool_t cpufreq_verbose; - -struct cpufreq_governor; - -struct acpi_cpufreq_data { - struct processor_performance *acpi_data; - struct cpufreq_frequency_table *freq_table; - unsigned int arch_cpu_flags; -}; - -extern struct acpi_cpufreq_data *cpufreq_drv_data[NR_CPUS]; - -struct cpufreq_cpuinfo { - unsigned int max_freq; - unsigned int second_max_freq; /* P1 if Turbo Mode is on */ - unsigned int min_freq; - unsigned int transition_latency; /* in 10^(-9) s = nanoseconds */ -}; - -struct perf_limits { - bool_t no_turbo; - bool_t turbo_disabled; - uint32_t turbo_pct; - uint32_t max_perf_pct; /* max performance in percentage */ - uint32_t min_perf_pct; /* min performance in percentage */ - uint32_t max_perf; - uint32_t min_perf; - uint32_t max_policy_pct; - uint32_t min_policy_pct; -}; - -struct cpufreq_policy { - cpumask_var_t cpus; /* affected CPUs */ - unsigned int shared_type; /* ANY or ALL affected CPUs - should set cpufreq */ - unsigned int cpu; /* cpu nr of registered CPU */ - struct cpufreq_cpuinfo cpuinfo; - - unsigned int min; /* in kHz */ - unsigned int max; /* in kHz */ - unsigned int cur; /* in kHz, only needed if cpufreq - * governors are used */ - struct perf_limits limits; - struct cpufreq_governor *governor; - - bool_t resume; /* flag for cpufreq 1st run - * S3 wakeup, hotplug cpu, etc */ - 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 */ -}; -DECLARE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_policy); - -extern int __cpufreq_set_policy(struct cpufreq_policy *data, - struct cpufreq_policy *policy); - -#define CPUFREQ_SHARED_TYPE_NONE (0) /* None */ -#define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */ -#define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */ -#define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/ - -/******************** cpufreq transition notifiers *******************/ - -struct cpufreq_freqs { - unsigned int cpu; /* cpu nr */ - unsigned int old; - unsigned int new; - u8 flags; /* flags of cpufreq_driver, see below. */ -}; - - -/********************************************************************* - * CPUFREQ GOVERNORS * - *********************************************************************/ - -#define CPUFREQ_GOV_START 1 -#define CPUFREQ_GOV_STOP 2 -#define CPUFREQ_GOV_LIMITS 3 - -struct cpufreq_governor { - char name[CPUFREQ_NAME_LEN]; - int (*governor)(struct cpufreq_policy *policy, - unsigned int event); - bool_t (*handle_option)(const char *name, const char *value); - struct list_head governor_list; -}; - -extern struct cpufreq_governor *cpufreq_opt_governor; -extern struct cpufreq_governor cpufreq_gov_dbs; -extern struct cpufreq_governor cpufreq_gov_userspace; -extern struct cpufreq_governor cpufreq_gov_performance; -extern struct cpufreq_governor cpufreq_gov_powersave; - -extern struct list_head cpufreq_governor_list; - -extern int cpufreq_register_governor(struct cpufreq_governor *governor); -extern struct cpufreq_governor *__find_governor(const char *governor); -#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_dbs - -/* pass a target to the cpufreq driver */ -extern int __cpufreq_driver_target(struct cpufreq_policy *policy, - unsigned int target_freq, - unsigned int relation); - -#define GOV_GETAVG 1 -#define USR_GETAVG 2 -extern int cpufreq_driver_getavg(unsigned int cpu, unsigned int flag); - -#define CPUFREQ_TURBO_DISABLED -1 -#define CPUFREQ_TURBO_UNSUPPORTED 0 -#define CPUFREQ_TURBO_ENABLED 1 - -extern int cpufreq_update_turbo(int cpuid, int new_state); -extern int cpufreq_get_turbo_status(int cpuid); - -static __inline__ int -__cpufreq_governor(struct cpufreq_policy *policy, unsigned int event) -{ - return policy->governor->governor(policy, event); -} - - -/********************************************************************* - * CPUFREQ DRIVER INTERFACE * - *********************************************************************/ - -#define CPUFREQ_RELATION_L 0 /* lowest frequency at or above target */ -#define CPUFREQ_RELATION_H 1 /* highest frequency below or at target */ - -struct cpufreq_driver { - char name[CPUFREQ_NAME_LEN]; - int (*init)(struct cpufreq_policy *policy); - int (*verify)(struct cpufreq_policy *policy); - int (*setpolicy)(struct cpufreq_policy *policy); - int (*update)(int cpuid, struct cpufreq_policy *policy); - int (*target)(struct cpufreq_policy *policy, - unsigned int target_freq, - unsigned int relation); - unsigned int (*get)(unsigned int cpu); - unsigned int (*getavg)(unsigned int cpu, unsigned int flag); - int (*exit)(struct cpufreq_policy *policy); -}; - -extern struct cpufreq_driver *cpufreq_driver; - -int cpufreq_register_driver(struct cpufreq_driver *); - -static __inline__ -void cpufreq_verify_within_limits(struct cpufreq_policy *policy, - unsigned int min, unsigned int max) -{ - if (policy->min < min) - policy->min = min; - if (policy->max < min) - policy->max = min; - if (policy->min > max) - policy->min = max; - if (policy->max > max) - policy->max = max; - if (policy->min > policy->max) - policy->min = policy->max; - return; -} - - -/********************************************************************* - * FREQUENCY TABLE HELPERS * - *********************************************************************/ - -#define CPUFREQ_ENTRY_INVALID ~0 -#define CPUFREQ_TABLE_END ~1 - -struct cpufreq_frequency_table { - unsigned int index; /* any */ - unsigned int frequency; /* kHz - doesn't need to be in ascending - * order */ -}; - -int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, - struct cpufreq_frequency_table *table); - -int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, - struct cpufreq_frequency_table *table); - -int cpufreq_frequency_table_target(struct cpufreq_policy *policy, - struct cpufreq_frequency_table *table, - unsigned int target_freq, - unsigned int relation, - unsigned int *index); - - -/********************************************************************* - * UNIFIED DEBUG HELPERS * - *********************************************************************/ - -struct cpu_dbs_info_s { - uint64_t prev_cpu_idle; - uint64_t prev_cpu_wall; - struct cpufreq_policy *cur_policy; - struct cpufreq_frequency_table *freq_table; - int cpu; - unsigned int enable:1; - unsigned int stoppable:1; - unsigned int turbo_enabled:1; -}; - -int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event); -int get_cpufreq_ondemand_para(uint32_t *sampling_rate_max, - uint32_t *sampling_rate_min, - uint32_t *sampling_rate, - uint32_t *up_threshold); -int write_ondemand_sampling_rate(unsigned int sampling_rate); -int write_ondemand_up_threshold(unsigned int up_threshold); - -int write_userspace_scaling_setspeed(unsigned int cpu, unsigned int freq); - -void cpufreq_dbs_timer_suspend(void); -void cpufreq_dbs_timer_resume(void); - -#endif /* __XEN_CPUFREQ_PM_H__ */ diff --git a/xen/include/xen/cpufreq.h b/xen/include/xen/cpufreq.h new file mode 100644 index 0000000..ed38a6c --- /dev/null +++ b/xen/include/xen/cpufreq.h @@ -0,0 +1,248 @@ +/* + * xen/include/acpi/cpufreq/cpufreq.h + * + * Copyright (C) 2001 Russell King + * (C) 2002 - 2003 Dominik Brodowski + * + * $Id: cpufreq.h,v 1.36 2003/01/20 17:31:48 db Exp $ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __XEN_CPUFREQ_PM_H__ +#define __XEN_CPUFREQ_PM_H__ + +#include +#include +#include +#include +#include +#include + +#include + +DECLARE_PER_CPU(spinlock_t, cpufreq_statistic_lock); + +extern bool_t cpufreq_verbose; + +struct cpufreq_governor; + +struct acpi_cpufreq_data { + struct processor_performance *acpi_data; + struct cpufreq_frequency_table *freq_table; + unsigned int arch_cpu_flags; +}; + +extern struct acpi_cpufreq_data *cpufreq_drv_data[NR_CPUS]; + +struct cpufreq_cpuinfo { + unsigned int max_freq; + unsigned int second_max_freq; /* P1 if Turbo Mode is on */ + unsigned int min_freq; + unsigned int transition_latency; /* in 10^(-9) s = nanoseconds */ +}; + +struct perf_limits { + bool_t no_turbo; + bool_t turbo_disabled; + uint32_t turbo_pct; + uint32_t max_perf_pct; /* max performance in percentage */ + uint32_t min_perf_pct; /* min performance in percentage */ + uint32_t max_perf; + uint32_t min_perf; + uint32_t max_policy_pct; + uint32_t min_policy_pct; +}; + +struct cpufreq_policy { + cpumask_var_t cpus; /* affected CPUs */ + unsigned int shared_type; /* ANY or ALL affected CPUs + should set cpufreq */ + unsigned int cpu; /* cpu nr of registered CPU */ + struct cpufreq_cpuinfo cpuinfo; + + unsigned int min; /* in kHz */ + unsigned int max; /* in kHz */ + unsigned int cur; /* in kHz, only needed if cpufreq + * governors are used */ + struct perf_limits limits; + struct cpufreq_governor *governor; + + bool_t resume; /* flag for cpufreq 1st run + * S3 wakeup, hotplug cpu, etc */ + 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 */ +}; +DECLARE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_policy); + +extern int __cpufreq_set_policy(struct cpufreq_policy *data, + struct cpufreq_policy *policy); + +#define CPUFREQ_SHARED_TYPE_NONE (0) /* None */ +#define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */ +#define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */ +#define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/ + +/******************** cpufreq transition notifiers *******************/ + +struct cpufreq_freqs { + unsigned int cpu; /* cpu nr */ + unsigned int old; + unsigned int new; + u8 flags; /* flags of cpufreq_driver, see below. */ +}; + + +/********************************************************************* + * CPUFREQ GOVERNORS * + *********************************************************************/ + +#define CPUFREQ_GOV_START 1 +#define CPUFREQ_GOV_STOP 2 +#define CPUFREQ_GOV_LIMITS 3 + +struct cpufreq_governor { + char name[CPUFREQ_NAME_LEN]; + int (*governor)(struct cpufreq_policy *policy, + unsigned int event); + bool_t (*handle_option)(const char *name, const char *value); + struct list_head governor_list; +}; + +extern struct cpufreq_governor *cpufreq_opt_governor; +extern struct cpufreq_governor cpufreq_gov_dbs; +extern struct cpufreq_governor cpufreq_gov_userspace; +extern struct cpufreq_governor cpufreq_gov_performance; +extern struct cpufreq_governor cpufreq_gov_powersave; + +extern struct list_head cpufreq_governor_list; + +extern int cpufreq_register_governor(struct cpufreq_governor *governor); +extern struct cpufreq_governor *__find_governor(const char *governor); +#define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_dbs + +/* pass a target to the cpufreq driver */ +extern int __cpufreq_driver_target(struct cpufreq_policy *policy, + unsigned int target_freq, + unsigned int relation); + +#define GOV_GETAVG 1 +#define USR_GETAVG 2 +extern int cpufreq_driver_getavg(unsigned int cpu, unsigned int flag); + +#define CPUFREQ_TURBO_DISABLED -1 +#define CPUFREQ_TURBO_UNSUPPORTED 0 +#define CPUFREQ_TURBO_ENABLED 1 + +extern int cpufreq_update_turbo(int cpuid, int new_state); +extern int cpufreq_get_turbo_status(int cpuid); + +static __inline__ int +__cpufreq_governor(struct cpufreq_policy *policy, unsigned int event) +{ + return policy->governor->governor(policy, event); +} + + +/********************************************************************* + * CPUFREQ DRIVER INTERFACE * + *********************************************************************/ + +#define CPUFREQ_RELATION_L 0 /* lowest frequency at or above target */ +#define CPUFREQ_RELATION_H 1 /* highest frequency below or at target */ + +struct cpufreq_driver { + char name[CPUFREQ_NAME_LEN]; + int (*init)(struct cpufreq_policy *policy); + int (*verify)(struct cpufreq_policy *policy); + int (*setpolicy)(struct cpufreq_policy *policy); + int (*update)(int cpuid, struct cpufreq_policy *policy); + int (*target)(struct cpufreq_policy *policy, + unsigned int target_freq, + unsigned int relation); + unsigned int (*get)(unsigned int cpu); + unsigned int (*getavg)(unsigned int cpu, unsigned int flag); + int (*exit)(struct cpufreq_policy *policy); +}; + +extern struct cpufreq_driver *cpufreq_driver; + +int cpufreq_register_driver(struct cpufreq_driver *); + +static __inline__ +void cpufreq_verify_within_limits(struct cpufreq_policy *policy, + unsigned int min, unsigned int max) +{ + if (policy->min < min) + policy->min = min; + if (policy->max < min) + policy->max = min; + if (policy->min > max) + policy->min = max; + if (policy->max > max) + policy->max = max; + if (policy->min > policy->max) + policy->min = policy->max; + return; +} + + +/********************************************************************* + * FREQUENCY TABLE HELPERS * + *********************************************************************/ + +#define CPUFREQ_ENTRY_INVALID ~0 +#define CPUFREQ_TABLE_END ~1 + +struct cpufreq_frequency_table { + unsigned int index; /* any */ + unsigned int frequency; /* kHz - doesn't need to be in ascending + * order */ +}; + +int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, + struct cpufreq_frequency_table *table); + +int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, + struct cpufreq_frequency_table *table); + +int cpufreq_frequency_table_target(struct cpufreq_policy *policy, + struct cpufreq_frequency_table *table, + unsigned int target_freq, + unsigned int relation, + unsigned int *index); + + +/********************************************************************* + * UNIFIED DEBUG HELPERS * + *********************************************************************/ + +struct cpu_dbs_info_s { + uint64_t prev_cpu_idle; + uint64_t prev_cpu_wall; + struct cpufreq_policy *cur_policy; + struct cpufreq_frequency_table *freq_table; + int cpu; + unsigned int enable:1; + unsigned int stoppable:1; + unsigned int turbo_enabled:1; +}; + +int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event); +int get_cpufreq_ondemand_para(uint32_t *sampling_rate_max, + uint32_t *sampling_rate_min, + uint32_t *sampling_rate, + uint32_t *up_threshold); +int write_ondemand_sampling_rate(unsigned int sampling_rate); +int write_ondemand_up_threshold(unsigned int up_threshold); + +int write_userspace_scaling_setspeed(unsigned int cpu, unsigned int freq); + +void cpufreq_dbs_timer_suspend(void); +void cpufreq_dbs_timer_resume(void); + +#endif /* __XEN_CPUFREQ_PM_H__ */