From patchwork Thu Nov 12 06:22:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Bur X-Patchwork-Id: 543243 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 AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6EE57140761 for ; Thu, 12 Nov 2015 17:24:48 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 52E9A1A08AC for ; Thu, 12 Nov 2015 17:24:48 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp03.au.ibm.com (e23smtp03.au.ibm.com [202.81.31.145]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 8F2F61A0835 for ; Thu, 12 Nov 2015 17:24:31 +1100 (AEDT) Received: from localhost by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Nov 2015 16:24:30 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp03.au.ibm.com (202.81.31.209) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 12 Nov 2015 16:24:28 +1000 X-IBM-Helo: d23dlp03.au.ibm.com X-IBM-MailFrom: cyril.bur@au1.ibm.com X-IBM-RcptTo: skiboot@lists.ozlabs.org Received: from d23relay09.au.ibm.com (d23relay09.au.ibm.com [9.185.63.181]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 01D643578052 for ; Thu, 12 Nov 2015 17:24:27 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tAC6OJKq53739586 for ; Thu, 12 Nov 2015 17:24:27 +1100 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 tAC6Ntbv027884 for ; Thu, 12 Nov 2015 17:23:55 +1100 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 tAC6NteC027331 for ; Thu, 12 Nov 2015 17:23:55 +1100 Received: from camb691.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 8BA3FA0258 for ; Thu, 12 Nov 2015 17:23:31 +1100 (AEDT) From: Cyril Bur To: skiboot@lists.ozlabs.org Date: Thu, 12 Nov 2015 17:22:57 +1100 Message-Id: <1447309379-7683-4-git-send-email-cyril.bur@au1.ibm.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1447309379-7683-1-git-send-email-cyril.bur@au1.ibm.com> References: <1447309379-7683-1-git-send-email-cyril.bur@au1.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15111206-0009-0000-0000-0000025B97A3 Subject: [Skiboot] [PATCH V2 3/5] hw/bt: Remove state machine and use only B2H_ATN and H2B_ATN. X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.20 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" Correct use of B2H_ATN and H2B_ATN means that we don't need to track states. The only caveat is that currently we use states to know if we need to send a message to the BMC, change this to simply seeing if the top message has been sent or not. Signed-off-by: Cyril Bur Acked-by: Alistair Popple --- hw/bt.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/hw/bt.c b/hw/bt.c index 253ca2a..215a05b 100644 --- a/hw/bt.c +++ b/hw/bt.c @@ -101,11 +101,6 @@ #define BT_Q_INF(msg, fmt, args...) BT_INF(fmt, ##args) #endif -enum bt_states { - BT_STATE_IDLE = 0, - BT_STATE_RESP_WAIT, -}; - struct bt_msg { struct list_node link; unsigned long tb; @@ -116,7 +111,6 @@ struct bt_msg { struct bt { uint32_t base_addr; - enum bt_states state; struct lock lock; struct list_head msgq; struct timer poller; @@ -153,11 +147,6 @@ static inline bool bt_idle(void) return !(bt_ctrl & BT_CTRL_B_BUSY) && !(bt_ctrl & BT_CTRL_H2B_ATN); } -static inline void bt_set_state(enum bt_states next_state) -{ - bt.state = next_state; -} - /* Must be called with bt.lock held */ static void bt_msg_del(struct bt_msg *bt_msg) { @@ -177,8 +166,6 @@ static void bt_init_interface(void) /* Take care of a stable H_BUSY if any */ bt_set_h_busy(false); - - bt_set_state(BT_STATE_IDLE); } static void bt_reset_interface(void) @@ -220,7 +207,6 @@ static void bt_send_msg(struct bt_msg *bt_msg) bt_msg->send_count++; bt_outb(BT_CTRL_H2B_ATN, BT_CTRL); - bt_set_state(BT_STATE_RESP_WAIT); return; } @@ -275,7 +261,6 @@ static void bt_get_resp(void) BT_INF("BT: Nobody cared about a response to an BT/IPMI message" "(seq 0x%02x netfn 0x%02x cmd 0x%02x)", seq, netfn, cmd); bt_flush_msg(); - bt_set_state(BT_STATE_IDLE); return; } @@ -298,8 +283,6 @@ static void bt_get_resp(void) ipmi_msg->data[i] = bt_inb(BT_HOST2BMC); bt_set_h_busy(false); - bt_set_state(BT_STATE_IDLE); - BT_Q_DBG(bt_msg, "IPMI MSG done"); list_del(&bt_msg->link); @@ -382,7 +365,12 @@ static void bt_send_and_unlock(void) if (bt_msg->tb == 0) bt_msg->tb = mftb(); - if (bt_idle() && bt.state == BT_STATE_IDLE) + /* + * Only send it if we haven't already. + * Timeouts and retries happen in bt_expire_old_msg() + * called from bt_poll() + */ + if (bt_idle() && bt_msg->send_count == 0) bt_send_msg(bt_msg); } @@ -408,8 +396,7 @@ static void bt_poll(struct timer *t __unused, void *data __unused, bt_ctrl = bt_inb(BT_CTRL); /* Is there a response waiting for us? */ - if (bt.state == BT_STATE_RESP_WAIT && - (bt_ctrl & BT_CTRL_B2H_ATN)) + if (bt_ctrl & BT_CTRL_B2H_ATN) bt_get_resp(); bt_expire_old_msg(now); @@ -576,7 +563,6 @@ void bt_init(void) * The iBT interface comes up in the busy state until the daemon has * initialised it. */ - bt_set_state(BT_STATE_IDLE); list_head_init(&bt.msgq); bt.queue_len = 0;