Skip to content

Commit bcad0e5

Browse files
mosheshemesh2Saeed Mahameed
authored andcommitted
net/mlx5: Return specific error code for timeout on wait_fw_init
The function wait_fw_init() returns same error code either if it breaks waiting due to timeout or other reason. Thus, the function callers print error message on timeout without checking error type. Return different error code for different failure reason and print error message accordingly on wait_fw_init(). Signed-off-by: Moshe Shemesh <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 137cef6 commit bcad0e5

File tree

1 file changed

+19
-19
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+19
-19
lines changed

drivers/net/ethernet/mellanox/mlx5/core/main.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -187,31 +187,36 @@ static struct mlx5_profile profile[] = {
187187
};
188188

189189
static int wait_fw_init(struct mlx5_core_dev *dev, u32 max_wait_mili,
190-
u32 warn_time_mili)
190+
u32 warn_time_mili, const char *init_state)
191191
{
192192
unsigned long warn = jiffies + msecs_to_jiffies(warn_time_mili);
193193
unsigned long end = jiffies + msecs_to_jiffies(max_wait_mili);
194194
u32 fw_initializing;
195-
int err = 0;
196195

197196
do {
198197
fw_initializing = ioread32be(&dev->iseg->initializing);
199198
if (!(fw_initializing >> 31))
200199
break;
201-
if (time_after(jiffies, end) ||
202-
test_bit(MLX5_BREAK_FW_WAIT, &dev->intf_state)) {
203-
err = -EBUSY;
204-
break;
200+
if (time_after(jiffies, end)) {
201+
mlx5_core_err(dev, "Firmware over %u MS in %s state, aborting\n",
202+
max_wait_mili, init_state);
203+
return -ETIMEDOUT;
204+
}
205+
if (test_bit(MLX5_BREAK_FW_WAIT, &dev->intf_state)) {
206+
mlx5_core_warn(dev, "device is being removed, stop waiting for FW %s\n",
207+
init_state);
208+
return -ENODEV;
205209
}
206210
if (warn_time_mili && time_after(jiffies, warn)) {
207-
mlx5_core_warn(dev, "Waiting for FW initialization, timeout abort in %ds (0x%x)\n",
208-
jiffies_to_msecs(end - warn) / 1000, fw_initializing);
211+
mlx5_core_warn(dev, "Waiting for FW %s, timeout abort in %ds (0x%x)\n",
212+
init_state, jiffies_to_msecs(end - warn) / 1000,
213+
fw_initializing);
209214
warn = jiffies + msecs_to_jiffies(warn_time_mili);
210215
}
211216
msleep(mlx5_tout_ms(dev, FW_PRE_INIT_WAIT));
212217
} while (true);
213218

214-
return err;
219+
return 0;
215220
}
216221

217222
static void mlx5_set_driver_version(struct mlx5_core_dev *dev)
@@ -1151,12 +1156,10 @@ static int mlx5_function_enable(struct mlx5_core_dev *dev, bool boot, u64 timeou
11511156
/* wait for firmware to accept initialization segments configurations
11521157
*/
11531158
err = wait_fw_init(dev, timeout,
1154-
mlx5_tout_ms(dev, FW_PRE_INIT_WARN_MESSAGE_INTERVAL));
1155-
if (err) {
1156-
mlx5_core_err(dev, "Firmware over %llu MS in pre-initializing state, aborting\n",
1157-
timeout);
1159+
mlx5_tout_ms(dev, FW_PRE_INIT_WARN_MESSAGE_INTERVAL),
1160+
"pre-initializing");
1161+
if (err)
11581162
return err;
1159-
}
11601163

11611164
err = mlx5_cmd_enable(dev);
11621165
if (err) {
@@ -1166,12 +1169,9 @@ static int mlx5_function_enable(struct mlx5_core_dev *dev, bool boot, u64 timeou
11661169

11671170
mlx5_tout_query_iseg(dev);
11681171

1169-
err = wait_fw_init(dev, mlx5_tout_ms(dev, FW_INIT), 0);
1170-
if (err) {
1171-
mlx5_core_err(dev, "Firmware over %llu MS in initializing state, aborting\n",
1172-
mlx5_tout_ms(dev, FW_INIT));
1172+
err = wait_fw_init(dev, mlx5_tout_ms(dev, FW_INIT), 0, "initializing");
1173+
if (err)
11731174
goto err_cmd_cleanup;
1174-
}
11751175

11761176
dev->caps.embedded_cpu = mlx5_read_embedded_cpu(dev);
11771177
mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_UP);

0 commit comments

Comments
 (0)