summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat/p9/prdfP9Ec.C
blob: 60200084d73fbee0f84bb0e2e8b4be537fcf2e46 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/p9/prdfP9Ec.C $                 */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2017                             */
/* [+] 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 <prdfPluginDef.H>
#include <iipServiceDataCollector.h>
#include <prdfExtensibleChip.H>
#include <prdfPluginMap.H>
#include <prdfErrlUtil.H>
#ifdef __HOSTBOOT_RUNTIME
  #include <hwas/common/hwas.H>
  #include <hwas/common/deconfigGard.H>
#endif

using namespace TARGETING;

namespace PRDF
{

using namespace PlatServices;

namespace Ec
{
#ifdef __HOSTBOOT_RUNTIME
void maskIfCoreCs( ExtensibleChip * i_chip )
{
    int32_t l_rc = SUCCESS;

    // Get core global mask register.
    SCAN_COMM_REGISTER_CLASS * coreFirMask =
        i_chip->getRegister("EC_CHIPLET_FIR_MASK");

    SCAN_COMM_REGISTER_CLASS * coreUcsMask =
        i_chip->getRegister("EC_CHIPLET_UCS_FIR_MASK");

    // Read values.
    l_rc  = coreFirMask->Read();
    l_rc |= coreUcsMask->Read();

    if (SUCCESS == l_rc)
    {
        // Mask bit 4 for recoverable and checkstop
        coreFirMask->SetBit(4);
        // Mask bit 0 for local checkstop summary
        coreFirMask->SetBit(0);
        // Mask bit 26 (mask for debug trigger)
        coreFirMask->SetBit(26);

        // Mask bit 1 for Unit checkstop
        coreUcsMask->SetBit(0); // setting bit 0 masks the FIR bit 1.

        coreFirMask->Write();
        coreUcsMask->Write();
    }
}

void rtDcnfgCore( ExtensibleChip * i_chip )
{
    TargetHandle_t coreTgt = i_chip->getTrgt();

    // Get the Global Errorlog
    errlHndl_t globalErrl =
        ServiceGeneratorClass::ThisServiceGenerator().getErrl();

    // Call Deconfig
    errlHndl_t errl = nullptr;
    errl = HWAS::theDeconfigGard().deconfigureTargetAtRuntime( coreTgt,
                       HWAS::DeconfigGard::FULLY_AT_RUNTIME, globalErrl );

    if (errl)
    {
        PRDF_ERR( "[EC::rtDcnfgCore] Deconfig failed on core %x",
                  getHuid(coreTgt));
        PRDF_COMMIT_ERRL( errl, ERRL_ACTION_REPORT );
    }
}
#endif

/**
 * @brief  Plugin function called after analysis is complete but before PRD
 *         exits.
 * @param  i_chip    EC chip.
 * @param  io_sc     The step code data struct.
 * @note   This is especially useful for any analysis that still needs to be
 *         done after the framework clears the FIR bits that were at attention.
 * @return SUCCESS.
 */
int32_t PostAnalysis( ExtensibleChip * i_chip,
                      STEP_CODE_DATA_STRUCT & io_sc )
{
#ifdef __HOSTBOOT_RUNTIME
    if ( io_sc.service_data->isProcCoreCS() )
    {
        ExtensibleChip * n_chip = getNeighborCore(i_chip);
        maskIfCoreCs(i_chip);
        rtDcnfgCore(i_chip);
        if (n_chip != nullptr)
        {
            maskIfCoreCs(n_chip);
        }
    }
    else
    {
        int32_t l_rc = restartTraceArray(i_chip->GetChipHandle());
        if (SUCCESS != l_rc)
        {
            PRDF_ERR( "[EC PostAnalysis HUID: 0x%08x RestartTraceArray failed",
                      i_chip->GetId());
        }

    }
#endif
    return SUCCESS;
}
PRDF_PLUGIN_DEFINE_NS( nimbus_ec,  Ec, PostAnalysis );
PRDF_PLUGIN_DEFINE_NS( cumulus_ec, Ec, PostAnalysis );
PRDF_PLUGIN_DEFINE_NS( axone_ec,   Ec, PostAnalysis );

/**
 * @brief Checks if this core has checkstopped as a side effect of its
 * fused-core neighbor checkstopping
 *
 * @param  i_chip    EC chip.
 * @return TRUE      If UCS root cause is on neighbor
 *         FALSE     If UCS root cause is not on neighbor
 */
bool neighborHasRealCoreCS( ExtensibleChip * i_chip )
{
    int32_t l_rc = SUCCESS;
    bool neighborHasRealCs = false;

    // Check if this core is reporting a neighbor Core Checkstop with no
    // other core checkstop bits of its own
    SCAN_COMM_REGISTER_CLASS *fir  = i_chip->getRegister("COREFIR");
    SCAN_COMM_REGISTER_CLASS *msk  = i_chip->getRegister("COREFIR_MASK");
    SCAN_COMM_REGISTER_CLASS *act0 = i_chip->getRegister("COREFIR_ACT0");
    SCAN_COMM_REGISTER_CLASS *act1 = i_chip->getRegister("COREFIR_ACT1");

    l_rc |=  fir->Read();
    l_rc |=  msk->Read();
    l_rc |= act0->Read();
    l_rc |= act1->Read();

    if (SUCCESS != l_rc)
    {
        PRDF_ERR( "[EC neighborHasRealCoreCS] scom fail on HUID 0x%08x",
                  i_chip->GetId());
        return false;
    }

    uint64_t firBits  =  fir->GetBitFieldJustified(0, 64);
    uint64_t mskBits  =  msk->GetBitFieldJustified(0, 64);
    uint64_t act0Bits = act0->GetBitFieldJustified(0, 64);
    uint64_t act1Bits = act1->GetBitFieldJustified(0, 64);

    if ( ( firBits & ~mskBits & act0Bits & act1Bits ) == 0x0000000000000040ULL )
    {
        // If the only Unit checkstop bit set on this core is bit 57, then
        // we will skip this core and check the neighbor for the true cause

        // Get neighbor core
        ExtensibleChip * n_chip = getNeighborCore( i_chip );
        if (n_chip == nullptr)
            return false;

        // Get neighbor regs
        SCAN_COMM_REGISTER_CLASS * wof;
        uint64_t wofBits;

        fir  = n_chip->getRegister("COREFIR");
        wof  = n_chip->getRegister("COREFIR_WOF");
        msk  = n_chip->getRegister("COREFIR_MASK");
        act1 = n_chip->getRegister("COREFIR_ACT1");

        l_rc |=  fir->Read();
        l_rc |=  wof->Read();
        l_rc |=  msk->Read();
        l_rc |= act1->Read();

        if (SUCCESS != l_rc)
        {
            PRDF_ERR( "[EC neighborHasRealCoreCS] scom fail on HUID 0x%08x",
                      n_chip->GetId());
            return false;
        }

        firBits  =  fir->GetBitFieldJustified(0, 64);
        wofBits  =  wof->GetBitFieldJustified(0, 64);
        mskBits  =  msk->GetBitFieldJustified(0, 64);
        act1Bits = act1->GetBitFieldJustified(0, 64);

        // Ensure that neighbor has something to analyze (RE or UCS)
        if ( (firBits | wofBits) & ~mskBits & act1Bits )
        {
            PRDF_TRAC("[EC neighborHasRealCoreCS] need to analyze neighbor "
                      "0x%08x for UCS root cause.", n_chip->GetId());
            neighborHasRealCs = true;
        }
    }

    return neighborHasRealCs;
}


/*
 Core checkstop is only supported on PHYP systems. PHYP only supports
 fused-cores. When a normal core checkstops, its fused-core neighbor will
 checkstop along with it. Both cores will end up reporting core checkstop
 attentions. This plugin checks if this core's fused-core neighbor has the
 original core checkstop that we should be analyzing.
*/
int32_t PreAnalysis( ExtensibleChip * i_chip, STEP_CODE_DATA_STRUCT & io_sc,
                     bool & o_analyzed )
{
    o_analyzed = false;

    if (neighborHasRealCoreCS( i_chip ))
    {
        // Get neighbor core
        ExtensibleChip * n_chip = getNeighborCore( i_chip );
        if (n_chip != nullptr)
        {
            if ( SUCCESS == n_chip->Analyze(io_sc,
                                io_sc.service_data->getSecondaryAttnType()) )
            {
                o_analyzed = true;
            }
        }
    }

    return SUCCESS;
}
PRDF_PLUGIN_DEFINE_NS( nimbus_ec,  Ec, PreAnalysis );
PRDF_PLUGIN_DEFINE_NS( cumulus_ec, Ec, PreAnalysis );
PRDF_PLUGIN_DEFINE_NS( axone_ec,   Ec, PreAnalysis );

void checkCoreRePresent( ExtensibleChip * i_chip,
                         STEP_CODE_DATA_STRUCT & io_sc )
{
    int32_t l_rc = SUCCESS;
    SCAN_COMM_REGISTER_CLASS *coreWOF =
             i_chip->getRegister("COREFIR_WOF");
    SCAN_COMM_REGISTER_CLASS * coreMask =
             i_chip->getRegister("COREFIR_MASK");
    SCAN_COMM_REGISTER_CLASS * coreAct0 =
             i_chip->getRegister("COREFIR_ACT0");
    SCAN_COMM_REGISTER_CLASS * coreAct1 =
             i_chip->getRegister("COREFIR_ACT1");

    l_rc  = coreWOF->Read();
    l_rc |= coreMask->Read();
    l_rc |= coreAct0->Read();
    l_rc |= coreAct1->Read();
    if (SUCCESS != l_rc)
    {
        PRDF_ERR( "[EC::checkCoreRePresent] HUID: 0x%08x failed to read"
                  "CORE FIR", i_chip->GetId());
        return;
    }

    uint64_t coreWOFbits  =  coreWOF->GetBitFieldJustified(0, 64);
    uint64_t coreMaskbits = coreMask->GetBitFieldJustified(0, 64);
    uint64_t coreAct0bits = coreAct0->GetBitFieldJustified(0, 64);
    uint64_t coreAct1bits = coreAct1->GetBitFieldJustified(0, 64);

    // If do not have a valid recoverable bit in COREFIR_WOF, we need to
    // switch analysis to look at core checkstop bits
    if ( !( coreWOFbits  & ~coreMaskbits & ~coreAct0bits & coreAct1bits) )
    {
        io_sc.service_data->setSecondaryAttnType(UNIT_CS);
    }
}


/**
 * @brief Determine if there is a core unit checkstop and perform appropriate
 * action.
 *
 * 1) Set error to predictive / at threshold.
 * 2) Wait for PHYP to evacuate core.
 * 3) Terminate if PHYP doesn't evacuate.
 * 4) If we have UCS without RE, switch attn type to analyze UCS
 * @param i_chip Ex chip.
 * @param io_sc Step Code data struct
 * @return PRD return code
 */
int32_t CheckCoreCheckstop( ExtensibleChip * i_chip,
                            STEP_CODE_DATA_STRUCT & io_sc )
{
    #define PRDF_FUNC "[Ec::CheckCoreCheckstop] "
    int32_t l_rc = SUCCESS;
    static const uint32_t CORECS_SECONDS_TO_SLEEP = 10;

    do
    {
        // Skip if we're already at core checkstop in SDC.
        if (io_sc.service_data->isProcCoreCS())
            break;

        // Read core checkstop bit in chiplet RER.
        SCAN_COMM_REGISTER_CLASS * coreRER
                                = i_chip->getRegister("EC_CHIPLET_RE_FIR");
        l_rc = coreRER->ForceRead();
        if (SUCCESS != l_rc)
            break;

        // Check core checkstop bit.
        if (!coreRER->IsBitSet(0))
            break;

        // We must be at core checkstop.
        io_sc.service_data->setProcCoreCS();
        io_sc.service_data->SetThresholdMaskId(0);

        // Check if we need to switch attn type to analyze Unit checkstop
        checkCoreRePresent(i_chip, io_sc);

        if( CHECK_STOP == io_sc.service_data->getPrimaryAttnType() )
        {
            // if both Unit CS and Platform CS occur together, PHYP will not
            // respond to the core evacuation hand-shaking. Don't wait for them
            // and don't collect SH dump. This specifically targets a case
            //  where COREFIR bit 54 and 55 assert together.

            break;
        }

        SCAN_COMM_REGISTER_CLASS *coreHMEER
            = i_chip->getRegister("HOMER_ENABLE");
        l_rc = coreHMEER->Read();
        if (SUCCESS != l_rc)
            break;

        // Check if PHYP has enabled core checkstop (HMEER[0]).
        if (!coreHMEER->IsBitSet(0))
        {
            // Core checkstop not enabled, terminate.
            io_sc.service_data->setFlag( ServiceDataCollector::TERMINATE );

            // PHYP was unresponsive, be sure to get SW content.
            io_sc.service_data->SetDump(CONTENT_SW, i_chip->GetChipHandle());
            break;
        }

        // Wait for PHYP evacuation by checking SPATTN register.
        SCAN_COMM_REGISTER_CLASS * coreSPAttn
            = i_chip->getRegister("SPEC_ATTN_REASON");

        bool spAttnCleared = false;
        uint32_t secondsToSleep = CORECS_SECONDS_TO_SLEEP;

        do
        {
            // Don't sleep on first time through.
            if (secondsToSleep != CORECS_SECONDS_TO_SLEEP)
            {
                PlatServices::milliSleep(1,0); // 1 second
            }
            secondsToSleep--;

            l_rc = coreSPAttn->ForceRead();
            if (SUCCESS == l_rc)
            {
                if (!coreSPAttn->IsBitSet(2))
                {
                    spAttnCleared = 1;
                }
            }
        } while ((secondsToSleep != 0) && (!spAttnCleared));

        if (SUCCESS == l_rc && !spAttnCleared)
        {
            // If we waited and never cleared, terminate machine.
            io_sc.service_data->setFlag( ServiceDataCollector::TERMINATE );

            // PHYP was unresponsive, so get SW content.
            io_sc.service_data->SetDump(CONTENT_SW, i_chip->GetChipHandle());
        }
    } while(0);
    return SUCCESS;
    #undef PRDF_FUNC
}
PRDF_PLUGIN_DEFINE_NS( nimbus_ec,  Ec, CheckCoreCheckstop );
PRDF_PLUGIN_DEFINE_NS( cumulus_ec, Ec, CheckCoreCheckstop );
PRDF_PLUGIN_DEFINE_NS( axone_ec,   Ec, CheckCoreCheckstop );

} // end namespace Ec
} // end namespace PRDF
OpenPOWER on IntegriCloud