<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.5512" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=922162914-17112009><FONT face=Arial color=#0000ff
size=2>Applied in 2582.</FONT></SPAN></DIV><BR>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> ofw-bounces@lists.openfabrics.org
[mailto:ofw-bounces@lists.openfabrics.org] <B>On Behalf Of </B>Leonid
Keller<BR><B>Sent:</B> Monday, November 16, 2009 10:44 AM<BR><B>To:</B>
ofw_list<BR><B>Subject:</B> [ofw][patch][MLX4] improve debug in error flow of
command interface<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2>Index:
V:/svn/winib/trunk/hw/mlx4/kernel/bus/net/cmd.c<BR>===================================================================<BR>---
V:/svn/winib/trunk/hw/mlx4/kernel/bus/net/cmd.c (revision 5038)<BR>+++
V:/svn/winib/trunk/hw/mlx4/kernel/bus/net/cmd.c (revision 5039)<BR>@@
-102,6 +102,7
@@<BR> int next;<BR> u64 out_param;<BR> u16 token;<BR>+ u8 status;<BR> };<BR> <BR> static
int mlx4_status_to_errno(u8 status) {<BR>@@ -137,13 +138,13
@@<BR> return trans_table[status];<BR> }<BR> <BR>-static
int cmd_pending(struct mlx4_dev *dev)<BR>+static int cmd_pending(struct
mlx4_dev *dev, u32 *p_status)<BR> {<BR>- u32 status =
readl(mlx4_priv(dev)->cmd.hcr + HCR_STATUS_OFFSET);<BR>+ *p_status =
readl(mlx4_priv(dev)->cmd.hcr +
HCR_STATUS_OFFSET);<BR> <BR>- return (status & swab32(1 <<
HCR_GO_BIT)) ||<BR>+ return (*p_status & swab32(1 <<
HCR_GO_BIT)) ||<BR> (mlx4_priv(dev)->cmd.toggle
==<BR>- !!(status & swab32(1 <<
HCR_T_BIT)));<BR>+ !!(*p_status & swab32(1 <<
HCR_T_BIT)));<BR> }<BR> <BR> static int mlx4_cmd_post(struct
mlx4_dev *dev, u64 in_param, u64 out_param,<BR>@@ -154,6 +155,7
@@<BR> u32 __iomem *hcr = (u32 __iomem
*)cmd->hcr;<BR> int ret = -EAGAIN;<BR> u64
end;<BR>+ u32
hcr_status;<BR> <BR> mutex_lock(&cmd->hcr_mutex);<BR> <BR>@@
-161,9 +163,12 @@<BR> if (event)<BR> end +=
msecs_to_jiffies(GO_BIT_TIMEOUT_MSECS);<BR> <BR>- while
(cmd_pending(dev)) {<BR>- if (time_after_eq(jiffies,
end))<BR>+ while (cmd_pending(dev, &hcr_status)) {<BR>+ if
(time_after_eq(jiffies, end)) {<BR>+ mlx4_err(dev, "Failed to
post command %02x during %d msecs, hcr_status %#x, toggle
%#x\n",<BR>+ op, GO_BIT_TIMEOUT_MSECS, hcr_status,
mlx4_priv(dev)->cmd.toggle );<BR> goto
out;<BR>+ }<BR> cond_resched();<BR> }<BR> <BR>@@
-212,8 +217,9 @@<BR> u8 __iomem *hcr =
priv->cmd.hcr;<BR> int err = 0;<BR> u64
end;<BR>- u8 status;<BR>+ u8 status = 0xff; /* means "unknown"
*/<BR> long do_reset;<BR>+ u32
hcr_status;<BR> <BR> down(&priv->cmd.poll_sem);<BR> <BR>@@
-223,13 +229,13 @@<BR> goto out;<BR> <BR> end
= msecs_to_jiffies(timeout) + jiffies;<BR>- while (cmd_pending(dev)
&& time_before(jiffies, end))<BR>+ while (cmd_pending(dev,
&hcr_status) && time_before(jiffies,
end))<BR> cond_resched();<BR> <BR>- if
(cmd_pending(dev)) {<BR>+ if (cmd_pending(dev, &hcr_status))
{<BR> err = -ETIMEDOUT;<BR>- mlx4_err(dev,
"mlx4_cmd_poll: Command %02x completed with timeout after %d msecs
\n",<BR>- op, timeout);<BR>+ mlx4_err(dev,
"mlx4_cmd_poll: Command %02x: timeout after %d msecs, hcr_status %#x, toggle
%#x \n",<BR>+ op, timeout, hcr_status,
mlx4_priv(dev)->cmd.toggle);<BR> <BR> do_reset =
InterlockedCompareExchange(&dev->reset_pending, 1,
0);<BR> if (!do_reset) {<BR>@@ -258,11 +264,11
@@<BR> <BR> status = (u8)(be32_to_cpu((__force
__be32)__raw_readl(hcr + HCR_STATUS_OFFSET)) >> 24);<BR> err
= mlx4_status_to_errno(status);<BR>+<BR>+out:<BR> if (status
&& status != 0x50)<BR>- mlx4_err(dev, "Command failed: op
%#hx, status %#02x, errno %d.\n", <BR>+ mlx4_err(dev,
"mlx4_cmd_poll: Command failed: op %#hx, status %#02x, errno %d.\n",
<BR> op, status,
err);<BR>-<BR>-out:<BR> up(&priv->cmd.poll_sem);<BR> return
err;<BR> }<BR>@@ -274,14 +280,14
@@<BR> &priv->cmd.context[token &
priv->cmd.token_mask];<BR> <BR> /* previously timed out
command completing at long last */<BR>- if (token !=
context->token)<BR>+ if (token != context->token)
{<BR>+ mlx4_err(dev, "mlx4_cmd_event: Command skipped: token %#hx,
ctx_token %#hx\n", <BR>+ token,
context->token);<BR> return;<BR>+ }<BR> <BR> context->result
= mlx4_status_to_errno(status);<BR>- <BR>- if
(status)<BR>- mlx4_err(dev, "Command failed: token %#hx, status
%#02x, errno %d.\n", <BR>- token, status,
context->result);<BR>+ context->status =
status;<BR> context->out_param =
out_param;<BR> <BR> complete(&context->done);<BR>@@
-296,6 +302,7 @@<BR> int err = 0;<BR> u64 out_prm =
out_param ? *out_param : 0;<BR> long do_reset;<BR>+ u8 status
= 0xff; /* means "unknown"
*/<BR> <BR> down(&cmd->event_sem);<BR> if (
dev->flags & MLX4_FLAG_RESET_DRIVER ) {<BR>@@ -312,8 +319,10
@@<BR> <BR> init_completion(&context->done);<BR> <BR>- mlx4_cmd_post(dev,
in_param, out_prm,<BR>+ err = mlx4_cmd_post(dev, in_param,
out_prm,<BR> in_modifier, op_modifier, op, context->token,
1);<BR>+ if (err)<BR>+ goto out;<BR> <BR> if
(wait_for_completion_timeout(&context->done,
msecs_to_jiffies(timeout))) {<BR> if (!context->done.done)
{<BR>@@ -348,12 +357,14 @@<BR> }<BR> else
{<BR> err =
-EFAULT;<BR>- mlx4_err(dev, "mlx4_cmd_wait: Unexpected end of
waiting for a comand \n");<BR>+ mlx4_err(dev, "mlx4_cmd_wait:
Unexpected end of waiting for a command
\n");<BR> ASSERT(0);<BR> }<BR> }<BR>- else<BR>+ else
{<BR> err = context->result;<BR>+ status =
context->status;<BR>+ }<BR> <BR> if
(err)<BR> goto out;<BR>@@ -366,6 +377,9
@@<BR> context->next =
cmd->free_head;<BR> cmd->free_head = (int)(context -
cmd->context);<BR> spin_unlock(&cmd->context_lock);<BR>+ if
(status && status != 0x50)<BR>+ mlx4_err(dev,
"mlx4_cmd_wait: Command failed: op %#hx, status %#02x, errno %d, token
%#hx.\n", <BR>+ op, status, err,
context->token);<BR> <BR> exit: <BR> up(&cmd->event_sem);<BR></FONT></DIV></BLOCKQUOTE></BODY></HTML>