ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / ppc / platforms / error_log.c
1 /*
2  *  arch/ppc/kernel/error_log.c
3  *
4  *  Copyright (c) 2000 Tilmann Bitterberg
5  *  (tilmann@bitterberg.de)
6  *
7  *  Error processing of errors found by rtas even-scan routine
8  *  which is done with every heartbeat. (chrp_setup.c)
9  */
10
11 #include <linux/sched.h>
12
13 #include <asm/prom.h>
14
15 #include "error_log.h"
16
17 /* ****************************************************************** */
18 /*
19  * EVENT-SCAN
20  * The whole stuff below here doesn't take any action when it found
21  * an error, it just prints as much information as possible and
22  * then its up to the user to decide what to do.
23  *
24  * Returns 0 if no errors were found
25  * Returns 1 if there may be more errors
26  */
27 int ppc_rtas_errorlog_scan(void)
28 {
29 const char *_errlog_severity[] = {
30 #ifdef VERBOSE_ERRORS
31         "No Error\n\t\
32 Should require no further information",
33         "Event\n\t\
34 This is not really an error, it is an event. I use events\n\t\
35 to communicate with RTAS back and forth.",
36         "Warning\n\t\
37 Indicates a non-state-losing error, either fully recovered\n\t\
38 by RTAS or not needing recovery. Ignore it.",
39         "Error sync\n\t\
40 May only be fatal to a certain program or thread. Recovery\n\t\
41 and continuation is possible, if I only had a handler for\n\t\
42 this. Less serious",
43         "Error\n\t\
44 Less serious, but still causing a loss of data and state.\n\t\
45 I can't tell you exactly what to do, You have to decide\n\t\
46 with help from the target and initiator field, what kind\n\t\
47 of further actions may take place.",
48         "Fatal\n\t\
49 Represent a permanent hardware failure and I believe this\n\t\
50 affects my overall performance and behaviour. I would not\n\t\
51 attempt to continue normal operation."
52 #else
53         "No Error",
54         "Event",
55         "Warning",
56         "Error sync",
57         "Error",
58         "Fatal"
59 #endif /* VERBOSE_ERRORS */
60 };
61
62 #if 0 /* unused?? */
63 const char *_errlog_disposition[] = {
64 #ifdef VERBOSE_ERRORS
65         "Fully recovered\n\t\
66 There was an error, but it is fully recovered by RTAS.",
67         "Limited recovery\n\t\
68 RTAS was able to recover the state of the machine, but some\n\t\
69 feature of the machine has been disabled or lost (for example\n\t\
70 error checking) or performance may suffer.",
71         "Not recovered\n\t\
72 Whether RTAS did not try to recover anything or recovery failed:\n\t\
73 HOUSTON, WE HAVE A PROBLEM!"
74 #else
75         "Fully recovered",
76         "Limited recovery",
77         "Not recovered"
78 #endif /* VERBOSE_ERRORS */
79 };
80 #endif
81
82 const char *_errlog_extended[] = {
83 #ifdef VERBOSE_ERRORS
84         "Not present\n\t\
85 Sad, the RTAS call didn't return an extended error log.",
86         "Present\n\t\
87 The extended log is present and hopefully it contains a lot of\n\t\
88 useful information, which leads to the solution of the problem."
89 #else
90         "Not present",
91         "Present"
92 #endif /* VERBOSE_ERRORS */
93 };
94
95 const char *_errlog_initiator[] = {
96         "Unknown or not applicable",
97         "CPU",
98         "PCI",
99         "ISA",
100         "Memory",
101         "Power management"
102 };
103
104 const char *_errlog_target[] = {
105         "Unknown or not applicable",
106         "CPU",
107         "PCI",
108         "ISA",
109         "Memory",
110         "Power management"
111 };
112         rtas_error_log error_log;
113         char logdata[1024];
114         int error;
115 #if 0 /* unused?? */
116         int retries = 0; /* if HW error, try 10 times */
117 #endif
118
119         error = call_rtas ("event-scan", 4, 1, (unsigned long *)&error_log,
120                         INTERNAL_ERROR | EPOW_WARNING,
121                         0, __pa(logdata), 1024);
122
123         if (error == 1) /* no errors found */
124                 return 0;
125
126         if (error == -1) {
127                 printk(KERN_ERR "Unable to get errors. Do you a favor and throw this box away\n");
128                 return 0;
129         }
130         if (error_log.version != 1)
131                 printk(KERN_WARNING "Unknown version (%d), please implement me\n",
132                                 error_log.version);
133
134         switch (error_log.disposition) {
135                 case DISP_FULLY_RECOVERED:
136                         /* there was an error, but everything is fine now */
137                         return 0;
138                 case DISP_NOT_RECOVERED:
139                         printk("We have a really serious Problem!\n");
140                 case DISP_LIMITED_RECOVERY:
141                         printk("Error classification\n");
142                         printk("Severity  : %s\n",
143                                         ppc_rtas_errorlog_check_severity (error_log));
144                         printk("Initiator : %s\n",
145                                         ppc_rtas_errorlog_check_initiator (error_log));
146                         printk("Target    : %s\n",
147                                         ppc_rtas_errorlog_check_target (error_log));
148                         printk("Type      : %s\n",
149                                         ppc_rtas_errorlog_check_type (error_log));
150                         printk("Ext. log  : %s\n",
151                                         ppc_rtas_errorlog_check_extended (error_log));
152                         if (error_log.extended)
153                                 ppc_rtas_errorlog_disect_extended (logdata);
154                         return 1;
155                 default:
156                         /* nothing */
157                         break;
158         }
159         return 0;
160 }
161 /* ****************************************************************** */
162 const char * ppc_rtas_errorlog_check_type (rtas_error_log error_log)
163 {
164         const char *_errlog_type[] = {
165                 "unknown type",
166                 "too many tries failed",
167                 "TCE error",
168                 "RTAS device failed",
169                 "target timed out",
170                 "parity error on data",                 /* 5 */
171                 "parity error on address",
172                 "parity error on external cache",
173                 "access to invalid address",
174                 "uncorrectable ECC error",
175                 "corrected ECC error"                   /* 10 */
176         };
177         if (error_log.type == TYPE_EPOW)
178                 return "EPOW";
179         if (error_log.type >= TYPE_PMGM_POWER_SW_ON)
180                 return "PowerMGM Event (not handled right now)";
181         return _errlog_type[error_log.type];
182 }
183