From patchwork Thu Jun 29 12:39:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Bur X-Patchwork-Id: 782225 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wz0082T3Mz9s3T for ; Thu, 29 Jun 2017 22:51:20 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3wz0080xkTzDrBC for ; Thu, 29 Jun 2017 22:51:20 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org 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 3wyzlP6RFCzDrLN for ; Thu, 29 Jun 2017 22:40:17 +1000 (AEST) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v5TCcxB4015121 for ; Thu, 29 Jun 2017 08:40:16 -0400 Received: from e23smtp04.au.ibm.com (e23smtp04.au.ibm.com [202.81.31.146]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bd1dt0ubx-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 29 Jun 2017 08:40:15 -0400 Received: from localhost by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 29 Jun 2017 22:40:07 +1000 Received: from d23relay10.au.ibm.com (202.81.31.229) by e23smtp04.au.ibm.com (202.81.31.210) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 29 Jun 2017 22:40:04 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v5TCe23I8978730 for ; Thu, 29 Jun 2017 22:40:02 +1000 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 v5TCdsVh023765 for ; Thu, 29 Jun 2017 22:39:54 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v5TCdsRj023758; Thu, 29 Jun 2017 22:39:54 +1000 Received: from camb691.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 16E85A02C6; Thu, 29 Jun 2017 22:40:02 +1000 (AEST) From: Cyril Bur To: skiboot@lists.ozlabs.org, sjitindarsingh@gmail.com Date: Thu, 29 Jun 2017 22:39:21 +1000 X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170629123925.28243-1-cyril.bur@au1.ibm.com> References: <20170629123925.28243-1-cyril.bur@au1.ibm.com> X-TM-AS-MML: disable x-cbid: 17062912-0012-0000-0000-000002501E71 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17062912-0013-0000-0000-000007691E82 Message-Id: <20170629123925.28243-8-cyril.bur@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-29_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706290207 Subject: [Skiboot] [PATCH 07/11] libflash/mbox-flash: Use BMC suggested timeout value X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair@popple.id.au, sam@mendozajonas.com MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Signed-off-by: Cyril Bur --- libflash/mbox-flash.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/libflash/mbox-flash.c b/libflash/mbox-flash.c index 999f663c..2a7321f4 100644 --- a/libflash/mbox-flash.c +++ b/libflash/mbox-flash.c @@ -50,6 +50,7 @@ struct lpc_window { struct mbox_flash_data { int version; + uint16_t timeout; uint32_t shift; struct lpc_window read; struct lpc_window write; @@ -286,7 +287,12 @@ static int mbox_flash_ack(struct mbox_flash_data *mbox_flash, uint8_t reg) /* Clear this first so msg_send() doesn't freak out */ mbox_flash->reboot = false; - rc = msg_send(mbox_flash, &msg, MBOX_DEFAULT_TIMEOUT); + /* + * Use a lower timeout - there is strong evidence to suggest the + * BMC won't respond, don't waste time spinning here just have the + * high levels retry when the BMC might be back + */ + rc = msg_send(mbox_flash, &msg, 3); /* Still need to deal with it, we've only acked it now. */ mbox_flash->reboot = true; @@ -340,6 +346,9 @@ static void mbox_flash_do_get_mbox_info(struct mbox_flash_data *mbox_flash, mbox_flash->write.size = blocks_to_bytes(mbox_flash, msg_get_u16(msg, 3)); } else { /* V2 compatible */ mbox_flash->shift = msg_get_u8(msg, 5); + mbox_flash->timeout = msg_get_u16(msg, 6); + if (mbox_flash->timeout == 0) + mbox_flash->timeout = MBOX_DEFAULT_TIMEOUT; } /* Callers will handle the case where the version is not known * @@ -472,13 +481,13 @@ static int mbox_flash_mark_write(struct mbox_flash_data *mbox_flash, msg_put_u16(&msg, 2, end - start); /* Total Length */ } - rc = msg_send(mbox_flash, &msg, MBOX_DEFAULT_TIMEOUT); + rc = msg_send(mbox_flash, &msg, mbox_flash->timeout); if (rc) { prlog(PR_ERR, "Failed to enqueue/send BMC MBOX message\n"); return rc; } - rc = wait_for_bmc(mbox_flash, MBOX_DEFAULT_TIMEOUT); + rc = wait_for_bmc(mbox_flash, mbox_flash->timeout); if (rc) prlog(PR_ERR, "Error waiting for BMC\n"); @@ -519,13 +528,13 @@ static int mbox_flash_flush(struct mbox_flash_data *mbox_flash) return FLASH_ERR_DEVICE_GONE; } - rc = msg_send(mbox_flash, &msg, MBOX_DEFAULT_TIMEOUT); + rc = msg_send(mbox_flash, &msg, mbox_flash->timeout); if (rc) { prlog(PR_ERR, "Failed to enqueue/send BMC MBOX message\n"); return rc; } - rc = wait_for_bmc(mbox_flash, MBOX_DEFAULT_TIMEOUT); + rc = wait_for_bmc(mbox_flash, mbox_flash->timeout); if (rc) prlog(PR_ERR, "Error waiting for BMC\n"); @@ -568,7 +577,7 @@ static int mbox_window_move(struct mbox_flash_data *mbox_flash, win->cur_pos = pos & ~mbox_flash_mask(mbox_flash); msg_put_u16(&msg, 0, bytes_to_blocks(mbox_flash, pos)); - rc = msg_send(mbox_flash, &msg, MBOX_DEFAULT_TIMEOUT); + rc = msg_send(mbox_flash, &msg, mbox_flash->timeout); if (rc) { prlog(PR_ERR, "Failed to enqueue/send BMC MBOX message\n"); return rc; @@ -577,7 +586,7 @@ static int mbox_window_move(struct mbox_flash_data *mbox_flash, mbox_flash->read.open = false; mbox_flash->write.open = false; - rc = wait_for_bmc(mbox_flash, MBOX_DEFAULT_TIMEOUT); + rc = wait_for_bmc(mbox_flash, mbox_flash->timeout); if (rc) { prlog(PR_ERR, "Error waiting for BMC\n"); return rc; @@ -725,13 +734,13 @@ static int mbox_flash_get_info(struct blocklevel_device *bl, const char **name, *name = NULL; mbox_flash->busy = true; - rc = msg_send(mbox_flash, &msg, MBOX_DEFAULT_TIMEOUT); + rc = msg_send(mbox_flash, &msg, mbox_flash->timeout); if (rc) { prlog(PR_ERR, "Failed to enqueue/send BMC MBOX message\n"); return rc; } - if (wait_for_bmc(mbox_flash, MBOX_DEFAULT_TIMEOUT)) { + if (wait_for_bmc(mbox_flash, mbox_flash->timeout)) { prlog(PR_ERR, "Error waiting for BMC\n"); return rc; } @@ -905,6 +914,12 @@ static int protocol_init(struct mbox_flash_data *mbox_flash) mbox_flash->shift = 12; /* + * For V1 we'll use this value. + * V2: The init code (may) update this + */ + mbox_flash->timeout = MBOX_DEFAULT_TIMEOUT; + + /* * Always attempt init with V2. * The GET_MBOX_INFO response will confirm that the other side can * talk V2, we'll update this variable then if V2 is not supported @@ -912,13 +927,13 @@ static int protocol_init(struct mbox_flash_data *mbox_flash) mbox_flash->version = 2; msg_put_u8(&msg, 0, mbox_flash->version); - rc = msg_send(mbox_flash, &msg, MBOX_DEFAULT_TIMEOUT); + rc = msg_send(mbox_flash, &msg, mbox_flash->timeout); if (rc) { prlog(PR_ERR, "Failed to enqueue/send BMC MBOX message\n"); return rc; } - rc = wait_for_bmc(mbox_flash, MBOX_DEFAULT_TIMEOUT); + rc = wait_for_bmc(mbox_flash, mbox_flash->timeout); if (rc) { prlog(PR_ERR, "Error waiting for BMC\n"); return rc;