summaryrefslogtreecommitdiffstats
path: root/src/usr/isteps/istep16/call_host_activate_slave_cores.C
blob: c5f941e8f33ac1a2564a35c53ee80c7c9d065723 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/isteps/istep16/call_host_activate_slave_cores.C $     */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2019                        */
/* [+] 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                                                     */

#include    <errl/errlentry.H>
#include    <errno.h>
#include    <initservice/isteps_trace.H>
#include    <isteps/hwpisteperror.H>
#include    <errl/errludtarget.H>

#include    <arch/pirformat.H>
#include    <console/consoleif.H>

//  targeting support
#include    <targeting/common/commontargeting.H>
#include    <targeting/common/utilFilter.H>
#include    <targeting/namedtarget.H>
#include    <fapi2/target.H>
#include    <errl/errlmanager.H>
#include    <sys/task.h>
#include    <sys/misc.h>

#include    <fapi2/plat_hwp_invoker.H>
#include    <p9_check_idle_stop_done.H>

#ifdef CONFIG_IPLTIME_CHECKSTOP_ANALYSIS
  #include <isteps/pm/occCheckstop.H>
#endif

#include    <scom/scomif.H>
#include    <errl/errludprintk.H>
#include    <intr/intr_reasoncodes.H>
#include    <initservice/istepdispatcherif.H>

using   namespace   ERRORLOG;
using   namespace   TARGETING;
using   namespace   ISTEP;
using   namespace   ISTEP_ERROR;
using   namespace   p9_check_idle_stop;

namespace ISTEP_16
{
void* call_host_activate_slave_cores (void *io_pArgs)
{
    IStepError  l_stepError;

    errlHndl_t  l_timeout_errl  =   NULL;
    errlHndl_t  l_errl          =   NULL;


    TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
               "call_host_activate_slave_cores entry" );

    // @@@@@    CUSTOM BLOCK:   @@@@@

    //track master group/chip/core (no threads)
    uint64_t l_masterPIR_wo_thread = PIR_t(task_getcpuid()).word &
                                     ~PIR_t::THREAD_MASK;

    TargetHandleList l_cores;
    getAllChiplets(l_cores, TYPE_CORE);
    TARGETING::Target* sys = NULL;
    TARGETING::targetService().getTopLevelTarget(sys);
    assert( sys != NULL );
    uint32_t l_numCores = 0;

    // keep track of which cores started
    TargetHandleList l_startedCores;

    for(TargetHandleList::const_iterator
        l_core = l_cores.begin();
        l_core != l_cores.end();
        ++l_core)
    {
        TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                   "Iterating all cores in system - "
                   "This is core: %d", l_numCores);
        l_numCores += 1;

        ConstTargetHandle_t l_processor = getParentChip(*l_core);

        CHIP_UNIT_ATTR l_coreId =
                (*l_core)->getAttr<TARGETING::ATTR_CHIP_UNIT>();
        FABRIC_GROUP_ID_ATTR l_logicalGroupId =
          l_processor->getAttr<TARGETING::ATTR_FABRIC_GROUP_ID>();
        FABRIC_CHIP_ID_ATTR l_chipId =
          l_processor->getAttr<TARGETING::ATTR_FABRIC_CHIP_ID>();


        const fapi2::Target<fapi2::TARGET_TYPE_CORE> l_fapi2_coreTarget(
              const_cast<TARGETING::Target*> (*l_core));

        //Determine PIR and threads to enable for this core
        uint64_t pir = PIR_t(l_logicalGroupId, l_chipId, l_coreId).word;
        uint64_t en_threads = sys->getAttr<ATTR_ENABLED_THREADS>();
        TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                   "pir for this core is: %lx", pir);

        //If not the master core, skip
        if ((pir & ~PIR_t::THREAD_MASK) != l_masterPIR_wo_thread)
        {
            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                       "call_host_activate_slave_cores: Waking %x.",
                       pir );

            int rc = cpu_start_core(pir, en_threads);

            // Workaround to handle some syncing issues with new cpus
            //  waking
            if (-ETIME == rc)
            {
                TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                        "call_host_activate_slave_cores: "
                        "Time out rc from kernel %d on core 0x%x, resending doorbell",
                        rc,
                        pir);
                rc = cpu_wakeup_core(pir,en_threads);
            }

            // Handle time out error
            uint32_t l_checkidle_eid = 0;
            if (-ETIME == rc)
            {
                TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                        "call_host_activate_slave_cores: "
                        "Time out rc from kernel %d on core 0x%x",
                        rc,
                        pir);

                // only called if the core doesn't report in
                const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>
                    l_fapi2ProcTarget(
                        const_cast<TARGETING::Target*>(l_processor) );

                TARGETING::ATTR_FAPI_NAME_type l_targName = {0};
                fapi2::toString( l_fapi2ProcTarget,
                                 l_targName,
                                 sizeof(l_targName) );

                TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                    "Call p9_check_idle_stop_done on processor %s", l_targName );

                FAPI_INVOKE_HWP( l_timeout_errl,
                                 p9_check_idle_stop_done,
                                 l_fapi2_coreTarget );

                if (l_timeout_errl)
                {
                    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                          "ERROR : p9_check_idle_stop_done" );

                    // Add chip target info
                    ErrlUserDetailsTarget(l_processor).addToLog(l_timeout_errl);

                    // Create IStep error log
                    l_stepError.addErrorDetails(l_timeout_errl);

                    l_checkidle_eid = l_timeout_errl->eid();

                    // Commit error
                    errlCommit( l_timeout_errl, HWPF_COMP_ID );
                }
            } // End of handle time out error

            // Check if this core failed last time
            ATTR_PREVIOUS_WAKEUP_FAIL_type l_prevFail =
              (*l_core)->getAttr<TARGETING::ATTR_PREVIOUS_WAKEUP_FAIL>();

            // Create predictive error log if this is the first failure
            //   AND the HWP didn't see a problem
            if( (0 != rc) && (l_prevFail == 0) && (l_checkidle_eid == 0) )
            {
                TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                        "call_host_activate_slave_cores: "
                        "Error from kernel %d on core %x",
                        rc,
                        pir);
                /*@
                  * @errortype
                  * @reasoncode  RC_BAD_RC
                  * @severity    ERRORLOG::ERRL_SEV_UNRECOVERABLE
                  * @moduleid    MOD_HOST_ACTIVATE_SLAVE_CORES
                  * @userdata1   PIR of failing core.
                  * @userdata2[00:31]   EID from p9_check_idle_stop_done().
                  * @userdata2[32:63]   rc of cpu_start_core().
                  *
                  * @devdesc Kernel returned error when trying to activate
                  *          core.
                  */
                l_errl = new ERRORLOG::ErrlEntry(
                             ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                             MOD_HOST_ACTIVATE_SLAVE_CORES,
                             RC_BAD_RC,
                             pir,
                             TWO_UINT32_TO_UINT64(
                                 l_checkidle_eid,
                                 rc) );

                // Going to assume some kind of SW error unless it fails
                //  again
                l_errl->addProcedureCallout( HWAS::EPUB_PRC_HB_CODE,
                                             HWAS::SRCI_PRIORITY_HIGH);

                // Callout core that failed to wake up.
                l_errl->addHwCallout(*l_core,
                        HWAS::SRCI_PRIORITY_LOW,
                        HWAS::NO_DECONFIG,
                        HWAS::GARD_NULL);

                // Could be an interrupt issue
                l_errl->collectTrace(INTR_TRACE_NAME,256);

                // Throw printk in there too in case it is a kernel issue
                ERRORLOG::ErrlUserDetailsPrintk().addToLog(l_errl);

                // Add interesting ISTEP traces
                l_errl->collectTrace(ISTEP_COMP_NAME,256);

                // Choosing to ignore this intermittent error
                l_errl->setSev(ERRORLOG::ERRL_SEV_INFORMATIONAL);
                errlCommit( l_errl, HWPF_COMP_ID );

                // Remember that we failed so we can gard the core if it
                //  happens again on the reboot
                l_prevFail = 1;
                (*l_core)->
                  setAttr<TARGETING::ATTR_PREVIOUS_WAKEUP_FAIL>(l_prevFail);

#ifdef CONFIG_BMC_IPMI
                // Initiate a graceful power cycle
                CONSOLE::displayf(ISTEP_COMP_NAME, "System Rebooting To Retry Recoverable Error");
                CONSOLE::flush();
                TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,"call_host_activate_slave_cores: requesting power cycle");
                INITSERVICE::requestReboot();
#endif

                break;
            }
            // Create unrecoverable error log if this is a repeat
            //  OR if the HWP hit something
            else if( (0 != rc) &&
                     ((l_prevFail > 0) || (l_checkidle_eid != 0)) )
            {
                TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                           "call_host_activate_slave_cores: "
                           "Core errors during wakeup on core %x",
                           pir);
                /*@
                 * @errortype
                 * @reasoncode  RC_SLAVE_CORE_WAKEUP_ERROR
                 * @severity    ERRORLOG::ERRL_SEV_UNRECOVERABLE
                 * @moduleid    MOD_HOST_ACTIVATE_SLAVE_CORES
                 * @userdata1[00:31]   PIR of failing core.
                 * @userdata2[32:63]   Number of previous failures.
                 * @userdata2[00:31]   EID from p9_check_idle_stop_done().
                 * @userdata2[32:63]   rc of cpu_start_core().
                 *
                 * @devdesc Kernel returned error when trying to activate
                 *          core.
                 */
                l_errl = new ERRORLOG::ErrlEntry(
                               ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                               MOD_HOST_ACTIVATE_SLAVE_CORES,
                               RC_SLAVE_CORE_WAKEUP_ERROR,
                               TWO_UINT32_TO_UINT64(
                                   pir,
                                   l_prevFail),
                               TWO_UINT32_TO_UINT64(
                                   l_checkidle_eid,
                                   rc) );

                // Callout and gard core that failed to wake up.
                l_errl->addHwCallout(*l_core,
                                     HWAS::SRCI_PRIORITY_HIGH,
                                     HWAS::DECONFIG,
                                     HWAS::GARD_Predictive);

                // Could be an interrupt issue
                l_errl->collectTrace(INTR_TRACE_NAME,256);

                // Throw printk in there too in case it is a kernel issue
                ERRORLOG::ErrlUserDetailsPrintk().addToLog(l_errl);

                // Add interesting ISTEP traces
                l_errl->collectTrace(ISTEP_COMP_NAME,256);

                l_stepError.addErrorDetails( l_errl );
                errlCommit( l_errl, HWPF_COMP_ID );

                // We garded the core so we should zero out the fail
                //  counter so the replacement doesn't get blamed
                l_prevFail = 0;
                (*l_core)->
                  setAttr<TARGETING::ATTR_PREVIOUS_WAKEUP_FAIL>(l_prevFail);

                break;
            }
            // Zero out the counter if we passed 
            else if( l_prevFail > 0 )
            {
                // Add to the list of passing cores so we can
                //  clear ATTR_PREVIOUS_WAKEUP_FAIL later
                l_startedCores.push_back(*l_core);
            }
        }
    }

    // Clear out the wakeup_fail indicators only after every core has passed.
    //  Doing this outside the loop helps mitigate the (unlikely) case where
    //  a failure bounces between different cores on several consecutive boots.
    for(TargetHandleList::const_iterator
        l_core = l_startedCores.begin();
        l_core != l_startedCores.end();
        ++l_core)
    {
        TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                   "call_host_activate_slave_cores: "
                   "Resetting failure count for core %.8X",
                   TARGETING::get_huid(*l_core) );
        ATTR_PREVIOUS_WAKEUP_FAIL_type l_prevFail = 0;
        (*l_core)->
          setAttr<TARGETING::ATTR_PREVIOUS_WAKEUP_FAIL>(l_prevFail);
    }

#if defined(CONFIG_IPLTIME_CHECKSTOP_ANALYSIS) && !defined(__HOSTBOOT_RUNTIME)
    if( l_stepError.isNull() )
    {
        // update firdata inputs for OCC
        TARGETING::Target* masterproc = NULL;
        TARGETING::targetService().masterProcChipTargetHandle(masterproc);
        l_errl = HBOCC::loadHostDataToSRAM(masterproc,
                                            PRDF::ALL_HARDWARE);
        if (l_errl)
        {
            TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                    "Error returned from call to HBOCC::loadHostDataToSRAM");

            //Create IStep error log and cross reference error that occurred
            l_stepError.addErrorDetails(l_errl);

            // Commit Error
            errlCommit(l_errl, HWPF_COMP_ID);
        }
    }
#endif

    //Set SKIP_WAKEUP to false after all cores are powered on (16.2)
    //If this is not set false, PM_RESET will fail to enable special wakeup.
    // PM_RESET is expected to enable special_wakeup after all the cores powered on
    sys->setAttr<ATTR_SKIP_WAKEUP>(0);

    // Now that the slave cores are running, we need to include them in
    //  multicast scom operations
    SCOM::enableSlaveCoreMulticast();

    TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
               "call_host_activate_slave_cores exit" );

    // end task, returning any errorlogs to IStepDisp
    return l_stepError.getErrorHandle();
}

};
OpenPOWER on IntegriCloud