Skip to content

Commit dce27a0

Browse files
brs332wghoffa
authored andcommitted
Change mss::pos for DIMM to leverage FAPI_POS
Change-Id: Ibc29722256387d599da0d624e014de2be4f67d7f Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/34734 Reviewed-by: Louis Stermole <stermole@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: STEPHEN GLANCY <sglancy@us.ibm.com> Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com> Reviewed-by: ANDRE A. MARIN <aamarin@us.ibm.com> Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com> Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/34739 Reviewed-by: Hostboot Team <hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
1 parent 3088c3d commit dce27a0

File tree

1 file changed

+30
-31
lines changed
  • src/import/chips/p9/procedures/hwp/memory/lib/utils

1 file changed

+30
-31
lines changed

src/import/chips/p9/procedures/hwp/memory/lib/utils/pos.H

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/* */
66
/* OpenPOWER HostBoot Project */
77
/* */
8-
/* Contributors Listed Below - COPYRIGHT 2015,2016 */
8+
/* Contributors Listed Below - COPYRIGHT 2015,2017 */
99
/* [+] International Business Machines Corp. */
1010
/* */
1111
/* */
@@ -84,85 +84,86 @@ class posTraits<fapi2::TARGET_TYPE_PROC_CHIP>
8484
template< fapi2::TargetType T, typename TT = posTraits<T> >
8585
inline typename TT::pos_type pos(const fapi2::Target<T>& i_target)
8686
{
87-
typename TT::pos_type i_pos = 0;
87+
typename TT::pos_type l_pos = 0;
8888

8989
// Don't use FAPI_TRY as you'll mess up fapi2::current_err which
9090
// lmits where this can be used.
91-
if (FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS, i_target, i_pos) != fapi2::FAPI2_RC_SUCCESS)
91+
if (FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS, i_target, l_pos) != fapi2::FAPI2_RC_SUCCESS)
9292
{
9393
goto fapi_try_exit;
9494
}
9595

96-
return i_pos;
96+
return l_pos;
9797

9898
fapi_try_exit:
9999
// If we can't get our unit position, we're in other trouble
100100
FAPI_ERR("can't get our chip unit position");
101-
102-
// Cronusflex doesn't support Assert.
103-
// Enable once move to dev complete - AAM
104-
#if MOVED_AWAY_FROM_CRONUSFLEX
105101
fapi2::Assert(false);
106-
#endif
107102
return 0;
108103
}
109104

110105
///
111-
/// @brief Return a DIMM's position from a fapi2 target
106+
/// @brief Return a processor's position from a fapi2 target
112107
/// @param[in] i_target a target representing the target in question
113108
/// @return The position relative to the chip
114109
///
115110
template<>
116-
inline posTraits<fapi2::TARGET_TYPE_DIMM>::pos_type pos(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target)
111+
inline posTraits<fapi2::TARGET_TYPE_PROC_CHIP>::pos_type pos(
112+
const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
117113
{
118-
posTraits<fapi2::TARGET_TYPE_DIMM>::pos_type i_pos = 0;
114+
posTraits<fapi2::TARGET_TYPE_PROC_CHIP>::pos_type l_pos = 0;
119115

120-
if (FAPI_ATTR_GET(fapi2::ATTR_POS, i_target, i_pos) != fapi2::FAPI2_RC_SUCCESS)
116+
if (FAPI_ATTR_GET(fapi2::ATTR_POS, i_target, l_pos) != fapi2::FAPI2_RC_SUCCESS)
121117
{
122118
goto fapi_try_exit;
123119
}
124120

125-
return i_pos;
121+
return l_pos;
126122

127123
fapi_try_exit:
128124
// If we can't get our position, we're in other trouble
129125
FAPI_ERR("can't get our position");
130-
#if MOVED_AWAY_FROM_CRONUSFLEX
131126
fapi2::Assert(false);
132-
#endif
133127
return 0;
134128

135129
}
136130

137131
///
138-
/// @brief Return a processor's position from a fapi2 target
132+
/// @brief Return a DIMM's position from a fapi2 target
139133
/// @param[in] i_target a target representing the target in question
140134
/// @return The position relative to the chip
141135
///
142136
template<>
143-
inline posTraits<fapi2::TARGET_TYPE_PROC_CHIP>::pos_type pos(
144-
const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
137+
inline posTraits<fapi2::TARGET_TYPE_DIMM>::pos_type pos(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target)
145138
{
146-
posTraits<fapi2::TARGET_TYPE_PROC_CHIP>::pos_type i_pos = 0;
139+
// Proc 0 is DIMM 0-15, proc 2 is 64-79 - 64 is the stride between processors
140+
constexpr uint64_t DIMM_STRIDE_PER_PROC = 64;
141+
constexpr uint64_t TOTAL_DIMM = MC_PER_MODULE * MCS_PER_MC * PORTS_PER_MCS * MAX_DIMM_PER_PORT;
142+
143+
posTraits<fapi2::TARGET_TYPE_DIMM>::pos_type l_pos = 0;
144+
145+
// Using fapi2 rather than mss::find as this is pretty low level stuff.
146+
const auto l_proc_pos =
147+
mss::template pos(i_target.getParent<fapi2::TARGET_TYPE_MCA>().getParent<fapi2::TARGET_TYPE_PROC_CHIP>());
147148

148-
if (FAPI_ATTR_GET(fapi2::ATTR_POS, i_target, i_pos) != fapi2::FAPI2_RC_SUCCESS)
149+
if (FAPI_ATTR_GET(fapi2::ATTR_FAPI_POS, i_target, l_pos) != fapi2::FAPI2_RC_SUCCESS)
149150
{
150151
goto fapi_try_exit;
151152
}
152153

153-
return i_pos;
154+
// To get the FAPI_POS to the equivilent of ATTR_POS, we need to normalize the fapi_pos value
155+
// to the processor (stride across which ever processor we're on) and then add in the delta
156+
// per processor as ATTR_POS isn't processor relative (delta is the total dimm on a processor)
157+
return ((l_pos - (l_proc_pos * DIMM_STRIDE_PER_PROC)) % TOTAL_DIMM) + (TOTAL_DIMM * l_proc_pos);
154158

155159
fapi_try_exit:
156160
// If we can't get our position, we're in other trouble
157-
FAPI_ERR("can't get our position");
158-
#if MOVED_AWAY_FROM_CRONUSFLEX
161+
FAPI_ERR("can't get our fapi position");
159162
fapi2::Assert(false);
160-
#endif
161163
return 0;
162164

163165
}
164166

165-
166167
///
167168
/// @brief Return a target's relative position from a fapi2 target
168169
/// @tparam T the fapi2::TargetType
@@ -234,23 +235,21 @@ relative_pos<fapi2::TARGET_TYPE_MCS>(const fapi2::Target<fapi2::TARGET_TYPE_MCA>
234235
template< fapi2::TargetType T, typename TT = posTraits<T> >
235236
inline uint32_t fapi_pos(const fapi2::Target<T>& i_target)
236237
{
237-
uint32_t i_pos = 0;
238+
uint32_t l_pos = 0;
238239

239240
// Don't use FAPI_TRY as you'll mess up fapi2::current_err which
240241
// lmits where this can be used.
241-
if (FAPI_ATTR_GET(fapi2::ATTR_FAPI_POS, i_target, i_pos) != fapi2::FAPI2_RC_SUCCESS)
242+
if (FAPI_ATTR_GET(fapi2::ATTR_FAPI_POS, i_target, l_pos) != fapi2::FAPI2_RC_SUCCESS)
242243
{
243244
goto fapi_try_exit;
244245
}
245246

246-
return i_pos;
247+
return l_pos;
247248

248249
fapi_try_exit:
249250
// If we can't get our fapi position, we're in other trouble
250251
FAPI_ERR("can't get our fapi position");
251-
#if MOVED_AWAY_FROM_CRONUSFLEX
252252
fapi2::Assert(false);
253-
#endif
254253
return 0;
255254
}
256255

0 commit comments

Comments
 (0)