summaryrefslogtreecommitdiffstats
path: root/src/usr/isteps/istep16/call_host_activate_slave_cores.C
blob: 6e4977524ee3683e9e460a4f7ecbac65d00363df (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
/* 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,2016                        */
/* [+] 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_cpu_special_wakeup.H>

using   namespace   ERRORLOG;
using   namespace   TARGETING;
using   namespace   ISTEP;
using   namespace   ISTEP_ERROR;
using   namespace   p9specialWakeup;

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:   @@@@@

    uint64_t l_masterCoreID = task_getcpuid() & ~7;

    TargetHandleList l_cores;
    getAllChiplets(l_cores, TYPE_CORE);

    for(TargetHandleList::const_iterator
        l_core = l_cores.begin();
        l_core != l_cores.end();
        ++l_core)
    {
        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>();
        TARGETING::Target* sys = NULL;
        TARGETING::targetService().getTopLevelTarget(sys);
        assert( sys != NULL );
        uint64_t en_threads = sys->getAttr<ATTR_ENABLED_THREADS>();

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

        uint64_t pir = PIR_t(l_logicalGroupId, l_chipId, l_coreId).word;

        if (pir != l_masterCoreID)
        {
            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                       "call_host_activate_slave_cores: Waking %x",
                       pir );

            int rc = cpu_start_core(pir,en_threads);

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

//@TODO RTC:147376
//Spoke with Thi and he said this is not planned for awhile
//FAPI_INVOKE_HWP( l_timeout_errl, proc_check_slw_done,
//l_fapi2_ex_target);
//                 if (l_timeout_errl)
//                 {
//                     TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
//                             "ERROR : proc_check_slw_done" );
//                     // Add chip target info
//                     ErrlUserDetailsTarget(l_processor).addToLog(
//                                                             l_timeout_errl );
//                     // Create IStep error log
//                     l_stepError.addErrorDetails(l_timeout_errl);
//                     // Commit error
//                     errlCommit( l_timeout_errl, HWPF_COMP_ID );
//                     break;
//                 }
//                 else
//                 {
//                     TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
//                             "SUCCESS : proc_check_slw_done - "
//                               "SLW is in clean state");
//                 }
            }
            // Create error log
            if (0 != rc)
            {
                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   rc of cpu_start_core().
                  *
                  * @devdesc Kernel returned error when trying to activate
                  *          core.
                  */
                errlHndl_t l_errl =
                    new ERRORLOG::ErrlEntry(
                            ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                            MOD_HOST_ACTIVATE_SLAVE_CORES,
                            RC_BAD_RC,
                            pir,
                            rc );

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

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

            TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                    "Running p9_cpu_special_wakeup (ENABLE)"
                    " EX target HUID %.8X",
                    TARGETING::get_huid(*l_core));

            // Enable special wakeup on core
            FAPI_INVOKE_HWP( l_errl,
                    p9_cpu_special_wakeup,
                    l_fapi2_coreTarget,
                    SPCWKUP_ENABLE,
                    HOST);

            if( l_errl )
            {
                ErrlUserDetailsTarget(*l_core).addToLog( l_errl );

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

                // Commit Error
                errlCommit( l_errl, HWPF_COMP_ID );

                TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                        "ERROR : enable p9_cpu_special_wakeup, "
                        "PLID=0x%x", l_errl->plid()  );
            }
            else
            {
                TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                        "SUCCESS: enable p9_cpu_special_wakeup");
            }
        }
    }
    // @@@@@    END CUSTOM BLOCK:   @@@@@

#ifdef CONFIG_ENABLE_CHECKSTOP_ANALYSIS
    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

    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