summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/plat/cen/prdfCenMembuf.C
blob: 112a9d157aa3939ccb226ea55e6953919977e18c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/plat/cen/prdfCenMembuf.C $                  */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2018                             */
/* [+] 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                                                     */

// Framework includes
#include <iipServiceDataCollector.h>
#include <prdfExtensibleChip.H>
#include <prdfPluginDef.H>
#include <prdfPluginMap.H>
#include <UtilHash.H> // for Util::hashString

// Platform includes

using namespace TARGETING;

namespace PRDF
{

using namespace PlatServices;

namespace cen_centaur
{

//##############################################################################
//
//                                  MBSFIR
//
//##############################################################################

/**
 * @brief  Captures trapped address for L4 cache ECC errors.
 * @param  i_chip Centaur chip
 * @param  io_sc  Step code data struct
 * @return SUCCESS always
 * @note   This function also reset ECC trapped address regsiters so that HW can
 *         capture address for next L4 ecc error.
 */
int32_t CaptureL4CacheErr( ExtensibleChip * i_chip,
                           STEP_CODE_DATA_STRUCT & io_sc )
{
    #define PRDF_FUNC "[CaptureL4CacheErr] "

    do
    {
        i_chip->CaptureErrorData( io_sc.service_data->GetCaptureData(),
                                  Util::hashString( "L4CacheErr" ) );

        // NOTE: FW should write on MBCELOG so that HW can capture
        // address for next L4 CE error.

        // NOTE: Line delete feature for L4 cache is not available yet, but if
        // it is ever supported, we need to make sure following should be the
        // order of events:
        // 1. Capture group of registers associated with group L4CacheErr
        // 2. do L4 line delete.
        // 3. clear register MBCELOG

        // If we clear register MBCELOG before doing line delete, it is possible
        // that hardware procedures shall run into erroneous scenarios. One
        // probable order of events from PRDF's perspective which can cause
        // this is below:
        // 1. Receives an attention due to failure at cache address X.
        // 2. captures all relevant register including MBCELOG.
        // 3. cleares MBCELOG - i.e. failed address info is lost. HW populates
        //    this register with another L4 CE address say Y.
        // 4. requestes HWP for line delete operation on address X but it
        //    actually  deletes Y. It's because MBCELOG now contains address Y.

        SCAN_COMM_REGISTER_CLASS * mbcelogReg = i_chip->getRegister("MBCELOG");
        mbcelogReg->clearAllBits();

        if ( SUCCESS != mbcelogReg->Write() )
        {
            PRDF_ERR( PRDF_FUNC "MBCELOG write failed for 0x%08x",
                      i_chip->GetId() );
            break;
        }

    } while (0);

    return SUCCESS;

    #undef PRDF_FUNC
}
PRDF_PLUGIN_DEFINE( cen_centaur, CaptureL4CacheErr );

//------------------------------------------------------------------------------

/**
 * @brief  Clears MBS secondary FIR bits which may come up because of primary
 *         MBS/MBI FIR bits.
 * @param  i_chip Centaur chip
 * @param  io_sc  Step code data struct
 * @return SUCCESS always
 */
int32_t ClearMbsSecondaryBits( ExtensibleChip * i_chip,
                               STEP_CODE_DATA_STRUCT & io_sc )
{
    #define PRDF_FUNC "[ClearMbsSecondaryBits] "

    int32_t l_rc = SUCCESS;

    do
    {
        SCAN_COMM_REGISTER_CLASS * mbsFir = i_chip->getRegister("MBSFIR");
        SCAN_COMM_REGISTER_CLASS * mbsFirMask =
                                        i_chip->getRegister("MBSFIR_MASK");
        SCAN_COMM_REGISTER_CLASS * mbsFirAnd =
                                        i_chip->getRegister("MBSFIR_AND");
        l_rc  = mbsFir->Read();
        l_rc |= mbsFirMask->Read();
        if ( SUCCESS != l_rc )
        {
            PRDF_ERR( PRDF_FUNC "MBSFIR/MBSFIR_MASK read failed for 0x%08x",
                      i_chip->GetId() );
            break;
        }

        mbsFirAnd->setAllBits();

        if ( mbsFir->IsBitSet(26) &&
             mbsFir->IsBitSet(9) && !mbsFirMask->IsBitSet(9) )
        {
            mbsFirAnd->ClearBit(26);
        }

        if ( mbsFir->IsBitSet(3) || mbsFir->IsBitSet(4) )
        {
            SCAN_COMM_REGISTER_CLASS * mbiFir = i_chip->getRegister("MBIFIR");
            SCAN_COMM_REGISTER_CLASS * mbiFirMask =
                                            i_chip->getRegister("MBIFIR_MASK");
            l_rc  = mbiFir->Read();
            l_rc |= mbiFirMask->Read();
            if ( SUCCESS != l_rc )
            {
                // Do not break from here, just print error trace. If there are
                // other secondary bits ( e.g. 26, 27 ), we want to clear them.
                PRDF_ERR( PRDF_FUNC "MBIFIR/MASK read failed for 0x%08x",
                          i_chip->GetId() );
            }
            else if ( mbiFir->IsBitSet(0) && !mbiFirMask->IsBitSet(0) )
            {
                mbsFirAnd->ClearBit(3);
                mbsFirAnd->ClearBit(4);
            }
        }

        l_rc = mbsFirAnd->Write();
        if ( SUCCESS != l_rc )
        {
            PRDF_ERR( PRDF_FUNC "MBSFIR_AND write failed for 0x%08x",
                      i_chip->GetId() );
            break;
        }

    } while (0);

    return SUCCESS;

    #undef PRDF_FUNC
}
PRDF_PLUGIN_DEFINE( cen_centaur, ClearMbsSecondaryBits );

//------------------------------------------------------------------------------

/**
 * @brief  Mask MBS secondary FIR bits which may come up because of L4 UE.
 * @param  i_chip Centaur chip
 * @param  io_sc  Step code data struct
 * @return SUCCESS always
 */
int32_t MaskMbsSecondaryBits( ExtensibleChip * i_chip,
                              STEP_CODE_DATA_STRUCT & io_sc  )
{
    #define PRDF_FUNC "[MaskMbsSecondaryBits] "

    int32_t l_rc = SUCCESS;

    do
    {
        SCAN_COMM_REGISTER_CLASS * mbsFirMaskOr =
                                        i_chip->getRegister("MBSFIR_MASK_OR");
        mbsFirMaskOr->SetBit(27);
        l_rc = mbsFirMaskOr->Write();
        if ( SUCCESS != l_rc )
        {
            PRDF_ERR( PRDF_FUNC "MBSFIR_MASK_OR write failedfor 0x%08x",
                      i_chip->GetId() );
            break;
        }

    } while (0);

    return SUCCESS;

    #undef PRDF_FUNC
}
PRDF_PLUGIN_DEFINE( cen_centaur, MaskMbsSecondaryBits );

//------------------------------------------------------------------------------

/**
 * @brief  Clears MBACAL secondary FIR bits which may come up because of MBSFIR.
 * @param  i_chip Centaur chip
 * @param  io_sc  Step code data struct
 * @return SUCCESS always

 */
int32_t ClearMbaCalSecondaryBits( ExtensibleChip * i_chip,
                                  STEP_CODE_DATA_STRUCT & io_sc  )
{
    #define PRDF_FUNC "[ClearMbaCalSecondaryBits] "

    int32_t l_rc = SUCCESS;

    do
    {
        SCAN_COMM_REGISTER_CLASS * mbsFir = i_chip->getRegister("MBSFIR");
        SCAN_COMM_REGISTER_CLASS * mbsFirMask =
                                        i_chip->getRegister("MBSFIR_MASK");
        l_rc  = mbsFir->Read();
        l_rc |= mbsFirMask->Read();
        if ( SUCCESS != l_rc )
        {
            PRDF_ERR( PRDF_FUNC "MBSFIR/MBSFIR_MASK read failed for 0x%08x",
                      i_chip->GetId() );
            break;
        }

        for ( auto & mbaChip : getConnected(i_chip, TYPE_MBA) )
        {
            SCAN_COMM_REGISTER_CLASS * mbaCalFir =
                                mbaChip->getRegister("MBACALFIR");

            if ( SUCCESS != mbaCalFir->Read() )
            {
                // Do not break. Just print error trace and look for
                // other MBA.
                PRDF_ERR( PRDF_FUNC "MBACALFIR read failed for 0x%08x",
                          mbaChip->GetId() );
                continue;
            }

            if ( !( mbaCalFir->IsBitSet(10) || mbaCalFir->IsBitSet(14) ) )
                continue;

            SCAN_COMM_REGISTER_CLASS * mbaCalAndFir =
                                mbaChip->getRegister("MBACALFIR_AND");

            mbaCalAndFir->setAllBits();

            mbaCalAndFir->ClearBit(10);
            mbaCalAndFir->ClearBit(14);

            l_rc = mbaCalAndFir->Write();
            if ( SUCCESS != l_rc )
            {
                // Do not break. Just print error trace and look for
                // other MBA.
                PRDF_ERR( PRDF_FUNC "MBACALFIR_AND write failed for 0x%08x",
                          mbaChip->GetId() );
            }
        }

    } while (0);

    return SUCCESS;

    #undef PRDF_FUNC
}
PRDF_PLUGIN_DEFINE( cen_centaur, ClearMbaCalSecondaryBits );

//------------------------------------------------------------------------------

/**
 * @brief  Mask MBACAL secondary FIR bits which may come up because of L4 UE.
 * @param  i_chip Centaur chip
 * @param  io_sc  Step code data struct
 * @return SUCCESS always
 */
int32_t MaskMbaCalSecondaryBits( ExtensibleChip * i_chip,
                                 STEP_CODE_DATA_STRUCT & io_sc )
{
    #define PRDF_FUNC "[MaskMbaCalSecondaryBits] "

    int32_t l_rc = SUCCESS;

    do
    {
        for ( auto & mbaChip : getConnected(i_chip, TYPE_MBA) )
        {
            SCAN_COMM_REGISTER_CLASS * mbaCalFirMaskOr =
                                mbaChip->getRegister("MBACALFIR_MASK_OR");

            mbaCalFirMaskOr->SetBit(9);
            mbaCalFirMaskOr->SetBit(15);
            l_rc = mbaCalFirMaskOr->Write();
            if ( SUCCESS != l_rc )
            {
                // Do not break. Just print error trace and look for other MBA.
                PRDF_ERR( PRDF_FUNC "MBACALFIR_MASK_OR write failed for 0x%08x",
                          mbaChip->GetId() );
            }
        }

    } while (0);

    return SUCCESS;

    #undef PRDF_FUNC
}
PRDF_PLUGIN_DEFINE( cen_centaur, MaskMbaCalSecondaryBits );

//------------------------------------------------------------------------------

} // end namespace cen_centaur

} // end namespace PRDF

OpenPOWER on IntegriCloud