summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/plat/mem/prdfP9Mcbist.C
blob: 4d81a49898b149f324e9cc985637b7fd7c45d87f (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/plat/mem/prdfP9Mcbist.C $                   */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,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                                                     */

/** @file  prdfP9Mcbist.C
 *  @brief Contains plugin code for MCBIST on Hostboot (IPL and runtime).
 */

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

// Platform includes
#include <prdfPlatServices.H>
#include <prdfP9McbistDataBundle.H>
#include <prdfP9McbistExtraSig.H>

namespace PRDF
{

using namespace PlatServices;

namespace p9_mcbist
{

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

/**
 * @brief  Plugin that initializes the data bundle.
 * @param  i_mcbChip An MCBIST chip.
 * @return SUCCESS
 */
int32_t Initialize( ExtensibleChip * i_mcbChip )
{
    i_mcbChip->getDataBundle() = new McbistDataBundle( i_mcbChip );
    return SUCCESS;
}
PRDF_PLUGIN_DEFINE( p9_mcbist, Initialize );

/**
 * @brief  Plugin function called after analysis is complete but before PRD
 *         exits.
 * @param  i_mcbChip An MCBIST 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_mcbChip,
                      STEP_CODE_DATA_STRUCT & io_sc )
{
    #define PRDF_FUNC "[p9_mcbist::PostAnalysis] "

    return SUCCESS; // Always return SUCCESS for this plugin.

    #undef PRDF_FUNC
}
PRDF_PLUGIN_DEFINE( p9_mcbist, PostAnalysis );

//##############################################################################
//
//                                 MCBISTFIR
//
//##############################################################################

/**
 * @brief  MCBIST[10] - MCBIST Command Complete.
 * @param  i_mcbChip An MCBIST chip.
 * @param  io_sc     The step code data struct.
 * @return SUCCESS
 */
int32_t McbistCmdComplete( ExtensibleChip * i_mcbChip,
                           STEP_CODE_DATA_STRUCT & io_sc )
{
    #define PRDF_FUNC "[p9_mcbist::McbistCmdComplete] "

    // Tell the TD controller there was a command complete attention.
    McbistDataBundle * db = getMcbistDataBundle( i_mcbChip );
    if ( SUCCESS != db->getTdCtlr()->handleCmdComplete(io_sc) )
    {
        // Something failed. It is possible the command complete attention has
        // not been cleared. Make the rule code do it.
        return SUCCESS;
    }
    else
    {
        // Everything was successful. Whether we started a new command or told
        // MDIA to do it, the command complete bit has already been cleared.
        // Don't do it again.
        return PRD_NO_CLEAR_FIR_BITS;
    }

    #undef PRDF_FUNC
}
PRDF_PLUGIN_DEFINE( p9_mcbist, McbistCmdComplete );

/**
 * @brief  MCBIST[12] - MCBIST Command Complete Nimbus DD1.0 workaround.
 * @param  i_mcbChip An MCBIST chip.
 * @param  io_sc     The step code data struct.
 * @return SUCCESS or PRD_NO_CLEAR_FIR_BITS
 */
int32_t CmdCompleteDd1Workaround( ExtensibleChip * i_mcbChip,
                                  STEP_CODE_DATA_STRUCT & io_sc )
{
    #define PRDF_FUNC "[p9_mcbist::CmdCompleteDd1Workaround] "

    int32_t o_rc = SUCCESS; // Returned to rule code.

    #ifndef __HOSTBOOT_RUNTIME

    TARGETING::TargetHandle_t mcbTrgt = i_mcbChip->getTrgt();

    // This workaround should only be seen during super fast MCBIST commands,
    // which are only run during Memory Diagnostics. Also, the workaround only
    // applies to P9 Nimbus DD1.0.
    PRDF_ASSERT( isInMdiaMode() );
    PRDF_ASSERT( (TARGETING::MODEL_NIMBUS == getChipModel(mcbTrgt)) &&
                 (0x10                    == getChipLevel(mcbTrgt)) );

    int32_t l_rc = SUCCESS; // For local rc handling.

    SCAN_COMM_REGISTER_CLASS * mcbmcat = i_mcbChip->getRegister("MCBMCAT");

    do
    {
        //read MCBMCAT from cache first then from HW
        l_rc = mcbmcat->Read();
        if (SUCCESS != l_rc)
        {
            PRDF_ERR(PRDF_FUNC "Read() failed on MCBMCAT");
            break;
        }
        uint64_t tmp1 = mcbmcat->GetBitFieldJustified(0, 64);

        l_rc = mcbmcat->ForceRead();
        if (SUCCESS != l_rc)
        {
            PRDF_ERR(PRDF_FUNC "ForceRead() failed on MCBMCAT");
            break;
        }
        uint64_t tmp2 = mcbmcat->GetBitFieldJustified(0, 64);

        //compare the two values to determine if the command is completed

        //if the values are the same the command has completed
        if (tmp1 == tmp2)
        {
            // This plugin is only called when MCBISTFIR[12] is on by itself,
            // however, there is a small window where MCBISTFIR[10] could be set
            // after the initial register capture, but before this point in the
            // code. So clear MCBISTFIR[10] just in case. Also, do this before
            // handling the command complete attention to ease complication in
            // error path handling.
            SCAN_COMM_REGISTER_CLASS * mcbFirAnd =
                i_mcbChip->getRegister("MCBISTFIR_AND");
            mcbFirAnd->setAllBits();

            mcbFirAnd->ClearBit(10);

            l_rc = mcbFirAnd->Write();
            if ( SUCCESS != l_rc )
            {
                PRDF_ERR( PRDF_FUNC "Write() failed on MCBISTFIR" );
                break;
            }

            //handle like a normal command complete
            o_rc = McbistCmdComplete( i_mcbChip, io_sc );
        }
        //if the values are different the command has not completed yet
        else
        {
            //sleep for a bit - hopefully will be enough for the cmd to complete
            PlatServices::milliSleep(0, 20);

            //do not commit the errl - it won't have useful data
            io_sc.service_data->setDontCommitErrl();

            //return PRD_NO_CLEAR_FIR_BITS so PRD is called again
            o_rc = PRD_NO_CLEAR_FIR_BITS;
        }

    } while(0);

    // There is some error path handling that needs to be done if there is a
    // local error.
    if ( SUCCESS != l_rc )
    {
        PRDF_ERR( PRDF_FUNC "Failed on 0x%08x", i_mcbChip->getHuid() );

        // Change signature indicating there was an error in analysis.
        io_sc.service_data->SetErrorSig( PRDFSIG_CmdComplete_ERROR );

        // Something definitely failed, so callout 2nd level support.
        io_sc.service_data->SetCallout( NextLevelSupport_ENUM, MRU_HIGH );
        io_sc.service_data->setServiceCall();

        // Tell MDIA to skip further analysis on this target.
        l_rc = mdiaSendEventMsg( mcbTrgt, MDIA::STOP_TESTING );
        if ( SUCCESS != l_rc )
            PRDF_ERR( PRDF_FUNC "mdiaSendEventMsg(STOP_TESTING) failed" );
    }

    #endif // not __HOSTBOOT_RUNTIME

    return o_rc;

    #undef PRDF_FUNC
}
PRDF_PLUGIN_DEFINE( p9_mcbist, CmdCompleteDd1Workaround );

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

/**
 * @brief  MCBISTFIR[1] - COMMAND_ADDRESS_TIMEOUT.
 * @param  i_chip An MCBIST chip.
 * @param  io_sc  The step code data struct.
 * @return SUCCESS
 */
int32_t commandAddrTimeout( ExtensibleChip * i_chip,
                            STEP_CODE_DATA_STRUCT & io_sc )
{
    #define PRDF_FUNC "[p9_mcbist::commandAddrTimeout] "

    // The current MCBIST command is hung and will not complete. All conditions
    // that would cause this are contained within the MCAs in which the command
    // was executed. Restarting the command will likely fail with the same
    // issue. Callout and gard all MCAs in which the command was executed.

    std::vector<ExtensibleChip *> mcaList;

    if ( SUCCESS != getMcbistMaintPort(i_chip, mcaList) )
    {
        PRDF_ERR( PRDF_FUNC "getMcbistMaintPort(0x%08x) failed",
                  i_chip->getHuid() );
    }
    else
    {
        for ( auto & mcaChip : mcaList )
        {
            io_sc.service_data->SetCallout( mcaChip->getTrgt() );
        }
    }

    return SUCCESS; // nothing to return to rule code

    #undef PRDF_FUNC
}
PRDF_PLUGIN_DEFINE( p9_mcbist, commandAddrTimeout );

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

} // end namespace p9_mcbist

} // end namespace PRDF

OpenPOWER on IntegriCloud