summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat/p9/prdfP9PllDomain.C
blob: 1524e899f8f8cd54151b064bd69bc8dc770c4068 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/p9/prdfP9PllDomain.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  prdfPllDomain.C
 *  @brief Definition of PllDomain class
 */

#include <prdfPllDomain.H>

#include <CcAutoDeletePointer.h>
#include <iipscr.h>
#include <iipsdbug.h>
#include <iipServiceDataCollector.h>
#include <prdfErrorSignature.H>
#include <iipResolution.h>
#include <prdfPlatServices.H>
#include <prdfPluginDef.H>
#include <prdfGlobal.H>
#include <iipSystem.h>
#include <UtilHash.H>
#include <prdfP9Pll.H>

#include <prdfP9ProcMbCommonExtraSig.H>

using namespace TARGETING;

namespace PRDF
{

using namespace PlatServices;
using namespace PLL;

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

int32_t PllDomain::Initialize(void)
{

  int32_t rc = SUCCESS;
  return(rc);
}

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

bool PllDomain::Query(ATTENTION_TYPE attentionType)
{
    bool atAttn = false;
    // System always checks for RE's first, even if there is an XSTOP
    // So we only need to check for PLL errors on RECOVERABLE type
    if(attentionType == RECOVERABLE)
    {
        // check sysdbug for attention first
        SYSTEM_DEBUG_CLASS sysdbug;
        for(unsigned int index = 0; (index < GetSize()) && (atAttn == false);
            ++index)
        {
            ExtensibleChip * l_chip = LookUp( index );
            TARGETING::TargetHandle_t l_chipTgt = l_chip->getTrgt();
            bool l_analysisPending =
                  sysdbug.isActiveAttentionPending( l_chipTgt, RECOVERABLE );

            if( l_analysisPending )
            {
                // Check if any clock errors are present
                uint32_t l_errType = 0;
                ExtensibleChipFunction * l_query =
                    l_chip->getExtensibleFunction("CheckErrorType");
                int32_t rc = (*l_query)(l_chip,
                    PluginDef::bindParm<uint32_t &> (l_errType));

                // Check if clock errors apply to this domain
                if ( GetId() == CLOCK_DOMAIN_IO )
                {
                    if ( ( l_errType & PCI_PLL_UNLOCK ) ||
                         ( l_errType & PCI_OSC_FAILOVER ) )
                        atAttn = true;
                }
                else
                {
                    if ( ( l_errType & SYS_PLL_UNLOCK ) ||
                         ( l_errType & SYS_OSC_FAILOVER ) )
                        atAttn = true;
                }

                // if rc then scom read failed
                // Error log has already been generated
                if( PRD_POWER_FAULT == rc )
                {
                    PRDF_ERR( "prdfPllDomain::Query() Power Fault detected!" );
                    break;
                }
                else if(SUCCESS != rc)
                {
                    PRDF_ERR( "prdfPllDomain::Query() SCOM fail. RC=%x", rc );
                }
            }
        }
    }

    return(atAttn);
}

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

int32_t PllDomain::Analyze(STEP_CODE_DATA_STRUCT & serviceData,
                           ATTENTION_TYPE attentionType)
{
    #define PRDF_FUNC "[PllDomain::Analyze] "
    std::vector<ExtensibleChip *> pllUnlockList;
    std::vector<ExtensibleChip *> failoverList;
    int32_t rc = SUCCESS;
    uint32_t mskErrType =  0;

    // Due to clock issues some chips may be moved to non-functional during
    // analysis. In this case, these chips will need to be removed from their
    // domains.
    std::vector<ExtensibleChip *>  nfchips;

    // Examine each chip in domain
    for(unsigned int index = 0; index < GetSize(); ++index)
    {
        uint32_t l_errType = 0;

        ExtensibleChip * l_chip = LookUp(index);

        if ( !PlatServices::isFunctional(l_chip->getTrgt()) )
        {
            // The chip is now non-functional.
            nfchips.push_back( l_chip );
            continue;
        }

        // Check if this chip has a clock error
        ExtensibleChipFunction * l_query =
            l_chip->getExtensibleFunction("CheckErrorType");
        rc |= (*l_query)(l_chip,
            PluginDef::bindParm<uint32_t &> (l_errType));

        // Continue if no clock errors reported on this chip
        if ( 0 == l_errType )
            continue;

        if (GetId() == CLOCK_DOMAIN_IO)
        {
            if (l_errType & PCI_PLL_UNLOCK  ) pllUnlockList.push_back(l_chip);
            if (l_errType & PCI_OSC_FAILOVER)  failoverList.push_back(l_chip);
        }
        else
        {
            if (l_errType & SYS_PLL_UNLOCK  ) pllUnlockList.push_back(l_chip);
            if (l_errType & SYS_OSC_FAILOVER)  failoverList.push_back(l_chip);
        }

        // Get this chip's capture data for any error
        l_chip->CaptureErrorData(
                    serviceData.service_data->GetCaptureData());
        // Capture PllFIRs group
        l_chip->CaptureErrorData(
                    serviceData.service_data->GetCaptureData(),
                    Util::hashString("PllFIRs"));

        // Call this chip's capturePllFfdc plugin if it exists.
        ExtensibleChipFunction * l_captureFfdc =
            l_chip->getExtensibleFunction("capturePllFfdc", true);
        if ( NULL != l_captureFfdc )
        {
            (*l_captureFfdc)( l_chip,
            PluginDef::bindParm<STEP_CODE_DATA_STRUCT &>(serviceData) );
        }

        // In the case of a PLL_UNLOCK error, we want to do additional isolation
        // in case of a HWP failure.
        if ( (l_errType & SYS_PLL_UNLOCK) || (l_errType & PCI_PLL_UNLOCK) )
        {
            PlatServices::hwpErrorIsolation( l_chip, serviceData );
        }
    } // end for each chip in domain

    // Remove all non-functional chips.
    if ( CHECK_STOP != serviceData.service_data->getPrimaryAttnType() )
    {
        for (  auto i : nfchips )
        {
            systemPtr->RemoveStoppedChips( i->getTrgt() );
        }
    }

    // TODO: RTC 184513 - It is possible to have a PLL unlock, a UE RE, and an
    //       SUE CS. Isolation should be to the PLL error and then the
    //       additional FFDC should show there was an SUE CS were the root is
    //       the UE RE. However, PRD does not know how to handle three
    //       attentions at the same time. For now this will remain a limitation
    //       due to time contraits, but there is a proposal in RTC 184513 that
    //       will be solved later. In the meantime, there is a hole in our
    //       analysis that needs to be fixed. If the is a SUE CS and no UE RE,
    //       PRD assumes the UE RE was already predictively called out in a
    //       previous error log. Therefore, nothing will be garded in this error
    //       log. In the example stated above, the current PRD code will not see
    //       the UE RE because of the higher priority PLL unlock. So even though
    //       there is a UE RE present, nothing gets garded. To circumvent this,
    //       we will set the UERE flag here even though the PLL error is not the
    //       true SUE source.
    if ( CHECK_STOP == serviceData.service_data->getPrimaryAttnType() )
    {
        serviceData.service_data->SetUERE();
    }

    // always suspect the clock source
    closeClockSource.Resolve(serviceData);
    if(&closeClockSource != &farClockSource)
    {
        farClockSource.Resolve(serviceData);
    }

    if (pllUnlockList.size() > 0)
    {
        // Test for threshold
        iv_threshold.Resolve(serviceData);
        if(serviceData.service_data->IsAtThreshold())
        {
            mskErrType |= (GetId() == CLOCK_DOMAIN_IO) ?
                         PCI_PLL_UNLOCK : SYS_PLL_UNLOCK;
        }

        // Set Signature
        serviceData.service_data->GetErrorSignature()->
            setChipId(pllUnlockList[0]->getHuid());
        serviceData.service_data->SetErrorSig( PRDFSIG_PLL_ERROR );

        // If only one detected sys ref error, add it to the callout list.
        if (pllUnlockList.size() == 1)
        {
            const uint32_t tmpCount =
                serviceData.service_data->getMruListSize();

            // Call this chip's CalloutPll plugin if it exists.
            ExtensibleChipFunction * l_callout =
                pllUnlockList[0]->getExtensibleFunction( "CalloutPll", true );
            if ( NULL != l_callout )
            {
                (*l_callout)( pllUnlockList[0],
                    PluginDef::bindParm<STEP_CODE_DATA_STRUCT &>(serviceData) );
            }

            // If CalloutPll plugin does not add anything new to the callout
            // list, callout this chip
            if ( tmpCount == serviceData.service_data->getMruListSize() )
            {
                // No additional callouts were made so add this chip to the list
                serviceData.service_data->SetCallout(
                    pllUnlockList[0]->getTrgt());
            }
        }
    }

    if (failoverList.size() > 0)
    {
        if (GetId() == CLOCK_DOMAIN_IO)
        {
            // Mask failovers for this domain
            mskErrType |= PCI_OSC_FAILOVER;

            // Set signature
            serviceData.service_data->SetErrorSig( PRDFSIG_MF_REF_FAILOVER );
        }
        else
        {
            // Mask failovers for this domain
            mskErrType |= SYS_OSC_FAILOVER;

            // Set signature
            serviceData.service_data->SetErrorSig( PRDFSIG_SYS_REF_FAILOVER );
        }

        serviceData.service_data->GetErrorSignature()->
            setChipId(failoverList[0]->getHuid());

        // Make the error log predictive on first occurrence.
        serviceData.service_data->SetThresholdMaskId(0);
    }

    if (serviceData.service_data->IsAtThreshold())
    {
        // Mask appropriate errors on all chips in domain
        ExtensibleDomainFunction * l_mask =
                            getExtensibleFunction("MaskPll");
        (*l_mask)(this,
              PluginDef::bindParm<STEP_CODE_DATA_STRUCT&, uint32_t>
                  (serviceData, mskErrType));
    }

    // Clear PLLs from this domain.
    ExtensibleDomainFunction * l_clear = getExtensibleFunction("ClearPll");
    (*l_clear)(this,
               PluginDef::bindParm<STEP_CODE_DATA_STRUCT&>(serviceData));

    // Run PLL Post Analysis on any analyzed chips in this domain.
    for(auto l_chip : pllUnlockList)
    {
        // Send any special messages indicating there was a PLL error.
        ExtensibleChipFunction * l_pllPostAnalysis =
                l_chip->getExtensibleFunction("PllPostAnalysis", true);
        (*l_pllPostAnalysis)(l_chip,
                PluginDef::bindParm<STEP_CODE_DATA_STRUCT&>(serviceData));
    }

    for(auto l_chip : failoverList)
    {
        // Send any special messages indicating there was a PLL error.
        ExtensibleChipFunction * l_pllPostAnalysis =
                l_chip->getExtensibleFunction("PllPostAnalysis", true);
        (*l_pllPostAnalysis)(l_chip,
                PluginDef::bindParm<STEP_CODE_DATA_STRUCT&>(serviceData));
    }

    return SUCCESS;

    #undef PRDF_FUNC
}

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

void PllDomain::Order(ATTENTION_TYPE attentionType)
{
    // Order is not important for PLL errors
}

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

int32_t PllDomain::ClearPll( ExtensibleDomain * i_domain,
                             STEP_CODE_DATA_STRUCT & i_sc )
{
    PllDomain * l_domain = (PllDomain *) i_domain;

    const char * clearPllFuncName = (l_domain->GetId() == CLOCK_DOMAIN_IO) ?
        "ClearMfPll" : "ClearPll";

    // Clear children chips.
    for ( uint32_t i = 0; i < l_domain->GetSize(); i++ )
    {
        ExtensibleChip * l_chip = l_domain->LookUp(i);
        ExtensibleChipFunction * l_clear =
                        l_chip->getExtensibleFunction(clearPllFuncName);
        (*l_clear)( l_chip,
                    PluginDef::bindParm<STEP_CODE_DATA_STRUCT&>(i_sc) );
    }

    // Clear children domains.
    // This looks like a recursive call.  It calls other domains of Clear.
    ParentDomain<ExtensibleDomain>::iterator i;
    for (i = l_domain->getBeginIterator(); i != l_domain->getEndIterator(); i++)
    {
        // Clear PLLs from this domain.
        ExtensibleDomainFunction * l_clear =
                                (i->second)->getExtensibleFunction("ClearPll");
        (*l_clear)( i->second,
                    PluginDef::bindParm<STEP_CODE_DATA_STRUCT&>(i_sc) );
    }

    return SUCCESS;
}
PRDF_PLUGIN_DEFINE( PllDomain, ClearPll );

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

int32_t PllDomain::MaskPll( ExtensibleDomain * i_domain,
                            STEP_CODE_DATA_STRUCT & i_sc,
                            uint32_t i_errType )
{
    PllDomain * l_domain = (PllDomain *) i_domain;

    // Mask children chips.
    for ( uint32_t i = 0; i < l_domain->GetSize(); i++ )
    {
        ExtensibleChip * l_chip = l_domain->LookUp(i);
        ExtensibleChipFunction * l_mask =
                            l_chip->getExtensibleFunction("MaskPll");
        (*l_mask)( l_chip,
            PluginDef::bindParm<STEP_CODE_DATA_STRUCT&, uint32_t>
                (i_sc, i_errType) );
    }

    // Mask children domains.
    // This looks like a recursive call.  It calls other domains of Mask.
    ParentDomain<ExtensibleDomain>::iterator i;
    for (i = l_domain->getBeginIterator(); i != l_domain->getEndIterator(); i++)
    {
        ExtensibleDomainFunction * l_mask =
                                (i->second)->getExtensibleFunction("MaskPll");
        (*l_mask)( i->second,
            PluginDef::bindParm<STEP_CODE_DATA_STRUCT&, uint32_t>
                (i_sc, i_errType) );
    }

    return SUCCESS;
}
PRDF_PLUGIN_DEFINE( PllDomain, MaskPll );

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

} // end namespace PRDF

OpenPOWER on IntegriCloud