|
@@ -1075,15 +1075,14 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
|
|
*low_freq_reg = NULL, *nom_freq_reg = NULL;
|
|
*low_freq_reg = NULL, *nom_freq_reg = NULL;
|
|
u64 high, low, nom, min_nonlinear, low_f = 0, nom_f = 0;
|
|
u64 high, low, nom, min_nonlinear, low_f = 0, nom_f = 0;
|
|
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum);
|
|
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum);
|
|
- struct cppc_pcc_data *pcc_ss_data;
|
|
|
|
|
|
+ struct cppc_pcc_data *pcc_ss_data = NULL;
|
|
int ret = 0, regs_in_pcc = 0;
|
|
int ret = 0, regs_in_pcc = 0;
|
|
|
|
|
|
- if (!cpc_desc || pcc_ss_id < 0) {
|
|
|
|
|
|
+ if (!cpc_desc) {
|
|
pr_debug("No CPC descriptor for CPU:%d\n", cpunum);
|
|
pr_debug("No CPC descriptor for CPU:%d\n", cpunum);
|
|
return -ENODEV;
|
|
return -ENODEV;
|
|
}
|
|
}
|
|
|
|
|
|
- pcc_ss_data = pcc_data[pcc_ss_id];
|
|
|
|
highest_reg = &cpc_desc->cpc_regs[HIGHEST_PERF];
|
|
highest_reg = &cpc_desc->cpc_regs[HIGHEST_PERF];
|
|
lowest_reg = &cpc_desc->cpc_regs[LOWEST_PERF];
|
|
lowest_reg = &cpc_desc->cpc_regs[LOWEST_PERF];
|
|
lowest_non_linear_reg = &cpc_desc->cpc_regs[LOW_NON_LINEAR_PERF];
|
|
lowest_non_linear_reg = &cpc_desc->cpc_regs[LOW_NON_LINEAR_PERF];
|
|
@@ -1095,6 +1094,11 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
|
|
if (CPC_IN_PCC(highest_reg) || CPC_IN_PCC(lowest_reg) ||
|
|
if (CPC_IN_PCC(highest_reg) || CPC_IN_PCC(lowest_reg) ||
|
|
CPC_IN_PCC(lowest_non_linear_reg) || CPC_IN_PCC(nominal_reg) ||
|
|
CPC_IN_PCC(lowest_non_linear_reg) || CPC_IN_PCC(nominal_reg) ||
|
|
CPC_IN_PCC(low_freq_reg) || CPC_IN_PCC(nom_freq_reg)) {
|
|
CPC_IN_PCC(low_freq_reg) || CPC_IN_PCC(nom_freq_reg)) {
|
|
|
|
+ if (pcc_ss_id < 0) {
|
|
|
|
+ pr_debug("Invalid pcc_ss_id\n");
|
|
|
|
+ return -ENODEV;
|
|
|
|
+ }
|
|
|
|
+ pcc_ss_data = pcc_data[pcc_ss_id];
|
|
regs_in_pcc = 1;
|
|
regs_in_pcc = 1;
|
|
down_write(&pcc_ss_data->pcc_lock);
|
|
down_write(&pcc_ss_data->pcc_lock);
|
|
/* Ring doorbell once to update PCC subspace */
|
|
/* Ring doorbell once to update PCC subspace */
|
|
@@ -1150,16 +1154,15 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
|
|
struct cpc_register_resource *delivered_reg, *reference_reg,
|
|
struct cpc_register_resource *delivered_reg, *reference_reg,
|
|
*ref_perf_reg, *ctr_wrap_reg;
|
|
*ref_perf_reg, *ctr_wrap_reg;
|
|
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum);
|
|
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum);
|
|
- struct cppc_pcc_data *pcc_ss_data;
|
|
|
|
|
|
+ struct cppc_pcc_data *pcc_ss_data = NULL;
|
|
u64 delivered, reference, ref_perf, ctr_wrap_time;
|
|
u64 delivered, reference, ref_perf, ctr_wrap_time;
|
|
int ret = 0, regs_in_pcc = 0;
|
|
int ret = 0, regs_in_pcc = 0;
|
|
|
|
|
|
- if (!cpc_desc || pcc_ss_id < 0) {
|
|
|
|
|
|
+ if (!cpc_desc) {
|
|
pr_debug("No CPC descriptor for CPU:%d\n", cpunum);
|
|
pr_debug("No CPC descriptor for CPU:%d\n", cpunum);
|
|
return -ENODEV;
|
|
return -ENODEV;
|
|
}
|
|
}
|
|
|
|
|
|
- pcc_ss_data = pcc_data[pcc_ss_id];
|
|
|
|
delivered_reg = &cpc_desc->cpc_regs[DELIVERED_CTR];
|
|
delivered_reg = &cpc_desc->cpc_regs[DELIVERED_CTR];
|
|
reference_reg = &cpc_desc->cpc_regs[REFERENCE_CTR];
|
|
reference_reg = &cpc_desc->cpc_regs[REFERENCE_CTR];
|
|
ref_perf_reg = &cpc_desc->cpc_regs[REFERENCE_PERF];
|
|
ref_perf_reg = &cpc_desc->cpc_regs[REFERENCE_PERF];
|
|
@@ -1175,6 +1178,11 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
|
|
/* Are any of the regs PCC ?*/
|
|
/* Are any of the regs PCC ?*/
|
|
if (CPC_IN_PCC(delivered_reg) || CPC_IN_PCC(reference_reg) ||
|
|
if (CPC_IN_PCC(delivered_reg) || CPC_IN_PCC(reference_reg) ||
|
|
CPC_IN_PCC(ctr_wrap_reg) || CPC_IN_PCC(ref_perf_reg)) {
|
|
CPC_IN_PCC(ctr_wrap_reg) || CPC_IN_PCC(ref_perf_reg)) {
|
|
|
|
+ if (pcc_ss_id < 0) {
|
|
|
|
+ pr_debug("Invalid pcc_ss_id\n");
|
|
|
|
+ return -ENODEV;
|
|
|
|
+ }
|
|
|
|
+ pcc_ss_data = pcc_data[pcc_ss_id];
|
|
down_write(&pcc_ss_data->pcc_lock);
|
|
down_write(&pcc_ss_data->pcc_lock);
|
|
regs_in_pcc = 1;
|
|
regs_in_pcc = 1;
|
|
/* Ring doorbell once to update PCC subspace */
|
|
/* Ring doorbell once to update PCC subspace */
|
|
@@ -1225,15 +1233,14 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls)
|
|
struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpu);
|
|
struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpu);
|
|
struct cpc_register_resource *desired_reg;
|
|
struct cpc_register_resource *desired_reg;
|
|
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu);
|
|
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu);
|
|
- struct cppc_pcc_data *pcc_ss_data;
|
|
|
|
|
|
+ struct cppc_pcc_data *pcc_ss_data = NULL;
|
|
int ret = 0;
|
|
int ret = 0;
|
|
|
|
|
|
- if (!cpc_desc || pcc_ss_id < 0) {
|
|
|
|
|
|
+ if (!cpc_desc) {
|
|
pr_debug("No CPC descriptor for CPU:%d\n", cpu);
|
|
pr_debug("No CPC descriptor for CPU:%d\n", cpu);
|
|
return -ENODEV;
|
|
return -ENODEV;
|
|
}
|
|
}
|
|
|
|
|
|
- pcc_ss_data = pcc_data[pcc_ss_id];
|
|
|
|
desired_reg = &cpc_desc->cpc_regs[DESIRED_PERF];
|
|
desired_reg = &cpc_desc->cpc_regs[DESIRED_PERF];
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -1244,6 +1251,11 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls)
|
|
* achieve that goal here
|
|
* achieve that goal here
|
|
*/
|
|
*/
|
|
if (CPC_IN_PCC(desired_reg)) {
|
|
if (CPC_IN_PCC(desired_reg)) {
|
|
|
|
+ if (pcc_ss_id < 0) {
|
|
|
|
+ pr_debug("Invalid pcc_ss_id\n");
|
|
|
|
+ return -ENODEV;
|
|
|
|
+ }
|
|
|
|
+ pcc_ss_data = pcc_data[pcc_ss_id];
|
|
down_read(&pcc_ss_data->pcc_lock); /* BEGIN Phase-I */
|
|
down_read(&pcc_ss_data->pcc_lock); /* BEGIN Phase-I */
|
|
if (pcc_ss_data->platform_owns_pcc) {
|
|
if (pcc_ss_data->platform_owns_pcc) {
|
|
ret = check_pcc_chan(pcc_ss_id, false);
|
|
ret = check_pcc_chan(pcc_ss_id, false);
|