Skip to content

Commit b9cfda9

Browse files
shayshyiSasha Levin
authored andcommitted
net/mlx5: Split function_setup() to enable and open functions
[ Upstream commit 2059cf5 ] mlx5_cmd_init_hca() is taking ~0.2 seconds. In case of a user who desire to disable some of the SF aux devices, and with large scale-1K SFs for example, this user will waste more than 3 minutes on mlx5_cmd_init_hca() which isn't needed at this stage. Downstream patch will change SFs which are probe over the E-switch, local SFs, to be probed without any aux dev. In order to support this, split function_setup() to avoid executing mlx5_cmd_init_hca(). Signed-off-by: Shay Drory <[email protected]> Reviewed-by: Moshe Shemesh <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Stable-dep-of: c8b3f38 ("net/mlx5: Always stop health timer during driver removal") Signed-off-by: Sasha Levin <[email protected]>
1 parent 794cd62 commit b9cfda9

File tree

1 file changed

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

1 file changed

+58
-25
lines changed

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

Lines changed: 58 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev)
10931093
mlx5_devcom_unregister_device(dev->priv.devcom);
10941094
}
10951095

1096-
static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot, u64 timeout)
1096+
static int mlx5_function_enable(struct mlx5_core_dev *dev, bool boot, u64 timeout)
10971097
{
10981098
int err;
10991099

@@ -1158,55 +1158,70 @@ static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot, u64 timeout
11581158
goto reclaim_boot_pages;
11591159
}
11601160

1161+
return 0;
1162+
1163+
reclaim_boot_pages:
1164+
mlx5_reclaim_startup_pages(dev);
1165+
err_disable_hca:
1166+
mlx5_core_disable_hca(dev, 0);
1167+
stop_health_poll:
1168+
mlx5_stop_health_poll(dev, boot);
1169+
err_cmd_cleanup:
1170+
mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_DOWN);
1171+
mlx5_cmd_cleanup(dev);
1172+
1173+
return err;
1174+
}
1175+
1176+
static void mlx5_function_disable(struct mlx5_core_dev *dev, bool boot)
1177+
{
1178+
mlx5_reclaim_startup_pages(dev);
1179+
mlx5_core_disable_hca(dev, 0);
1180+
mlx5_stop_health_poll(dev, boot);
1181+
mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_DOWN);
1182+
mlx5_cmd_cleanup(dev);
1183+
}
1184+
1185+
static int mlx5_function_open(struct mlx5_core_dev *dev)
1186+
{
1187+
int err;
1188+
11611189
err = set_hca_ctrl(dev);
11621190
if (err) {
11631191
mlx5_core_err(dev, "set_hca_ctrl failed\n");
1164-
goto reclaim_boot_pages;
1192+
return err;
11651193
}
11661194

11671195
err = set_hca_cap(dev);
11681196
if (err) {
11691197
mlx5_core_err(dev, "set_hca_cap failed\n");
1170-
goto reclaim_boot_pages;
1198+
return err;
11711199
}
11721200

11731201
err = mlx5_satisfy_startup_pages(dev, 0);
11741202
if (err) {
11751203
mlx5_core_err(dev, "failed to allocate init pages\n");
1176-
goto reclaim_boot_pages;
1204+
return err;
11771205
}
11781206

11791207
err = mlx5_cmd_init_hca(dev, sw_owner_id);
11801208
if (err) {
11811209
mlx5_core_err(dev, "init hca failed\n");
1182-
goto reclaim_boot_pages;
1210+
return err;
11831211
}
11841212

11851213
mlx5_set_driver_version(dev);
11861214

11871215
err = mlx5_query_hca_caps(dev);
11881216
if (err) {
11891217
mlx5_core_err(dev, "query hca failed\n");
1190-
goto reclaim_boot_pages;
1218+
return err;
11911219
}
11921220
mlx5_start_health_fw_log_up(dev);
1193-
11941221
return 0;
1195-
1196-
reclaim_boot_pages:
1197-
mlx5_reclaim_startup_pages(dev);
1198-
err_disable_hca:
1199-
mlx5_core_disable_hca(dev, 0);
1200-
stop_health_poll:
1201-
mlx5_stop_health_poll(dev, boot);
1202-
err_cmd_cleanup:
1203-
mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_DOWN);
1204-
mlx5_cmd_cleanup(dev);
1205-
1206-
return err;
12071222
}
12081223

1209-
static int mlx5_function_teardown(struct mlx5_core_dev *dev, bool boot)
1224+
static int mlx5_function_close(struct mlx5_core_dev *dev)
12101225
{
12111226
int err;
12121227

@@ -1215,15 +1230,33 @@ static int mlx5_function_teardown(struct mlx5_core_dev *dev, bool boot)
12151230
mlx5_core_err(dev, "tear_down_hca failed, skip cleanup\n");
12161231
return err;
12171232
}
1218-
mlx5_reclaim_startup_pages(dev);
1219-
mlx5_core_disable_hca(dev, 0);
1220-
mlx5_stop_health_poll(dev, boot);
1221-
mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_DOWN);
1222-
mlx5_cmd_cleanup(dev);
12231233

12241234
return 0;
12251235
}
12261236

1237+
static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot, u64 timeout)
1238+
{
1239+
int err;
1240+
1241+
err = mlx5_function_enable(dev, boot, timeout);
1242+
if (err)
1243+
return err;
1244+
1245+
err = mlx5_function_open(dev);
1246+
if (err)
1247+
mlx5_function_disable(dev, boot);
1248+
return err;
1249+
}
1250+
1251+
static int mlx5_function_teardown(struct mlx5_core_dev *dev, bool boot)
1252+
{
1253+
int err = mlx5_function_close(dev);
1254+
1255+
if (!err)
1256+
mlx5_function_disable(dev, boot);
1257+
return err;
1258+
}
1259+
12271260
static int mlx5_load(struct mlx5_core_dev *dev)
12281261
{
12291262
int err;

0 commit comments

Comments
 (0)