summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/pstates
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@us.ibm.com>2014-09-28 18:41:51 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2014-12-02 18:07:13 -0600
commitf722d8c15b0ffa1d7d57608b8cff4e2865961aa8 (patch)
tree730144ecc90386c0ad3fddc417d2628bbe8ba5a4 /src/usr/hwpf/hwp/pstates
parentaeb70d93bba10dcddc9d4f8f35b460359cf864c2 (diff)
downloadtalos-hostboot-f722d8c15b0ffa1d7d57608b8cff4e2865961aa8.tar.gz
talos-hostboot-f722d8c15b0ffa1d7d57608b8cff4e2865961aa8.zip
Port HWSV FreqVoltageSvc functionality to HB for Habanero
Change-Id: I90abd08bb6abf042273da606c6241bd22c58fa29 RTC: 108816 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/13642 Tested-by: Jenkins Server Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/hwpf/hwp/pstates')
-rw-r--r--src/usr/hwpf/hwp/pstates/makefile1
-rw-r--r--src/usr/hwpf/hwp/pstates/pstates/freqVoltageSvc.C398
-rw-r--r--src/usr/hwpf/hwp/pstates/pstates/freqVoltageSvc.H152
-rwxr-xr-xsrc/usr/hwpf/hwp/pstates/pstates/p8_build_pstate_datablock.C151
4 files changed, 603 insertions, 99 deletions
diff --git a/src/usr/hwpf/hwp/pstates/makefile b/src/usr/hwpf/hwp/pstates/makefile
index defe4b1e4..21a98b899 100644
--- a/src/usr/hwpf/hwp/pstates/makefile
+++ b/src/usr/hwpf/hwp/pstates/makefile
@@ -54,6 +54,7 @@ OBJS += p8_build_pstate_datablock.o
OBJS += proc_get_voltage.o
OBJS += pstates.o
OBJS += pstate_tables.o
+OBJS += $(if $(CONFIG_SET_NOMINAL_PSTATE)$(CONFIG_HTMGT),freqVoltageSvc.o)
OBJS += proc_set_max_pstate.o
diff --git a/src/usr/hwpf/hwp/pstates/pstates/freqVoltageSvc.C b/src/usr/hwpf/hwp/pstates/pstates/freqVoltageSvc.C
new file mode 100644
index 000000000..cfda8a083
--- /dev/null
+++ b/src/usr/hwpf/hwp/pstates/pstates/freqVoltageSvc.C
@@ -0,0 +1,398 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/hwpf/hwp/pstates/pstates/freqVoltageSvc.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2014 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+/**
+ * @file freqVoltageSvc.C
+ *
+ * @brief Contains freqVoltage class definition
+ *
+ * This file contains implementation of frequency voltage service class. This
+ * class is used for reading/parsing/writing frequency and voltage related
+ * data.
+ *
+ */
+
+#include <stdio.h>
+
+#include <freqVoltageSvc.H>
+
+#include <devicefw/userif.H>
+#include <errl/errlentry.H>
+#include <errl/errlmanager.H>
+#include <fapiPlatHwpInvoker.H>
+#include <hwpf/fapi/fapiMvpdAccess.H>
+#include <hwpf/hwpf_reasoncodes.H>
+#include <p8_build_pstate_datablock.H>
+#include <proc_get_voltage.H>
+#include <pstates.h>
+#include <targeting/common/commontargeting.H>
+#include <targeting/common/utilFilter.H>
+#include <vpd/mvpdenums.H>
+
+extern trace_desc_t* g_fapiTd;
+
+using namespace TARGETING;
+
+namespace FREQVOLTSVC
+{
+
+ //**************************************************************************
+ // FREQVOLTSVC::setSysFreq
+ //**************************************************************************
+ errlHndl_t setSysFreq()
+ {
+ errlHndl_t l_err = NULL;
+ uint32_t l_sysHighestPowerSaveFreq = 0x0;
+ TARGETING::ATTR_NOMINAL_FREQ_MHZ_type l_sysNomFreq = 0x0;
+ TARGETING::ATTR_FREQ_CORE_MAX_type l_sysLowestTurboFreq = 0x0;
+
+ // Get system frequency
+ l_err = getSysFreq(l_sysHighestPowerSaveFreq,
+ l_sysNomFreq,
+ l_sysLowestTurboFreq);
+ if (l_err != NULL)
+ {
+ TRACFCOMP( g_fapiTd,ERR_MRK"Error getting system frequency");
+ }
+ else
+ {
+ // Successfully got system frequency. Now update
+ // system attributes.
+
+ //Get the top level (system) target handle
+ TARGETING::Target* l_pTopLevel = NULL;
+ (void)TARGETING::targetService().getTopLevelTarget(l_pTopLevel);
+
+ // Assert on failure getting system target
+ assert( l_pTopLevel != NULL );
+
+ // Top level target successfully retrieved.
+ // Set nominal frequency attribute
+ (void)l_pTopLevel->setAttr
+ < TARGETING::ATTR_NOMINAL_FREQ_MHZ > (l_sysNomFreq);
+
+ // Set max turbo frequency attribute
+ (void)l_pTopLevel->setAttr
+ < TARGETING::ATTR_FREQ_CORE_MAX > (l_sysLowestTurboFreq);
+
+ // Set min freq attribute based on power save
+ (void)l_pTopLevel->setAttr<TARGETING::ATTR_MIN_FREQ_MHZ>
+ (l_sysHighestPowerSaveFreq);
+
+ verifyBootFreq(l_pTopLevel);
+ }
+
+ return l_err;
+ }
+
+ //**************************************************************************
+ // FREQVOLTSVC::verifyBootFreq
+ //**************************************************************************
+ void verifyBootFreq(TARGETING::Target* const i_pTarget)
+ {
+ TARGETING::ATTR_MIN_FREQ_MHZ_type l_sysMinFreq =
+ i_pTarget->getAttr<TARGETING::ATTR_MIN_FREQ_MHZ>();
+ TARGETING::ATTR_BOOT_FREQ_MHZ_type l_boot_freq_mhz =
+ i_pTarget->getAttr<TARGETING::ATTR_BOOT_FREQ_MHZ>();
+
+ l_boot_freq_mhz = (l_sysMinFreq > l_boot_freq_mhz) ? l_sysMinFreq:
+ l_boot_freq_mhz;
+
+ i_pTarget->setAttr<TARGETING::ATTR_BOOT_FREQ_MHZ>(l_boot_freq_mhz);
+ }
+
+ //**************************************************************************
+ // FREQVOLTSVC::getSysFreq
+ //**************************************************************************
+ errlHndl_t getSysFreq(
+ uint32_t & o_sysVPDPowerSaveMinFreqMhz,
+ TARGETING::ATTR_NOMINAL_FREQ_MHZ_type & o_sysNomFreqMhz,
+ TARGETING::ATTR_FREQ_CORE_MAX_type & o_sysVPDTurboMaxFreqMhz)
+ {
+ uint32_t l_minsysVPDTurboMaxFreqMhz = 0;
+ uint32_t l_maxsysVPDPowerSaveMinFreqMhz = 0;
+ fapi::ReturnCode l_rc;
+ errlHndl_t l_err = NULL;
+
+ do
+ {
+ o_sysNomFreqMhz = 0;
+ o_sysVPDTurboMaxFreqMhz = 0;
+ o_sysVPDPowerSaveMinFreqMhz = 0;
+
+ //Filter functional unit
+ TARGETING::PredicateIsFunctional l_isFunctional;
+
+ // Filter core unit
+ TARGETING::PredicateCTM l_coreUnitFilter(TARGETING::CLASS_UNIT,
+ TARGETING::TYPE_CORE);
+
+ //Filter functional cores
+ TARGETING::PredicatePostfixExpr l_funcCoreUnitFilter;
+
+ // core units AND functional
+ l_funcCoreUnitFilter.push(&l_coreUnitFilter).push
+ (&l_isFunctional).And();
+
+ // Loop through all the targets, looking for functional core units.
+ TARGETING::TargetRangeFilter l_pFilter(
+ TARGETING::targetService().begin(),
+ TARGETING::targetService().end(),
+ &l_funcCoreUnitFilter);
+ // Assert if no functional cores are found
+ assert(l_pFilter);
+
+ bool l_copyOnce = true;
+
+ // Loop through functional cores to get frequency
+ for(; l_pFilter; ++l_pFilter )
+ {
+ TARGETING::Target * l_pTarget = *l_pFilter;
+
+ fapi::voltageBucketData_t l_poundVdata = {0};
+
+ // Get Parent Chip target
+ const TARGETING::Target * l_pChipTarget =
+ getParentChip(l_pTarget);
+
+ // Get core number for record number
+ TARGETING::ATTR_CHIP_UNIT_type l_coreNum =
+ l_pTarget->getAttr<TARGETING::ATTR_CHIP_UNIT>();
+
+ uint32_t l_record = (uint32_t) MVPD::LRP0 + l_coreNum;
+
+ // Get #V bucket data
+ l_rc = fapiGetPoundVBucketData(l_pChipTarget,
+ l_record,
+ l_poundVdata);
+ if(l_rc)
+ {
+ TRACFCOMP( g_fapiTd,ERR_MRK"Error getting #V data for HUID:"
+ "0x%08X",
+ l_pTarget->getAttr<TARGETING::ATTR_HUID>());
+
+ // Convert fapi returnCode to Error handle
+ l_err = fapiRcToErrl(l_rc);
+
+ break;
+ }
+
+ uint32_t l_sysVPDPowerSaveMinFreqMhz = l_poundVdata.PSFreq;
+ TARGETING::ATTR_NOMINAL_FREQ_MHZ_type l_sysNomFreqMhz =
+ l_poundVdata.nomFreq;
+ TARGETING::ATTR_FREQ_CORE_MAX_type l_sysVPDTurboMaxFreqMhz =
+ l_poundVdata.turboFreq;
+ TRACFCOMP(g_fapiTd,INFO_MRK"Nominal freq is: [0x%08X]. Turbo "
+ "freq is: [0x%08x]. PowerSave freq is: [0x%08X]",
+ l_sysNomFreqMhz, l_sysVPDTurboMaxFreqMhz,
+ l_sysVPDPowerSaveMinFreqMhz );
+
+ if( true == l_copyOnce)
+ {
+ o_sysNomFreqMhz = l_sysNomFreqMhz;
+ l_minsysVPDTurboMaxFreqMhz = l_sysVPDTurboMaxFreqMhz;
+ l_maxsysVPDPowerSaveMinFreqMhz =
+ l_sysVPDPowerSaveMinFreqMhz;
+ l_copyOnce = false;
+ }
+
+ // frequency is never zero so create error if it is zero.
+ if( (l_sysNomFreqMhz == 0) ||
+ (l_sysVPDTurboMaxFreqMhz == 0) ||
+ (l_sysVPDPowerSaveMinFreqMhz == 0) )
+ {
+ TRACFCOMP(g_fapiTd,ERR_MRK"Frequency is zero, "
+ "nominal freq: 0x%04X,turbo freq: 0x%08X",
+ "PowerSave freq is: [0x%08X]",
+ l_sysNomFreqMhz,
+ l_sysVPDTurboMaxFreqMhz,
+ l_sysVPDPowerSaveMinFreqMhz);
+
+ /*@
+ * @errortype
+ * @moduleid fapi::MOD_GET_SYS_FREQ
+ * @reasoncode fapi::RC_INVALID_DATA
+ * @userdata1[0:31] Proc HUID
+ * @userdata1[32:63] Nominal frequency
+ * @userdata2[0:31] Max Turbo frequency from VPD
+ * @userdata2[32:63] Min Power Save frequency from VPD
+ * @devdesc Either nominal, max turbo or min power
+ * save frequency for the processor HUID
+ * (userdata1) is zero
+ */
+ l_err =
+ new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ fapi::MOD_GET_SYS_FREQ,
+ fapi::RC_INVALID_DATA,
+ TWO_UINT32_TO_UINT64(
+ l_pTarget->getAttr<TARGETING::ATTR_HUID>(),
+ l_sysNomFreqMhz),
+ TWO_UINT32_TO_UINT64(l_sysVPDTurboMaxFreqMhz,
+ l_sysVPDPowerSaveMinFreqMhz));
+
+ // Callout HW as VPD data is incorrect
+ l_err->addHwCallout(l_pTarget, HWAS::SRCI_PRIORITY_HIGH,
+ HWAS::DECONFIG, HWAS::GARD_NULL);
+
+ break;
+ }
+
+ // Validate nominal frequency. If differs,
+ // create error and stop processing further.
+ if( o_sysNomFreqMhz != l_sysNomFreqMhz )
+ {
+ TRACFCOMP(g_fapiTd,ERR_MRK
+ "Nominal Frequency:[0x%04X] does not "
+ "match with other core nominal frequency:[0x%04X]",
+ l_sysNomFreqMhz, o_sysNomFreqMhz);
+
+ /*@
+ * @errortype
+ * @moduleid fapi::MOD_GET_SYS_FREQ
+ * @reasoncode fapi::RC_INVALID_FREQ
+ * @userdata1 Invalid frequency
+ * @userdata2 Expected frequency
+ * @devdesc Nominal frequency(userdata1) does not match
+ * nominal frequency(userdata2) on other cores.
+ * Should be the same for all chips.
+ */
+ l_err =
+ new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ fapi::MOD_GET_SYS_FREQ,
+ fapi::RC_INVALID_FREQ,
+ l_sysNomFreqMhz,
+ o_sysNomFreqMhz);
+
+ // Callout HW as VPD data is incorrect
+ l_err->addHwCallout(l_pTarget, HWAS::SRCI_PRIORITY_HIGH,
+ HWAS::DECONFIG, HWAS::GARD_NULL);
+
+ break;
+ }
+
+ // Save the min turbo freq
+ if (l_sysVPDTurboMaxFreqMhz < l_minsysVPDTurboMaxFreqMhz)
+ {
+ l_minsysVPDTurboMaxFreqMhz = l_sysVPDTurboMaxFreqMhz;
+ }
+ // Save the max powersave freq
+ if (l_sysVPDPowerSaveMinFreqMhz >
+ l_maxsysVPDPowerSaveMinFreqMhz)
+ {
+ l_maxsysVPDPowerSaveMinFreqMhz =
+ l_sysVPDPowerSaveMinFreqMhz;
+ }
+
+ } // end for loop
+ if (l_err != NULL)
+ {
+ break;
+ }
+
+ // Get min turbo freq
+ o_sysVPDTurboMaxFreqMhz = l_minsysVPDTurboMaxFreqMhz;
+
+ // Get max powersave freq
+ o_sysVPDPowerSaveMinFreqMhz = l_maxsysVPDPowerSaveMinFreqMhz;
+
+ } while (0);
+
+ TRACFCOMP(g_fapiTd,EXIT_MRK"o_sysNomFreqMhz: 0x%08X, "
+ "o_sysVPDTurboMaxFreqMhz: 0x%08X, "
+ "o_sysVPDPowerSaveMinFreqMhz: 0x%08X",
+ o_sysNomFreqMhz, o_sysVPDTurboMaxFreqMhz,
+ o_sysVPDPowerSaveMinFreqMhz );
+
+ return l_err;
+ }
+
+ //**************************************************************************
+ // FREQVOLTSVC::runP8BuildPstateDataBlock
+ //**************************************************************************
+ errlHndl_t runP8BuildPstateDataBlock(
+ const TARGETING::Target * i_procChip,
+ PstateSuperStructure * o_data)
+ {
+ errlHndl_t l_err = NULL;
+
+ // Assert on NULL input target
+ assert(i_procChip != NULL);
+
+ // convert to fapi target
+ fapi::Target l_fapiProcChip(fapi::TARGET_TYPE_PROC_CHIP,
+ reinterpret_cast<void *>
+ (const_cast<TARGETING::Target*>(i_procChip)) );
+
+ FAPI_INVOKE_HWP(l_err, p8_build_pstate_datablock,l_fapiProcChip,o_data);
+
+ if( l_err != NULL)
+ {
+ TRACFCOMP( g_fapiTd,ERR_MRK"Error from HWP: "
+ "p8_build_pstate_datablock for target HUID: 0x%08X",
+ i_procChip->getAttr<TARGETING::ATTR_HUID>());
+ }
+
+ return l_err;
+ }
+
+ //**************************************************************************
+ // FREQVOLTSVC::runProcGetVoltage
+ //**************************************************************************
+ errlHndl_t runProcGetVoltage(
+ const TARGETING::Target * i_procChip,
+ const uint32_t i_bootFreqMhz,
+ uint8_t & o_vdd_vid,
+ uint8_t & o_vcs_vid)
+ {
+ errlHndl_t l_err = NULL;
+
+ TRACFCOMP(g_fapiTd,INFO_MRK"i_bootFreqMhz: 0x%08X",i_bootFreqMhz);
+
+ // Assert on NULL input target
+ assert(i_procChip != NULL);
+
+ // convert to fapi target
+ fapi::Target l_fapiProcChip(fapi::TARGET_TYPE_PROC_CHIP,
+ reinterpret_cast<void *>
+ (const_cast<TARGETING::Target*>(i_procChip)));
+
+ // Invoke HW procedure
+ FAPI_INVOKE_HWP(l_err, proc_get_voltage,l_fapiProcChip,i_bootFreqMhz,
+ o_vdd_vid,o_vcs_vid);
+
+ if( l_err != NULL)
+ {
+ TRACFCOMP( g_fapiTd,ERR_MRK"Error from HWP: proc_get_voltage: "
+ "i_bootFreq: 0x%08X, "
+ "HUID: 0x%08X", i_bootFreqMhz,
+ i_procChip->getAttr<TARGETING::ATTR_HUID>());
+ }
+
+ return l_err;
+ }
+
+} // end namespace FREQVOLTSVC
+
diff --git a/src/usr/hwpf/hwp/pstates/pstates/freqVoltageSvc.H b/src/usr/hwpf/hwp/pstates/pstates/freqVoltageSvc.H
new file mode 100644
index 000000000..183f7be9e
--- /dev/null
+++ b/src/usr/hwpf/hwp/pstates/pstates/freqVoltageSvc.H
@@ -0,0 +1,152 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/hwpf/hwp/pstates/pstates/freqVoltageSvc.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2014 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+/** @file freqVoltageSvc.H
+ * @brief Contains freqVoltage class declaration
+ *
+ * This file contains information about frequency voltage service class. This
+ * class is used for reading/parsing/writing frequency and voltage related
+ * data.
+ */
+
+#ifndef __PSTATES_FREQVOLTAGESVC_H
+#define __PSTATES_FREQVOLTAGESVC_H
+
+#include <errl/errlentry.H>
+#include <hwpf/fapi/fapiMvpdAccess.H>
+#include <pstates.h>
+
+namespace FREQVOLTSVC
+{
+
+ /**
+ * @brief Set system frequency attribute
+ *
+ * @par Detailed Description:
+ * This function reads nominal, max turbo frequency, and min power
+ * save frequency from VPD and updates system target attributes.
+ *
+ * @return Error log handle indicating the status of the request
+ *
+ * @retval NULL Successfully set system frequency
+ * @retval !NULL Failed to set system frequency.
+ */
+ errlHndl_t setSysFreq();
+
+ /**
+ * @brief Run p8_build_pstate_datablock HWP
+ *
+ * @par Detailed Description:
+ * This function is wrapper for executing p8_build_pstate_datablock
+ * HW procedure.
+ *
+ * @param[in] i_procChip
+ * Valid functional Processor Chip target pointer
+ * @param[out] o_data
+ * On success, holds pstate data
+ *
+ * @return Error log handle indicating the status of the request
+ *
+ * @retval NULL Successfully retrieved pstate data
+ * @retval !NULL Failed to get pstate data, ignore output
+ */
+ errlHndl_t runP8BuildPstateDataBlock(const TARGETING::Target * i_procChip,
+ PstateSuperStructure * o_data);
+
+ /**
+ * @brief Run proc_get_voltage HWP
+ *
+ * @par Detailed Description:
+ * This function is wrapper for executing proc_get_voltage
+ * HW procedure.
+ *
+ * @param[in] i_procChip
+ * Valid functional Processor Chip target pointer
+ * @param[in] i_bootFreqMhz
+ * Boot Frequency in MHZ
+ * @param[out] o_vdd_vid
+ * On success, holds VDD value
+ * @param[out] o_vcs_vid
+ * On success, holds VCS value
+ *
+ * @return Error log handle indicating the status of the request
+ *
+ * @retval NULL Successfully retrieved boot voltage data
+ * @retval !NULL Failed to get boot voltage, ignore output
+ */
+ errlHndl_t runProcGetVoltage(const TARGETING::Target * i_procChip,
+ const uint32_t i_bootFreqMhz,
+ uint8_t & o_vdd_vid,
+ uint8_t & o_vcs_vid);
+
+ /**
+ * @brief Get system frequency
+ *
+ * @par Detailed Description:
+ * This function reads nominal, max turbo and min PowerSave frequency
+ * from VPD.
+ * It also does validation (check if all functional core voltage data
+ * points to the same nominal frequency value). Returns error if
+ * validation fails.
+ * Max Turbo frequency returned is the lowest turbo freq of all the
+ * functional cores in the system, obtained from VPD.
+ * Min PowerSave frequency returned is the highest powersave freq of
+ * all the functional cores in the system, obtained from VPD.
+ *
+ * @param[out] o_sysNomFreqMhz
+ * On success, holds system nominal frequency
+ * On failure, set to zero.
+ * @param[out] o_sysVPDTurboMaxFreqMhz
+ * On success, holds lowest turbo frequency
+ * On failure, set to zero.
+ * @param[out] o_sysVPDPowerSaveMinFreqMhz
+ * On success, holds highest powersave frequency
+ * On failure, set to zero.
+ *
+ * @return Error log handle indicating the status of the request
+ *
+ * @retval NULL Successfully retrieved system frequency
+ * @retval !NULL Failed to get system frequency, ignore output
+ */
+ errlHndl_t getSysFreq(
+ uint32_t & o_sysVPDPowerSaveMinFreqMhz,
+ TARGETING::ATTR_NOMINAL_FREQ_MHZ_type & o_sysNomFreqMhz,
+ TARGETING::ATTR_FREQ_CORE_MAX_type & o_sysVPDTurboMaxFreqMhz);
+
+ /**
+ * @brief Verify the system boot frequency attribute
+ *
+ * @par Detailed Description:
+ * This method reads the system's boot frequency (ATTR_BOOT_FREQ_MHZ)
+ * and verifies that it is greater than or equal to the minimum
+ * power save frequency from VPD.
+ *
+ * @param[in] i_pTarget
+ * Pointer to system target.
+ */
+ void verifyBootFreq(TARGETING::Target* const i_pTarget);
+
+}; // end namespace FREQVOLTSVC
+
+#endif // __PSTATES_FREQVOLTAGESVC_H
diff --git a/src/usr/hwpf/hwp/pstates/pstates/p8_build_pstate_datablock.C b/src/usr/hwpf/hwp/pstates/pstates/p8_build_pstate_datablock.C
index 54a2290d6..70b57df45 100755
--- a/src/usr/hwpf/hwp/pstates/pstates/p8_build_pstate_datablock.C
+++ b/src/usr/hwpf/hwp/pstates/pstates/p8_build_pstate_datablock.C
@@ -6,8 +6,8 @@
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2013,2014 */
-/* [+] International Business Machines Corp. */
/* [+] Google Inc. */
+/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
@@ -23,7 +23,7 @@
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
-// $Id: p8_build_pstate_datablock.C,v 1.00039 2014/07/22 21:45:45 daviddu Exp $
+// $Id: p8_build_pstate_datablock.C,v 1.42 2014/11/18 18:08:49 anoo Exp $
// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/chips/p8/working/procedures/ipl/fapi/p8_build_pstate_datablock.C,v $
//------------------------------------------------------------------------------
// *! (C) Copyright International Business Machines Corp. 2012
@@ -99,7 +99,7 @@ p8_build_pstate_datablock(const Target& i_target,
uint8_t i = 0;
uint8_t present_chiplets = 0;
uint8_t functional_chiplets = 0;
- uint8_t poundm_ver = 0;
+ uint8_t poundm_ver = 0;
uint8_t poundm_valid = 1; // assume valid until code determines invalid
uint8_t lpst_valid = 1; // assume valid until code determines invalid
uint8_t attr_pm_ivrms_enabled_wr = 0;
@@ -116,7 +116,7 @@ p8_build_pstate_datablock(const Target& i_target,
ivrm_mvpd_t ivrm_mvpd;
FAPI_INF("Executing p8_build_pstate_datablock ....");
-
+
do
{
// -----------------------------------------------------------
@@ -138,21 +138,21 @@ p8_build_pstate_datablock(const Target& i_target,
// --------------------------------
// check chip ec feature attributes
- // --------------------------------
+ // --------------------------------
if (attr.attr_proc_ec_core_hang_pulse_bug) {
FAPI_INF("ATTR_PROC_EC_CORE_HANG_PULSE_BUG is set so disable iVRMs - setting PSTATE_NO_INSTALL_LPSA");
(*io_pss).gpst.options.options = revle32(revle32((*io_pss).gpst.options.options) |
PSTATE_NO_INSTALL_LPSA);
poundm_valid = 0;
- lpst_valid = 0;
+ lpst_valid = 0;
}
-
+
if (! attr.attr_chip_ec_feature_resonant_clk_valid) {
- FAPI_INF("ATTR_CHIP_EC_FEATURE_RESONANT_CLK_VALID is not set so disable resonant clocking - setting PSTATE_NO_INSTALL_RESCLK");
+ FAPI_INF("ATTR_CHIP_EC_FEATURE_RESONANT_CLK_VALID is not set so disable resonant clocking - setting PSTATE_NO_INSTALL_RESCLK");
(*io_pss).gpst.options.options = revle32(revle32((*io_pss).gpst.options.options) |
PSTATE_NO_INSTALL_RESCLK );
}
-
+
// ----------------
// get #V & #M data
// ----------------
@@ -173,9 +173,9 @@ p8_build_pstate_datablock(const Target& i_target,
FAPI_SET_HWP_ERROR(l_rc, RC_PROCPM_PSTATE_DATABLOCK_NO_CORES_PRESENT_ERROR);
break;
}
-
+
if (!functional_chiplets || !poundm_valid) {
-
+
if (!functional_chiplets)
{
FAPI_IMP("No FUNCTIONAL chiplets found - set PSTATE_NO_INSTALL_LPSA");
@@ -184,7 +184,7 @@ p8_build_pstate_datablock(const Target& i_target,
{
FAPI_IMP("Invalid #M found - set PSTATE_NO_INSTALL_LPSA");
}
-
+
// indicate no LPST installed in PSS
(*io_pss).gpst.options.options = revle32(revle32((*io_pss).gpst.options.options) |
PSTATE_NO_INSTALL_LPSA);
@@ -343,10 +343,10 @@ p8_build_pstate_datablock(const Target& i_target,
// Create the Local Pstate table
// -----------------------------
uint8_t vid_incr_gt7_nonreg = 0;
-
+
if (! attr.attr_proc_ec_core_hang_pulse_bug) {
FAPI_IMP("Creating Local Pstate Table");
-
+
rc = lpst_create( &((*io_pss).gpst), &((*io_pss).lpsa), DEAD_ZONE_5MV, volt_int_vdd_bias, volt_int_vcs_bias, &vid_incr_gt7_nonreg);
int & LPST_RETURN_CODE = rc;
@@ -364,28 +364,28 @@ p8_build_pstate_datablock(const Target& i_target,
FAPI_ERR("**** ERROR : lpst_create encountered a vid increment > 7 in regulation");
FAPI_SET_HWP_ERROR(l_rc, RC_PROCPM_PSTATE_DATABLOCK_LPST_CREATE_VID_INCR_CLIP_INREG_ERROR);
break;
- }
+ }
else if (rc == -LPST_GPST_WARNING) {
FAPI_IMP("No Local Pstate Generated - Global Pstate Table is completely within Deadzone - set PSTATE_NO_INSTALL_LPSA" );
// indicate no LPST installed in PSS
(*io_pss).gpst.options.options = revle32(revle32((*io_pss).gpst.options.options) |
PSTATE_NO_INSTALL_LPSA);
- lpst_valid = 0;
+ lpst_valid = 0;
}
else if (rc) {
FAPI_ERR("**** ERROR : lpst_create returned error rc = %d", rc );
FAPI_SET_HWP_ERROR(l_rc, RC_PROCPM_PSTATE_DATABLOCK_LPST_CREATE_ERROR);
break;
}
-
+
// display warning message if this condition occurs
if (vid_incr_gt7_nonreg) {
FAPI_IMP("Warning : vid increment field was > 7 in non-regulation - clipped to 7 in lpst");
}
-
+
}
-
+
// -----------------------
// Create VDS & VIN tables
// -----------------------
@@ -458,7 +458,7 @@ p8_build_pstate_datablock(const Target& i_target,
FAPI_INF(" Set PSTATE_FORCE_INITIAL_PMIN in GPST control options");
(*io_pss).gpst.options.options = revle32(revle32((*io_pss).gpst.options.options) | PSTATE_FORCE_INITIAL_PMIN);
FAPI_INF(" GPST control options mask is now: [%x].", (*io_pss).gpst.options.options);
-
+
// -------------------
// Attributes to write
// -------------------
@@ -475,18 +475,18 @@ p8_build_pstate_datablock(const Target& i_target,
attr_pm_ivrms_enabled_wr = 1;
}
else
- {
+ {
attr_pm_ivrms_enabled_wr = 0;
FAPI_INF(" ATTR_PM_IVRMS_ENABLED will be set to 0 - set PSTATE_NO_INSTALL_LPSA");
// indicate no LPST installed in PSS
(*io_pss).gpst.options.options = revle32(revle32((*io_pss).gpst.options.options) |
- PSTATE_NO_INSTALL_LPSA);
+ PSTATE_NO_INSTALL_LPSA);
}
-
+
// write ATTR_PM_IVRMS_ENABLED
- SETATTR(l_rc, ATTR_PM_IVRMS_ENABLED, "ATTR_PM_IVRMS_ENABLED", &i_target, attr_pm_ivrms_enabled_wr);
+ SETATTR(l_rc, ATTR_PM_IVRMS_ENABLED, "ATTR_PM_IVRMS_ENABLED", &i_target, attr_pm_ivrms_enabled_wr);
- // Read back attribute to see if overridden
+ // Read back attribute to see if overridden
GETATTR (l_rc, ATTR_PM_IVRMS_ENABLED, "ATTR_PM_IVRMS_ENABLED", &i_target, attr_pm_ivrms_enabled_rd);
if (attr_pm_ivrms_enabled_rd && !attr_pm_ivrms_enabled_wr) {
@@ -496,9 +496,9 @@ p8_build_pstate_datablock(const Target& i_target,
FAPI_INF("WARNING : ATTR_PM_IVRMS_ENABLED was overriden to 0, but #V or #M data are valid - set PSTATE_NO_INSTALL_LPSA");
// indicate no LPST installed in PSS
(*io_pss).gpst.options.options = revle32(revle32((*io_pss).gpst.options.options) |
- PSTATE_NO_INSTALL_LPSA);
+ PSTATE_NO_INSTALL_LPSA);
}
-
+
} while(0);
return l_rc;
@@ -584,11 +584,11 @@ ReturnCode proc_get_attributes(const Target& i_target,
DATABLOCK_GET_ATTR(ATTR_CHIP_EC_FEATURE_RESONANT_CLK_VALID, &i_target, attr_chip_ec_feature_resonant_clk_valid);
DATABLOCK_GET_ATTR(ATTR_PROC_EC_CORE_HANG_PULSE_BUG , &i_target, attr_proc_ec_core_hang_pulse_bug);
DATABLOCK_GET_ATTR(ATTR_CHIP_EC_FEATURE_IVRM_WINKLE_BUG , &i_target, attr_chip_ec_feature_ivrm_winkle_bug);
-
- // Read IVRM attributes
+
+ // Read IVRM attributes
DATABLOCK_GET_ATTR(ATTR_PM_SYSTEM_IVRMS_ENABLED , NULL, attr_pm_system_ivrms_enabled);
DATABLOCK_GET_ATTR(ATTR_PM_SYSTEM_IVRM_VPD_MIN_LEVEL , NULL, attr_pm_system_ivrm_vpd_min_level);
-
+
// --------------------------------------------------------------
// do basic attribute value checking and generate error if needed
// --------------------------------------------------------------
@@ -706,36 +706,6 @@ ReturnCode proc_get_attributes(const Target& i_target,
return l_rc;
}
-const uint8_t NON_ECO_VOLTAGE_BUCKET_OFFFSET = 0x04;
-const uint8_t ALTERNATE_BUCKET_OFFSET = 0x05;
-const uint8_t BUCKET_ID_MASK = 0x0F;
-const uint8_t VPD_VINI_PR_DATA_LENGTH = 8;
-
-const uint8_t DEFAULT_BUCKET = 1;
-
-static int get_bucket_from_pr(const Target& i_target)
-{
- ReturnCode l_rc;
- uint8_t l_buffer[VPD_VINI_PR_DATA_LENGTH];
- uint32_t l_bufferSize = sizeof(l_buffer);
-
- l_rc = fapiGetMvpdField(fapi::MVPD_RECORD_VINI,
- fapi::MVPD_KEYWORD_PR,
- i_target,
- l_buffer,
- l_bufferSize);
-
- if (l_rc)
- {
- return DEFAULT_BUCKET;
- }
-
- uint8_t l_bucketId = l_buffer[NON_ECO_VOLTAGE_BUCKET_OFFFSET] &
- BUCKET_ID_MASK;
-
- return l_bucketId != 0 ? l_bucketId : DEFAULT_BUCKET;
-}
-
/// ----------------------------------------------------------------
/// \brief Get #V data and put into array
/// \param[in] i_target => Chip Target
@@ -766,7 +736,6 @@ ReturnCode proc_get_mvpd_data(const Target& i_target,
uint8_t ii = 0;
uint8_t first_chplt = 1;
uint8_t bucket_id = 0;
- uint8_t pr_bucket_id = 0;
uint16_t cal_data[4];
do
@@ -803,10 +772,10 @@ ReturnCode proc_get_mvpd_data(const Target& i_target,
// set l_record to appropriate lprx record (add core number to lrp0)
l_record = (uint32_t)fapi::MVPD_RECORD_LRP0 + l_chipNum;
-
+
// clear out buffer to known value before calling fapiGetMvpdField
memset(l_buffer, 0, 512);
-
+
// Get Chiplet MVPD data and put in chiplet_mvpd_data using accessor function
l_rc = fapiGetMvpdField((fapi::MvpdRecord)l_record,
fapi::MVPD_KEYWORD_PDV,
@@ -827,16 +796,6 @@ ReturnCode proc_get_mvpd_data(const Target& i_target,
break;
}
- // Get the correct bucket according to FRU PR data.
- pr_bucket_id = get_bucket_from_pr(i_target);
- if (l_bufferSize < PDV_BUFFER_SIZE * pr_bucket_id) {
- const uint32_t &BUFFER_SIZE = l_bufferSize;
- const Target &CHIP_TARGET= i_target;
- FAPI_ERR("**** ERROR : Not enough buckets returned from fapiGetMvpdField for #V => %d", l_bufferSize );
- FAPI_SET_HWP_ERROR(l_rc, RC_PROCPM_PSTATE_DATABLOCK_PDV_BUFFER_SIZE_ERROR);
- break;
- }
-
// clear array
memset(chiplet_mvpd_data, 0, sizeof(chiplet_mvpd_data));
@@ -844,15 +803,9 @@ ReturnCode proc_get_mvpd_data(const Target& i_target,
#define UINT16_GET(__uint8_ptr) ((uint16_t)( ( (*((const uint8_t *)(__uint8_ptr)) << 8) | *((const uint8_t *)(__uint8_ptr) + 1) ) ))
// use copy of allocated buffer pointer to increment through buffer
- // Skip version and 'PNP' from header.
- l_buffer_inc = l_buffer + 4;
+ l_buffer_inc = l_buffer;
bucket_id = *l_buffer_inc;
- while (bucket_id != pr_bucket_id &&
- (l_buffer_inc - l_buffer) < l_bufferSize) {
- l_buffer_inc += PDV_BUFFER_SIZE;
- bucket_id = *l_buffer_inc;
- }
l_buffer_inc++;
FAPI_INF("#V chiplet = %u bucket id = %u", l_chipNum, bucket_id);
@@ -979,14 +932,14 @@ ReturnCode proc_get_mvpd_data(const Target& i_target,
ivrm_mvpd->data.ex[j].point[i].drain_current = cal_data[3];
FAPI_INF("#M data (hex & dec) = 0x%04x 0x%04x 0x%04x 0x%04x %5u %5u %5u %5u", cal_data[0], cal_data[1], cal_data[2], cal_data[3], cal_data[0], cal_data[1], cal_data[2], cal_data[3]);
-
+
// #M validity check - not valid if measurements are 0 (exception : cal_data[0](Vg) can be 0)
if (cal_data[1] == 0 || cal_data[2] == 0 || cal_data[3] == 0 )
- {
+ {
FAPI_INF("**** Warning : #M has zero valued measurements - IVRMs will not be enabled");
- *poundm_valid = 0;
- }
-
+ *poundm_valid = 0;
+ }
+
}
// set number of samples to 13
@@ -1151,7 +1104,7 @@ ReturnCode proc_boost_gpst (PstateSuperStructure *pss,
uint32_t pstate_diff;
gpst_entry_t entry;
uint8_t gpsi_max;
-
+
const uint32_t MAXIMUM_BOOST_PERCENT_SUPPORTED = 20;
const uint32_t MAXIMUM_PSTATE_RANGE = 255; // maximum represented by uint8_t
@@ -1162,17 +1115,17 @@ ReturnCode proc_boost_gpst (PstateSuperStructure *pss,
FAPI_INF("CPM Turbo Boost Attribute = 0 -- no boosting will be done");
break;
}
-
+
// check that percentage is rational. Note: attribute information is .1 percent units
- if (attr_boost_percent > MAXIMUM_BOOST_PERCENT_SUPPORTED * 10) {
+ if (attr_boost_percent > MAXIMUM_BOOST_PERCENT_SUPPORTED * 10) {
FAPI_ERR("Boost percentage is greater than maximum supported. Max: %u; Value: %u",
- MAXIMUM_BOOST_PERCENT_SUPPORTED, attr_boost_percent);
+ MAXIMUM_BOOST_PERCENT_SUPPORTED, attr_boost_percent);
const uint32_t& MAXBOOSTPERCENT = MAXIMUM_BOOST_PERCENT_SUPPORTED;
const uint32_t& ATTRBOOSTPERCENT = attr_boost_percent;
- FAPI_SET_HWP_ERROR(l_rc, RC_PROCPM_PSTATE_DATABLOCK_INVALID_BOOST_PERCENTAGE_ERROR);
- break;
+ FAPI_SET_HWP_ERROR(l_rc, RC_PROCPM_PSTATE_DATABLOCK_INVALID_BOOST_PERCENTAGE_ERROR);
+ break;
}
-
+
// calculate percent to boost
boosted_pct = 1.0 + (BOOST_PCT_UNIT * (double)attr_boost_percent);
@@ -1199,7 +1152,7 @@ ReturnCode proc_boost_gpst (PstateSuperStructure *pss,
FAPI_INF("CPM Turbo Boost Attribute resulted in no increase in pstates - boost_pct = %f turbo_freq_khz = %u boosted_freq_khz = %u",
boosted_pct, pstate0_frequency_khz, boosted_freq_khz);
break;
- }
+ }
else if (pstate_diff > MAXIMUM_PSTATE_RANGE) {
FAPI_ERR("Percentage boost calculation overrun produced invalid Pstate Difference: %u", pstate_diff);
const uint32_t& PSTATEDIFF = pstate_diff;
@@ -1208,9 +1161,9 @@ ReturnCode proc_boost_gpst (PstateSuperStructure *pss,
const uint32_t& FREQSTEPKHZ = frequency_step_khz;
const uint32_t& ATTRBOOSTPERCENT = attr_boost_percent;
const double& BOOSTEDPCT = boosted_pct;
- FAPI_SET_HWP_ERROR(l_rc, RC_PROCPM_PSTATE_DATABLOCK_PSTATE_DIFF_ERROR);
- break;
- }
+ FAPI_SET_HWP_ERROR(l_rc, RC_PROCPM_PSTATE_DATABLOCK_PSTATE_DIFF_ERROR);
+ break;
+ }
else {
gpsi_max = pss->gpst.entries - 1;
entry.value = revle64(pss->gpst.pstate[gpsi_max].value);
@@ -1283,7 +1236,7 @@ ReturnCode proc_chk_valid_poundv(const Target& i_target,
FAPI_INF("Checking for relationship between #V operating point (%s <= %s)", pv_op_str[pv_op_order[i-1]], pv_op_str[pv_op_order[i]]);
FAPI_INF(" f=%u <= f=%u", poundv_data[pv_op_order[i-1]][0], poundv_data[pv_op_order[i]][0]);
FAPI_INF(" v=%u <= v=%u i=%u <= i=%u", poundv_data[pv_op_order[i-1]][1], poundv_data[pv_op_order[i]][1], poundv_data[pv_op_order[i-1]][2], poundv_data[pv_op_order[i]][2]);
- FAPI_INF(" v=%u <= v=%u i=%u <= i=%u", poundv_data[pv_op_order[i-1]][3], poundv_data[pv_op_order[i]][3], poundv_data[pv_op_order[i-1]][4], poundv_data[pv_op_order[i]][4]);
+ FAPI_INF(" v=%u <= v=%u i=%u <= i=%u", poundv_data[pv_op_order[i-1]][3], poundv_data[pv_op_order[i]][3], poundv_data[pv_op_order[i-1]][4], poundv_data[pv_op_order[i]][4]);
if (poundv_data[pv_op_order[i-1]][0] > poundv_data[pv_op_order[i]][0] ||
poundv_data[pv_op_order[i-1]][1] > poundv_data[pv_op_order[i]][1] ||
@@ -1369,7 +1322,7 @@ ReturnCode proc_res_clock (PstateSuperStructure *pss,
/// ------------------------------------------------------------
-/// \brief Update Psafe_pstate
+/// \brief Update Psafe_pstate
/// \param[inout] *pss => pointer to pstate superstructure
/// \param[in] *attr => pointer to attribute list structure
/// ------------------------------------------------------------
@@ -1424,7 +1377,7 @@ ReturnCode proc_upd_psafe_ps (PstateSuperStructure *pss,
/// ------------------------------------------------------------
-/// \brief Update Floor_pstate
+/// \brief Update Floor_pstate
/// \param[inout] *pss => pointer to pstate superstructure
/// \param[in] *attr => pointer to attribute list structure
/// ------------------------------------------------------------
OpenPOWER on IntegriCloud