aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAlistair Popple <alistair@popple.id.au>2016-02-23 15:34:33 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2016-02-25 14:02:32 +1100
commit9a6e83c5552e49d11f602131859cca4eafff28d0 (patch)
tree4e6fd90595f5ac9e36e909b1b6ea7266f88740a9 /hw
parent7edd87afae3627de3012d902bce0f5e15251422c (diff)
downloadskiboot-9a6e83c5552e49d11f602131859cca4eafff28d0.zip
skiboot-9a6e83c5552e49d11f602131859cca4eafff28d0.tar.gz
skiboot-9a6e83c5552e49d11f602131859cca4eafff28d0.tar.bz2
hw/bt.c: Fix message timeout
Commit fb457c9 (hw/bt: Ask the BMC for its BT interface capabilities) sets the BT message timeout based on the IPMI get capabilities command. This adds a new structure containing a uint8_t to store the message timeout in seconds (msg_timeout). This introduces two problems: 1) The code that checks for timeouts assumes msg_timeout is in units of the timebase (tb_hz). 2) If get_bt_caps() fails msg_timeout is set to BT_MSG_TIMEOUT which is in units of tb_hz and easily overflows a uint8_t. This patch solves the above two problems by changing the definition of BT_MSG_TIMEOUT to seconds and using secs_to_tb() when comparing timebases. It also converts the timebase comparison to use tb_compare(). Signed-off-by: Alistair Popple <alistair@popple.id.au> Cc: Cyril Bur <cyril.bur@au1.ibm.com> Cc: Stewart Smith <stewart@linux.vnet.ibm.com> Cc: Jeremy Kerr <jk@ozlabs.org> Cc: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com> Tested-by: Vipin K Parashar <vipin@linux.vnet.ibm.com> Reviewed-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/bt.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/hw/bt.c b/hw/bt.c
index df4a4f0..3325f69 100644
--- a/hw/bt.c
+++ b/hw/bt.c
@@ -24,6 +24,7 @@
#include <bt.h>
#include <timer.h>
#include <ipmi.h>
+#include <timebase.h>
/* BT registers */
#define BT_CTRL 0
@@ -65,9 +66,9 @@
#define BT_MAX_QUEUE_LEN 10
/*
- * How long (in TB ticks) before a message is timed out.
+ * How long (in seconds) before a message is timed out.
*/
-#define BT_MSG_TIMEOUT (secs_to_tb(3))
+#define BT_MSG_TIMEOUT 3
/*
* Maximum number of times to attempt sending a message before giving up.
@@ -390,7 +391,8 @@ static void bt_expire_old_msg(uint64_t tb)
bt_msg = list_top(&bt.msgq, struct bt_msg, link);
- if (bt_msg && bt_msg->tb > 0 && (bt_msg->tb + bt.caps.msg_timeout) < tb) {
+ if (bt_msg && bt_msg->tb > 0 &&
+ (tb_compare(tb, bt_msg->tb + secs_to_tb(bt.caps.msg_timeout)) == TB_AAFTERB)) {
if (bt_msg->send_count < BT_MAX_SEND_COUNT) {
/* A message timeout is usually due to the BMC
clearing the H2B_ATN flag without actually