Skip to content

Commit 3a1556a

Browse files
committed
net/mlx5: Split function_setup() to enable and open functions
jira LE-3064 Rebuild_History Non-Buildable kernel-4.18.0-553.53.1.el8_10 commit-author Shay Drory <[email protected]> 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]> (cherry picked from commit 2059cf5) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 1632872 commit 3a1556a

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
@@ -1125,7 +1125,7 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev)
11251125
mlx5_devcom_unregister_device(dev->priv.devcom);
11261126
}
11271127

1128-
static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot, u64 timeout)
1128+
static int mlx5_function_enable(struct mlx5_core_dev *dev, bool boot, u64 timeout)
11291129
{
11301130
int err;
11311131

@@ -1190,55 +1190,70 @@ static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot, u64 timeout
11901190
goto reclaim_boot_pages;
11911191
}
11921192

1193+
return 0;
1194+
1195+
reclaim_boot_pages:
1196+
mlx5_reclaim_startup_pages(dev);
1197+
err_disable_hca:
1198+
mlx5_core_disable_hca(dev, 0);
1199+
stop_health_poll:
1200+
mlx5_stop_health_poll(dev, boot);
1201+
err_cmd_cleanup:
1202+
mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_DOWN);
1203+
mlx5_cmd_cleanup(dev);
1204+
1205+
return err;
1206+
}
1207+
1208+
static void mlx5_function_disable(struct mlx5_core_dev *dev, bool boot)
1209+
{
1210+
mlx5_reclaim_startup_pages(dev);
1211+
mlx5_core_disable_hca(dev, 0);
1212+
mlx5_stop_health_poll(dev, boot);
1213+
mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_DOWN);
1214+
mlx5_cmd_cleanup(dev);
1215+
}
1216+
1217+
static int mlx5_function_open(struct mlx5_core_dev *dev)
1218+
{
1219+
int err;
1220+
11931221
err = set_hca_ctrl(dev);
11941222
if (err) {
11951223
mlx5_core_err(dev, "set_hca_ctrl failed\n");
1196-
goto reclaim_boot_pages;
1224+
return err;
11971225
}
11981226

11991227
err = set_hca_cap(dev);
12001228
if (err) {
12011229
mlx5_core_err(dev, "set_hca_cap failed\n");
1202-
goto reclaim_boot_pages;
1230+
return err;
12031231
}
12041232

12051233
err = mlx5_satisfy_startup_pages(dev, 0);
12061234
if (err) {
12071235
mlx5_core_err(dev, "failed to allocate init pages\n");
1208-
goto reclaim_boot_pages;
1236+
return err;
12091237
}
12101238

12111239
err = mlx5_cmd_init_hca(dev, sw_owner_id);
12121240
if (err) {
12131241
mlx5_core_err(dev, "init hca failed\n");
1214-
goto reclaim_boot_pages;
1242+
return err;
12151243
}
12161244

12171245
mlx5_set_driver_version(dev);
12181246

12191247
err = mlx5_query_hca_caps(dev);
12201248
if (err) {
12211249
mlx5_core_err(dev, "query hca failed\n");
1222-
goto reclaim_boot_pages;
1250+
return err;
12231251
}
12241252
mlx5_start_health_fw_log_up(dev);
1225-
12261253
return 0;
1227-
1228-
reclaim_boot_pages:
1229-
mlx5_reclaim_startup_pages(dev);
1230-
err_disable_hca:
1231-
mlx5_core_disable_hca(dev, 0);
1232-
stop_health_poll:
1233-
mlx5_stop_health_poll(dev, boot);
1234-
err_cmd_cleanup:
1235-
mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_DOWN);
1236-
mlx5_cmd_cleanup(dev);
1237-
1238-
return err;
12391254
}
12401255

1241-
static int mlx5_function_teardown(struct mlx5_core_dev *dev, bool boot)
1256+
static int mlx5_function_close(struct mlx5_core_dev *dev)
12421257
{
12431258
int err;
12441259

@@ -1247,15 +1262,33 @@ static int mlx5_function_teardown(struct mlx5_core_dev *dev, bool boot)
12471262
mlx5_core_err(dev, "tear_down_hca failed, skip cleanup\n");
12481263
return err;
12491264
}
1250-
mlx5_reclaim_startup_pages(dev);
1251-
mlx5_core_disable_hca(dev, 0);
1252-
mlx5_stop_health_poll(dev, boot);
1253-
mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_DOWN);
1254-
mlx5_cmd_cleanup(dev);
12551265

12561266
return 0;
12571267
}
12581268

1269+
static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot, u64 timeout)
1270+
{
1271+
int err;
1272+
1273+
err = mlx5_function_enable(dev, boot, timeout);
1274+
if (err)
1275+
return err;
1276+
1277+
err = mlx5_function_open(dev);
1278+
if (err)
1279+
mlx5_function_disable(dev, boot);
1280+
return err;
1281+
}
1282+
1283+
static int mlx5_function_teardown(struct mlx5_core_dev *dev, bool boot)
1284+
{
1285+
int err = mlx5_function_close(dev);
1286+
1287+
if (!err)
1288+
mlx5_function_disable(dev, boot);
1289+
return err;
1290+
}
1291+
12591292
static int mlx5_load(struct mlx5_core_dev *dev)
12601293
{
12611294
int err;

0 commit comments

Comments
 (0)