aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/cppc_acpi.c
diff options
context:
space:
mode:
authorXiongfeng Wang <wangxiongfeng2@huawei.com>2019-02-16 22:54:14 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2019-02-18 05:27:42 -0500
commit1757d05f3112acc5c0cdbcccad3afdee99655bf9 (patch)
tree6fee7b7291a0f0191a1e0b54da6e80eaeaad46be /drivers/acpi/cppc_acpi.c
parenta9a22b570bd512eb1ed946042bb88f11ecccca0c (diff)
ACPI / CPPC: Add a helper to get desired performance
This patch add a helper to get the value of desired performance register. Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com> [ rjw: More white space ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/cppc_acpi.c')
-rw-r--r--drivers/acpi/cppc_acpi.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index 217a782c3e55..1b207fca1420 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -1051,6 +1051,48 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
1051} 1051}
1052 1052
1053/** 1053/**
1054 * cppc_get_desired_perf - Get the value of desired performance register.
1055 * @cpunum: CPU from which to get desired performance.
1056 * @desired_perf: address of a variable to store the returned desired performance
1057 *
1058 * Return: 0 for success, -EIO otherwise.
1059 */
1060int cppc_get_desired_perf(int cpunum, u64 *desired_perf)
1061{
1062 struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum);
1063 int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum);
1064 struct cpc_register_resource *desired_reg;
1065 struct cppc_pcc_data *pcc_ss_data = NULL;
1066
1067 desired_reg = &cpc_desc->cpc_regs[DESIRED_PERF];
1068
1069 if (CPC_IN_PCC(desired_reg)) {
1070 int ret = 0;
1071
1072 if (pcc_ss_id < 0)
1073 return -EIO;
1074
1075 pcc_ss_data = pcc_data[pcc_ss_id];
1076
1077 down_write(&pcc_ss_data->pcc_lock);
1078
1079 if (send_pcc_cmd(pcc_ss_id, CMD_READ) >= 0)
1080 cpc_read(cpunum, desired_reg, desired_perf);
1081 else
1082 ret = -EIO;
1083
1084 up_write(&pcc_ss_data->pcc_lock);
1085
1086 return ret;
1087 }
1088
1089 cpc_read(cpunum, desired_reg, desired_perf);
1090
1091 return 0;
1092}
1093EXPORT_SYMBOL_GPL(cppc_get_desired_perf);
1094
1095/**
1054 * cppc_get_perf_caps - Get a CPUs performance capabilities. 1096 * cppc_get_perf_caps - Get a CPUs performance capabilities.
1055 * @cpunum: CPU from which to get capabilities info. 1097 * @cpunum: CPU from which to get capabilities info.
1056 * @perf_caps: ptr to cppc_perf_caps. See cppc_acpi.h 1098 * @perf_caps: ptr to cppc_perf_caps. See cppc_acpi.h