summaryrefslogtreecommitdiffstats
path: root/src/occ_405/scom.c
blob: c891dba52ae16e1cd20019b75aff7fcfd7f19a37 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/occ_405/scom.c $                                          */
/*                                                                        */
/* OpenPOWER OnChipController Project                                     */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2011,2015                        */
/* [+] 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 <occ_common.h>
#include "ssx.h"
#include "scom.h"
#include "trac.h"
#include "occ_service_codes.h"
#include "occ_sys_config.h"
#include "polling.h"

#define MAX_SCOM_FFDC_RETRIES 1

// Function Specification
//
// Name: getscom_ffdc
//
// Description: peforms a getscom that does not panic on error and will add
//              trace data and create a predictive error log with callouts.
//              If caller passes in NULL for o_errp, the error will be
//              committed internally.  Otherwise, o_errp will point to the
//              uncomitted error log.
//
// End Function Specification
int getscom_ffdc(uint32_t i_addr, uint64_t* o_data, errlHndl_t* o_errp)
{
    pmc_o2p_addr_reg_t          l_addr;
    pmc_o2p_ctrl_status_reg_t   l_status;
    int                         l_rc;
    int                         l_retries = 0;
    errlHndl_t                  l_err = NULL;

    while(l_retries <= MAX_SCOM_FFDC_RETRIES)
    {
        l_rc = _getscom(i_addr, o_data, SCOM_TIMEOUT);
        if(!l_rc)
        {
            break;
        }

        //_getscom returns immediately if the o2p interface was busy
        //wait to see if busy condition clears up
        if(l_rc == -SCOM_PROTOCOL_ERROR_GETSCOM_BUSY)
        {
            busy_wait(SCOM_TIMEOUT);
        }

        l_retries++;
    }

    if(l_rc)
    {
        //grab additional ffdc
        l_status.value = in32(PMC_O2P_CTRL_STATUS_REG);
        l_addr.value = in32(PMC_O2P_ADDR_REG);
        TRAC_ERR("getscom_ffdc: scom failed.  addr[%08x] rc[%08x] o2p_stat[%08x] o2p_addr[%08x]",
                 i_addr,
                 -l_rc,
                 l_status.value,
                 l_addr.value);

        /* @
         * @errortype
         * @moduleid    GETSCOM_FFDC_MID
         * @reasoncode  PROC_SCOM_ERROR
         * @userdata1   scom address
         * @userdata2   failure code
         * @userdata4   OCC_NO_EXTENDED_RC
         * @devdesc     Processor register read failure
         */
         l_err = createErrl(GETSCOM_FFDC_MID,                 //modId
                            PROC_SCOM_ERROR,                  //reasoncode
                            OCC_NO_EXTENDED_RC,               //Extended reason code
                            ERRL_SEV_PREDICTIVE,              //Severity
                            NULL,                             //Trace Buf
                            DEFAULT_TRACE_SIZE,               //Trace Size
                            i_addr,                           //userdata1
                            -l_rc);                           //userdata2

         //adding a processor callout should also cause data to be collected by PRDF component on FSP
         addCalloutToErrl(l_err,
                          ERRL_CALLOUT_TYPE_HUID,
                          G_sysConfigData.proc_huid,
                          ERRL_CALLOUT_PRIORITY_MED);
         addCalloutToErrl(l_err,
                          ERRL_CALLOUT_TYPE_COMPONENT_ID,
                          ERRL_COMPONENT_ID_FIRMWARE,
                          ERRL_CALLOUT_PRIORITY_HIGH);

         if(o_errp)
         {
             //caller will commit the error
             *o_errp = l_err;
         }
         else
         {
             //error committed internally
             commitErrl(&l_err);
         }
    }

    return l_rc;
}

// Function Specification
//
// Name: putscom_ffdc
//
// Description: peforms a putscom that does not panic on error and will add
//              trace data and create a predictive error log with callouts.
//              If caller passes in NULL for o_errp, the error will be
//              committed internally.  Otherwise, o_errp will point to the
//              uncomitted error log.
//
// End Function Specification
int putscom_ffdc(uint32_t i_addr, uint64_t i_data, errlHndl_t* o_errp)
{
    pmc_o2p_addr_reg_t          l_addr;
    pmc_o2p_ctrl_status_reg_t   l_status;
    int                         l_rc;
    int                         l_retries = 0;
    errlHndl_t                  l_err = NULL;

    while(l_retries <= MAX_SCOM_FFDC_RETRIES)
    {
        l_rc = _putscom(i_addr, i_data, SCOM_TIMEOUT);
        if(!l_rc)
        {
            break;
        }

        //_putscom returns immediately if the o2p interface was busy.  Instead, see if
        //it cleared after SCOM_TIMEOUT period.
        if(l_rc == -SCOM_PROTOCOL_ERROR_PUTSCOM_BUSY)
        {
            busy_wait(SCOM_TIMEOUT);
        }

        l_retries++;
    }

    if(l_rc)
    {
        //grab addtional ffdc
        l_status.value = in32(PMC_O2P_CTRL_STATUS_REG);
        l_addr.value = in32(PMC_O2P_ADDR_REG);
        TRAC_ERR("putscom_ffdc: scom failed.  addr[%08x] rc[%08x] o2p_stat[%08x] o2p_addr[%08x]",
                 i_addr,
                 -l_rc,
                 l_status.value,
                 l_addr.value);

        /* @
         * @errortype
         * @moduleid    PUTSCOM_FFDC_MID
         * @reasoncode  PROC_SCOM_ERROR
         * @userdata1   scom address
         * @userdata2   failure code
         * @userdata4   OCC_NO_EXTENDED_RC
         * @devdesc     Processor register write failure
         */
         l_err = createErrl(PUTSCOM_FFDC_MID,                 //modId
                            PROC_SCOM_ERROR,                  //reasoncode
                            OCC_NO_EXTENDED_RC,               //Extended reason code
                            ERRL_SEV_PREDICTIVE,              //Severity
                            NULL,                             //Trace Buf
                            DEFAULT_TRACE_SIZE,               //Trace Size
                            i_addr,                           //userdata1
                            -l_rc);                           //userdata2

         //adding a processor callout should also cause data to be collected by PRDF component on FSP
         addCalloutToErrl(l_err,
                          ERRL_CALLOUT_TYPE_HUID,
                          G_sysConfigData.proc_huid,
                          ERRL_CALLOUT_PRIORITY_MED);
         addCalloutToErrl(l_err,
                          ERRL_CALLOUT_TYPE_COMPONENT_ID,
                          ERRL_COMPONENT_ID_FIRMWARE,
                          ERRL_CALLOUT_PRIORITY_HIGH);
         if(o_errp)
         {
             //caller will commit the error
             *o_errp = l_err;
         }
         else
         {
             //commit error internally
             commitErrl(&l_err);
         }
    }

    return l_rc;
}

OpenPOWER on IntegriCloud