summaryrefslogtreecommitdiffstats
path: root/src/usr/isteps/istep10/call_proc_build_smp.C
blob: adf809a5d553921640a03b7011042da9e9e95b3d (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/isteps/istep10/call_proc_build_smp.C $                */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,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                                                     */
#include    <errl/errlentry.H>
#include    <errl/errludtarget.H>
#include    <errl/errlmanager.H>
#include    <isteps/hwpisteperror.H>
#include    <initservice/isteps_trace.H>
#include    <fsi/fsiif.H>


//  targeting support
#include    <targeting/common/commontargeting.H>
#include    <targeting/common/utilFilter.H>
#include    <targeting/common/target.H>
#include    <pbusLinkSvc.H>

#include    <fapi2/target.H>
#include    <fapi2/plat_hwp_invoker.H>
#include    <intr/interrupt.H>

//@TODO RTC:150562 - Remove when BAR setting handled by INTRRP
#include <devicefw/userif.H>
#include <sys/misc.h>
#include <sbeio/sbeioif.H>
#include <usr/vmmconst.h>
#include <p9_build_smp.H>

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



namespace ISTEP_10
{
void* call_proc_build_smp (void *io_pArgs)
{

    IStepError l_StepError;

    do
    {
        errlHndl_t  l_errl  =   nullptr;
        TARGETING::TargetHandleList l_cpuTargetList;
        getAllChips(l_cpuTargetList, TYPE_PROC);

        //
        //  Identify the master processor
        //
        TARGETING::Target * l_masterProc =   nullptr;
        TARGETING::Target * l_masterNode =   nullptr;
        bool l_onlyFunctional = true; // Make sure masterproc is functional
        l_errl = TARGETING::targetService().queryMasterProcChipTargetHandle(
                                                 l_masterProc,
                                                 l_masterNode,
                                                 l_onlyFunctional);

        if(l_errl)
        {
            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                       "ERROR : call_proc_build_smp: "
                       "queryMasterProcChipTargetHandle() returned PLID=0x%x",
                       l_errl->plid() );
            // Create IStep error log and cross reference error that occurred
            l_StepError.addErrorDetails(l_errl);
            // Commit error
            errlCommit( l_errl, HWPF_COMP_ID );
            break;
        }

        std::vector<fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>> l_procList;

        // Loop through all proc chips and convert them to FAPI targets
        for (const auto & curproc: l_cpuTargetList)
        {
            const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>
                    l_fapi2_proc_target (curproc);
            l_procList.push_back(l_fapi2_proc_target);
        }

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

        const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>
                            l_fapi2_master_proc (l_masterProc);

        FAPI_INVOKE_HWP( l_errl, p9_build_smp,
                         l_procList,
                         l_fapi2_master_proc,
                         SMP_ACTIVATE_PHASE1 );

        if(l_errl)
        {
            TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
                       "ERROR : call p9_build_smp, PLID=0x%x", l_errl->plid() );
            // Create IStep error log and cross reference error that occurred
            l_StepError.addErrorDetails(l_errl);
            // Commit error
            errlCommit( l_errl, HWPF_COMP_ID );

            break;
        }

        // At the point where we can now change the proc chips to use
        // XSCOM rather than SBESCOM which is the default.

        TARGETING::TargetHandleList procChips;
        getAllChips(procChips, TYPE_PROC);

        TARGETING::TargetHandleList::iterator curproc = procChips.begin();

        // Loop through all proc chips
        while(curproc != procChips.end())
        {
            TARGETING::Target*  l_proc_target = *curproc;

            // If the proc chip supports xscom..
            if (l_proc_target->getAttr<ATTR_PRIMARY_CAPABILITIES>()
                .supportsXscom)
            {
                ScomSwitches l_switches =
                  l_proc_target->getAttr<ATTR_SCOM_SWITCHES>();

                // If Xscom is not already enabled.
                if ((l_switches.useXscom != 1) || (l_switches.useSbeScom != 0))
                {
                    l_switches.useSbeScom = 0;
                    l_switches.useXscom = 1;

                    // Turn off SBE scom and turn on Xscom.
                    l_proc_target->setAttr<ATTR_SCOM_SWITCHES>(l_switches);

                    // Reset the FSI2OPB logic on the new chips
                    l_errl = FSI::resetPib2Opb(l_proc_target);
                    if(l_errl)
                    {
                        TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                                  "ERROR : resetPib2Opb on %.8X",
                                  TARGETING::get_huid(l_proc_target));
                        // Create IStep error log and
                        // cross reference error that occurred
                        l_StepError.addErrorDetails(l_errl);
                        // Commit error
                        errlCommit( l_errl, HWPF_COMP_ID );
                        break;
                    }
                }
            }

            if (l_proc_target != l_masterProc)
            {
                //Enable PSIHB Interrupts for slave proc -- moved from above
                l_errl = INTR::enablePsiIntr(l_proc_target);
                if(l_errl)
                {
                    // capture the target data in the elog
                    ErrlUserDetailsTarget(l_proc_target).addToLog( l_errl );
                    l_StepError.addErrorDetails(l_errl);
                    errlCommit( l_errl, HWPF_COMP_ID );
                    break;
                }

                // Now that the SMP is connected, it's possible to establish
                // untrusted memory windows for non-master processor SBEs.  Open
                // up the Hostboot read-only memory range for each one to allow
                // Hostboot dumps / attention handling via any processor chip.
                const auto hbHrmor = cpu_spr_value(CPU_SPR_HRMOR);
                l_errl = SBEIO::openUnsecureMemRegion(
                    hbHrmor,
                    VMM_MEMORY_SIZE,
                    false, // False = read-only
                    l_proc_target);
                if(l_errl)
                {
                    TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,
                              ERR_MRK "Failed attempting to open Hostboot's "
                              "VMM region in SBE of non-master processor chip "
                              "with HUID=0x%08X.  Requested address=0x%016llX, "
                              "size=0x%08X",
                              TARGETING::get_huid(l_proc_target),
                              hbHrmor,VMM_MEMORY_SIZE);

                    ErrlUserDetailsTarget(l_proc_target).addToLog(l_errl);
                    l_StepError.addErrorDetails(l_errl);
                    errlCommit(l_errl,HWPF_COMP_ID);
                    break;
                }
            }

            ++curproc;
        }

    } while (0);

    TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace,
            "call_proc_build_smp exit" );

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

};
OpenPOWER on IntegriCloud