History

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma

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

Linus Torvalds committed 7 years ago

Commit 6e383352 parents a02a532 4f240df17 files · +95 −35Browse files

Unified · Split

17 files
  1. drivers/infiniband/core/device.c +35 −14
  2. drivers/infiniband/core/rdma_core.h +2 −0
  3. drivers/infiniband/core/uverbs_cmd.c +21 −9
  4. drivers/infiniband/core/uverbs_std_types_cq.c +1 −1
  5. drivers/infiniband/core/uverbs_std_types_mr.c +1 −1
  6. drivers/infiniband/hw/efa/efa_verbs.c +0 −1
  7. drivers/infiniband/hw/hfi1/chip.c +1 −0
  8. drivers/infiniband/hw/hfi1/user_exp_rcv.c +3 −0
  9. drivers/infiniband/hw/hfi1/verbs.c +0 −2
  10. drivers/infiniband/hw/hns/hns_roce_hw_v1.c +1 −0
  11. drivers/infiniband/hw/mlx5/cmd.c +7 −2
  12. drivers/infiniband/hw/mlx5/main.c +1 −1
  13. drivers/infiniband/hw/qib/qib_verbs.c +0 −2
  14. drivers/infiniband/sw/rdmavt/mr.c +2 −0
  15. drivers/infiniband/sw/rdmavt/qp.c +2 −1
  16. drivers/infiniband/ulp/srp/ib_srp.c +17 −1
  17. include/rdma/ib_verbs.h +1 −0
drivers/infiniband/core/device.c+35−14
@@ -409,27 +409,44 @@ static int rename_compat_devs(struct ib_device *device) · 408 unmodified lines
409409
410410 int ib_device_rename(struct ib_device *ibdev, const char *name)
411411 {
412+ unsigned long index;
413+ void *client_data;
412414 int ret;
413415
414416 down_write(&devices_rwsem);
415417 if (!strcmp(name, dev_name(&ibdev->dev))) {
416− ret = 0;
417− goto out;
418+ up_write(&devices_rwsem);
419+ return 0;
418420 }
419421
420422 if (__ib_device_get_by_name(name)) {
421− ret = -EEXIST;
422− goto out;
423+ up_write(&devices_rwsem);
424+ return -EEXIST;
423425 }
424426
425427 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+
428433 strlcpy(ibdev->name, name, IB_DEVICE_NAME_MAX);
429434 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;
433450 }
434451
435452 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
474491
475492 free_netdevs(dev);
476493 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);
482497 kfree_rcu(container_of(dev->port_data, struct ib_port_data_rcu,
483498 pdata[0]),
484499 rcu_head);
500+ }
501+ xa_destroy(&dev->compat_devs);
502+ xa_destroy(&dev->client_data);
485503 kfree_rcu(dev, rcu_head);
486504 }
487505
@@ -1935,6 +1953,9 @@ static void free_netdevs(struct ib_device *ib_dev) · 1447 unmodified lines
19351953 unsigned long flags;
19361954 unsigned int port;
19371955
1956+ if (!ib_dev->port_data)
1957+ return;
1958+
19381959 rdma_for_each_port (ib_dev, port) {
19391960 struct ib_port_data *pdata = &ib_dev->port_data[port];
19401961 struct net_device *ndev;
drivers/infiniband/core/rdma_core.h+2−0
@@ -110,6 +110,8 @@ int uverbs_output_written(const struct uverbs_attr_bundle *bundle, size_t idx); · 109 unmodified lines
110110 void setup_ufile_idr_uobject(struct ib_uverbs_file *ufile);
111111 void release_ufile_idr_uobject(struct ib_uverbs_file *ufile);
112112
113+struct ib_udata *uverbs_get_cleared_udata(struct uverbs_attr_bundle *attrs);
114+
113115 /*
114116 * This is the runtime description of the uverbs API, used by the syscall
115117 * machinery to validate and dispatch calls.
drivers/infiniband/core/uverbs_cmd.c+21−9
@@ -174,6 +174,17 @@ static int uverbs_request_finish(struct uverbs_req_iter *iter) · 173 unmodified lines
174174 return 0;
175175 }
176176
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+
177188 static struct ib_uverbs_completion_event_file *
178189 _ib_uverbs_lookup_comp_file(s32 fd, struct uverbs_attr_bundle *attrs)
179190 {
@@ -441,7 +452,7 @@ static int ib_uverbs_alloc_pd(struct uverbs_attr_bundle *attrs) · 261 unmodified lines
441452 return uobj_alloc_commit(uobj, attrs);
442453
443454 err_copy:
444− ib_dealloc_pd_user(pd, &attrs->driver_udata);
455+ ib_dealloc_pd_user(pd, uverbs_get_cleared_udata(attrs));
445456 pd = NULL;
446457 err_alloc:
447458 kfree(pd);
@@ -644,7 +655,7 @@ err_copy: · 196 unmodified lines
644655 }
645656
646657 err_dealloc_xrcd:
647− ib_dealloc_xrcd(xrcd, &attrs->driver_udata);
658+ ib_dealloc_xrcd(xrcd, uverbs_get_cleared_udata(attrs));
648659
649660 err:
650661 uobj_alloc_abort(&obj->uobject, attrs);
@@ -767,7 +778,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs) · 116 unmodified lines
767778 return uobj_alloc_commit(uobj, attrs);
768779
769780 err_copy:
770− ib_dereg_mr_user(mr, &attrs->driver_udata);
781+ ib_dereg_mr_user(mr, uverbs_get_cleared_udata(attrs));
771782
772783 err_put:
773784 uobj_put_obj_read(pd);
@@ -1042,7 +1053,7 @@ static struct ib_ucq_object *create_cq(struct uverbs_attr_bundle *attrs, · 268 unmodified lines
10421053 return obj;
10431054
10441055 err_cb:
1045− ib_destroy_cq(cq);
1056+ ib_destroy_cq_user(cq, uverbs_get_cleared_udata(attrs));
10461057
10471058 err_file:
10481059 if (ev_file)
@@ -1478,7 +1489,7 @@ static int create_qp(struct uverbs_attr_bundle *attrs, · 429 unmodified lines
14781489
14791490 return uobj_alloc_commit(&obj->uevent.uobject, attrs);
14801491 err_cb:
1481− ib_destroy_qp(qp);
1492+ ib_destroy_qp_user(qp, uverbs_get_cleared_udata(attrs));
14821493
14831494 err_put:
14841495 if (!IS_ERR(xrcd_uobj))
@@ -1611,7 +1622,7 @@ static int ib_uverbs_open_qp(struct uverbs_attr_bundle *attrs) · 126 unmodified lines
16111622 return uobj_alloc_commit(&obj->uevent.uobject, attrs);
16121623
16131624 err_destroy:
1614− ib_destroy_qp(qp);
1625+ ib_destroy_qp_user(qp, uverbs_get_cleared_udata(attrs));
16151626 err_xrcd:
16161627 uobj_put_read(xrcd_uobj);
16171628 err_put:
@@ -2453,7 +2464,8 @@ static int ib_uverbs_create_ah(struct uverbs_attr_bundle *attrs) · 835 unmodified lines
24532464 return uobj_alloc_commit(uobj, attrs);
24542465
24552466 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));
24572469
24582470 err_put:
24592471 uobj_put_obj_read(pd);
@@ -2964,7 +2976,7 @@ static int ib_uverbs_ex_create_wq(struct uverbs_attr_bundle *attrs) · 504 unmodified lines
29642976 return uobj_alloc_commit(&obj->uevent.uobject, attrs);
29652977
29662978 err_copy:
2967− ib_destroy_wq(wq, &attrs->driver_udata);
2979+ ib_destroy_wq(wq, uverbs_get_cleared_udata(attrs));
29682980 err_put_cq:
29692981 uobj_put_obj_read(cq);
29702982 err_put_pd:
@@ -3464,7 +3476,7 @@ static int __uverbs_create_xsrq(struct uverbs_attr_bundle *attrs, · 493 unmodified lines
34643476 return uobj_alloc_commit(&obj->uevent.uobject, attrs);
34653477
34663478 err_copy:
3467− ib_destroy_srq_user(srq, &attrs->driver_udata);
3479+ ib_destroy_srq_user(srq, uverbs_get_cleared_udata(attrs));
34683480
34693481 err_free:
34703482 kfree(srq);
drivers/infiniband/core/uverbs_std_types_cq.c+1−1
@@ -135,7 +135,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)( · 134 unmodified lines
135135
136136 return 0;
137137 err_cq:
138− ib_destroy_cq(cq);
138+ ib_destroy_cq_user(cq, uverbs_get_cleared_udata(attrs));
139139
140140 err_event_file:
141141 if (ev_file)
drivers/infiniband/core/uverbs_std_types_mr.c+1−1
@@ -148,7 +148,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_DM_MR_REG)( · 147 unmodified lines
148148 return 0;
149149
150150 err_dereg:
151− ib_dereg_mr_user(mr, &attrs->driver_udata);
151+ ib_dereg_mr_user(mr, uverbs_get_cleared_udata(attrs));
152152
153153 return ret;
154154 }
drivers/infiniband/hw/efa/efa_verbs.c+0−1
@@ -1728,7 +1728,6 @@ int efa_mmap(struct ib_ucontext *ibucontext, · 1727 unmodified lines
17281728 ibdev_dbg(&dev->ibdev, "Mapping executable pages is not permitted\n");
17291729 return -EPERM;
17301730 }
1731− vma->vm_flags &= ~VM_MAYEXEC;
17321731
17331732 return __efa_mmap(dev, ucontext, vma, key, length);
17341733 }
drivers/infiniband/hw/hfi1/chip.c+1−0
@@ -9850,6 +9850,7 @@ void hfi1_quiet_serdes(struct hfi1_pportdata *ppd) · 9849 unmodified lines
98509850
98519851 /* disable the port */
98529852 clear_rcvctrl(dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK);
9853+ cancel_work_sync(&ppd->freeze_work);
98539854 }
98549855
98559856 static inline int init_cpu_counters(struct hfi1_devdata *dd)
drivers/infiniband/hw/hfi1/user_exp_rcv.c+3−0
@@ -324,6 +324,9 @@ int hfi1_user_exp_rcv_setup(struct hfi1_filedata *fd, · 323 unmodified lines
324324 u32 *tidlist = NULL;
325325 struct tid_user_buf *tidbuf;
326326
327+ if (!PAGE_ALIGNED(tinfo->vaddr))
328+ return -EINVAL;
329+
327330 tidbuf = kzalloc(sizeof(*tidbuf), GFP_KERNEL);
328331 if (!tidbuf)
329332 return -ENOMEM;
drivers/infiniband/hw/hfi1/verbs.c+0−2
@@ -1356,8 +1356,6 @@ static void hfi1_fill_device_attr(struct hfi1_devdata *dd) · 1355 unmodified lines
13561356 rdi->dparms.props.max_cq = hfi1_max_cqs;
13571357 rdi->dparms.props.max_ah = hfi1_max_ahs;
13581358 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;
13611359 rdi->dparms.props.max_map_per_fmr = 32767;
13621360 rdi->dparms.props.max_pd = hfi1_max_pds;
13631361 rdi->dparms.props.max_qp_rd_atom = HFI1_MAX_RDMA_ATOMIC;
drivers/infiniband/hw/hns/hns_roce_hw_v1.c+1−0
@@ -899,6 +899,7 @@ static void hns_roce_v1_release_lp_qp(struct hns_roce_dev *hr_dev) · 898 unmodified lines
899899 dev_err(dev, "Destroy cq for mr_free failed(%d)!\n", ret);
900900
901901 hns_roce_dealloc_pd(&free_mr->mr_free_pd->ibpd, NULL);
902+ kfree(&free_mr->mr_free_pd->ibpd);
902903 }
903904
904905 static int hns_roce_db_init(struct hns_roce_dev *hr_dev)
drivers/infiniband/hw/mlx5/cmd.c+7−2
@@ -190,12 +190,12 @@ int mlx5_cmd_alloc_sw_icm(struct mlx5_dm *dm, int type, u64 length, · 189 unmodified lines
190190 u16 uid, phys_addr_t *addr, u32 *obj_id)
191191 {
192192 struct mlx5_core_dev *dev = dm->dev;
193− u32 num_blocks = DIV_ROUND_UP(length, MLX5_SW_ICM_BLOCK_SIZE(dev));
194193 u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {};
195194 u32 in[MLX5_ST_SZ_DW(create_sw_icm_in)] = {};
196195 unsigned long *block_map;
197196 u64 icm_start_addr;
198197 u32 log_icm_size;
198+ u32 num_blocks;
199199 u32 max_blocks;
200200 u64 block_idx;
201201 void *sw_icm;
@@ -224,6 +224,8 @@ int mlx5_cmd_alloc_sw_icm(struct mlx5_dm *dm, int type, u64 length, · 22 unmodified lines
224224 return -EINVAL;
225225 }
226226
227+ num_blocks = (length + MLX5_SW_ICM_BLOCK_SIZE(dev) - 1) >>
228+ MLX5_LOG_SW_ICM_BLOCK_SIZE(dev);
227229 max_blocks = BIT(log_icm_size - MLX5_LOG_SW_ICM_BLOCK_SIZE(dev));
228230 spin_lock(&dm->lock);
229231 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
266268 u16 uid, phys_addr_t addr, u32 obj_id)
267269 {
268270 struct mlx5_core_dev *dev = dm->dev;
269− u32 num_blocks = DIV_ROUND_UP(length, MLX5_SW_ICM_BLOCK_SIZE(dev));
270271 u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {};
271272 u32 in[MLX5_ST_SZ_DW(general_obj_in_cmd_hdr)] = {};
272273 unsigned long *block_map;
274+ u32 num_blocks;
273275 u64 start_idx;
274276 int err;
275277
278+ num_blocks = (length + MLX5_SW_ICM_BLOCK_SIZE(dev) - 1) >>
279+ MLX5_LOG_SW_ICM_BLOCK_SIZE(dev);
280+
276281 switch (type) {
277282 case MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM:
278283 start_idx =
drivers/infiniband/hw/mlx5/main.c+1−1
@@ -2344,7 +2344,7 @@ static int handle_alloc_dm_sw_icm(struct ib_ucontext *ctx, · 2343 unmodified lines
23442344 /* Allocation size must a multiple of the basic block size
23452345 * and a power of 2.
23462346 */
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));
23482348 act_size = roundup_pow_of_two(act_size);
23492349
23502350 dm->size = act_size;
drivers/infiniband/hw/qib/qib_verbs.c+0−2
@@ -1459,8 +1459,6 @@ static void qib_fill_device_attr(struct qib_devdata *dd) · 1458 unmodified lines
14591459 rdi->dparms.props.max_cq = ib_qib_max_cqs;
14601460 rdi->dparms.props.max_cqe = ib_qib_max_cqes;
14611461 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;
14641462 rdi->dparms.props.max_map_per_fmr = 32767;
14651463 rdi->dparms.props.max_qp_rd_atom = QIB_MAX_RDMA_ATOMIC;
14661464 rdi->dparms.props.max_qp_init_rd_atom = 255;
drivers/infiniband/sw/rdmavt/mr.c+2−0
@@ -96,6 +96,8 @@ int rvt_driver_mr_init(struct rvt_dev_info *rdi) · 95 unmodified lines
9696 for (i = 0; i < rdi->lkey_table.max; i++)
9797 RCU_INIT_POINTER(rdi->lkey_table.table[i], NULL);
9898
99+ rdi->dparms.props.max_mr = rdi->lkey_table.max;
100+ rdi->dparms.props.max_fmr = rdi->lkey_table.max;
99101 return 0;
100102 }
101103
drivers/infiniband/sw/rdmavt/qp.c+2−1
@@ -594,7 +594,8 @@ static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, · 593 unmodified lines
594594 offset = qpt->incr | ((offset & 1) ^ 1);
595595 }
596596 /* 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));
598599 qpn = mk_qpn(qpt, map, offset);
599600 }
600601
drivers/infiniband/ulp/srp/ib_srp.c+17−1
@@ -148,6 +148,7 @@ MODULE_PARM_DESC(ch_count, · 147 unmodified lines
148148
149149 static void srp_add_one(struct ib_device *device);
150150 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);
151152 static void srp_recv_done(struct ib_cq *cq, struct ib_wc *wc);
152153 static void srp_handle_qp_err(struct ib_cq *cq, struct ib_wc *wc,
153154 const char *opname);
@@ -162,7 +163,8 @@ static struct workqueue_struct *srp_remove_wq; · 8 unmodified lines
162163 static struct ib_client srp_client = {
163164 .name = "srp",
164165 .add = srp_add_one,
165− .remove = srp_remove_one
166+ .remove = srp_remove_one,
167+ .rename = srp_rename_dev
166168 };
167169
168170 static struct ib_sa_client srp_sa_client;
@@ -4112,6 +4114,20 @@ free_host: · 3943 unmodified lines
41124114 return NULL;
41134115 }
41144116
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+
41154131 static void srp_add_one(struct ib_device *device)
41164132 {
41174133 struct srp_device *srp_dev;
include/rdma/ib_verbs.h+1−0
@@ -2698,6 +2698,7 @@ struct ib_client { · 2697 unmodified lines
26982698 const char *name;
26992699 void (*add) (struct ib_device *);
27002700 void (*remove)(struct ib_device *, void *client_data);
2701+ void (*rename)(struct ib_device *dev, void *client_data);
27012702
27022703 /* Returns the net_dev belonging to this ib_client and matching the
27032704 * given parameters.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t