From abbb687e7485e01f46554b6211b00db2e4b93182 Mon Sep 17 00:00:00 2001 From: Jack Morgenstein Date: Mon, 11 Feb 2013 18:44:14 +0200 Subject: [PATCH] mlx4_core: print more info when command times out To assist in diagnosing command timeouts, print the go-bit status and toggle-bit status in the warning output. In addition, print an indication of the pci_bus is offline. Signed-off-by: Jack Morgenstein (Ported from Mellanox OFED 2.4) Signed-off-by: Mukesh Kacker --- drivers/net/ethernet/mellanox/mlx4/cmd.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c index 529ef0594b90..a3d99554c132 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c @@ -679,6 +679,19 @@ void mlx4_cmd_event(struct mlx4_dev *dev, u16 token, u8 status, u64 out_param) complete(&context->done); } +static int get_status(struct mlx4_dev *dev, u32 *status, int *go_bit, + int *t_bit) +{ + if (pci_channel_offline(dev->persist->pdev)) + return -EIO; + + *status = readl(mlx4_priv(dev)->cmd.hcr + HCR_STATUS_OFFSET); + *t_bit = !!(*status & swab32(1 << HCR_T_BIT)); + *go_bit = !!(*status & swab32(1 << HCR_GO_BIT)); + + return 0; +} + static int mlx4_cmd_wait(struct mlx4_dev *dev, u64 in_param, u64 *out_param, int out_is_imm, u32 in_modifier, u8 op_modifier, u16 op, unsigned long timeout) @@ -686,6 +699,8 @@ static int mlx4_cmd_wait(struct mlx4_dev *dev, u64 in_param, u64 *out_param, struct mlx4_cmd *cmd = &mlx4_priv(dev)->cmd; struct mlx4_cmd_context *context; int err = 0; + int go_bit = 0, t_bit = 0, stat_err; + u32 status = 0; down(&cmd->event_sem); @@ -712,8 +727,11 @@ static int mlx4_cmd_wait(struct mlx4_dev *dev, u64 in_param, u64 *out_param, if (!wait_for_completion_timeout(&context->done, msecs_to_jiffies(timeout))) { - mlx4_warn(dev, "command 0x%x timed out (go bit not cleared)\n", - op); + stat_err = get_status(dev, &status, &go_bit, &t_bit); + mlx4_warn(dev, "command 0x%x timed out: " + "get_status err=%d, status=0x%x, go_bit=%d, " + "t_bit=%d, toggle=0x%x\n", op, stat_err, status, + go_bit, t_bit, mlx4_priv(dev)->cmd.toggle); if (op == MLX4_CMD_NOP) { err = -EBUSY; goto out; -- 2.50.1