diff options
Diffstat (limited to 'drivers/infiniband/hw/mlx5/main.c')
-rw-r--r-- | drivers/infiniband/hw/mlx5/main.c | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 1ba6c42e4df8..8a87404e9c76 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c | |||
@@ -244,6 +244,12 @@ static int mlx5_ib_query_device(struct ib_device *ibdev, | |||
244 | props->max_mcast_grp; | 244 | props->max_mcast_grp; |
245 | props->max_map_per_fmr = INT_MAX; /* no limit in ConnectIB */ | 245 | props->max_map_per_fmr = INT_MAX; /* no limit in ConnectIB */ |
246 | 246 | ||
247 | #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING | ||
248 | if (dev->mdev->caps.gen.flags & MLX5_DEV_CAP_FLAG_ON_DMND_PG) | ||
249 | props->device_cap_flags |= IB_DEVICE_ON_DEMAND_PAGING; | ||
250 | props->odp_caps = dev->odp_caps; | ||
251 | #endif | ||
252 | |||
247 | out: | 253 | out: |
248 | kfree(in_mad); | 254 | kfree(in_mad); |
249 | kfree(out_mad); | 255 | kfree(out_mad); |
@@ -568,6 +574,10 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev, | |||
568 | goto out_count; | 574 | goto out_count; |
569 | } | 575 | } |
570 | 576 | ||
577 | #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING | ||
578 | context->ibucontext.invalidate_range = &mlx5_ib_invalidate_range; | ||
579 | #endif | ||
580 | |||
571 | INIT_LIST_HEAD(&context->db_page_list); | 581 | INIT_LIST_HEAD(&context->db_page_list); |
572 | mutex_init(&context->db_page_mutex); | 582 | mutex_init(&context->db_page_mutex); |
573 | 583 | ||
@@ -858,7 +868,7 @@ static ssize_t show_reg_pages(struct device *device, | |||
858 | struct mlx5_ib_dev *dev = | 868 | struct mlx5_ib_dev *dev = |
859 | container_of(device, struct mlx5_ib_dev, ib_dev.dev); | 869 | container_of(device, struct mlx5_ib_dev, ib_dev.dev); |
860 | 870 | ||
861 | return sprintf(buf, "%d\n", dev->mdev->priv.reg_pages); | 871 | return sprintf(buf, "%d\n", atomic_read(&dev->mdev->priv.reg_pages)); |
862 | } | 872 | } |
863 | 873 | ||
864 | static ssize_t show_hca(struct device *device, struct device_attribute *attr, | 874 | static ssize_t show_hca(struct device *device, struct device_attribute *attr, |
@@ -1321,6 +1331,8 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) | |||
1321 | (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ) | | 1331 | (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ) | |
1322 | (1ull << IB_USER_VERBS_CMD_CREATE_XSRQ) | | 1332 | (1ull << IB_USER_VERBS_CMD_CREATE_XSRQ) | |
1323 | (1ull << IB_USER_VERBS_CMD_OPEN_QP); | 1333 | (1ull << IB_USER_VERBS_CMD_OPEN_QP); |
1334 | dev->ib_dev.uverbs_ex_cmd_mask = | ||
1335 | (1ull << IB_USER_VERBS_EX_CMD_QUERY_DEVICE); | ||
1324 | 1336 | ||
1325 | dev->ib_dev.query_device = mlx5_ib_query_device; | 1337 | dev->ib_dev.query_device = mlx5_ib_query_device; |
1326 | dev->ib_dev.query_port = mlx5_ib_query_port; | 1338 | dev->ib_dev.query_port = mlx5_ib_query_port; |
@@ -1366,6 +1378,8 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) | |||
1366 | dev->ib_dev.free_fast_reg_page_list = mlx5_ib_free_fast_reg_page_list; | 1378 | dev->ib_dev.free_fast_reg_page_list = mlx5_ib_free_fast_reg_page_list; |
1367 | dev->ib_dev.check_mr_status = mlx5_ib_check_mr_status; | 1379 | dev->ib_dev.check_mr_status = mlx5_ib_check_mr_status; |
1368 | 1380 | ||
1381 | mlx5_ib_internal_query_odp_caps(dev); | ||
1382 | |||
1369 | if (mdev->caps.gen.flags & MLX5_DEV_CAP_FLAG_XRC) { | 1383 | if (mdev->caps.gen.flags & MLX5_DEV_CAP_FLAG_XRC) { |
1370 | dev->ib_dev.alloc_xrcd = mlx5_ib_alloc_xrcd; | 1384 | dev->ib_dev.alloc_xrcd = mlx5_ib_alloc_xrcd; |
1371 | dev->ib_dev.dealloc_xrcd = mlx5_ib_dealloc_xrcd; | 1385 | dev->ib_dev.dealloc_xrcd = mlx5_ib_dealloc_xrcd; |
@@ -1379,16 +1393,19 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) | |||
1379 | goto err_eqs; | 1393 | goto err_eqs; |
1380 | 1394 | ||
1381 | mutex_init(&dev->cap_mask_mutex); | 1395 | mutex_init(&dev->cap_mask_mutex); |
1382 | spin_lock_init(&dev->mr_lock); | ||
1383 | 1396 | ||
1384 | err = create_dev_resources(&dev->devr); | 1397 | err = create_dev_resources(&dev->devr); |
1385 | if (err) | 1398 | if (err) |
1386 | goto err_eqs; | 1399 | goto err_eqs; |
1387 | 1400 | ||
1388 | err = ib_register_device(&dev->ib_dev, NULL); | 1401 | err = mlx5_ib_odp_init_one(dev); |
1389 | if (err) | 1402 | if (err) |
1390 | goto err_rsrc; | 1403 | goto err_rsrc; |
1391 | 1404 | ||
1405 | err = ib_register_device(&dev->ib_dev, NULL); | ||
1406 | if (err) | ||
1407 | goto err_odp; | ||
1408 | |||
1392 | err = create_umr_res(dev); | 1409 | err = create_umr_res(dev); |
1393 | if (err) | 1410 | if (err) |
1394 | goto err_dev; | 1411 | goto err_dev; |
@@ -1410,6 +1427,9 @@ err_umrc: | |||
1410 | err_dev: | 1427 | err_dev: |
1411 | ib_unregister_device(&dev->ib_dev); | 1428 | ib_unregister_device(&dev->ib_dev); |
1412 | 1429 | ||
1430 | err_odp: | ||
1431 | mlx5_ib_odp_remove_one(dev); | ||
1432 | |||
1413 | err_rsrc: | 1433 | err_rsrc: |
1414 | destroy_dev_resources(&dev->devr); | 1434 | destroy_dev_resources(&dev->devr); |
1415 | 1435 | ||
@@ -1425,8 +1445,10 @@ err_dealloc: | |||
1425 | static void mlx5_ib_remove(struct mlx5_core_dev *mdev, void *context) | 1445 | static void mlx5_ib_remove(struct mlx5_core_dev *mdev, void *context) |
1426 | { | 1446 | { |
1427 | struct mlx5_ib_dev *dev = context; | 1447 | struct mlx5_ib_dev *dev = context; |
1448 | |||
1428 | ib_unregister_device(&dev->ib_dev); | 1449 | ib_unregister_device(&dev->ib_dev); |
1429 | destroy_umrc_res(dev); | 1450 | destroy_umrc_res(dev); |
1451 | mlx5_ib_odp_remove_one(dev); | ||
1430 | destroy_dev_resources(&dev->devr); | 1452 | destroy_dev_resources(&dev->devr); |
1431 | free_comp_eqs(dev); | 1453 | free_comp_eqs(dev); |
1432 | ib_dealloc_device(&dev->ib_dev); | 1454 | ib_dealloc_device(&dev->ib_dev); |
@@ -1440,15 +1462,30 @@ static struct mlx5_interface mlx5_ib_interface = { | |||
1440 | 1462 | ||
1441 | static int __init mlx5_ib_init(void) | 1463 | static int __init mlx5_ib_init(void) |
1442 | { | 1464 | { |
1465 | int err; | ||
1466 | |||
1443 | if (deprecated_prof_sel != 2) | 1467 | if (deprecated_prof_sel != 2) |
1444 | pr_warn("prof_sel is deprecated for mlx5_ib, set it for mlx5_core\n"); | 1468 | pr_warn("prof_sel is deprecated for mlx5_ib, set it for mlx5_core\n"); |
1445 | 1469 | ||
1446 | return mlx5_register_interface(&mlx5_ib_interface); | 1470 | err = mlx5_ib_odp_init(); |
1471 | if (err) | ||
1472 | return err; | ||
1473 | |||
1474 | err = mlx5_register_interface(&mlx5_ib_interface); | ||
1475 | if (err) | ||
1476 | goto clean_odp; | ||
1477 | |||
1478 | return err; | ||
1479 | |||
1480 | clean_odp: | ||
1481 | mlx5_ib_odp_cleanup(); | ||
1482 | return err; | ||
1447 | } | 1483 | } |
1448 | 1484 | ||
1449 | static void __exit mlx5_ib_cleanup(void) | 1485 | static void __exit mlx5_ib_cleanup(void) |
1450 | { | 1486 | { |
1451 | mlx5_unregister_interface(&mlx5_ib_interface); | 1487 | mlx5_unregister_interface(&mlx5_ib_interface); |
1488 | mlx5_ib_odp_cleanup(); | ||
1452 | } | 1489 | } |
1453 | 1490 | ||
1454 | module_init(mlx5_ib_init); | 1491 | module_init(mlx5_ib_init); |