Skip to content

Commit

Permalink
PSTATE: System Calc Parameters Fix
Browse files Browse the repository at this point in the history
    - Adds PStateVSlopes and VPStateSlopes to Global Parm Struct
    - Calculates slopes for RAW/SYSP/BIASED/SYSP_BIASED Operating Pts
    - Leaves the old slopes and calculation in
      p9_pstate_parameter_block.C using slope shift of 13. To be removed later
    - Adds a new slopes format of 4.12[4 bits integer + 12 bit
      fractional
    - Recovers the lost system parameter equation fix

Change-Id: Ic79ed4d0311c46612d68d6dffdabc459ec88d8e1
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/40891
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Reviewed-by: Juan R. Medina <jrmedina@us.ibm.com>
Reviewed-by: RANGANATHPRASAD G. BRAHMASAMUDRA <prasadbgr@in.ibm.com>
Reviewed-by: Gregory S. Still <stillgs@us.ibm.com>
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/40996
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
  • Loading branch information
rbatraAustinIBM authored and crgeddes committed Jun 1, 2017
1 parent 2309514 commit 1551812
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 23 deletions.
18 changes: 12 additions & 6 deletions src/import/chips/p9/procedures/hwp/lib/p9_pstates_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,18 @@
#define VPD_PV_VDN_MV 1
#define VPD_PV_IDN_100MA 2

#define VPD_NUM_SLOPES_SET 2
#define VPD_SLOPES_RAW 0
#define VPD_SLOPES_BIASED 1
//Remove this. RTC: 174743
#define VPD_NUM_SLOPES_SET 2
#define VPD_SLOPES_RAW 0
#define VPD_SLOPES_BIASED 1
//Remove until here. RTC: 174743

#define VPD_NUM_SLOPES_REGION 3
#define REGION_POWERSAVE_NOMINAL 0
#define REGION_NOMINAL_TURBO 1
#define REGION_TURBO_ULTRA 2
#define VPD_OP_SLOPES_REGION_ORDER {REGION_POWERSAVE_NOMINAL,REGION_NOMINAL_TURBO,REGION_TURBO_ULTRA}
#define VPD_OP_SLOPES_REGION_ORDER_STR {"POWERSAVE_NOMINAL", "NOMINAL_TURBO ","TURBO_ULTRA "}

// Different points considered for calculating slopes
#define NUM_VPD_PTS_SET 4
Expand All @@ -133,13 +138,14 @@
#define VPD_PT_SET_BIASED 2
#define VPD_PT_SET_BIASED_SYSP 3
#define VPD_PT_SET_ORDER {VPD_PT_SET_RAW, VPD_PT_SET_SYSP, VPD_PT_SET_BIASED, VPD_PT_SET_BIASED_SYSP}
#define VPD_PT_SET_ORDER_STR {"Raw ", "SysParam ","Biased ", "Biased/SysParam"}
#define VPD_PT_SET_ORDER_STR {"Raw", "SysParam","Biased", "Biased/SysParam"}

#define VID_SLOPE_FP_SHIFT 13
#define VID_SLOPE_FP_SHIFT 13 //TODO: Remove this. RTC 174743
#define VID_SLOPE_FP_SHIFT_12 12
#define THRESH_SLOPE_FP_SHIFT 12

// 0 = PowerSave, 1 = Nominal; 2 = Turbo; 3 = UltraTurbo; 4 = Enable
#define VDM_DROOP_OP_POINTS 5
#define VDM_DROOP_OP_POINTS 5



Expand Down
10 changes: 10 additions & 0 deletions src/import/chips/p9/procedures/hwp/lib/p9_pstates_pgpe.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ typedef struct
/// VPD operating points are stored without load-line correction. Frequencies
/// are in MHz, voltages are specified in units of 5mV, and currents are
/// in units of 500mA.
/// \todo Remove this. RTC: 174743
VpdOperatingPoint operating_points[NUM_OP_POINTS];

/// Biases
Expand Down Expand Up @@ -260,9 +261,11 @@ typedef struct
uint32_t nest_frequency_mhz;

/// Precalculated Pstate-Voltage Slopes
/// \todo Remove this. RTC: 174743
uint16_t PsVSlopes[VPD_NUM_SLOPES_SET][VPD_NUM_SLOPES_REGION];

/// Precalculated Voltage-Pstates Slopes
/// \todo Remove this. RTC: 174743
uint16_t VPsSlopes[VPD_NUM_SLOPES_SET][VPD_NUM_SLOPES_REGION];

/// All operating points
Expand All @@ -271,6 +274,13 @@ typedef struct
//DPLL pstate 0 value
uint32_t dpll_pstate0_value;

/// Precalculated Pstate-Voltage Slopes
uint16_t PStateVSlopes[NUM_VPD_PTS_SET][VPD_NUM_SLOPES_REGION];

/// Precalculated Voltage-Pstates Slopes
uint16_t VPStateSlopes[NUM_VPD_PTS_SET][VPD_NUM_SLOPES_REGION];


// @todo DPLL Droop Settings. These need communication to SGPE for STOP

} GlobalPstateParmBlock;
Expand Down
124 changes: 107 additions & 17 deletions src/import/chips/p9/procedures/hwp/pm/p9_pstate_parameter_block.C
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,12 @@ p9_pstate_parameter_block( const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_
memcpy(l_globalppb.operating_points_set, l_operating_points, sizeof(l_operating_points));

// Calculate pre-calculated slopes
p9_pstate_compute_PsV_slopes(l_operating_points, &l_globalppb);
p9_pstate_compute_PsV_slopes(l_operating_points, &l_globalppb); //Remote this RTC: 174743

p9_pstate_compute_PStateV_slope(VPD_PT_SET_RAW, l_operating_points, &l_globalppb);
p9_pstate_compute_PStateV_slope(VPD_PT_SET_SYSP, l_operating_points, &l_globalppb);
p9_pstate_compute_PStateV_slope(VPD_PT_SET_BIASED, l_operating_points, &l_globalppb);
p9_pstate_compute_PStateV_slope(VPD_PT_SET_BIASED_SYSP, l_operating_points, &l_globalppb);

l_globalppb.dpll_pstate0_value = revle32((revle32(l_globalppb.reference_frequency_khz) + revle32(
l_globalppb.frequency_step_khz) - 1) / revle32(
Expand Down Expand Up @@ -1688,15 +1693,15 @@ void p9_pstate_compute_vpd_pts(VpdOperatingPoint (*o_operating_points)[NUM_OP_PO
for (p = 0; p < NUM_OP_POINTS; p++)
{
o_operating_points[VPD_PT_SET_SYSP][p].vdd_mv =
revle32((revle32(i_gppb->operating_points[p].vdd_mv) * 1000 +
(revle32(i_gppb->operating_points[p].idd_100ma) * 100 * revle32(i_gppb->vdd_sysparm.loadline_uohm +
i_gppb->vdd_sysparm.distloss_uohm)) / 1000 +
revle32(i_gppb->vdd_sysparm.distoffset_uv)) / 1000) ;
revle32(revle32(i_gppb->operating_points[p].vdd_mv) +
(((revle32(i_gppb->operating_points[p].idd_100ma) * 100) *
(revle32(i_gppb->vdd_sysparm.loadline_uohm) + revle32(i_gppb->vdd_sysparm.distloss_uohm))) / 1000 +
(revle32(i_gppb->vdd_sysparm.distoffset_uv))) / 1000) ;
o_operating_points[VPD_PT_SET_SYSP][p].vcs_mv =
revle32( (revle32(i_gppb->operating_points[p].vcs_mv) * 1000 +
(revle32(i_gppb->operating_points[p].ics_100ma) * 100 * (i_gppb->vcs_sysparm.loadline_uohm +
i_gppb->vcs_sysparm.distloss_uohm) / 1000) +
(i_gppb->vcs_sysparm.distoffset_uv)) / 1000) ;
revle32(revle32(i_gppb->operating_points[p].vcs_mv) +
(((revle32(i_gppb->operating_points[p].ics_100ma) * 100) *
(revle32(i_gppb->vcs_sysparm.loadline_uohm) + revle32(i_gppb->vcs_sysparm.distloss_uohm))) / 1000 +
(revle32(i_gppb->vcs_sysparm.distoffset_uv))) / 1000) ;
o_operating_points[VPD_PT_SET_SYSP][p].idd_100ma = (i_gppb->operating_points[p].idd_100ma);
o_operating_points[VPD_PT_SET_SYSP][p].ics_100ma = (i_gppb->operating_points[p].ics_100ma);
o_operating_points[VPD_PT_SET_SYSP][p].frequency_mhz = (i_gppb->operating_points[p].frequency_mhz);
Expand Down Expand Up @@ -1745,14 +1750,14 @@ void p9_pstate_compute_vpd_pts(VpdOperatingPoint (*o_operating_points)[NUM_OP_PO
for (p = 0; p < NUM_OP_POINTS; p++)
{
o_operating_points[VPD_PT_SET_BIASED_SYSP][p].vdd_mv =
revle32(((revle32(o_operating_points[VPD_PT_SET_BIASED][p].vdd_mv) * 1000) +
((revle32(o_operating_points[VPD_PT_SET_BIASED][p].idd_100ma) * 100) *
(revle32(i_gppb->vdd_sysparm.loadline_uohm + i_gppb->vdd_sysparm.distloss_uohm))) / 1000 +
(revle32(i_gppb->vdd_sysparm.distoffset_uv))) / 1000 );
revle32(revle32(o_operating_points[VPD_PT_SET_BIASED][p].vdd_mv) +
(((revle32(o_operating_points[VPD_PT_SET_BIASED][p].idd_100ma) * 100) *
(revle32(i_gppb->vdd_sysparm.loadline_uohm) + revle32(i_gppb->vdd_sysparm.distloss_uohm))) / 1000 +
(revle32(i_gppb->vdd_sysparm.distoffset_uv))) / 1000);
o_operating_points[VPD_PT_SET_BIASED_SYSP][p].vcs_mv =
revle32(((revle32(o_operating_points[VPD_PT_SET_BIASED][p].vcs_mv) * 1000) +
((revle32(o_operating_points[VPD_PT_SET_BIASED][p].ics_100ma) * 100) *
(revle32(i_gppb->vcs_sysparm.loadline_uohm + i_gppb->vcs_sysparm.distloss_uohm))) / 1000 +
revle32(revle32(o_operating_points[VPD_PT_SET_BIASED][p].vcs_mv) +
(((revle32(o_operating_points[VPD_PT_SET_BIASED][p].ics_100ma) * 100) *
(revle32(i_gppb->vcs_sysparm.loadline_uohm) + revle32(i_gppb->vcs_sysparm.distloss_uohm))) / 1000 +
(revle32(i_gppb->vcs_sysparm.distoffset_uv))) / 1000 );
o_operating_points[VPD_PT_SET_BIASED_SYSP][p].idd_100ma =
(o_operating_points[VPD_PT_SET_BIASED][p].idd_100ma);
Expand Down Expand Up @@ -1788,6 +1793,7 @@ void p9_pstate_compute_vpd_pts(VpdOperatingPoint (*o_operating_points)[NUM_OP_PO
//Inflection Point 1 is NOMINAL
//Inflection Point 0 is POWERSAVE
//
//\todo: Remove this. RTC: 174743
void p9_pstate_compute_PsV_slopes(VpdOperatingPoint i_operating_points[][4],
GlobalPstateParmBlock* o_gppb)
{
Expand Down Expand Up @@ -1967,6 +1973,90 @@ void p9_pstate_compute_PsV_slopes(VpdOperatingPoint i_operating_points[][4],
while(0);
}

//This fills up the PStateVSlopes and VPStatesSlopes in GlobalParmBlock
//Going forward this method should be retained in favor of the p9_pstate_compute_PsVSlopes
void p9_pstate_compute_PStateV_slope(uint32_t pt_set, VpdOperatingPoint i_operating_points[][4],
GlobalPstateParmBlock* o_gppb)
{

uint32_t tmp;
uint32_t eVidFP[NUM_OP_POINTS];
char const* vpdSetStr[NUM_VPD_PTS_SET] = VPD_PT_SET_ORDER_STR;

//convert to a fixed-point number
eVidFP[POWERSAVE] = revle32(revle32(i_operating_points[pt_set][POWERSAVE].vdd_mv) << VID_SLOPE_FP_SHIFT_12);
eVidFP[NOMINAL] = revle32(revle32(i_operating_points[pt_set][NOMINAL].vdd_mv) << VID_SLOPE_FP_SHIFT_12);
eVidFP[TURBO] = revle32(revle32(i_operating_points[pt_set][TURBO].vdd_mv) << VID_SLOPE_FP_SHIFT_12);
eVidFP[ULTRA] = revle32(revle32(i_operating_points[pt_set][ULTRA].vdd_mv) << VID_SLOPE_FP_SHIFT_12);

FAPI_INF("eVidFP[POWERSAVE] %x %04x", revle32(eVidFP[POWERSAVE]),
revle32(i_operating_points[pt_set][POWERSAVE].vdd_mv));
FAPI_INF("eVidFP[NOMINAL] %x %04x", revle32(eVidFP[NOMINAL]), revle32(i_operating_points[pt_set][NOMINAL].vdd_mv));
FAPI_INF("eVidFP[TURBO] %x %04x", revle32(eVidFP[TURBO]), revle32(i_operating_points[pt_set][TURBO].vdd_mv));
FAPI_INF("eVidFP[ULTRA] %x %04x", revle32(eVidFP[ULTRA]), revle32(i_operating_points[pt_set][ULTRA].vdd_mv));

// ULTRA TURBO pstate check is not required..because it's pstate will be
// 0
if (!(i_operating_points[pt_set][POWERSAVE].pstate) ||
!(i_operating_points[pt_set][NOMINAL].pstate) ||
!(i_operating_points[pt_set][TURBO].pstate))
{
FAPI_ERR("PSTATE value shouldn't be zero for %s", vpdSetStr[pt_set]);
return;
}

//Calculate slopes
tmp = revle32((revle32(eVidFP[NOMINAL]) - revle32(eVidFP[POWERSAVE])) /
((uint32_t)(-i_operating_points[pt_set][NOMINAL].pstate +
i_operating_points[pt_set][POWERSAVE].pstate)));
o_gppb->PStateVSlopes[pt_set][REGION_POWERSAVE_NOMINAL] = revle16( revle32(tmp));
FAPI_INF("PStateVSlopes[%s][REGION_POWERSAVE_NOMINAL] %X tmp %X ", vpdSetStr[pt_set],
revle16(o_gppb->PStateVSlopes[pt_set][REGION_POWERSAVE_NOMINAL]), revle32(tmp));


tmp = revle32((revle32(eVidFP[TURBO]) - revle32(eVidFP[NOMINAL])) /
((uint32_t)(-i_operating_points[pt_set][TURBO].pstate +
i_operating_points[pt_set][NOMINAL].pstate)));
o_gppb->PStateVSlopes[pt_set][REGION_NOMINAL_TURBO] = revle16( revle32(tmp));
FAPI_INF("PStateVSlopes[%s][REGION_NOMINAL_TURBO] %X tmp %X ", vpdSetStr[pt_set],
revle16(o_gppb->PStateVSlopes[pt_set][REGION_NOMINAL_TURBO]), revle32(tmp));


tmp = revle32((revle32(eVidFP[ULTRA]) - revle32(eVidFP[TURBO])) /
((uint32_t)(-i_operating_points[pt_set][ULTRA].pstate +
i_operating_points[pt_set][TURBO].pstate)));
o_gppb->PStateVSlopes[pt_set][REGION_TURBO_ULTRA] = revle16( revle32(tmp));
FAPI_INF("PStateVSlopes[%s][REGION_TURBO_ULTRA] %X tmp %X ", vpdSetStr[pt_set],
revle16(o_gppb->PStateVSlopes[pt_set][REGION_TURBO_ULTRA]), revle32(tmp));

//Calculate inverted slopes
tmp = revle32((uint32_t)((-i_operating_points[pt_set][NOMINAL].pstate +
i_operating_points[pt_set][POWERSAVE].pstate) << VID_SLOPE_FP_SHIFT_12)
/ (uint32_t) (revle32(i_operating_points[pt_set][NOMINAL].vdd_mv) -
revle32(i_operating_points[pt_set][POWERSAVE].vdd_mv)));
o_gppb->VPStateSlopes[pt_set][REGION_POWERSAVE_NOMINAL] = revle16( revle32(tmp));
FAPI_INF("VPStateSlopes[%s][REGION_POWERSAVE_NOMINAL] %X tmp %X", vpdSetStr[pt_set],
(revle16(o_gppb->VPStateSlopes[pt_set][REGION_POWERSAVE_NOMINAL])), revle32(tmp));


tmp = revle32((uint32_t)((-i_operating_points[pt_set][TURBO].pstate +
i_operating_points[pt_set][NOMINAL].pstate) << VID_SLOPE_FP_SHIFT_12)
/ (uint32_t) (revle32(i_operating_points[pt_set][TURBO].vdd_mv) -
revle32(i_operating_points[pt_set][NOMINAL].vdd_mv)));
o_gppb->VPStateSlopes[pt_set][REGION_NOMINAL_TURBO] = revle16( revle32(tmp));
FAPI_INF("VPStateSlopes[%s][REGION_NOMINAL_TURBO] %X tmp %X", vpdSetStr[pt_set],
(revle16(o_gppb->VPStateSlopes[pt_set][REGION_NOMINAL_TURBO])), revle32(tmp));


tmp = revle32((uint32_t)((-i_operating_points[pt_set][ULTRA].pstate +
i_operating_points[pt_set][TURBO].pstate) << VID_SLOPE_FP_SHIFT_12)
/ (uint32_t) (revle32(i_operating_points[pt_set][ULTRA].vdd_mv) -
revle32(i_operating_points[pt_set][TURBO].vdd_mv)));
o_gppb->VPStateSlopes[pt_set][REGION_TURBO_ULTRA] = revle16( revle32(tmp));
FAPI_INF("VPStateSlopes[%s][REGION_TURBO_ULTRA] %X tmp %X", vpdSetStr[pt_set],
(revle16(o_gppb->VPStateSlopes[pt_set][REGION_TURBO_ULTRA])), revle32(tmp));
}

/// Print a GlobalPstateParameterBlock structure on a given stream
///
/// \param gppb The Global Pstate Parameter Block print
Expand Down Expand Up @@ -2789,7 +2879,7 @@ void p9_pstate_compute_PsVIDCompSlopes_slopes(PoundW_data i_data,
//convert to fixed-point number
for (uint8_t p = 0; p < NUM_OP_POINTS; ++p)
{
cVidFP[p] = revle32((io_lppb->vid_point_set[p]) << VID_SLOPE_FP_SHIFT);
cVidFP[p] = revle32((io_lppb->vid_point_set[p]) << VID_SLOPE_FP_SHIFT_12);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,10 @@ void p9_pstate_compute_vpd_pts(VpdOperatingPoint (*o_operating_points)[NUM_OP_PO
void p9_pstate_compute_PsV_slopes(VpdOperatingPoint i_operating_points[][4],
GlobalPstateParmBlock* o_gppb);

void p9_pstate_compute_PStateV_slope(uint32_t i_pt_set, VpdOperatingPoint i_operating_points[][4],
GlobalPstateParmBlock* o_gppb);


/// Print a GlobalPstateParameterBlock structure on a given stream
///
/// @param[in] gppb The Global Pstate Parameter Block to print
Expand Down

0 comments on commit 1551812

Please sign in to comment.