hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/infiniband/hw/hfi1/file_ops.c
....@@ -1,5 +1,6 @@
11 /*
2
- * Copyright(c) 2015-2017 Intel Corporation.
2
+ * Copyright(c) 2020 Cornelis Networks, Inc.
3
+ * Copyright(c) 2015-2020 Intel Corporation.
34 *
45 * This file is provided under a dual BSD/GPLv2 license. When using or
56 * redistributing this file, you may do so under either license.
....@@ -206,10 +207,7 @@
206207 spin_lock_init(&fd->tid_lock);
207208 spin_lock_init(&fd->invalid_lock);
208209 fd->rec_cpu_num = -1; /* no cpu affinity by default */
209
- fd->mm = current->mm;
210
- mmgrab(fd->mm);
211210 fd->dd = dd;
212
- kobject_get(&fd->dd->kobj);
213211 fp->private_data = fd;
214212 return 0;
215213 nomem:
....@@ -308,6 +306,8 @@
308306 unsigned long dim = from->nr_segs;
309307 int idx;
310308
309
+ if (!HFI1_CAP_IS_KSET(SDMA))
310
+ return -EINVAL;
311311 idx = srcu_read_lock(&fd->pq_srcu);
312312 pq = srcu_dereference(fd->pq, &fd->pq_srcu);
313313 if (!cq || !pq) {
....@@ -516,12 +516,12 @@
516516 ret = -EINVAL;
517517 goto done;
518518 }
519
- if ((flags & VM_WRITE) || !uctxt->rcvhdrtail_kvaddr) {
519
+ if ((flags & VM_WRITE) || !hfi1_rcvhdrtail_kvaddr(uctxt)) {
520520 ret = -EPERM;
521521 goto done;
522522 }
523523 memlen = PAGE_SIZE;
524
- memvirt = (void *)uctxt->rcvhdrtail_kvaddr;
524
+ memvirt = (void *)hfi1_rcvhdrtail_kvaddr(uctxt);
525525 flags &= ~VM_MAYWRITE;
526526 break;
527527 case SUBCTXT_UREGS:
....@@ -692,7 +692,8 @@
692692 HFI1_RCVCTRL_TAILUPD_DIS |
693693 HFI1_RCVCTRL_ONE_PKT_EGR_DIS |
694694 HFI1_RCVCTRL_NO_RHQ_DROP_DIS |
695
- HFI1_RCVCTRL_NO_EGR_DROP_DIS, uctxt);
695
+ HFI1_RCVCTRL_NO_EGR_DROP_DIS |
696
+ HFI1_RCVCTRL_URGENT_DIS, uctxt);
696697 /* Clear the context's J_KEY */
697698 hfi1_clear_ctxt_jkey(dd, uctxt);
698699 /*
....@@ -711,8 +712,6 @@
711712
712713 deallocate_ctxt(uctxt);
713714 done:
714
- mmdrop(fdata->mm);
715
- kobject_put(&dd->kobj);
716715
717716 if (atomic_dec_and_test(&dd->user_refcount))
718717 complete(&dd->user_comp);
....@@ -1101,13 +1100,14 @@
11011100 * don't have to wait to be sure the DMA update has happened
11021101 * (chip resets head/tail to 0 on transition to enable).
11031102 */
1104
- if (uctxt->rcvhdrtail_kvaddr)
1103
+ if (hfi1_rcvhdrtail_kvaddr(uctxt))
11051104 clear_rcvhdrtail(uctxt);
11061105
11071106 /* Setup J_KEY before enabling the context */
11081107 hfi1_set_ctxt_jkey(uctxt->dd, uctxt, uctxt->jkey);
11091108
11101109 rcvctrl_ops = HFI1_RCVCTRL_CTXT_ENB;
1110
+ rcvctrl_ops |= HFI1_RCVCTRL_URGENT_ENB;
11111111 if (HFI1_CAP_UGET_MASK(uctxt->flags, HDRSUPP))
11121112 rcvctrl_ops |= HFI1_RCVCTRL_TIDFLOW_ENB;
11131113 /*
....@@ -1148,7 +1148,7 @@
11481148 HFI1_CAP_UGET_MASK(uctxt->flags, MASK) |
11491149 HFI1_CAP_KGET_MASK(uctxt->flags, K2U);
11501150 /* adjust flag if this fd is not able to cache */
1151
- if (!fd->handler)
1151
+ if (!fd->use_mn)
11521152 cinfo.runtime_flags |= HFI1_CAP_TID_UNMAP; /* no caching */
11531153
11541154 cinfo.num_active = hfi1_count_active_units();
....@@ -1164,8 +1164,8 @@
11641164 cinfo.send_ctxt = uctxt->sc->hw_context;
11651165
11661166 cinfo.egrtids = uctxt->egrbufs.alloced;
1167
- cinfo.rcvhdrq_cnt = uctxt->rcvhdrq_cnt;
1168
- cinfo.rcvhdrq_entsize = uctxt->rcvhdrqentsize << 2;
1167
+ cinfo.rcvhdrq_cnt = get_hdrq_cnt(uctxt);
1168
+ cinfo.rcvhdrq_entsize = get_hdrqentsize(uctxt) << 2;
11691169 cinfo.sdma_ring_size = fd->cq->nentries;
11701170 cinfo.rcvegr_size = uctxt->egrbufs.rcvtid_size;
11711171
....@@ -1220,8 +1220,10 @@
12201220 goto done;
12211221
12221222 ret = init_user_ctxt(fd, uctxt);
1223
- if (ret)
1223
+ if (ret) {
1224
+ hfi1_free_ctxt_rcv_groups(uctxt);
12241225 goto done;
1226
+ }
12251227
12261228 user_init(uctxt);
12271229
....@@ -1264,7 +1266,7 @@
12641266 memset(&binfo, 0, sizeof(binfo));
12651267 binfo.hw_version = dd->revision;
12661268 binfo.sw_version = HFI1_KERN_SWVERSION;
1267
- binfo.bthqp = kdeth_qp;
1269
+ binfo.bthqp = RVT_KDETH_QP_PREFIX;
12681270 binfo.jkey = uctxt->jkey;
12691271 /*
12701272 * If more than 64 contexts are enabled the allocated credit
....@@ -1553,7 +1555,7 @@
15531555 * always resets it's tail register back to 0 on a
15541556 * transition from disabled to enabled.
15551557 */
1556
- if (uctxt->rcvhdrtail_kvaddr)
1558
+ if (hfi1_rcvhdrtail_kvaddr(uctxt))
15571559 clear_rcvhdrtail(uctxt);
15581560 rcvctrl_op = HFI1_RCVCTRL_CTXT_ENB;
15591561 } else {
....@@ -1694,7 +1696,7 @@
16941696 snprintf(name, sizeof(name), "%s_%d", class_name(), dd->unit);
16951697 ret = hfi1_cdev_init(dd->unit, name, &hfi1_file_ops,
16961698 &dd->user_cdev, &dd->user_device,
1697
- true, &dd->kobj);
1699
+ true, &dd->verbs_dev.rdi.ibdev.dev.kobj);
16981700 if (ret)
16991701 user_remove(dd);
17001702