From patchwork Wed May 20 11:51:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 1294284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49RrhQ5wgJz9sT1 for ; Wed, 20 May 2020 21:52:06 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49RrhP5p6vzDqNL for ; Wed, 20 May 2020 21:52:05 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=hegdevasant@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 49RrhF3nBkzDqLW for ; Wed, 20 May 2020 21:51:56 +1000 (AEST) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04KBZWf2006151 for ; Wed, 20 May 2020 07:51:53 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 314ua47uuk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 May 2020 07:51:53 -0400 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 04KBcQDK014553 for ; Wed, 20 May 2020 07:51:53 -0400 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 314ua47utw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2020 07:51:53 -0400 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 04KBppvE004433; Wed, 20 May 2020 11:51:51 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03fra.de.ibm.com with ESMTP id 313xdhsemp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2020 11:51:51 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 04KBoaee57606404 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 May 2020 11:50:37 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4B0FCA4055; Wed, 20 May 2020 11:51:49 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 43AA2A4051; Wed, 20 May 2020 11:51:48 +0000 (GMT) Received: from hegdevasant.in.ibm.com (unknown [9.199.57.19]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 May 2020 11:51:48 +0000 (GMT) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Wed, 20 May 2020 17:21:37 +0530 Message-Id: <20200520115139.20734-1-hegdevasant@linux.vnet.ibm.com> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-20_07:2020-05-19, 2020-05-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 malwarescore=0 mlxlogscore=656 impostorscore=0 phishscore=0 cotscore=-2147483648 suspectscore=1 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005200096 Subject: [Skiboot] [PATCH 1/3] uart: Drop console write data if BMC becomes unresponsive X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" If BMC becomes unresponsive (ex: during BMC reboot) during console write then we may get stuck in uart_wait_tx_room(). This will result in kernel lockups and in some cases host becomes unresponsive. This patch retries for `tx_room` for predefined number of time. If we don't get space within that time it will return zero. This will result in dropping console message. Signed-off-by: Vasant Hegde --- hw/lpc-uart.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/lpc-uart.c b/hw/lpc-uart.c index 979a617c3..ed56a4bdc 100644 --- a/hw/lpc-uart.c +++ b/hw/lpc-uart.c @@ -63,6 +63,8 @@ static void *mmio_uart_base; static int uart_console_policy = UART_CONSOLE_OPAL; static int lpc_irq = -1; +#define UART_WRITE_MAX_RETRIES 0x100 + void uart_set_console_policy(int policy) { uart_console_policy = policy; @@ -106,6 +108,8 @@ static void uart_check_tx_room(void) static void uart_wait_tx_room(void) { + int retry_cnt = 0; + while (!tx_room) { uart_check_tx_room(); if (!tx_room) { @@ -113,6 +117,10 @@ static void uart_wait_tx_room(void) do { barrier(); uart_check_tx_room(); + + retry_cnt++; + if (retry_cnt > UART_WRITE_MAX_RETRIES) + return; } while (!tx_room); smt_medium(); } From patchwork Wed May 20 11:51:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 1294285 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Rrj052dyz9sT1 for ; Wed, 20 May 2020 21:52:36 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49Rrj04Fq4zDqPR for ; Wed, 20 May 2020 21:52:36 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) 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=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com 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 49RrhG404GzDqLW for ; Wed, 20 May 2020 21:51:58 +1000 (AEST) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04KBZBXc110847 for ; Wed, 20 May 2020 07:51:56 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 312agepyfu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 May 2020 07:51:56 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 04KBcrDh124130 for ; Wed, 20 May 2020 07:51:55 -0400 Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 312agepyex-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2020 07:51:55 -0400 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 04KBpEgR007141; Wed, 20 May 2020 11:51:53 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma05fra.de.ibm.com with ESMTP id 313x4xhevq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2020 11:51:53 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 04KBpo9X10879372 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 May 2020 11:51:50 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C0453A4055; Wed, 20 May 2020 11:51:50 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ADA4DA4040; Wed, 20 May 2020 11:51:49 +0000 (GMT) Received: from hegdevasant.in.ibm.com (unknown [9.199.57.19]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 May 2020 11:51:49 +0000 (GMT) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Wed, 20 May 2020 17:21:38 +0530 Message-Id: <20200520115139.20734-2-hegdevasant@linux.vnet.ibm.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200520115139.20734-1-hegdevasant@linux.vnet.ibm.com> References: <20200520115139.20734-1-hegdevasant@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-20_07:2020-05-19, 2020-05-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 mlxlogscore=887 clxscore=1015 bulkscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=1 cotscore=-2147483648 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005200096 Subject: [Skiboot] [PATCH 2/3] uart: Workaround for unresponsive console X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" We use 4K internal output buffer for host console write. Whenever kernel makes opal_console_write() call it first write to internal buffer and then calls uart_con_flush() to flush data to UART console. If kernel is doing heavy console write operation and BMC becomes unresponsive (like BMC reboot) then our internal buffer becomes full. Kernel will keep on retrying write operation. This will result in kernel lockups. This patch introduces new timer. It starts timer whenever our write operation to UART is not making progress. If situation doesn't improve within specified time (10 seconds) then it will send error back to kernel. Signed-off-by: Vasant Hegde --- hw/lpc-uart.c | 60 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/hw/lpc-uart.c b/hw/lpc-uart.c index ed56a4bdc..672d4612b 100644 --- a/hw/lpc-uart.c +++ b/hw/lpc-uart.c @@ -217,6 +217,11 @@ static uint8_t *out_buf; static uint32_t out_buf_prod; static uint32_t out_buf_cons; +#define UART_BUFFER_OUT_TIMEOUT 10 +static uint64_t out_buf_timeout; +static uint64_t out_buf_prev_len; +static uint64_t con_flush_timeout; + /* Asynchronous flush, uart_lock must be held */ static int64_t uart_con_flush(void) { @@ -246,14 +251,31 @@ static int64_t uart_con_flush(void) } if (tx_full != tx_was_full) uart_update_ier(); + if (out_buf_prod != out_buf_cons) { - /* Return busy if nothing was flushed this call */ - if (out_buf_cons == out_buf_cons_initial) - return OPAL_BUSY; /* Return partial if there's more to flush */ - return OPAL_PARTIAL; + if (out_buf_cons != out_buf_cons_initial) { + con_flush_timeout = 0; + return OPAL_PARTIAL; + } + + /* + * Nothing was flushed. Start internal timer. We will continue + * returning BUSY until timeout happens, hoping BMC will consume + * data within timeout period. + */ + if (con_flush_timeout == 0) { + con_flush_timeout = mftb() + + secs_to_tb(UART_BUFFER_OUT_TIMEOUT); + } + + if (tb_compare(mftb(), con_flush_timeout) != TB_AAFTERB) + return OPAL_BUSY; + + return OPAL_INTERNAL_ERROR; } + con_flush_timeout = 0; return OPAL_SUCCESS; } @@ -273,6 +295,11 @@ static int64_t uart_opal_write(int64_t term_number, __be64 *__length, lock(&uart_lock); + if (!uart_tx_buf_space()) { + unlock(&uart_lock); + return OPAL_INTERNAL_ERROR; + } + /* Copy data to out buffer */ while (uart_tx_buf_space() && len--) { out_buf[out_buf_prod++] = *(buffer++); @@ -293,14 +320,35 @@ static int64_t uart_opal_write(int64_t term_number, __be64 *__length, static int64_t uart_opal_write_buffer_space(int64_t term_number, __be64 *__length) { + uint64_t tx_buf_len; + if (term_number != 0) return OPAL_PARAMETER; lock(&uart_lock); - *__length = cpu_to_be64(uart_tx_buf_space()); + tx_buf_len = uart_tx_buf_space(); + *__length = cpu_to_be64(tx_buf_len); unlock(&uart_lock); - return OPAL_SUCCESS; + if ((tx_buf_len != out_buf_prev_len) || (tx_buf_len == OUT_BUF_SIZE - 1)) { + out_buf_prev_len = tx_buf_len; + out_buf_timeout = 0; + return OPAL_SUCCESS; + } + + /* + * Buffer is full, start internal timer. We will continue returning + * SUCCESS until timeout happens, hoping BMC will consume data within + * timeout period. + */ + if (out_buf_timeout == 0) + out_buf_timeout = mftb() + secs_to_tb(UART_BUFFER_OUT_TIMEOUT); + + if (tb_compare(mftb(), out_buf_timeout) != TB_AAFTERB) + return OPAL_SUCCESS; + + /* Timeout happened. Lets drop incoming data */ + return OPAL_INTERNAL_ERROR; } /* Must be called with UART lock held */ From patchwork Wed May 20 11:51:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 1294286 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49RrjT0mbZz9sT1 for ; Wed, 20 May 2020 21:53:01 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49RrjS68HWzDqPm for ; Wed, 20 May 2020 21:53:00 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) 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=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com 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 49RrhH1cN2zDqLW for ; Wed, 20 May 2020 21:51:58 +1000 (AEST) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04KBX2Yt060048 for ; Wed, 20 May 2020 07:51:57 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 313x642tkm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 May 2020 07:51:57 -0400 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 04KBY5VM063239 for ; Wed, 20 May 2020 07:51:56 -0400 Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 313x642tjh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2020 07:51:56 -0400 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 04KBpEgS007141; Wed, 20 May 2020 11:51:54 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma05fra.de.ibm.com with ESMTP id 313x4xhevs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 May 2020 11:51:54 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 04KBpqg858785868 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 May 2020 11:51:52 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C61BA4051; Wed, 20 May 2020 11:51:52 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 13BAAA4040; Wed, 20 May 2020 11:51:51 +0000 (GMT) Received: from hegdevasant.in.ibm.com (unknown [9.199.57.19]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 May 2020 11:51:50 +0000 (GMT) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Wed, 20 May 2020 17:21:39 +0530 Message-Id: <20200520115139.20734-3-hegdevasant@linux.vnet.ibm.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200520115139.20734-1-hegdevasant@linux.vnet.ibm.com> References: <20200520115139.20734-1-hegdevasant@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-20_06:2020-05-19, 2020-05-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 impostorscore=0 phishscore=0 mlxscore=0 mlxlogscore=821 suspectscore=1 cotscore=-2147483648 malwarescore=0 clxscore=1011 lowpriorityscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005200101 Subject: [Skiboot] [PATCH 3/3] xscom: Do not wait indefinitely for xscom operation to complete X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" In some corner cases (specially on P8), xscom_wait_done() won't complete.. resulting in waiting forever. This patch retries for predefined time and then exits even if xscom operation did not complete. Signed-off-by: Vasant Hegde --- hw/xscom.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/xscom.c b/hw/xscom.c index 0eda567fc..500b6c0e9 100644 --- a/hw/xscom.c +++ b/hw/xscom.c @@ -72,10 +72,13 @@ static inline void *xscom_addr(uint32_t gcid, uint32_t pcb_addr) static uint64_t xscom_wait_done(void) { uint64_t hmer; + int retry_cnt = 0; - do + do { hmer = mfspr(SPR_HMER); - while(!(hmer & SPR_HMER_XSCOM_DONE)); + if (retry_cnt++ > 5) + break; + } while(!(hmer & SPR_HMER_XSCOM_DONE)); /* * HW822317: We need to read a second time as the actual