ACPI / CPPC: Add a helper to get desired performance
authorXiongfeng Wang <wangxiongfeng2@huawei.com>
Sun, 17 Feb 2019 03:54:14 +0000 (11:54 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 18 Feb 2019 10:27:42 +0000 (11:27 +0100)
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>
drivers/acpi/cppc_acpi.c
include/acpi/cppc_acpi.h

index 217a782c3e552783a2acf3b072dd18648f7c6e89..1b207fca1420bbc5c40469e1b3558cb38a57c450 100644 (file)
@@ -1050,6 +1050,48 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
        return ret_val;
 }
 
+/**
+ * cppc_get_desired_perf - Get the value of desired performance register.
+ * @cpunum: CPU from which to get desired performance.
+ * @desired_perf: address of a variable to store the returned desired performance
+ *
+ * Return: 0 for success, -EIO otherwise.
+ */
+int cppc_get_desired_perf(int cpunum, u64 *desired_perf)
+{
+       struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum);
+       int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum);
+       struct cpc_register_resource *desired_reg;
+       struct cppc_pcc_data *pcc_ss_data = NULL;
+
+       desired_reg = &cpc_desc->cpc_regs[DESIRED_PERF];
+
+       if (CPC_IN_PCC(desired_reg)) {
+               int ret = 0;
+
+               if (pcc_ss_id < 0)
+                       return -EIO;
+
+               pcc_ss_data = pcc_data[pcc_ss_id];
+
+               down_write(&pcc_ss_data->pcc_lock);
+
+               if (send_pcc_cmd(pcc_ss_id, CMD_READ) >= 0)
+                       cpc_read(cpunum, desired_reg, desired_perf);
+               else
+                       ret = -EIO;
+
+               up_write(&pcc_ss_data->pcc_lock);
+
+               return ret;
+       }
+
+       cpc_read(cpunum, desired_reg, desired_perf);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(cppc_get_desired_perf);
+
 /**
  * cppc_get_perf_caps - Get a CPUs performance capabilities.
  * @cpunum: CPU from which to get capabilities info.
index 4f34734e7f3616bb5e07a77a4c8573ff6e155b42..ba6fd7202775e4c3d2b221c9eaf0675e69cc3929 100644 (file)
@@ -137,6 +137,7 @@ struct cppc_cpudata {
        cpumask_var_t shared_cpu_map;
 };
 
+extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf);
 extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs);
 extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls);
 extern int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps);