summaryrefslogtreecommitdiffstats
path: root/src/occ/proc/proc_data_control.c
blob: f87625f500c1fa67a923f3204fdb60fc4e335ca5 (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
/******************************************************************************
// @file proc_data_control.c
// @brief Data codes for proc component.
*/
/******************************************************************************
 *
 *       @page ChangeLogs Change Logs
 *       @section _proc_data_control_c proc_data_control.c
 *       @verbatim
 *
 *   Flag    Def/Fea    Userid    Date        Description
 *   ------- ---------- --------  ----------  ----------------------------------
 *   @th010             thallet   06/27/2012  Created
 *   @th014             thallet   08/02/2012  Temporary Control Data Fix & TODO flags added
 *   @th015             thallet   08/03/2012  Set core Pstates function
 *   @gm006  SW224414   milesg    09/16/2013  Reset and FFDC improvements 
 *   @gm008  SW226989   milesg    09/30/2013  Sapphire initial support
 *   @gm025  915973     milesg    02/14/2014  Full support for sapphire (KVM) mode
 *
 *  @endverbatim
 *
 *///*************************************************************************/
 
//*************************************************************************
// Includes
//*************************************************************************
#include "proc_data.h"
#include "pgp_async.h"		
#include "threadSch.h" 
#include "pmc_register_addresses.h"
#include "proc_data_service_codes.h"
#include "occ_service_codes.h" 
#include "errl.h"             
#include "trac.h"
#include "rtls.h"
#include "apss.h"
#include "state.h"
#include "gpe_control.h"
#include "occ_sys_config.h"

//*************************************************************************
// Externs
//*************************************************************************

//*************************************************************************
// Macros
//*************************************************************************

//*************************************************************************
// Defines/Enums
//*************************************************************************

//*************************************************************************
// Structures
//*************************************************************************

//*************************************************************************
// Globals
//*************************************************************************

// Pore flex request for GPE job. The initialization will be done one time 
// during pore flex create.
PoreFlex G_core_data_control_req;   

// Global double buffering for core data control
GPE_BUFFER(PcbsPstateRegs G_core_data_control_a[MAX_NUM_HW_CORES]) = {{{0}}}; 
GPE_BUFFER(PcbsPstateRegs G_core_data_control_b[MAX_NUM_HW_CORES]) = {{{0}}}; 

// Pointer to the core data control that will be used by GPE engine.
GPE_BUFFER(PcbsPstateRegs * G_core_data_control_gpewrite_ptr) = { &G_core_data_control_a[0] }; 

// Pointer to the core data control that will be written to by the OCC FW.
GPE_BUFFER(PcbsPstateRegs * G_core_data_control_occwrite_ptr) = { &G_core_data_control_b[0] }; 

// The Gpe parameter fields are set up each time before the GPE starts. 
GPE_BUFFER(GpeSetPstatesParms G_core_data_control_parms);              

//*************************************************************************
// Functions
//*************************************************************************

// Function Specification
//
// Name: proc_set_pstate
//
// Description: Function to demonstrate setting Pstates to all cores
//              Should only be run from RTL
//
// Flow:  --/--/--    FN=
//
// End Function Specification
void proc_set_pstate_all(Pstate i_pstate)
{
  uint8_t l_chiplet = 0;

  for(; l_chiplet<MAX_NUM_HW_CORES; l_chiplet++)
  {
     set_chiplet_pstate(G_core_data_control_occwrite_ptr,
                        l_chiplet,
                        i_pstate,
                        i_pstate);
  }

  PROC_DBG("Setting Pstates to %d\n",i_pstate);
}


// Function Specification
//
// Name: proc_set_core_pstate
//
// Description: Function to demonstrate setting Pstates to all cores
//              Should only be run from RTL
//
// Flow:  --/--/--    FN=
//
// End Function Specification
void proc_set_core_pstate(Pstate i_pstate, uint8_t i_core)
{  
  set_chiplet_pstate(G_core_data_control_occwrite_ptr,
                        CORE_OCC2HW(i_core),
                        i_pstate,
                        i_pstate);
}

// gm025
// Function Specification
//
// Name: proc_set_core_bounds
//
// Description: Function to set core pmin/pmax
//              Should only be run from RTL
//
// Flow:  --/--/--    FN=
//
// End Function Specification
void proc_set_core_bounds(Pstate i_pmin, Pstate i_pmax, uint8_t i_core)
{ 
    Pstate l_pmax;
    uint8_t l_hw_core = CORE_OCC2HW(i_core);

    //don't allow pmax to be set lower than pmin
    if(i_pmax < i_pmin)
    {
        l_pmax = i_pmin;
    }
    else
    {
        l_pmax = i_pmax;
    }

    set_chiplet_pmax(G_core_data_control_occwrite_ptr,
                     l_hw_core,
                     l_pmax);
    set_chiplet_pmin(G_core_data_control_occwrite_ptr,
                     l_hw_core,
                     i_pmin);
}


// Function Specification
//
// Name: proc_core_data_control_init
//
// Description: Initializations needed for core data control task
//
// Flow:  --/--/--    FN=
//
// End Function Specification
void proc_core_data_control_init( void )
{
    errlHndl_t l_err = NULL;   //Error handler
    tracDesc_t l_trace = NULL; //Temporary trace descriptor
    int         rc = 0;	//Return code

    do
    {
        //Initializes PoreFlex object for fast core data
        rc = pore_flex_create( &G_core_data_control_req,  //gpe_req for the task
                &G_pore_gpe0_queue,                       //queue
                gpe_set_pstates,                          //entry point
                (uint32_t) &G_core_data_control_parms,    //parm for the task
                SSX_WAIT_FOREVER,                         //no timeout
                NULL,                                     //callback
                NULL,                                     //callback argument
                0 );                                      //options
        if( rc )
        {
            //If fail to create pore flex object then there is a problem.
            TRAC_ERR("Fail to create core control poreFlex object[0x%x]", rc );

            /*
             * @errortype
             * @moduleid    PROC_CORE_INIT_MOD
             * @reasoncode  SSX_GENERIC_FAILURE
             * @userdata1   pore_flex_create return code
             * @userdata4   ERC_PROC_CONTROL_INIT_FAILURE
             * @devdesc     Failure to create poreflex object
             */ 
            l_err = createErrl(
                    PROC_CORE_INIT_MOD,                     //modId
                    SSX_GENERIC_FAILURE,                    //reasoncode   
                    ERC_PROC_CONTROL_INIT_FAILURE,          //Extended reason code 
                    ERRL_SEV_PREDICTIVE,                    //Severity
                    l_trace,    //TODO: create l_trace      //Trace Buf
                    DEFAULT_TRACE_SIZE,                     //Trace Size
                    rc,                                     //userdata1
                    0                                       //userdata2
                    );

            // commit error log
            REQUEST_RESET(l_err); //$gm006
            break;
        }

    } while(0);
}

// Function Specification
//
// Name: task_core_data_control
//
// Description: Control core actuation for all configured cores on every tick.
//
// Flow:  07/02/12    FN=task_core_data_control
//
// End Function Specification
void task_core_data_control( task_t * i_task )
{
    errlHndl_t       l_err   = NULL;     //Error handler
    tracDesc_t       l_trace = NULL;     //Temporary trace descriptor
    int              rc      = 0;        //Return code
    PcbsPstateRegs * l_temp  = NULL;

    do
    {

        //Check to see if the previous GPE request still running
        if( !(async_request_is_idle(&G_core_data_control_req.request)) )
        {
            // Trace 1 time - This should not happen 

            //if( !G_fast_core_queue_not_idle_traced )
            //{
            //        TRAC_ERR("GPE is still running \n");
            //        G_fast_core_queue_not_idle_traced = TRUE;
            //}
            break;
        }

        //Check to see if the previosuly GPE request has been succeeded
        if( async_request_completed(&G_core_data_control_req.request) )
        {
            //If the previous GPE request succeeded then swap the
            //gpewrite ptr with the occwrite ptr.
            l_temp = G_core_data_control_occwrite_ptr;
            // TODO:  For now, set these ptrs equal to each other
            //        This data is not thread-safe/interrupt safe
            //        but will need to fix this later.
            //G_core_data_control_occwrite_ptr = G_core_data_control_gpewrite_ptr; // TODO: @th014
            G_core_data_control_gpewrite_ptr = l_temp;
        }

        //Setup the core data control parms
        G_core_data_control_parms.config = (uint64_t) (((uint64_t) G_present_hw_cores) << 32);
        if(G_sysConfigData.system_type.kvm) //gm025
        {
            //Set the chiplet bounds (pmax/pmin) only on sapphire
            G_core_data_control_parms.select = GPE_SET_PSTATES_PMBR;
        }
        else
        {
            //Set the chiplet pstate request on non-sapphire systems
            G_core_data_control_parms.select = GPE_SET_PSTATES_PMCR;
        }

        G_core_data_control_parms.regs = (uint32_t) G_core_data_control_gpewrite_ptr;

        rc = pore_flex_schedule( &G_core_data_control_req );
        if( rc != 0 )
        {
            TRAC_ERR("Failed PoreFlex schedule core data control [%x] \n", rc);

            /*
             * @errortype
             * @moduleid    PROC_TASK_CORE_DATA_MOD
             * @reasoncode  SSX_GENERIC_FAILURE
             * @userdata1   pore_flex_schedule return code
             * @userdata4   ERC_PROC_CONTROL_TASK_FAILURE
             * @devdesc     Failure to schedule poreflex object
             */ 
            l_err = createErrl(
                    PROC_TASK_CORE_DATA_MOD,                //modId
                    SSX_GENERIC_FAILURE,                    //reasoncode   
                    ERC_PROC_CONTROL_TASK_FAILURE,          //Extended reason code 
                    ERRL_SEV_PREDICTIVE,                    //Severity
                    l_trace,    //TODO: create l_trace      //Trace Buf
                    DEFAULT_TRACE_SIZE,                     //Trace Size
                    rc,                                     //userdata1
                    0                                       //userdata2
                    );

            // commit error log
            REQUEST_RESET(l_err); //@gm006
            break;
        }
    } while(0);

    return;
}


OpenPOWER on IntegriCloud