]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/powerpc/platforms/pseries/rtasd.c
[POWERPC] pseries: Fix jumbled no_logging flag
[linux-2.6-omap-h63xx.git] / arch / powerpc / platforms / pseries / rtasd.c
index 762fe87629ff6ac2f9db5654ddc9077e26e75b9d..b802a272bd29f843051c93e8132ccf4fb055a5cd 100644 (file)
@@ -53,7 +53,8 @@ static unsigned int rtas_event_scan_rate;
 
 static int full_rtas_msgs = 0;
 
-extern int no_logging;
+/* Stop logging to nvram after first fatal error */
+static int no_more_logging;
 
 volatile int error_log_cnt = 0;
 
@@ -64,8 +65,6 @@ volatile int error_log_cnt = 0;
  */
 static unsigned char logdata[RTAS_ERROR_LOG_MAX];
 
-static int get_eventscan_parms(void);
-
 static char *rtas_type[] = {
        "Unknown", "Retry", "TCE Error", "Internal Device Failure",
        "Timeout", "Data Parity", "Address Parity", "Cache Parity",
@@ -169,9 +168,9 @@ static int log_rtas_len(char * buf)
                len += err->extended_log_length;
        }
 
-       if (rtas_error_log_max == 0) {
-               get_eventscan_parms();
-       }
+       if (rtas_error_log_max == 0)
+               rtas_error_log_max = rtas_get_error_log_max();
+
        if (len > rtas_error_log_max)
                len = rtas_error_log_max;
 
@@ -218,7 +217,7 @@ void pSeries_log_error(char *buf, unsigned int err_type, int fatal)
        }
 
        /* Write error to NVRAM */
-       if (!no_logging && !(err_type & ERR_FLAG_BOOT))
+       if (!no_more_logging && !(err_type & ERR_FLAG_BOOT))
                nvram_write_error_log(buf, len, err_type);
 
        /*
@@ -230,8 +229,8 @@ void pSeries_log_error(char *buf, unsigned int err_type, int fatal)
                printk_log_rtas(buf, len);
 
        /* Check to see if we need to or have stopped logging */
-       if (fatal || no_logging) {
-               no_logging = 1;
+       if (fatal || no_more_logging) {
+               no_more_logging = 1;
                spin_unlock_irqrestore(&rtasd_log_lock, s);
                return;
        }
@@ -303,7 +302,7 @@ static ssize_t rtas_log_read(struct file * file, char __user * buf,
 
        spin_lock_irqsave(&rtasd_log_lock, s);
        /* if it's 0, then we know we got the last one (the one in NVRAM) */
-       if (rtas_log_size == 0 && !no_logging)
+       if (rtas_log_size == 0 && !no_more_logging)
                nvram_clear_error_log();
        spin_unlock_irqrestore(&rtasd_log_lock, s);
 
@@ -359,31 +358,6 @@ static int enable_surveillance(int timeout)
        return -1;
 }
 
-static int get_eventscan_parms(void)
-{
-       struct device_node *node;
-       const int *ip;
-
-       node = of_find_node_by_path("/rtas");
-
-       ip = of_get_property(node, "rtas-event-scan-rate", NULL);
-       if (ip == NULL) {
-               printk(KERN_ERR "rtasd: no rtas-event-scan-rate\n");
-               of_node_put(node);
-               return -1;
-       }
-       rtas_event_scan_rate = *ip;
-       DEBUG("rtas-event-scan-rate %d\n", rtas_event_scan_rate);
-
-       /* Make room for the sequence number */
-       rtas_error_log_max = rtas_get_error_log_max();
-       rtas_error_log_buffer_max = rtas_error_log_max + sizeof(int);
-
-       of_node_put(node);
-
-       return 0;
-}
-
 static void do_event_scan(void)
 {
        int error;
@@ -433,27 +407,13 @@ static int rtasd(void *unused)
 
        daemonize("rtasd");
 
-       if (get_eventscan_parms() == -1)
-               goto error;
-
-       rtas_log_buf = vmalloc(rtas_error_log_buffer_max*LOG_NUMBER);
-       if (!rtas_log_buf) {
-               printk(KERN_ERR "rtasd: no memory\n");
-               goto error;
-       }
-
        printk(KERN_DEBUG "RTAS daemon started\n");
-
        DEBUG("will sleep for %d milliseconds\n", (30000/rtas_event_scan_rate));
 
        /* See if we have any error stored in NVRAM */
        memset(logdata, 0, rtas_error_log_max);
-
        rc = nvram_read_error_log(logdata, rtas_error_log_max, &err_type);
 
-       /* We can use rtas_log_buf now */
-       no_logging = 0;
-
        if (!rc) {
                if (err_type != ERR_FLAG_ALREADY_LOGGED) {
                        pSeries_log_error(logdata, err_type | ERR_FLAG_BOOT, 0);
@@ -475,8 +435,6 @@ static int rtasd(void *unused)
        for (;;)
                do_event_scan_all_cpus(30000/rtas_event_scan_rate);
 
-error:
-       /* Should delete proc entries */
        return -EINVAL;
 }
 
@@ -494,6 +452,22 @@ static int __init rtas_init(void)
                return -ENODEV;
        }
 
+       rtas_event_scan_rate = rtas_token("rtas-event-scan-rate");
+       if (rtas_event_scan_rate == RTAS_UNKNOWN_SERVICE) {
+               printk(KERN_ERR "rtasd: no rtas-event-scan-rate on system\n");
+               return -ENODEV;
+       }
+
+       /* Make room for the sequence number */
+       rtas_error_log_max = rtas_get_error_log_max();
+       rtas_error_log_buffer_max = rtas_error_log_max + sizeof(int);
+
+       rtas_log_buf = vmalloc(rtas_error_log_buffer_max*LOG_NUMBER);
+       if (!rtas_log_buf) {
+               printk(KERN_ERR "rtasd: no memory\n");
+               return -ENOMEM;
+       }
+
        entry = create_proc_entry("ppc64/rtas/error_log", S_IRUSR, NULL);
        if (entry)
                entry->proc_fops = &proc_rtas_log_operations;