|
| 1 | +/* IBM_PROLOG_BEGIN_TAG */ |
| 2 | +/* This is an automatically generated prolog. */ |
| 3 | +/* */ |
| 4 | +/* $Source: src/import/chips/p9/procedures/hwp/pm/p9_query_cache_access_state.C $ */ |
| 5 | +/* */ |
| 6 | +/* OpenPOWER HostBoot Project */ |
| 7 | +/* */ |
| 8 | +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ |
| 9 | +/* [+] International Business Machines Corp. */ |
| 10 | +/* */ |
| 11 | +/* */ |
| 12 | +/* Licensed under the Apache License, Version 2.0 (the "License"); */ |
| 13 | +/* you may not use this file except in compliance with the License. */ |
| 14 | +/* You may obtain a copy of the License at */ |
| 15 | +/* */ |
| 16 | +/* http://www.apache.org/licenses/LICENSE-2.0 */ |
| 17 | +/* */ |
| 18 | +/* Unless required by applicable law or agreed to in writing, software */ |
| 19 | +/* distributed under the License is distributed on an "AS IS" BASIS, */ |
| 20 | +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ |
| 21 | +/* implied. See the License for the specific language governing */ |
| 22 | +/* permissions and limitations under the License. */ |
| 23 | +/* */ |
| 24 | +/* IBM_PROLOG_END_TAG */ |
| 25 | +/// |
| 26 | +/// @file p9_query_cache_access_state.C |
| 27 | +/// @brief Check the stop level for the EX caches and sets boolean scomable parameters |
| 28 | +/// |
| 29 | +// *HWP HWP Owner: Christina Graves <clgraves@us.ibm.com> |
| 30 | +// *HWP Backup HWP Owner: Greg Still <stillgs@us.ibm.com> |
| 31 | +// *HWP FW Owner: Sangeetha T S <sangeet2@in.ibm.com> |
| 32 | +// *HWP Team: PM |
| 33 | +// *HWP Level: 2 |
| 34 | +// *HWP Consumed by: FSP:HS:SBE |
| 35 | +/// |
| 36 | +/// |
| 37 | +/// |
| 38 | +/// @verbatim |
| 39 | +/// High-level procedure flow: |
| 40 | +/// - For the quad target, read the Stop State History register in the PPM |
| 41 | +/// and use the actual stop level to determine if the quad has power and is being |
| 42 | +/// clocked. |
| 43 | +/// @endverbatim |
| 44 | +/// |
| 45 | +//------------------------------------------------------------------------------ |
| 46 | + |
| 47 | + |
| 48 | +// ---------------------------------------------------------------------- |
| 49 | +// Includes |
| 50 | +// ---------------------------------------------------------------------- |
| 51 | + |
| 52 | +#include <p9_quad_scom_addresses.H> |
| 53 | +#include <p9_query_cache_access_state.H> |
| 54 | + |
| 55 | +// ---------------------------------------------------------------------- |
| 56 | +// Constants |
| 57 | +// ---------------------------------------------------------------------- |
| 58 | + |
| 59 | +const uint32_t eq_clk_l2_pos[] = {8, 9}; |
| 60 | +const uint32_t eq_clk_l3_pos[] = {6, 7}; |
| 61 | +const uint32_t SSH_REG_STOP_LEVEL = 8; |
| 62 | +const uint32_t SSH_REG_STOP_LEVEL_LEN = 4; |
| 63 | + |
| 64 | +// ---------------------------------------------------------------------- |
| 65 | +// Procedure Function |
| 66 | +// ---------------------------------------------------------------------- |
| 67 | + |
| 68 | +fapi2::ReturnCode |
| 69 | +p9_query_cache_access_state( |
| 70 | + const fapi2::Target<fapi2::TARGET_TYPE_EQ>& i_target, |
| 71 | + bool& o_l2_is_scomable, |
| 72 | + bool& o_l2_is_scannable, |
| 73 | + bool& o_l3_is_scomable, |
| 74 | + bool& o_l3_is_scannable) |
| 75 | +{ |
| 76 | + fapi2::buffer<uint64_t> l_qsshsrc; |
| 77 | + uint32_t l_quadStopLevel = 0; |
| 78 | + fapi2::buffer<uint64_t> l_data64; |
| 79 | + bool l_is_scomable = 1; |
| 80 | + uint8_t l_chpltNumber = 0; |
| 81 | + uint32_t l_exPos = 0; |
| 82 | + uint8_t l_execution_platform = 0; |
| 83 | + uint32_t l_stop_state_reg = 0; |
| 84 | + const fapi2::Target<fapi2::TARGET_TYPE_SYSTEM> FAPI_SYSTEM; |
| 85 | + |
| 86 | + FAPI_INF("> p9_query_cache_access_state..."); |
| 87 | + |
| 88 | + //Get the stop state from the SSHRC in the EQPPM |
| 89 | + //First figure out whether we should use the C_PPM_SSHFSP (if FSP platform) or C_PPM_SSHHYP (if HOST platform) |
| 90 | + FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_EXECUTION_PLATFORM, FAPI_SYSTEM, l_execution_platform), |
| 91 | + "Error: Failed to get platform"); |
| 92 | + |
| 93 | + if (l_execution_platform == 0x02) |
| 94 | + { |
| 95 | + l_stop_state_reg = C_PPM_SSHFSP; |
| 96 | + } |
| 97 | + else |
| 98 | + { |
| 99 | + l_stop_state_reg = C_PPM_SSHHYP; |
| 100 | + } |
| 101 | + |
| 102 | + FAPI_TRY(fapi2::getScom(i_target, l_stop_state_reg, l_qsshsrc), "Error reading data from QPPM SSHSRC"); |
| 103 | + |
| 104 | + //A unit is scommable if clocks are running |
| 105 | + //A unit is scannable if the unit is powered up |
| 106 | + |
| 107 | + //Extract the core stop state |
| 108 | + l_qsshsrc.extractToRight<uint32_t>(l_quadStopLevel, SSH_REG_STOP_LEVEL, SSH_REG_STOP_LEVEL_LEN); |
| 109 | + |
| 110 | + FAPI_DBG("EQ Stop State: EQ(%d)", l_quadStopLevel); |
| 111 | + |
| 112 | + //Set all attribtes to 1, then clear them based on the stop state |
| 113 | + o_l2_is_scomable = 1; |
| 114 | + o_l2_is_scannable = 1; |
| 115 | + o_l3_is_scomable = 1; |
| 116 | + o_l3_is_scannable = 1; |
| 117 | + |
| 118 | + // STOP8 - Half Quad Deep Sleep |
| 119 | + // VSU, ISU are powered off |
| 120 | + // IFU, LSU are powered off |
| 121 | + // PC, Core EPS are powered off |
| 122 | + // L20-EX0 is clocked off if both cores are >= 8 |
| 123 | + // L20-EX1 is clocked off if both cores are >= 8 |
| 124 | + if (l_quadStopLevel >= 8) |
| 125 | + { |
| 126 | + o_l2_is_scomable = 0; |
| 127 | + } |
| 128 | + |
| 129 | + // STOP9 - Fast Winkle (lab use only) |
| 130 | + // Both cores and cache are clocked off |
| 131 | + if (l_quadStopLevel >= 9) |
| 132 | + { |
| 133 | + o_l3_is_scomable = 0; |
| 134 | + } |
| 135 | + |
| 136 | + // STOP11 - Deep Winkle |
| 137 | + // Both cores and cache are powered off |
| 138 | + if (l_quadStopLevel >= 11) |
| 139 | + { |
| 140 | + o_l2_is_scannable = 0; |
| 141 | + o_l3_is_scannable = 0; |
| 142 | + } |
| 143 | + |
| 144 | + //Read clock status to confirm stop state history is accurate |
| 145 | + //If we trust the stop state history, this could be removed to save on code size |
| 146 | + //Compare Hardware status vs stop state status. If there is a mismatch the HW value overrides the stop state |
| 147 | + |
| 148 | + FAPI_TRY(fapi2::getScom(i_target, EQ_CLOCK_STAT_SL, l_data64), "Error reading data from EQ_CLOCK_STAT_SL"); |
| 149 | + |
| 150 | + FAPI_TRY(FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS, i_target, l_chpltNumber), |
| 151 | + "Error: Failed to get the position of the EX:0x%08X", i_target); |
| 152 | + l_exPos = l_chpltNumber % 2; |
| 153 | + |
| 154 | + l_is_scomable = !l_data64.getBit(eq_clk_l2_pos[l_exPos]); |
| 155 | + |
| 156 | + if (o_l2_is_scomable != l_is_scomable) |
| 157 | + { |
| 158 | + FAPI_INF("Clock status didn't match stop state, overriding is_scomable status"); |
| 159 | + o_l2_is_scomable = l_is_scomable; |
| 160 | + } |
| 161 | + |
| 162 | + l_is_scomable = !l_data64.getBit(eq_clk_l3_pos[l_exPos]); |
| 163 | + |
| 164 | + if (o_l3_is_scomable != l_is_scomable) |
| 165 | + { |
| 166 | + FAPI_INF("Clock status didn't match stop state, overriding is_scomable status"); |
| 167 | + o_l3_is_scomable = l_is_scomable; |
| 168 | + } |
| 169 | + |
| 170 | +fapi_try_exit: |
| 171 | + FAPI_INF("< p9_query_cache_access_state..."); |
| 172 | + return fapi2::current_err; |
| 173 | +} |
0 commit comments