summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat/p9/prdfP9Proc.C
blob: af1d304ce7753f99f86c07237770d7536b95cf8b (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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/p9/prdfP9Proc.C $               */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,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                                                     */

/** @file  prdfP9Proc.C
 *  @brief Contains all the plugin code for the PRD P9 Proc
 */

// Framework includes
#include <prdfPluginDef.H>
#include <iipServiceDataCollector.h>
#include <prdfExtensibleChip.H>
#include <prdfPluginMap.H>
#include <xspprdService.h>

#ifdef __HOSTBOOT_MODULE
#include <prdfPlatServices_ipl.H>
#include <prdfErrlUtil.H>
#include <sbeio/sbeioif.H>
#endif

#ifdef __HOSTBOOT_RUNTIME
#include <prdfP9PmRecovery.H>
#endif

#include <prdfLaneRepair.H>

// Platform includes

using namespace TARGETING;

namespace PRDF
{

using namespace PlatServices;

namespace Proc
{

//##############################################################################
//
//                             Special plugins
//
//##############################################################################

/**
 * @brief  Used when the chip has a CHECK_STOP or UNIT_CS attention to check for
 *         the presence of recoverable attentions.
 * @param  i_chip         A P9 chip.
 * @param  o_hasRecovered True if the chip has a recoverable attention.
 * @return SUCCESS
 */
int32_t CheckForRecovered( ExtensibleChip * i_chip,
                           bool & o_hasRecovered )
{
    o_hasRecovered = false;

    int32_t l_rc = SUCCESS;

    SCAN_COMM_REGISTER_CLASS * l_grer = i_chip->getRegister("GLOBAL_RE_FIR");
    l_rc = l_grer->Read();

    if ( SUCCESS != l_rc )
    {
        PRDF_ERR("[CheckForRecovered] GLOBAL_RE_FIR read failed"
                 "for 0x%08x", i_chip->GetId());
    }
    else if ( 0 != l_grer->GetBitFieldJustified(1,55) )
    {
        o_hasRecovered = true;
    }

    return SUCCESS;
}
PRDF_PLUGIN_DEFINE_NS( p9_nimbus,  Proc, CheckForRecovered );
PRDF_PLUGIN_DEFINE_NS( p9_cumulus, Proc, CheckForRecovered );

//------------------------------------------------------------------------------
/**
 * @brief Used when the chip is queried, by the fabric domain, for RECOVERED
 * attentions to assign a severity to the attention for sorting.
 * @param[in]   i_chip - P8 chip
 * @param[out]  o_sev - Priority order (lowest to highest):
 *  1 - Core chiplet checkstop
 *  2 - Core chiplet error
 *  3 - PCB chiplet error (TOD logic)
 *  4 - Other error
 *  5 - Memory controller chiplet
 *
 * @return SUCCESS
 *
 */
int32_t CheckForRecoveredSev(ExtensibleChip * i_chip, uint32_t & o_sev)
{
    int32_t o_rc = SUCCESS;
    bool l_runtime = atRuntime();

    SCAN_COMM_REGISTER_CLASS * l_rer = NULL;

    SCAN_COMM_REGISTER_CLASS * l_unitxstp = NULL;
    if ( l_runtime )
    {
        l_unitxstp = i_chip->getRegister("GLOBAL_UCS_FIR");
        o_rc |= l_unitxstp->Read();
    }

    l_rer = i_chip->getRegister("GLOBAL_RE_FIR");
    o_rc |= l_rer->Read();

    if (o_rc)
    {
        PRDF_ERR( "[CheckForRecoveredSev] SCOM fail on 0x%08x rc=%x",
                  i_chip->GetId(), o_rc);
        return o_rc;
    }

    if (l_rer->GetBitFieldJustified(7,2))
    {
        // errors from MC chiplets
        o_sev = 5;
    }
    else if(l_rer->GetBitFieldJustified(2, 4) ||
            l_rer->GetBitFieldJustified(9, 4) ||
            l_rer->GetBitFieldJustified(13,3) ||
            l_rer->IsBitSet(6))
    {
        // errors from PB, Xbus, OB, or PCI chiplets
        o_sev = 4;
    }
    else if(l_rer->IsBitSet(1))
    {
        // error from TP
        o_sev = 3;
    }
    else if (l_rer->GetBitFieldJustified(16,6))
    {
        // error from EQ
        o_sev = 2;
    }
    else if(l_runtime &&
            (l_rer->GetBitFieldJustified(32,24) &
             l_unitxstp->GetBitFieldJustified(32,24)) == 0 )
    {
        // core recoverable
        o_sev = 2;
    }
    else
    {
        // core checkstop
        o_sev = 1;
    }

    return SUCCESS;

}
PRDF_PLUGIN_DEFINE_NS( p9_nimbus,  Proc, CheckForRecoveredSev );
PRDF_PLUGIN_DEFINE_NS( p9_cumulus, Proc, CheckForRecoveredSev );

/** @func GetCheckstopInfo
 *  To be called from the fabric domain to gather Checkstop information.  This
 *  information is used in a sorting algorithm.
 *
 *  This is a plugin function: GetCheckstopInfo
 *
 *  @param i_chip - The chip.
 *  @param o_wasInternal - True if this chip has an internal checkstop.
 *  @param o_externalChips - List of external fabrics driving checkstop.
 *  @param o_wofValue - Current WOF value (unused for now).
 */
int32_t GetCheckstopInfo( ExtensibleChip * i_chip,
                          bool & o_wasInternal,
                          TargetHandleList & o_externalChips,
                          uint64_t & o_wofValue )
{
    // Clear parameters.
    o_wasInternal = false;
    o_externalChips.clear();
    o_wofValue = 0;

    SCAN_COMM_REGISTER_CLASS * l_globalFir =
      i_chip->getRegister("GLOBAL_CS_FIR");

    SCAN_COMM_REGISTER_CLASS * l_pbXstpFir =
      i_chip->getRegister("N3_CHIPLET_CS_FIR");

    SCAN_COMM_REGISTER_CLASS * l_extXstpFir =
      i_chip->getRegister("PBEXTFIR");

    int32_t o_rc = SUCCESS;
    o_rc |= l_globalFir->Read();
    o_rc |= l_pbXstpFir->Read();
    o_rc |= l_extXstpFir->Read();

    if(o_rc)
    {
        PRDF_ERR( "[GetCheckstopInfo] SCOM fail on 0x%08x rc=%x",
                  i_chip->GetId(), o_rc);
        return o_rc;
    }

    uint8_t l_connectedXstps = l_extXstpFir->GetBitFieldJustified(0,7);

    bool pbXstpFromOtherChip = l_pbXstpFir->IsBitSet(2);

    if ((0 != l_globalFir->GetBitFieldJustified(0,56)) &&
        (!l_globalFir->IsBitSet(5) || !pbXstpFromOtherChip))
        o_wasInternal = true;

    // Get connected chips.
    uint32_t l_positions[] =
    {
        0, // bit 0 - XBUS 0
        1, // bit 1 - XBUS 1
        2, // bit 2 - XBUS 2
        0, // bit 3 - OBUS 0
        1, // bit 4 - OBUS 1
        2, // bit 5 - OBUS 2
        3  // bit 6 - OBUS 3
    };

    for (uint8_t i = 0, j = 0x40; i < 7; i++, j >>= 1)
    {
        if (0 != (j & l_connectedXstps))
        {
            TargetHandle_t l_connectedFab =
              getConnectedPeerProc(i_chip->GetChipHandle(),
                                   i<3 ? TYPE_XBUS : TYPE_OBUS,
                                   l_positions[i]);

            if (NULL != l_connectedFab)
            {
                o_externalChips.push_back(l_connectedFab);
            }
        }
    }

    // Read WOF value.
    SCAN_COMM_REGISTER_CLASS * l_wof = i_chip->getRegister("TODWOF");
    o_rc |= l_wof->Read();

    if(o_rc)
    {
        PRDF_ERR( "[GetCheckstopInfo] SCOM fail on 0x%08x rc=%x",
                  i_chip->GetId(), o_rc);
        return o_rc;
    }

    o_wofValue = l_wof->GetBitFieldJustified(0,64);

    return SUCCESS;

}
PRDF_PLUGIN_DEFINE_NS( p9_nimbus,  Proc, GetCheckstopInfo );
PRDF_PLUGIN_DEFINE_NS( p9_cumulus, Proc, GetCheckstopInfo );

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

int32_t checkNimbusDD10( ExtensibleChip * i_chip,
                         STEP_CODE_DATA_STRUCT & io_sc )
{
    TargetHandle_t trgt = i_chip->getTrgt();

    // It does look a little weird to return FAIL when the chip is Nimbus DD1.0,
    // but the purpose of this plugin is to give a non-SUCCESS return code to
    // the 'try' statement in rule code so that it will execute actions
    // specifically for Nimbus DD1.0 in the default branch of the 'try'.
    // statement.

    if ( MODEL_NIMBUS == getChipModel(trgt) && 0x10 == getChipLevel(trgt) )
        return FAIL;
    else
        return SUCCESS;
}
PRDF_PLUGIN_DEFINE_NS( p9_nimbus, Proc, checkNimbusDD10 );

int32_t checkNotNimbusDD10( ExtensibleChip * i_chip,
                            STEP_CODE_DATA_STRUCT & io_sc )
{
    // Return the opposite of checkNimbusDD10().
    return (FAIL == checkNimbusDD10(i_chip, io_sc)) ? SUCCESS : FAIL;
}
PRDF_PLUGIN_DEFINE_NS( p9_nimbus, Proc, checkNotNimbusDD10 );

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

int32_t isHostAttnFirAccessible(ExtensibleChip * i_chip, bool & o_isOkToAccess)
{
    o_isOkToAccess = false;

    // Host Processor side can always access the 'host' attn reg
    // The FSP can not access it during IPL steps 15 thru 16.2
    // Host attn is only needed for MS diag and runtime case.

    if ( (true == atRuntime())
#ifdef __HOSTBOOT_MODULE
          || (true == isInMdiaMode())
#endif
       )
    {
        o_isOkToAccess = true;
    }

    return SUCCESS;
}
PRDF_PLUGIN_DEFINE_NS( p9_nimbus,  Proc, isHostAttnFirAccessible );
PRDF_PLUGIN_DEFINE_NS( p9_cumulus, Proc, isHostAttnFirAccessible );

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

int32_t isUcsFirAccessible(ExtensibleChip * i_chip, bool & o_isOkToAccess)
{
    // Host Processor side can always access the 'unitCS' reg
    // The FSP can not access it during IPL steps 15 thru 16.2
    o_isOkToAccess = atRuntime();


#ifdef CONFIG_ENABLE_CHECKSTOP_ANALYSIS
    if (false == o_isOkToAccess)
    {
        // For checkstop analysis (non-FSP systems), we
        // already collected registers in FIRDATA. Hence, we
        // can attempt reading the unit CS FIR from this data.
        Target   *l_sys = NULL;
        targetService().getTopLevelTarget( l_sys );
        assert(l_sys != NULL);

        // ATTN code sets an attribute to indicate we are
        // doing the analysis of FIR data from prior failure.
        uint8_t l_doingAnalysis =
                           CHKSTOP_ANALYSIS_ON_STARTUP_NOT_ANALYZING_DEFAULT;
        l_sys->tryGetAttr<ATTR_CHKSTOP_ANALYSIS_ON_STARTUP>(l_doingAnalysis);

        if (CHKSTOP_ANALYSIS_ON_STARTUP_ANALYZING_CHECKSTOP == l_doingAnalysis)
        {
            o_isOkToAccess = true;
        }
    }
#endif  // CONFIG_ENABLE_CHECKSTOP_ANALYSIS


    return SUCCESS;
}
PRDF_PLUGIN_DEFINE_NS( p9_nimbus,  Proc, isUcsFirAccessible );
PRDF_PLUGIN_DEFINE_NS( p9_cumulus, Proc, isUcsFirAccessible );

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

/** Call HW server rtn for Deadman Timer */
int32_t handleDeadmanTimer( ExtensibleChip * i_chip,
                            STEP_CODE_DATA_STRUCT & io_sc )
{
    TARGETING::TargetHandle_t  l_target = i_chip->getTrgt();


    // This routine adds FFDC information to the elog
    // and will also do the callouts as needed.
    deadmanTimerFFDC( l_target, io_sc );

    return SUCCESS;
}
PRDF_PLUGIN_DEFINE_NS( p9_nimbus,  Proc, handleDeadmanTimer );
PRDF_PLUGIN_DEFINE_NS( p9_cumulus, Proc, handleDeadmanTimer );

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

/** Call hostboot to indicate SBE bad, extract FFDC and handle recovery */
int32_t handleSbeVital( ExtensibleChip * i_chip,
                        STEP_CODE_DATA_STRUCT & io_sc )
{
    // Hostboot code is suppose to handle all Vital attentions
    // and initiate recovery with FSP,etc... if needed
#ifdef __HOSTBOOT_MODULE
    TARGETING::TargetHandle_t  l_target = i_chip->getTrgt();
    SCAN_COMM_REGISTER_CLASS * l_tpmask_or;

   PRDF_ERR("Invoking HB SBE vital routine");
   errlHndl_t  l_elog = SBEIO::handleVitalAttn( l_target );

    // commit any failures
    if (nullptr != l_elog)
    {
        // Need to MASK bit 26 of TPLFIR to avoid getting this again
        // (will use the 'OR' reg for doing the masking)
        l_tpmask_or = i_chip->getRegister("TP_LFIR_MASK_OR");
        l_tpmask_or->clearAllBits();
        l_tpmask_or->SetBit( 26  );

        int32_t l_rc = l_tpmask_or->Write();
        if (l_rc != SUCCESS)
        {   // we are probably stuck in an infinite loop now
            PRDF_ERR("Failed(%d) masking SBE bit for chip: 0x%08x",
                      l_rc,  i_chip->getHuid() );
        }

        PRDF_ERR("handleVitalAttn failure");
        PRDF_COMMIT_ERRL( l_elog, ERRL_ACTION_REPORT );
    }
#endif

    return SUCCESS;
}
PRDF_PLUGIN_DEFINE_NS( p9_nimbus,  Proc, handleSbeVital );
PRDF_PLUGIN_DEFINE_NS( p9_cumulus, Proc, handleSbeVital );

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

/**
 * @brief  Used when the chip has a CHECK_STOP to see if there
 *         is also a UNIT_CS present
 * @param  i_chip         A P9 chip.
 * @param  o_hasUcs True if the chip has a UNIT CS attention.
 * @return SUCCESS
 */
int32_t CheckForUnitCs( ExtensibleChip * i_chip,
                        bool & o_hasUcs )
{
    o_hasUcs = false;

    int32_t l_rc = SUCCESS;

    SCAN_COMM_REGISTER_CLASS * l_gUcsR = i_chip->getRegister("GLOBAL_UCS_FIR");
    l_rc = l_gUcsR->Read();

    if ( SUCCESS != l_rc )
    {
        PRDF_ERR("[CheckForUnitCs] GLOBAL_UCS_FIR read failed"
                 "for 0x%08x", i_chip->GetId());
    }
    else if ( 0 != l_gUcsR->GetBitFieldJustified(1,55) )
    {
        o_hasUcs = true;
    }

    return SUCCESS;
}
PRDF_PLUGIN_DEFINE_NS( p9_nimbus,  Proc, CheckForUnitCs );
PRDF_PLUGIN_DEFINE_NS( p9_cumulus, Proc, CheckForUnitCs );

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

/**
 * @brief Recovery actions for a power management STOP failure. Collects FFDC,
 *        runtime deconfigures lost cores, and makes appropriate callouts as
 *        determined by the p9_pm_callout procedure.
 * @param  i_chip         A P9 chip.
 * @param  io_sc          step code data struct
 * @return SUCCESS
 */
int32_t PmRecovery( ExtensibleChip * i_chip,
                    STEP_CODE_DATA_STRUCT & io_sc )
{

#ifdef __HOSTBOOT_RUNTIME

    if ( pmRecovery(i_chip, io_sc) != SUCCESS )
    {
        PRDF_ERR("[PmRecovery] failed for 0x%08x", i_chip->GetId());
    }

#else

    PRDF_ERR( "[PmRecovery] not expected outside of HB runtime" );
    io_sc.service_data->SetCallout(LEVEL2_SUPPORT, MRU_HIGH);
    io_sc.service_data->SetCallout(i_chip->getTrgt());

#endif

    return SUCCESS;
}
PRDF_PLUGIN_DEFINE_NS( p9_nimbus,  Proc, PmRecovery );
PRDF_PLUGIN_DEFINE_NS( p9_cumulus, Proc, PmRecovery );

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

/**
 * @brief  Callout a bus interface (i.e. XBUS, OBUS, DMI, etc.)
 * @param  i_chip PROC chip.
 * @param  i_type The bus endpoint type.
 * @param  i_pos  The bus endpoint position relative to the processor.
 * @param  io_sc  The step code data struct.
 * @return SUCCESS
 */
int32_t calloutBusInterface( ExtensibleChip * i_chip, TARGETING::TYPE i_type,
                             uint32_t i_pos, STEP_CODE_DATA_STRUCT & io_sc )
{
    ExtensibleChip * endPoint = getConnectedChild( i_chip, i_type, i_pos );
    if ( nullptr == endPoint )
    {
        PRDF_ERR( "[calloutBusInterface] connection lookup failed: 0x%08x "
                  "0x%02x %d", i_chip->getHuid(), i_type, i_pos );
        io_sc.service_data->SetCallout(LEVEL2_SUPPORT, MRU_HIGH);
        io_sc.service_data->SetCallout(i_chip->getTrgt());
        io_sc.service_data->SetThresholdMaskId(0);
    }
    else
    {
        LaneRepair::calloutBusInterface( endPoint, io_sc, MRU_LOW );
    }

    return SUCCESS;
}
PRDF_PLUGIN_DEFINE_NS( p9_nimbus,  Proc, calloutBusInterface );
PRDF_PLUGIN_DEFINE_NS( p9_cumulus, Proc, calloutBusInterface );

#define PLUGIN_CALLOUT_INTERFACE( TYPE, POS ) \
int32_t calloutBusInterface_##TYPE##POS( ExtensibleChip * i_chip, \
                                         STEP_CODE_DATA_STRUCT & io_sc ) \
{ \
    return calloutBusInterface( i_chip, TYPE_##TYPE, POS, io_sc ); \
} \
PRDF_PLUGIN_DEFINE_NS( p9_nimbus,  Proc, calloutBusInterface_##TYPE##POS ); \
PRDF_PLUGIN_DEFINE_NS( p9_cumulus, Proc, calloutBusInterface_##TYPE##POS );

PLUGIN_CALLOUT_INTERFACE( XBUS, 0 )
PLUGIN_CALLOUT_INTERFACE( XBUS, 1 )
PLUGIN_CALLOUT_INTERFACE( XBUS, 2 )
PLUGIN_CALLOUT_INTERFACE( OBUS, 0 )
PLUGIN_CALLOUT_INTERFACE( OBUS, 1 )
PLUGIN_CALLOUT_INTERFACE( OBUS, 2 )
PLUGIN_CALLOUT_INTERFACE( OBUS, 3 )

#undef PLUGIN_CALLOUT_INTERFACE

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

} // end namespace Proc

} // end namespace PRDF
OpenPOWER on IntegriCloud