Commit e9cd5941 authored by Roland Dreier's avatar Roland Dreier

IB/mthca: Convert FW commands to use wait_for_completion_timeout()

The kernel has had wait_for_completion_timeout() for a long time now.
mthca should use it to handle FW commands timing out, instead of
implementing the same thing in a much more complicated way by using
wait_for_completion() along with a timer that does complete().
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent f5358a17
...@@ -174,7 +174,6 @@ enum { ...@@ -174,7 +174,6 @@ enum {
struct mthca_cmd_context { struct mthca_cmd_context {
struct completion done; struct completion done;
struct timer_list timer;
int result; int result;
int next; int next;
u64 out_param; u64 out_param;
...@@ -362,15 +361,6 @@ void mthca_cmd_event(struct mthca_dev *dev, ...@@ -362,15 +361,6 @@ void mthca_cmd_event(struct mthca_dev *dev,
complete(&context->done); complete(&context->done);
} }
static void event_timeout(unsigned long context_ptr)
{
struct mthca_cmd_context *context =
(struct mthca_cmd_context *) context_ptr;
context->result = -EBUSY;
complete(&context->done);
}
static int mthca_cmd_wait(struct mthca_dev *dev, static int mthca_cmd_wait(struct mthca_dev *dev,
u64 in_param, u64 in_param,
u64 *out_param, u64 *out_param,
...@@ -401,11 +391,10 @@ static int mthca_cmd_wait(struct mthca_dev *dev, ...@@ -401,11 +391,10 @@ static int mthca_cmd_wait(struct mthca_dev *dev,
if (err) if (err)
goto out; goto out;
context->timer.expires = jiffies + timeout; if (!wait_for_completion_timeout(&context->done, timeout)) {
add_timer(&context->timer); err = -EBUSY;
goto out;
wait_for_completion(&context->done); }
del_timer_sync(&context->timer);
err = context->result; err = context->result;
if (err) if (err)
...@@ -535,10 +524,6 @@ int mthca_cmd_use_events(struct mthca_dev *dev) ...@@ -535,10 +524,6 @@ int mthca_cmd_use_events(struct mthca_dev *dev)
for (i = 0; i < dev->cmd.max_cmds; ++i) { for (i = 0; i < dev->cmd.max_cmds; ++i) {
dev->cmd.context[i].token = i; dev->cmd.context[i].token = i;
dev->cmd.context[i].next = i + 1; dev->cmd.context[i].next = i + 1;
init_timer(&dev->cmd.context[i].timer);
dev->cmd.context[i].timer.data =
(unsigned long) &dev->cmd.context[i];
dev->cmd.context[i].timer.function = event_timeout;
} }
dev->cmd.context[dev->cmd.max_cmds - 1].next = -1; dev->cmd.context[dev->cmd.max_cmds - 1].next = -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment