diff options
author | mbroyles <mbroyles@us.ibm.com> | 2018-01-30 15:35:23 -0600 |
---|---|---|
committer | Martha Broyles <mbroyles@us.ibm.com> | 2018-01-31 17:06:49 -0500 |
commit | c9954444fc8df5fa0bd79b57ce8a6434a7e0714e (patch) | |
tree | 20591093021552a9b7341e6e760500ffe6324626 /src/occ_405/proc | |
parent | f72f857b7e5ab25a5616b1655005b963405eb350 (diff) | |
download | talos-occ-c9954444fc8df5fa0bd79b57ce8a6434a7e0714e.tar.gz talos-occ-c9954444fc8df5fa0bd79b57ce8a6434a7e0714e.zip |
Calculate Pstate from a frequency starting at max frequency instead of min
Change-Id: Ic5c59d9a633a0c278b2dc20e3a04cefc13bd63dc
CQ: SW415606
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/52948
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Andres A. Lugo-Reyes <aalugore@us.ibm.com>
Reviewed-by: William A. Bryan <wilbryan@us.ibm.com>
Reviewed-by: Christopher J. Cain <cjcain@us.ibm.com>
Reviewed-by: Martha Broyles <mbroyles@us.ibm.com>
Diffstat (limited to 'src/occ_405/proc')
-rwxr-xr-x | src/occ_405/proc/proc_pstate.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/src/occ_405/proc/proc_pstate.c b/src/occ_405/proc/proc_pstate.c index 6d68863..12e3ac1 100755 --- a/src/occ_405/proc/proc_pstate.c +++ b/src/occ_405/proc/proc_pstate.c @@ -123,7 +123,7 @@ Pstate proc_freq2pstate(uint32_t i_freq_mhz) { int8_t l_pstate = 0; int8_t l_temp_pstate = 0; - int32_t l_temp_freq = 0; + int32_t l_temp_freq_khz = 0; uint32_t l_freq_khz = 0; do @@ -131,28 +131,42 @@ Pstate proc_freq2pstate(uint32_t i_freq_mhz) // Freq Units need to be in kHz, not Mhz for the following calculations l_freq_khz = i_freq_mhz * 1000; - // Make sure that we don't ever get a frequency below the min Freq from - // def file + // Return Pmin if the frequency is below or equal to the min Freq for the lowest Pstate + if(l_freq_khz <= G_oppb.frequency_min_khz ) + { + l_pstate = G_oppb.pstate_min; + break; + } + if(i_freq_mhz < G_sysConfigData.sys_mode_freq.table[OCC_MODE_MIN_FREQUENCY]) { l_freq_khz = G_sysConfigData.sys_mode_freq.table[OCC_MODE_MIN_FREQUENCY] * 1000; } - if(l_freq_khz < G_proc_fmax_mhz * 1000) + if(l_freq_khz < G_oppb.frequency_max_khz) { - // First, calculate the delta between passed in freq, and Pmin - l_temp_freq = l_freq_khz - G_oppb.frequency_min_khz; + // First, calculate the delta between passed in freq, and Pmax + l_temp_freq_khz = G_oppb.frequency_max_khz - l_freq_khz; // Next, calculate how many Pstate steps there are in that delta - l_temp_pstate = l_temp_freq / (int32_t) G_oppb.frequency_step_khz; + l_temp_pstate = l_temp_freq_khz / (int32_t) G_oppb.frequency_step_khz; - // Lastly, calculate Pstate, by adding delta Pstate steps to Pmin - l_pstate = G_oppb.pstate_min - l_temp_pstate; + // Higher Pstates are lower frequency, add number of steps to the highest frequency Pstate + l_pstate = PMAX + l_temp_pstate; + + // As an extra safety check make sure the calculated Pstate is not out of the PGPE range + // this should never happen! + if(l_pstate > G_oppb.pstate_min) + { + TRAC_ERR("proc_freq2pstate: Invalid calculated Pstate[%d] for freq[%dkHz] PGPE min Pstate[%d] freq[%dkHz]", + l_pstate, l_freq_khz, G_oppb.pstate_min, G_oppb.frequency_min_khz); + l_pstate = G_oppb.pstate_min; + } } else { - // Freq is higher than maximum frequency -- return Pmax - l_pstate = PMAX + (G_oppb.frequency_max_khz - G_proc_fmax_mhz*1000)/G_oppb.frequency_step_khz; + // Freq is higher than or equal to the maximum frequency -- return Pmax + l_pstate = PMAX; } } while(0); |