.. | .. |
---|
1 | 1 | /* |
---|
2 | | - * Copyright(c) 2015-2017 Intel Corporation. |
---|
| 2 | + * Copyright(c) 2020 Cornelis Networks, Inc. |
---|
| 3 | + * Copyright(c) 2015-2020 Intel Corporation. |
---|
3 | 4 | * |
---|
4 | 5 | * This file is provided under a dual BSD/GPLv2 license. When using or |
---|
5 | 6 | * redistributing this file, you may do so under either license. |
---|
.. | .. |
---|
206 | 207 | spin_lock_init(&fd->tid_lock); |
---|
207 | 208 | spin_lock_init(&fd->invalid_lock); |
---|
208 | 209 | fd->rec_cpu_num = -1; /* no cpu affinity by default */ |
---|
209 | | - fd->mm = current->mm; |
---|
210 | | - mmgrab(fd->mm); |
---|
211 | 210 | fd->dd = dd; |
---|
212 | | - kobject_get(&fd->dd->kobj); |
---|
213 | 211 | fp->private_data = fd; |
---|
214 | 212 | return 0; |
---|
215 | 213 | nomem: |
---|
.. | .. |
---|
308 | 306 | unsigned long dim = from->nr_segs; |
---|
309 | 307 | int idx; |
---|
310 | 308 | |
---|
| 309 | + if (!HFI1_CAP_IS_KSET(SDMA)) |
---|
| 310 | + return -EINVAL; |
---|
311 | 311 | idx = srcu_read_lock(&fd->pq_srcu); |
---|
312 | 312 | pq = srcu_dereference(fd->pq, &fd->pq_srcu); |
---|
313 | 313 | if (!cq || !pq) { |
---|
.. | .. |
---|
516 | 516 | ret = -EINVAL; |
---|
517 | 517 | goto done; |
---|
518 | 518 | } |
---|
519 | | - if ((flags & VM_WRITE) || !uctxt->rcvhdrtail_kvaddr) { |
---|
| 519 | + if ((flags & VM_WRITE) || !hfi1_rcvhdrtail_kvaddr(uctxt)) { |
---|
520 | 520 | ret = -EPERM; |
---|
521 | 521 | goto done; |
---|
522 | 522 | } |
---|
523 | 523 | memlen = PAGE_SIZE; |
---|
524 | | - memvirt = (void *)uctxt->rcvhdrtail_kvaddr; |
---|
| 524 | + memvirt = (void *)hfi1_rcvhdrtail_kvaddr(uctxt); |
---|
525 | 525 | flags &= ~VM_MAYWRITE; |
---|
526 | 526 | break; |
---|
527 | 527 | case SUBCTXT_UREGS: |
---|
.. | .. |
---|
692 | 692 | HFI1_RCVCTRL_TAILUPD_DIS | |
---|
693 | 693 | HFI1_RCVCTRL_ONE_PKT_EGR_DIS | |
---|
694 | 694 | 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); |
---|
696 | 697 | /* Clear the context's J_KEY */ |
---|
697 | 698 | hfi1_clear_ctxt_jkey(dd, uctxt); |
---|
698 | 699 | /* |
---|
.. | .. |
---|
711 | 712 | |
---|
712 | 713 | deallocate_ctxt(uctxt); |
---|
713 | 714 | done: |
---|
714 | | - mmdrop(fdata->mm); |
---|
715 | | - kobject_put(&dd->kobj); |
---|
716 | 715 | |
---|
717 | 716 | if (atomic_dec_and_test(&dd->user_refcount)) |
---|
718 | 717 | complete(&dd->user_comp); |
---|
.. | .. |
---|
1101 | 1100 | * don't have to wait to be sure the DMA update has happened |
---|
1102 | 1101 | * (chip resets head/tail to 0 on transition to enable). |
---|
1103 | 1102 | */ |
---|
1104 | | - if (uctxt->rcvhdrtail_kvaddr) |
---|
| 1103 | + if (hfi1_rcvhdrtail_kvaddr(uctxt)) |
---|
1105 | 1104 | clear_rcvhdrtail(uctxt); |
---|
1106 | 1105 | |
---|
1107 | 1106 | /* Setup J_KEY before enabling the context */ |
---|
1108 | 1107 | hfi1_set_ctxt_jkey(uctxt->dd, uctxt, uctxt->jkey); |
---|
1109 | 1108 | |
---|
1110 | 1109 | rcvctrl_ops = HFI1_RCVCTRL_CTXT_ENB; |
---|
| 1110 | + rcvctrl_ops |= HFI1_RCVCTRL_URGENT_ENB; |
---|
1111 | 1111 | if (HFI1_CAP_UGET_MASK(uctxt->flags, HDRSUPP)) |
---|
1112 | 1112 | rcvctrl_ops |= HFI1_RCVCTRL_TIDFLOW_ENB; |
---|
1113 | 1113 | /* |
---|
.. | .. |
---|
1148 | 1148 | HFI1_CAP_UGET_MASK(uctxt->flags, MASK) | |
---|
1149 | 1149 | HFI1_CAP_KGET_MASK(uctxt->flags, K2U); |
---|
1150 | 1150 | /* adjust flag if this fd is not able to cache */ |
---|
1151 | | - if (!fd->handler) |
---|
| 1151 | + if (!fd->use_mn) |
---|
1152 | 1152 | cinfo.runtime_flags |= HFI1_CAP_TID_UNMAP; /* no caching */ |
---|
1153 | 1153 | |
---|
1154 | 1154 | cinfo.num_active = hfi1_count_active_units(); |
---|
.. | .. |
---|
1164 | 1164 | cinfo.send_ctxt = uctxt->sc->hw_context; |
---|
1165 | 1165 | |
---|
1166 | 1166 | 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; |
---|
1169 | 1169 | cinfo.sdma_ring_size = fd->cq->nentries; |
---|
1170 | 1170 | cinfo.rcvegr_size = uctxt->egrbufs.rcvtid_size; |
---|
1171 | 1171 | |
---|
.. | .. |
---|
1220 | 1220 | goto done; |
---|
1221 | 1221 | |
---|
1222 | 1222 | ret = init_user_ctxt(fd, uctxt); |
---|
1223 | | - if (ret) |
---|
| 1223 | + if (ret) { |
---|
| 1224 | + hfi1_free_ctxt_rcv_groups(uctxt); |
---|
1224 | 1225 | goto done; |
---|
| 1226 | + } |
---|
1225 | 1227 | |
---|
1226 | 1228 | user_init(uctxt); |
---|
1227 | 1229 | |
---|
.. | .. |
---|
1264 | 1266 | memset(&binfo, 0, sizeof(binfo)); |
---|
1265 | 1267 | binfo.hw_version = dd->revision; |
---|
1266 | 1268 | binfo.sw_version = HFI1_KERN_SWVERSION; |
---|
1267 | | - binfo.bthqp = kdeth_qp; |
---|
| 1269 | + binfo.bthqp = RVT_KDETH_QP_PREFIX; |
---|
1268 | 1270 | binfo.jkey = uctxt->jkey; |
---|
1269 | 1271 | /* |
---|
1270 | 1272 | * If more than 64 contexts are enabled the allocated credit |
---|
.. | .. |
---|
1553 | 1555 | * always resets it's tail register back to 0 on a |
---|
1554 | 1556 | * transition from disabled to enabled. |
---|
1555 | 1557 | */ |
---|
1556 | | - if (uctxt->rcvhdrtail_kvaddr) |
---|
| 1558 | + if (hfi1_rcvhdrtail_kvaddr(uctxt)) |
---|
1557 | 1559 | clear_rcvhdrtail(uctxt); |
---|
1558 | 1560 | rcvctrl_op = HFI1_RCVCTRL_CTXT_ENB; |
---|
1559 | 1561 | } else { |
---|
.. | .. |
---|
1694 | 1696 | snprintf(name, sizeof(name), "%s_%d", class_name(), dd->unit); |
---|
1695 | 1697 | ret = hfi1_cdev_init(dd->unit, name, &hfi1_file_ops, |
---|
1696 | 1698 | &dd->user_cdev, &dd->user_device, |
---|
1697 | | - true, &dd->kobj); |
---|
| 1699 | + true, &dd->verbs_dev.rdi.ibdev.dev.kobj); |
---|
1698 | 1700 | if (ret) |
---|
1699 | 1701 | user_remove(dd); |
---|
1700 | 1702 | |
---|