From patchwork Tue Oct 10 09:37:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 823761 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yBBrL05pfz9tY3 for ; Tue, 10 Oct 2017 20:38:42 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yBBrK5zzbzDr5x for ; Tue, 10 Oct 2017 20:38:41 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=hegdevasant@linux.vnet.ibm.com; receiver=) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3yBBqk4qjMzDqlv for ; Tue, 10 Oct 2017 20:38:10 +1100 (AEDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9A9aVjK117656 for ; Tue, 10 Oct 2017 05:38:08 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dgp2s7trq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 10 Oct 2017 05:38:08 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Oct 2017 10:38:06 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 10 Oct 2017 10:38:03 +0100 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9A9c1bX19791882 for ; Tue, 10 Oct 2017 09:38:02 GMT Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v9A9bsUx021561 for ; Tue, 10 Oct 2017 20:37:54 +1100 Received: from hegdevasant.in.ibm.com ([9.199.177.253]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v9A9bmq9021439; Tue, 10 Oct 2017 20:37:53 +1100 From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Tue, 10 Oct 2017 15:07:47 +0530 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171010093748.26927-1-hegdevasant@linux.vnet.ibm.com> References: <20171010093748.26927-1-hegdevasant@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17101009-0008-0000-0000-0000049E417E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17101009-0009-0000-0000-00001E3045E6 Message-Id: <20171010093748.26927-3-hegdevasant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-10_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710100134 Subject: [Skiboot] [PATCH v2 3/4] FSP/CONSOLE: Fix fsp_console_write_buffer_space() call X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" 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 CC: Stewart Smith Signed-off-by: Vasant Hegde --- 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,