Pull rdma fixes from Jason Gunthorpe: "Things are looking pretty quiet here in RDMA, not too many bug fixes rolling in right now. The usual driver bug fixes and fixes for a couple of regressions introduced in 5.2: - Fix a race on bootup with RDMA device renaming and srp. SRP also needs to rename its internal sys files - Fix a memory leak in hns - Don't leak resources in efa on certain error unwinds - Don't panic in certain error unwinds in ib_register_device - Various small user visible bug fix patches for the hfi and efa drivers - Fix the 32 bit compilation break" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: RDMA/efa: Remove MAYEXEC flag check from mmap flow mlx5: avoid 64-bit division IB/hfi1: Validate page aligned for a given virtual address IB/{qib, hfi1, rdmavt}: Correct ibv_devinfo max_mr value IB/hfi1: Insure freeze_work work_struct is canceled on shutdown IB/rdmavt: Fix alloc_qpn() WARN_ON() RDMA/core: Fix panic when port_data isn't initialized RDMA/uverbs: Pass udata on uverbs error unwind RDMA/core: Clear out the udata before error unwind RDMA/hns: Fix PD memory leak for internal allocation RDMA/srp: Rename SRP sysfs name after IB device rename trigger
Unified · Split
| @@ -409,27 +409,44 @@ static int rename_compat_devs(struct ib_device *device) · 408 unmodified lines | ||
| 409 | 409 | |
| 410 | 410 | int ib_device_rename(struct ib_device *ibdev, const char *name) |
| 411 | 411 | { |
| 412 | + unsigned long index; | |
| 413 | + void *client_data; | |
| 412 | 414 | int ret; |
| 413 | 415 | |
| 414 | 416 | down_write(&devices_rwsem); |
| 415 | 417 | if (!strcmp(name, dev_name(&ibdev->dev))) { |
| 416 | − ret = 0; | |
| 417 | − goto out; | |
| 418 | + up_write(&devices_rwsem); | |
| 419 | + return 0; | |
| 418 | 420 | } |
| 419 | 421 | |
| 420 | 422 | if (__ib_device_get_by_name(name)) { |
| 421 | − ret = -EEXIST; | |
| 422 | − goto out; | |
| 423 | + up_write(&devices_rwsem); | |
| 424 | + return -EEXIST; | |
| 423 | 425 | } |
| 424 | 426 | |
| 425 | 427 | ret = device_rename(&ibdev->dev, name); |
| 426 | − if (ret) | |
| 427 | − goto out; | |
| 428 | + if (ret) { | |
| 429 | + up_write(&devices_rwsem); | |
| 430 | + return ret; | |
| 431 | + } | |
| 432 | + | |
| 428 | 433 | strlcpy(ibdev->name, name, IB_DEVICE_NAME_MAX); |
| 429 | 434 | ret = rename_compat_devs(ibdev); |
| 430 | −out: | |
| 431 | − up_write(&devices_rwsem); | |
| 432 | − return ret; | |
| 435 | + | |
| 436 | + downgrade_write(&devices_rwsem); | |
| 437 | + down_read(&ibdev->client_data_rwsem); | |
| 438 | + xan_for_each_marked(&ibdev->client_data, index, client_data, | |
| 439 | + CLIENT_DATA_REGISTERED) { | |
| 440 | + struct ib_client *client = xa_load(&clients, index); | |
| 441 | + | |
| 442 | + if (!client || !client->rename) | |
| 443 | + continue; | |
| 444 | + | |
| 445 | + client->rename(ibdev, client_data); | |
| 446 | + } | |
| 447 | + up_read(&ibdev->client_data_rwsem); | |
| 448 | + up_read(&devices_rwsem); | |
| 449 | + return 0; | |
| 433 | 450 | } |
| 434 | 451 | |
| 435 | 452 | static int alloc_name(struct ib_device *ibdev, const char *name) |
| @@ -474,14 +491,15 @@ static void ib_device_release(struct device *device) · 38 unmodified lines | ||
| 474 | 491 | |
| 475 | 492 | free_netdevs(dev); |
| 476 | 493 | WARN_ON(refcount_read(&dev->refcount)); |
| 477 | − ib_cache_release_one(dev); | |
| 478 | − ib_security_release_port_pkey_list(dev); | |
| 479 | − xa_destroy(&dev->compat_devs); | |
| 480 | − xa_destroy(&dev->client_data); | |
| 481 | − if (dev->port_data) | |
| 494 | + if (dev->port_data) { | |
| 495 | + ib_cache_release_one(dev); | |
| 496 | + ib_security_release_port_pkey_list(dev); | |
| 482 | 497 | kfree_rcu(container_of(dev->port_data, struct ib_port_data_rcu, |
| 483 | 498 | pdata[0]), |
| 484 | 499 | rcu_head); |
| 500 | + } | |
| 501 | + xa_destroy(&dev->compat_devs); | |
| 502 | + xa_destroy(&dev->client_data); | |
| 485 | 503 | kfree_rcu(dev, rcu_head); |
| 486 | 504 | } |
| 487 | 505 | |
| @@ -1935,6 +1953,9 @@ static void free_netdevs(struct ib_device *ib_dev) · 1447 unmodified lines | ||
| 1935 | 1953 | unsigned long flags; |
| 1936 | 1954 | unsigned int port; |
| 1937 | 1955 | |
| 1956 | + if (!ib_dev->port_data) | |
| 1957 | + return; | |
| 1958 | + | |
| 1938 | 1959 | rdma_for_each_port (ib_dev, port) { |
| 1939 | 1960 | struct ib_port_data *pdata = &ib_dev->port_data[port]; |
| 1940 | 1961 | struct net_device *ndev; |
| @@ -110,6 +110,8 @@ int uverbs_output_written(const struct uverbs_attr_bundle *bundle, size_t idx); · 109 unmodified lines | ||
| 110 | 110 | void setup_ufile_idr_uobject(struct ib_uverbs_file *ufile); |
| 111 | 111 | void release_ufile_idr_uobject(struct ib_uverbs_file *ufile); |
| 112 | 112 | |
| 113 | +struct ib_udata *uverbs_get_cleared_udata(struct uverbs_attr_bundle *attrs); | |
| 114 | + | |
| 113 | 115 | /* |
| 114 | 116 | * This is the runtime description of the uverbs API, used by the syscall |
| 115 | 117 | * machinery to validate and dispatch calls. |
| @@ -174,6 +174,17 @@ static int uverbs_request_finish(struct uverbs_req_iter *iter) · 173 unmodified lines | ||
| 174 | 174 | return 0; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | +/* | |
| 178 | + * When calling a destroy function during an error unwind we need to pass in | |
| 179 | + * the udata that is sanitized of all user arguments. Ie from the driver | |
| 180 | + * perspective it looks like no udata was passed. | |
| 181 | + */ | |
| 182 | +struct ib_udata *uverbs_get_cleared_udata(struct uverbs_attr_bundle *attrs) | |
| 183 | +{ | |
| 184 | + attrs->driver_udata = (struct ib_udata){}; | |
| 185 | + return &attrs->driver_udata; | |
| 186 | +} | |
| 187 | + | |
| 177 | 188 | static struct ib_uverbs_completion_event_file * |
| 178 | 189 | _ib_uverbs_lookup_comp_file(s32 fd, struct uverbs_attr_bundle *attrs) |
| 179 | 190 | { |
| @@ -441,7 +452,7 @@ static int ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs) · 261 unmodified lines | ||
| 441 | 452 | return uobj_alloc_commit(uobj, attrs); |
| 442 | 453 | |
| 443 | 454 | err_copy: |
| 444 | − ib_dealloc_pd_user(pd, &attrs->driver_udata); | |
| 455 | + ib_dealloc_pd_user(pd, uverbs_get_cleared_udata(attrs)); | |
| 445 | 456 | pd = NULL; |
| 446 | 457 | err_alloc: |
| 447 | 458 | kfree(pd); |
| @@ -644,7 +655,7 @@ err_copy: · 196 unmodified lines | ||
| 644 | 655 | } |
| 645 | 656 | |
| 646 | 657 | err_dealloc_xrcd: |
| 647 | − ib_dealloc_xrcd(xrcd, &attrs->driver_udata); | |
| 658 | + ib_dealloc_xrcd(xrcd, uverbs_get_cleared_udata(attrs)); | |
| 648 | 659 | |
| 649 | 660 | err: |
| 650 | 661 | uobj_alloc_abort(&obj->uobject, attrs); |
| @@ -767,7 +778,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs) · 116 unmodified lines | ||
| 767 | 778 | return uobj_alloc_commit(uobj, attrs); |
| 768 | 779 | |
| 769 | 780 | err_copy: |
| 770 | − ib_dereg_mr_user(mr, &attrs->driver_udata); | |
| 781 | + ib_dereg_mr_user(mr, uverbs_get_cleared_udata(attrs)); | |
| 771 | 782 | |
| 772 | 783 | err_put: |
| 773 | 784 | uobj_put_obj_read(pd); |
| @@ -1042,7 +1053,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs, · 268 unmodified lines | ||
| 1042 | 1053 | return obj; |
| 1043 | 1054 | |
| 1044 | 1055 | err_cb: |
| 1045 | − ib_destroy_cq(cq); | |
| 1056 | + ib_destroy_cq_user(cq, uverbs_get_cleared_udata(attrs)); | |
| 1046 | 1057 | |
| 1047 | 1058 | err_file: |
| 1048 | 1059 | if (ev_file) |
| @@ -1478,7 +1489,7 @@ static int create_qp(struct uverbs_attr_bundle *attrs, · 429 unmodified lines | ||
| 1478 | 1489 | |
| 1479 | 1490 | return uobj_alloc_commit(&obj->uevent.uobject, attrs); |
| 1480 | 1491 | err_cb: |
| 1481 | − ib_destroy_qp(qp); | |
| 1492 | + ib_destroy_qp_user(qp, uverbs_get_cleared_udata(attrs)); | |
| 1482 | 1493 | |
| 1483 | 1494 | err_put: |
| 1484 | 1495 | if (!IS_ERR(xrcd_uobj)) |
| @@ -1611,7 +1622,7 @@ static int ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs) · 126 unmodified lines | ||
| 1611 | 1622 | return uobj_alloc_commit(&obj->uevent.uobject, attrs); |
| 1612 | 1623 | |
| 1613 | 1624 | err_destroy: |
| 1614 | − ib_destroy_qp(qp); | |
| 1625 | + ib_destroy_qp_user(qp, uverbs_get_cleared_udata(attrs)); | |
| 1615 | 1626 | err_xrcd: |
| 1616 | 1627 | uobj_put_read(xrcd_uobj); |
| 1617 | 1628 | err_put: |
| @@ -2453,7 +2464,8 @@ static int ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs) · 835 unmodified lines | ||
| 2453 | 2464 | return uobj_alloc_commit(uobj, attrs); |
| 2454 | 2465 | |
| 2455 | 2466 | err_copy: |
| 2456 | − rdma_destroy_ah(ah, RDMA_DESTROY_AH_SLEEPABLE); | |
| 2467 | + rdma_destroy_ah_user(ah, RDMA_DESTROY_AH_SLEEPABLE, | |
| 2468 | + uverbs_get_cleared_udata(attrs)); | |
| 2457 | 2469 | |
| 2458 | 2470 | err_put: |
| 2459 | 2471 | uobj_put_obj_read(pd); |
| @@ -2964,7 +2976,7 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs) · 504 unmodified lines | ||
| 2964 | 2976 | return uobj_alloc_commit(&obj->uevent.uobject, attrs); |
| 2965 | 2977 | |
| 2966 | 2978 | err_copy: |
| 2967 | − ib_destroy_wq(wq, &attrs->driver_udata); | |
| 2979 | + ib_destroy_wq(wq, uverbs_get_cleared_udata(attrs)); | |
| 2968 | 2980 | err_put_cq: |
| 2969 | 2981 | uobj_put_obj_read(cq); |
| 2970 | 2982 | err_put_pd: |
| @@ -3464,7 +3476,7 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, · 493 unmodified lines | ||
| 3464 | 3476 | return uobj_alloc_commit(&obj->uevent.uobject, attrs); |
| 3465 | 3477 | |
| 3466 | 3478 | err_copy: |
| 3467 | − ib_destroy_srq_user(srq, &attrs->driver_udata); | |
| 3479 | + ib_destroy_srq_user(srq, uverbs_get_cleared_udata(attrs)); | |
| 3468 | 3480 | |
| 3469 | 3481 | err_free: |
| 3470 | 3482 | kfree(srq); |
| @@ -135,7 +135,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)( · 134 unmodified lines | ||
| 135 | 135 | |
| 136 | 136 | return 0; |
| 137 | 137 | err_cq: |
| 138 | − ib_destroy_cq(cq); | |
| 138 | + ib_destroy_cq_user(cq, uverbs_get_cleared_udata(attrs)); | |
| 139 | 139 | |
| 140 | 140 | err_event_file: |
| 141 | 141 | if (ev_file) |
| @@ -148,7 +148,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_DM_MR_REG)( · 147 unmodified lines | ||
| 148 | 148 | return 0; |
| 149 | 149 | |
| 150 | 150 | err_dereg: |
| 151 | − ib_dereg_mr_user(mr, &attrs->driver_udata); | |
| 151 | + ib_dereg_mr_user(mr, uverbs_get_cleared_udata(attrs)); | |
| 152 | 152 | |
| 153 | 153 | return ret; |
| 154 | 154 | } |
| @@ -1728,7 +1728,6 @@ int efa_mmap(struct ib_ucontext *ibucontext, · 1727 unmodified lines | ||
| 1728 | 1728 | ibdev_dbg(&dev->ibdev, "Mapping executable pages is not permitted\n"); |
| 1729 | 1729 | return -EPERM; |
| 1730 | 1730 | } |
| 1731 | − vma->vm_flags &= ~VM_MAYEXEC; | |
| 1732 | 1731 | |
| 1733 | 1732 | return __efa_mmap(dev, ucontext, vma, key, length); |
| 1734 | 1733 | } |
| @@ -9850,6 +9850,7 @@ void hfi1_quiet_serdes(struct hfi1_pportdata *ppd) · 9849 unmodified lines | ||
| 9850 | 9850 | |
| 9851 | 9851 | /* disable the port */ |
| 9852 | 9852 | clear_rcvctrl(dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK); |
| 9853 | + cancel_work_sync(&ppd->freeze_work); | |
| 9853 | 9854 | } |
| 9854 | 9855 | |
| 9855 | 9856 | static inline int init_cpu_counters(struct hfi1_devdata *dd) |
| @@ -324,6 +324,9 @@ int hfi1_user_exp_rcv_setup(struct hfi1_filedata *fd, · 323 unmodified lines | ||
| 324 | 324 | u32 *tidlist = NULL; |
| 325 | 325 | struct tid_user_buf *tidbuf; |
| 326 | 326 | |
| 327 | + if (!PAGE_ALIGNED(tinfo->vaddr)) | |
| 328 | + return -EINVAL; | |
| 329 | + | |
| 327 | 330 | tidbuf = kzalloc(sizeof(*tidbuf), GFP_KERNEL); |
| 328 | 331 | if (!tidbuf) |
| 329 | 332 | return -ENOMEM; |
| @@ -1356,8 +1356,6 @@ static void hfi1_fill_device_attr(struct hfi1_devdata *dd) · 1355 unmodified lines | ||
| 1356 | 1356 | rdi->dparms.props.max_cq = hfi1_max_cqs; |
| 1357 | 1357 | rdi->dparms.props.max_ah = hfi1_max_ahs; |
| 1358 | 1358 | rdi->dparms.props.max_cqe = hfi1_max_cqes; |
| 1359 | − rdi->dparms.props.max_mr = rdi->lkey_table.max; | |
| 1360 | − rdi->dparms.props.max_fmr = rdi->lkey_table.max; | |
| 1361 | 1359 | rdi->dparms.props.max_map_per_fmr = 32767; |
| 1362 | 1360 | rdi->dparms.props.max_pd = hfi1_max_pds; |
| 1363 | 1361 | rdi->dparms.props.max_qp_rd_atom = HFI1_MAX_RDMA_ATOMIC; |
| @@ -899,6 +899,7 @@ static void hns_roce_v1_release_lp_qp(struct hns_roce_dev *hr_dev) · 898 unmodified lines | ||
| 899 | 899 | dev_err(dev, "Destroy cq for mr_free failed(%d)!\n", ret); |
| 900 | 900 | |
| 901 | 901 | hns_roce_dealloc_pd(&free_mr->mr_free_pd->ibpd, NULL); |
| 902 | + kfree(&free_mr->mr_free_pd->ibpd); | |
| 902 | 903 | } |
| 903 | 904 | |
| 904 | 905 | static int hns_roce_db_init(struct hns_roce_dev *hr_dev) |
| @@ -190,12 +190,12 @@ int mlx5_cmd_alloc_sw_icm(struct mlx5_dm *dm, int type, u64 length, · 189 unmodified lines | ||
| 190 | 190 | u16 uid, phys_addr_t *addr, u32 *obj_id) |
| 191 | 191 | { |
| 192 | 192 | struct mlx5_core_dev *dev = dm->dev; |
| 193 | − u32 num_blocks = DIV_ROUND_UP(length, MLX5_SW_ICM_BLOCK_SIZE(dev)); | |
| 194 | 193 | u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {}; |
| 195 | 194 | u32 in[MLX5_ST_SZ_DW(create_sw_icm_in)] = {}; |
| 196 | 195 | unsigned long *block_map; |
| 197 | 196 | u64 icm_start_addr; |
| 198 | 197 | u32 log_icm_size; |
| 198 | + u32 num_blocks; | |
| 199 | 199 | u32 max_blocks; |
| 200 | 200 | u64 block_idx; |
| 201 | 201 | void *sw_icm; |
| @@ -224,6 +224,8 @@ int mlx5_cmd_alloc_sw_icm(struct mlx5_dm *dm, int type, u64 length, · 22 unmodified lines | ||
| 224 | 224 | return -EINVAL; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | + num_blocks = (length + MLX5_SW_ICM_BLOCK_SIZE(dev) - 1) >> | |
| 228 | + MLX5_LOG_SW_ICM_BLOCK_SIZE(dev); | |
| 227 | 229 | max_blocks = BIT(log_icm_size - MLX5_LOG_SW_ICM_BLOCK_SIZE(dev)); |
| 228 | 230 | spin_lock(&dm->lock); |
| 229 | 231 | block_idx = bitmap_find_next_zero_area(block_map, |
| @@ -266,13 +268,16 @@ int mlx5_cmd_dealloc_sw_icm(struct mlx5_dm *dm, int type, u64 length, · 36 unmodified lines | ||
| 266 | 268 | u16 uid, phys_addr_t addr, u32 obj_id) |
| 267 | 269 | { |
| 268 | 270 | struct mlx5_core_dev *dev = dm->dev; |
| 269 | − u32 num_blocks = DIV_ROUND_UP(length, MLX5_SW_ICM_BLOCK_SIZE(dev)); | |
| 270 | 271 | u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {}; |
| 271 | 272 | u32 in[MLX5_ST_SZ_DW(general_obj_in_cmd_hdr)] = {}; |
| 272 | 273 | unsigned long *block_map; |
| 274 | + u32 num_blocks; | |
| 273 | 275 | u64 start_idx; |
| 274 | 276 | int err; |
| 275 | 277 | |
| 278 | + num_blocks = (length + MLX5_SW_ICM_BLOCK_SIZE(dev) - 1) >> | |
| 279 | + MLX5_LOG_SW_ICM_BLOCK_SIZE(dev); | |
| 280 | + | |
| 276 | 281 | switch (type) { |
| 277 | 282 | case MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM: |
| 278 | 283 | start_idx = |
| @@ -2344,7 +2344,7 @@ static int handle_alloc_dm_sw_icm(struct ib_ucontext *ctx, · 2343 unmodified lines | ||
| 2344 | 2344 | /* Allocation size must a multiple of the basic block size |
| 2345 | 2345 | * and a power of 2. |
| 2346 | 2346 | */ |
| 2347 | − act_size = roundup(attr->length, MLX5_SW_ICM_BLOCK_SIZE(dm_db->dev)); | |
| 2347 | + act_size = round_up(attr->length, MLX5_SW_ICM_BLOCK_SIZE(dm_db->dev)); | |
| 2348 | 2348 | act_size = roundup_pow_of_two(act_size); |
| 2349 | 2349 | |
| 2350 | 2350 | dm->size = act_size; |
| @@ -1459,8 +1459,6 @@ static void qib_fill_device_attr(struct qib_devdata *dd) · 1458 unmodified lines | ||
| 1459 | 1459 | rdi->dparms.props.max_cq = ib_qib_max_cqs; |
| 1460 | 1460 | rdi->dparms.props.max_cqe = ib_qib_max_cqes; |
| 1461 | 1461 | rdi->dparms.props.max_ah = ib_qib_max_ahs; |
| 1462 | − rdi->dparms.props.max_mr = rdi->lkey_table.max; | |
| 1463 | − rdi->dparms.props.max_fmr = rdi->lkey_table.max; | |
| 1464 | 1462 | rdi->dparms.props.max_map_per_fmr = 32767; |
| 1465 | 1463 | rdi->dparms.props.max_qp_rd_atom = QIB_MAX_RDMA_ATOMIC; |
| 1466 | 1464 | rdi->dparms.props.max_qp_init_rd_atom = 255; |
| @@ -96,6 +96,8 @@ int rvt_driver_mr_init(struct rvt_dev_info *rdi) · 95 unmodified lines | ||
| 96 | 96 | for (i = 0; i < rdi->lkey_table.max; i++) |
| 97 | 97 | RCU_INIT_POINTER(rdi->lkey_table.table[i], NULL); |
| 98 | 98 | |
| 99 | + rdi->dparms.props.max_mr = rdi->lkey_table.max; | |
| 100 | + rdi->dparms.props.max_fmr = rdi->lkey_table.max; | |
| 99 | 101 | return 0; |
| 100 | 102 | } |
| 101 | 103 | |
| @@ -594,7 +594,8 @@ static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, · 593 unmodified lines | ||
| 594 | 594 | offset = qpt->incr | ((offset & 1) ^ 1); |
| 595 | 595 | } |
| 596 | 596 | /* there can be no set bits in low-order QoS bits */ |
| 597 | − WARN_ON(offset & (BIT(rdi->dparms.qos_shift) - 1)); | |
| 597 | + WARN_ON(rdi->dparms.qos_shift > 1 && | |
| 598 | + offset & ((BIT(rdi->dparms.qos_shift - 1) - 1) << 1)); | |
| 598 | 599 | qpn = mk_qpn(qpt, map, offset); |
| 599 | 600 | } |
| 600 | 601 | |
| @@ -148,6 +148,7 @@ MODULE_PARM_DESC(ch_count, · 147 unmodified lines | ||
| 148 | 148 | |
| 149 | 149 | static void srp_add_one(struct ib_device *device); |
| 150 | 150 | static void srp_remove_one(struct ib_device *device, void *client_data); |
| 151 | +static void srp_rename_dev(struct ib_device *device, void *client_data); | |
| 151 | 152 | static void srp_recv_done(struct ib_cq *cq, struct ib_wc *wc); |
| 152 | 153 | static void srp_handle_qp_err(struct ib_cq *cq, struct ib_wc *wc, |
| 153 | 154 | const char *opname); |
| @@ -162,7 +163,8 @@ static struct workqueue_struct *srp_remove_wq; · 8 unmodified lines | ||
| 162 | 163 | static struct ib_client srp_client = { |
| 163 | 164 | .name = "srp", |
| 164 | 165 | .add = srp_add_one, |
| 165 | − .remove = srp_remove_one | |
| 166 | + .remove = srp_remove_one, | |
| 167 | + .rename = srp_rename_dev | |
| 166 | 168 | }; |
| 167 | 169 | |
| 168 | 170 | static struct ib_sa_client srp_sa_client; |
| @@ -4112,6 +4114,20 @@ free_host: · 3943 unmodified lines | ||
| 4112 | 4114 | return NULL; |
| 4113 | 4115 | } |
| 4114 | 4116 | |
| 4117 | +static void srp_rename_dev(struct ib_device *device, void *client_data) | |
| 4118 | +{ | |
| 4119 | + struct srp_device *srp_dev = client_data; | |
| 4120 | + struct srp_host *host, *tmp_host; | |
| 4121 | + | |
| 4122 | + list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) { | |
| 4123 | + char name[IB_DEVICE_NAME_MAX + 8]; | |
| 4124 | + | |
| 4125 | + snprintf(name, sizeof(name), "srp-%s-%d", | |
| 4126 | + dev_name(&device->dev), host->port); | |
| 4127 | + device_rename(&host->dev, name); | |
| 4128 | + } | |
| 4129 | +} | |
| 4130 | + | |
| 4115 | 4131 | static void srp_add_one(struct ib_device *device) |
| 4116 | 4132 | { |
| 4117 | 4133 | struct srp_device *srp_dev; |
| @@ -2698,6 +2698,7 @@ struct ib_client { · 2697 unmodified lines | ||
| 2698 | 2698 | const char *name; |
| 2699 | 2699 | void (*add) (struct ib_device *); |
| 2700 | 2700 | void (*remove)(struct ib_device *, void *client_data); |
| 2701 | + void (*rename)(struct ib_device *dev, void *client_data); | |
| 2701 | 2702 | |
| 2702 | 2703 | /* Returns the net_dev belonging to this ib_client and matching the |
| 2703 | 2704 | * given parameters. |