From: Paul Mackerras <paulus@samba.org>

This patch uses the firmware-defined error log buffer length for calls to
the firmware routine 'check-exception'.  It also simplifies code in rtasd.c
that is attempting to obtain the error log length.

Signed-off-by: Linas Vepstas <linas@linas.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/ppc64/kernel/ras.c   |    6 ++++--
 25-akpm/arch/ppc64/kernel/rtas.c  |   21 +++++++++++++++++++++
 25-akpm/arch/ppc64/kernel/rtasd.c |   15 +--------------
 25-akpm/include/asm-ppc64/rtas.h  |   10 ++++++++--
 4 files changed, 34 insertions(+), 18 deletions(-)

diff -puN arch/ppc64/kernel/ras.c~ppc64-another-log-buffer-length-fix arch/ppc64/kernel/ras.c
--- 25/arch/ppc64/kernel/ras.c~ppc64-another-log-buffer-length-fix	2004-09-01 23:31:26.860191616 -0700
+++ 25-akpm/arch/ppc64/kernel/ras.c	2004-09-01 23:31:26.868190400 -0700
@@ -161,7 +161,8 @@ ras_epow_interrupt(int irq, void *dev_id
 			   RAS_VECTOR_OFFSET,
 			   virt_irq_to_real(irq_offset_down(irq)),
 			   RTAS_EPOW_WARNING | RTAS_POWERMGM_EVENTS,
-			   critical, __pa(&ras_log_buf), RTAS_ERROR_LOG_MAX);
+			   critical, __pa(&ras_log_buf),
+				rtas_get_error_log_max());
 
 	udbg_printf("EPOW <0x%lx 0x%x 0x%x>\n",
 		    *((unsigned long *)&ras_log_buf), status, state);
@@ -196,7 +197,8 @@ ras_error_interrupt(int irq, void *dev_i
 			   RAS_VECTOR_OFFSET,
 			   virt_irq_to_real(irq_offset_down(irq)),
 			   RTAS_INTERNAL_ERROR, 1 /*Time Critical */,
-			   __pa(&ras_log_buf), RTAS_ERROR_LOG_MAX);
+			   __pa(&ras_log_buf),
+				rtas_get_error_log_max());
 
 	rtas_elog = (struct rtas_error_log *)ras_log_buf;
 
diff -puN arch/ppc64/kernel/rtas.c~ppc64-another-log-buffer-length-fix arch/ppc64/kernel/rtas.c
--- 25/arch/ppc64/kernel/rtas.c~ppc64-another-log-buffer-length-fix	2004-09-01 23:31:26.861191464 -0700
+++ 25-akpm/arch/ppc64/kernel/rtas.c	2004-09-01 23:31:26.868190400 -0700
@@ -516,6 +516,26 @@ void rtas_stop_self(void)
 }
 #endif /* CONFIG_HOTPLUG_CPU */
 
+/*
+ * Return the firmware-specified size of the error log buffer
+ *  for all rtas calls that require an error buffer argument.
+ *  This includes 'check-exception' and 'rtas-last-error'.
+ */
+int rtas_get_error_log_max(void)
+{
+	static int rtas_error_log_max;
+	if (rtas_error_log_max)
+		return rtas_error_log_max;
+
+	rtas_error_log_max = rtas_token ("rtas-error-log-max");
+	if ((rtas_error_log_max == RTAS_UNKNOWN_SERVICE) ||
+	    (rtas_error_log_max > RTAS_ERROR_LOG_MAX)) {
+		printk (KERN_WARNING "RTAS: bad log buffer size %d\n", rtas_error_log_max);
+		rtas_error_log_max = RTAS_ERROR_LOG_MAX;
+	}
+	return rtas_error_log_max;
+}
+
 EXPORT_SYMBOL(rtas_firmware_flash_list);
 EXPORT_SYMBOL(rtas_token);
 EXPORT_SYMBOL(rtas_call);
@@ -526,3 +546,4 @@ EXPORT_SYMBOL(rtas_get_sensor);
 EXPORT_SYMBOL(rtas_get_power_level);
 EXPORT_SYMBOL(rtas_set_power_level);
 EXPORT_SYMBOL(rtas_set_indicator);
+EXPORT_SYMBOL(rtas_get_error_log_max);
diff -puN arch/ppc64/kernel/rtasd.c~ppc64-another-log-buffer-length-fix arch/ppc64/kernel/rtasd.c
--- 25/arch/ppc64/kernel/rtasd.c~ppc64-another-log-buffer-length-fix	2004-09-01 23:31:26.863191160 -0700
+++ 25-akpm/arch/ppc64/kernel/rtasd.c	2004-09-01 23:31:26.869190248 -0700
@@ -373,21 +373,8 @@ static int get_eventscan_parms(void)
 	rtas_event_scan_rate = *ip;
 	DEBUG("rtas-event-scan-rate %d\n", rtas_event_scan_rate);
 
-	ip = (int *)get_property(node, "rtas-error-log-max", NULL);
-	if (ip == NULL) {
-		printk(KERN_ERR "rtasd: no rtas-error-log-max\n");
-		of_node_put(node);
-		return -1;
-	}
-	rtas_error_log_max = *ip;
-	DEBUG("rtas-error-log-max %d\n", rtas_error_log_max);
-
-	if (rtas_error_log_max > RTAS_ERROR_LOG_MAX) {
-		printk(KERN_ERR "rtasd: truncated error log from %d to %d bytes\n", rtas_error_log_max, RTAS_ERROR_LOG_MAX);
-		rtas_error_log_max = RTAS_ERROR_LOG_MAX;
-	}
-
 	/* 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);
diff -puN include/asm-ppc64/rtas.h~ppc64-another-log-buffer-length-fix include/asm-ppc64/rtas.h
--- 25/include/asm-ppc64/rtas.h~ppc64-another-log-buffer-length-fix	2004-09-01 23:31:26.864191008 -0700
+++ 25-akpm/include/asm-ppc64/rtas.h	2004-09-01 23:31:26.870190096 -0700
@@ -211,8 +211,14 @@ extern void pSeries_log_error(char *buf,
 #define RTAS_DEBUG KERN_DEBUG "RTAS: "
  
 #define RTAS_ERROR_LOG_MAX 2048
- 
- 
+
+/*
+ * Return the firmware-specified size of the error log buffer
+ *  for all rtas calls that require an error buffer argument.
+ *  This includes 'check-exception' and 'rtas-last-error'.
+ */
+extern int rtas_get_error_log_max(void);
+
 /* Event Scan Parameters */
 #define EVENT_SCAN_ALL_EVENTS	0xf0000000
 #define SURVEILLANCE_TOKEN	9000
_