[Skiboot] [PATCH v2 3/4] FSP/CONSOLE: Fix fsp_console_write_buffer_space() call

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Tue Oct 10 20:37:47 AEDT 2017


Kernel calls fsp_console_write_buffer_space() to check console buffer space
availability. If there is enough buffer space to write data, then kernel will
call fsp_console_write() to write actual data.

In some extreme corner cases (like one explained in commit c8a7535f)
console becomes full and this function returns 0 to kernel (or space available
in console buffer < next incoming data size). Kernel will continue retrying
until it gets enough space. So we will start seeing RCU stalls.

This patch keeps track of previous available space. If previous space is same
as current means not enough space in console buffer to write incoming data.
It may be due to very high console write operation and slow response from FSP
-OR- FSP has stopped processing data (ex: because of ipmi daemon died). At this
point we will start timer with timeout of SER_BUFFER_OUT_TIMEOUT (10 secs).
If situation is not improved within 10 seconds means something went bad. Lets
return OPAL_RESOURCE so that kernel can drop console write and continue.

CC: Ananth N Mavinakayanahalli <ananth at linux.vnet.ibm.com>
CC: Stewart Smith <stewart at linux.vnet.ibm.com>
Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
Changes in v2:
  - Introduced buffer timeout

-Vasant
 hw/fsp/fsp-console.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/hw/fsp/fsp-console.c b/hw/fsp/fsp-console.c
index d1996cc..77eb69f 100644
--- a/hw/fsp/fsp-console.c
+++ b/hw/fsp/fsp-console.c
@@ -61,11 +61,15 @@ struct fsp_serial {
 	struct fsp_msg		*poke_msg;
 	u8			waiting;
 	u64			irq;
+	u16			out_buf_prev_len;
+	u64			out_buf_timeout;
 };
 
 #define SER_BUFFER_SIZE 0x00040000UL
 #define MAX_SERIAL	4
 
+#define SER_BUFFER_OUT_TIMEOUT	10
+
 static struct fsp_serial fsp_serials[MAX_SERIAL];
 static bool got_intf_query;
 static struct lock fsp_con_lock = LOCK_UNLOCKED;
@@ -315,6 +319,8 @@ static void fsp_open_vserial(struct fsp_msg *msg)
 	fs->in_buf->flags        = fs->out_buf->flags        = 0;
 	fs->in_buf->reserved     = fs->out_buf->reserved     = 0;
 	fs->in_buf->next_out     = fs->out_buf->next_out     = 0;
+	fs->out_buf_prev_len     = 0;
+	fs->out_buf_timeout      = 0;
 	unlock(&fsp_con_lock);
 
  already_open:
@@ -655,7 +661,29 @@ static int64_t fsp_console_write_buffer_space(int64_t term_number,
 		% SER_BUF_DATA_SIZE;
 	unlock(&fsp_con_lock);
 
-	return OPAL_SUCCESS;
+	/* Console buffer has enough space to write incoming data */
+	if (*length != fs->out_buf_prev_len) {
+		fs->out_buf_prev_len = *length;
+		fs->out_buf_timeout = 0;
+
+		return OPAL_SUCCESS;
+	}
+
+	/*
+	 * Buffer is full, start internal timer. We will continue returning
+	 * SUCCESS until timeout happens, hoping FSP will consume data within
+	 * timeout period.
+	 */
+	if (fs->out_buf_timeout == 0) {
+		fs->out_buf_timeout = mftb() +
+			secs_to_tb(SER_BUFFER_OUT_TIMEOUT);
+	}
+
+	if (tb_compare(mftb(), fs->out_buf_timeout) != TB_AAFTERB)
+		return OPAL_SUCCESS;
+
+	/* Timeout happened. Lets drop incoming data */
+	return OPAL_RESOURCE;
 }
 
 static int64_t fsp_console_read(int64_t term_number, int64_t *length,
-- 
2.9.3



More information about the Skiboot mailing list