[Skiboot] [PATCH 2/2] occ: Filter out entries from Pmin to Pmax in Pstate table

Shilpasri G Bhat shilpa.bhat at linux.vnet.ibm.com
Wed Nov 4 17:10:03 AEDT 2015


Parse the entire pstate table provided by OCC and filter out the
entries that are outside the Pmax and Pmin limits.

Signed-off-by: Shilpasri G Bhat <shilpa.bhat at linux.vnet.ibm.com>
---
 hw/occ.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/hw/occ.c b/hw/occ.c
index 783add9..c805bb7 100644
--- a/hw/occ.c
+++ b/hw/occ.c
@@ -143,7 +143,7 @@ static bool add_cpu_pstate_properties(s8 *pstate_nom)
 	u8 *dt_vdd, *dt_vcs, ultra_turbo_en = 0;
 	s8 pmax;
 	bool rc;
-	int i;
+	int i, j;
 
 	prlog(PR_DEBUG, "OCC: CPU pstate state device tree init\n");
 
@@ -239,11 +239,15 @@ next:	nr_pstates = pmax - occ_data->pstate_min + 1;
 		dt_core_max[i] = occ_data->core_max[i];
 
 populate:
-	for( i=0; i < nr_pstates; i++) {
-		dt_id[i] = occ_data->pstates[i].id;
-		dt_freq[i] = occ_data->pstates[i].freq_khz/1000;
-		dt_vdd[i] = occ_data->pstates[i].vdd;
-		dt_vcs[i] = occ_data->pstates[i].vcs;
+	for (i = 0, j = 0; i < MAX_PSTATES && j < nr_pstates; i++) {
+		if (occ_data->pstates[i].id > pmax ||
+		    occ_data->pstates[i].id < occ_data->pstate_min)
+			continue;
+		dt_id[j] = occ_data->pstates[i].id;
+		dt_freq[j] = occ_data->pstates[i].freq_khz/1000;
+		dt_vdd[j] = occ_data->pstates[i].vdd;
+		dt_vcs[j] = occ_data->pstates[i].vcs;
+		j++;
 	}
 
 	/* Add the device-tree entries */
-- 
1.9.3



More information about the Skiboot mailing list