Commit 5efe5355 authored by Jack Morgenstein's avatar Jack Morgenstein Committed by David S. Miller

net/mlx4_core: Return -EPROBE_DEFER when a VF is probed before PF is sufficiently initialized

In the PF initialization, SRIOV is enabled before the PF is fully initialized.
This allows the kernel to probe the newly-exposed VFs before the PF is ready
to handle them (nested probes).

Have the probe method return the -EPROBE_DEFER value in this situation (instead
of the VF probe method retrying its initialization in a loop, and returning -EIO
on failure). When -EPROBE_DEFER is returned by the VF probe method, the kernel
itself will retry the probe after a suitable delay.

Based upon a suggestion by Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: default avatarJack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a1c6693a
...@@ -222,8 +222,6 @@ static int mlx4_comm_cmd_poll(struct mlx4_dev *dev, u8 cmd, u16 param, ...@@ -222,8 +222,6 @@ static int mlx4_comm_cmd_poll(struct mlx4_dev *dev, u8 cmd, u16 param,
* FLR process. The only non-zero result in the RESET command * FLR process. The only non-zero result in the RESET command
* is MLX4_DELAY_RESET_SLAVE*/ * is MLX4_DELAY_RESET_SLAVE*/
if ((MLX4_COMM_CMD_RESET == cmd)) { if ((MLX4_COMM_CMD_RESET == cmd)) {
mlx4_warn(dev, "Got slave FLRed from Communication"
" channel (ret:0x%x)\n", ret_from_pending);
err = MLX4_DELAY_RESET_SLAVE; err = MLX4_DELAY_RESET_SLAVE;
} else { } else {
mlx4_warn(dev, "Communication channel timed out\n"); mlx4_warn(dev, "Communication channel timed out\n");
......
...@@ -1290,7 +1290,6 @@ static int mlx4_init_slave(struct mlx4_dev *dev) ...@@ -1290,7 +1290,6 @@ static int mlx4_init_slave(struct mlx4_dev *dev)
{ {
struct mlx4_priv *priv = mlx4_priv(dev); struct mlx4_priv *priv = mlx4_priv(dev);
u64 dma = (u64) priv->mfunc.vhcr_dma; u64 dma = (u64) priv->mfunc.vhcr_dma;
int num_of_reset_retries = NUM_OF_RESET_RETRIES;
int ret_from_reset = 0; int ret_from_reset = 0;
u32 slave_read; u32 slave_read;
u32 cmd_channel_ver; u32 cmd_channel_ver;
...@@ -1304,18 +1303,10 @@ static int mlx4_init_slave(struct mlx4_dev *dev) ...@@ -1304,18 +1303,10 @@ static int mlx4_init_slave(struct mlx4_dev *dev)
* NUM_OF_RESET_RETRIES times before leaving.*/ * NUM_OF_RESET_RETRIES times before leaving.*/
if (ret_from_reset) { if (ret_from_reset) {
if (MLX4_DELAY_RESET_SLAVE == ret_from_reset) { if (MLX4_DELAY_RESET_SLAVE == ret_from_reset) {
msleep(SLEEP_TIME_IN_RESET); mlx4_warn(dev, "slave is currently in the "
while (ret_from_reset && num_of_reset_retries) { "middle of FLR. Deferring probe.\n");
mlx4_warn(dev, "slave is currently in the" mutex_unlock(&priv->cmd.slave_cmd_mutex);
"middle of FLR. retrying..." return -EPROBE_DEFER;
"(try num:%d)\n",
(NUM_OF_RESET_RETRIES -
num_of_reset_retries + 1));
ret_from_reset =
mlx4_comm_cmd(dev, MLX4_COMM_CMD_RESET,
0, MLX4_COMM_TIME);
num_of_reset_retries = num_of_reset_retries - 1;
}
} else } else
goto err; goto err;
} }
...@@ -1526,7 +1517,8 @@ static int mlx4_init_hca(struct mlx4_dev *dev) ...@@ -1526,7 +1517,8 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
} else { } else {
err = mlx4_init_slave(dev); err = mlx4_init_slave(dev);
if (err) { if (err) {
mlx4_err(dev, "Failed to initialize slave\n"); if (err != -EPROBE_DEFER)
mlx4_err(dev, "Failed to initialize slave\n");
return err; return err;
} }
......
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