From patchwork Tue Dec 5 01:01:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Bur X-Patchwork-Id: 844522 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 3yrNnY0vK3z9s7g for ; Tue, 5 Dec 2017 12:04:49 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yrNnX6zlRzF06Z for ; Tue, 5 Dec 2017 12:04:48 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=au1.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=cyril.bur@au1.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 3yrNk25FbPzDrqV for ; Tue, 5 Dec 2017 12:01:46 +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 vB510Btl136442 for ; Mon, 4 Dec 2017 20:01:43 -0500 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2encqfsxga-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 04 Dec 2017 20:01:42 -0500 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 Dec 2017 01:01:40 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 5 Dec 2017 01:01:38 -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 vB511caC43057398; Tue, 5 Dec 2017 01:01:38 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4D791A405E; Tue, 5 Dec 2017 00:56:05 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ABB49A4055; Tue, 5 Dec 2017 00:56:04 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 5 Dec 2017 00:56:04 +0000 (GMT) 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 9AA9AA039B; Tue, 5 Dec 2017 12:01:34 +1100 (AEDT) From: Cyril Bur To: skiboot@lists.ozlabs.org Date: Tue, 5 Dec 2017 12:01:09 +1100 X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171205010113.23263-1-cyril.bur@au1.ibm.com> References: <20171205010113.23263-1-cyril.bur@au1.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17120501-0040-0000-0000-000003F65C5C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17120501-0041-0000-0000-000025F94EFE Message-Id: <20171205010113.23263-8-cyril.bur@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-12-04_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1712050012 Subject: [Skiboot] [PATCH v3 07/11] libflash/mbox-flash: Use BMC suggested timeout value 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: , Cc: alistair@popple.id.au 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 82d78717..401f5b13 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; } @@ -904,6 +913,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 @@ -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;