From patchwork Tue Dec 5 01:01:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Bur X-Patchwork-Id: 844516 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 3yrNlc3LY6z9s7g for ; Tue, 5 Dec 2017 12:03:08 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yrNlb2h0LzDrqW for ; Tue, 5 Dec 2017 12:03:07 +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 3yrNjz6v5VzDrqJ for ; Tue, 5 Dec 2017 12:01:43 +1100 (AEDT) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vB50x1gg067282 for ; Mon, 4 Dec 2017 20:01:42 -0500 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2encyxhbxk-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 04 Dec 2017 20:01:41 -0500 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 Dec 2017 01:01:38 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 5 Dec 2017 01:01:37 -0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vB511a5T3473662; Tue, 5 Dec 2017 01:01:36 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AA38F42045; Tue, 5 Dec 2017 00:56:03 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 344B142047; Tue, 5 Dec 2017 00:56:03 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 5 Dec 2017 00:56:03 +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 86639A0225; Tue, 5 Dec 2017 12:01:34 +1100 (AEDT) From: Cyril Bur To: skiboot@lists.ozlabs.org Date: Tue, 5 Dec 2017 12:01:05 +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-0020-0000-0000-000003D46312 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17120501-0021-0000-0000-00004269E344 Message-Id: <20171205010113.23263-4-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 03/11] libflash/mbox-flash: Move sequence handling to driver level 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 --- hw/lpc-mbox.c | 9 +++++++++ libflash/mbox-flash.c | 10 ---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/hw/lpc-mbox.c b/hw/lpc-mbox.c index 7a57f1e7..74214938 100644 --- a/hw/lpc-mbox.c +++ b/hw/lpc-mbox.c @@ -63,6 +63,7 @@ struct mbox { void *attn_data; struct lock lock; /* Protect in_flight */ struct bmc_mbox_msg *in_flight; + uint8_t sequence; }; static struct mbox mbox; @@ -130,6 +131,7 @@ int bmc_mbox_enqueue(struct bmc_mbox_msg *msg) mbox.in_flight = msg; unlock(&mbox.lock); + msg->seq = ++mbox.sequence; bmc_mbox_send_message(msg); @@ -162,7 +164,13 @@ static void mbox_poll(struct timer *t __unused, void *data __unused, prlog(PR_CRIT, "Couldn't find the message!!\n"); goto out_response; } + bmc_mbox_recv_message(msg); + if (mbox.sequence != msg->seq) { + prlog(PR_ERR, "Got a response to a message we no longer care about\n"); + goto out_response; + } + if (mbox.callback) mbox.callback(msg, mbox.drv_data); else @@ -330,6 +338,7 @@ void mbox_init(void) mbox.in_flight = NULL; mbox.callback = NULL; mbox.drv_data = NULL; + mbox.sequence = 0; init_lock(&mbox.lock); init_timer(&mbox.poller, mbox_poll, NULL); diff --git a/libflash/mbox-flash.c b/libflash/mbox-flash.c index c8a8dade..3615df78 100644 --- a/libflash/mbox-flash.c +++ b/libflash/mbox-flash.c @@ -59,7 +59,6 @@ struct mbox_flash_data { bool pause; bool busy; bool ack; - uint8_t seq; /* Plus one, commands start at 1 */ void (*handlers[MBOX_COMMAND_COUNT + 1])(struct mbox_flash_data *, struct bmc_mbox_msg*); struct bmc_mbox_msg msg_mem; @@ -199,7 +198,6 @@ static struct bmc_mbox_msg *msg_alloc(struct mbox_flash_data *mbox_flash, * really the performance optimisation you want to make. */ memset(&mbox_flash->msg_mem, 0, sizeof(mbox_flash->msg_mem)); - mbox_flash->msg_mem.seq = ++mbox_flash->seq; mbox_flash->msg_mem.command = command; return &mbox_flash->msg_mem; } @@ -900,14 +898,6 @@ static void mbox_flash_callback(struct bmc_mbox_msg *msg, void *priv) goto out; } - if (msg->seq != mbox_flash->seq) { - /* Uhoh */ - prlog(PR_ERR, "Sequence numbers don't match! Got: %02x Expected: %02x\n", - msg->seq, mbox_flash->seq); - mbox_flash->rc = MBOX_R_SYSTEM_ERROR; - goto out; - } - if (msg->command > MBOX_COMMAND_COUNT) { prlog(PR_ERR, "Got response to unknown command %02x\n", msg->command); mbox_flash->rc = -1;