Lines Matching refs:fd

15 			    struct hfi1_filedata *fd);
17 static int set_rcvarray_entry(struct hfi1_filedata *fd,
26 static int program_rcvarray(struct hfi1_filedata *fd, struct tid_user_buf *,
31 static int unprogram_rcvarray(struct hfi1_filedata *fd, u32 tidinfo,
33 static void clear_tid_node(struct hfi1_filedata *fd, struct tid_rb_node *node);
44 int hfi1_user_exp_rcv_init(struct hfi1_filedata *fd, in hfi1_user_exp_rcv_init() argument
49 fd->entry_to_rb = kcalloc(uctxt->expected_count, in hfi1_user_exp_rcv_init()
52 if (!fd->entry_to_rb) in hfi1_user_exp_rcv_init()
56 fd->invalid_tid_idx = 0; in hfi1_user_exp_rcv_init()
57 fd->invalid_tids = kcalloc(uctxt->expected_count, in hfi1_user_exp_rcv_init()
58 sizeof(*fd->invalid_tids), in hfi1_user_exp_rcv_init()
60 if (!fd->invalid_tids) { in hfi1_user_exp_rcv_init()
61 kfree(fd->entry_to_rb); in hfi1_user_exp_rcv_init()
62 fd->entry_to_rb = NULL; in hfi1_user_exp_rcv_init()
65 fd->use_mn = true; in hfi1_user_exp_rcv_init()
81 spin_lock(&fd->tid_lock); in hfi1_user_exp_rcv_init()
82 if (uctxt->subctxt_cnt && fd->use_mn) { in hfi1_user_exp_rcv_init()
85 fd->tid_limit = uctxt->expected_count / uctxt->subctxt_cnt; in hfi1_user_exp_rcv_init()
87 if (remainder && fd->subctxt < remainder) in hfi1_user_exp_rcv_init()
88 fd->tid_limit++; in hfi1_user_exp_rcv_init()
90 fd->tid_limit = uctxt->expected_count; in hfi1_user_exp_rcv_init()
92 spin_unlock(&fd->tid_lock); in hfi1_user_exp_rcv_init()
97 void hfi1_user_exp_rcv_free(struct hfi1_filedata *fd) in hfi1_user_exp_rcv_free() argument
99 struct hfi1_ctxtdata *uctxt = fd->uctxt; in hfi1_user_exp_rcv_free()
103 unlock_exp_tids(uctxt, &uctxt->tid_full_list, fd); in hfi1_user_exp_rcv_free()
105 unlock_exp_tids(uctxt, &uctxt->tid_used_list, fd); in hfi1_user_exp_rcv_free()
108 kfree(fd->invalid_tids); in hfi1_user_exp_rcv_free()
109 fd->invalid_tids = NULL; in hfi1_user_exp_rcv_free()
111 kfree(fd->entry_to_rb); in hfi1_user_exp_rcv_free()
112 fd->entry_to_rb = NULL; in hfi1_user_exp_rcv_free()
126 static void unpin_rcv_pages(struct hfi1_filedata *fd, in unpin_rcv_pages() argument
134 struct hfi1_devdata *dd = fd->uctxt->dd; in unpin_rcv_pages()
147 fd->tid_n_pinned -= npages; in unpin_rcv_pages()
153 static int pin_rcv_pages(struct hfi1_filedata *fd, struct tid_user_buf *tidbuf) in pin_rcv_pages() argument
159 struct hfi1_devdata *dd = fd->uctxt->dd; in pin_rcv_pages()
166 if (npages > fd->uctxt->expected_count) { in pin_rcv_pages()
181 if (!hfi1_can_pin_pages(dd, current->mm, fd->tid_n_pinned, npages)) { in pin_rcv_pages()
193 fd->tid_n_pinned += pinned; in pin_rcv_pages()
246 int hfi1_user_exp_rcv_setup(struct hfi1_filedata *fd, in hfi1_user_exp_rcv_setup() argument
250 struct hfi1_ctxtdata *uctxt = fd->uctxt; in hfi1_user_exp_rcv_setup()
273 pinned = pin_rcv_pages(fd, tidbuf); in hfi1_user_exp_rcv_setup()
288 spin_lock(&fd->tid_lock); in hfi1_user_exp_rcv_setup()
289 if (fd->tid_used + tidbuf->n_psets > fd->tid_limit) in hfi1_user_exp_rcv_setup()
290 pageset_count = fd->tid_limit - fd->tid_used; in hfi1_user_exp_rcv_setup()
293 spin_unlock(&fd->tid_lock); in hfi1_user_exp_rcv_setup()
320 ret = program_rcvarray(fd, tidbuf, grp, in hfi1_user_exp_rcv_setup()
366 ret = program_rcvarray(fd, tidbuf, grp, in hfi1_user_exp_rcv_setup()
402 spin_lock(&fd->tid_lock); in hfi1_user_exp_rcv_setup()
403 fd->tid_used += tididx; in hfi1_user_exp_rcv_setup()
404 spin_unlock(&fd->tid_lock); in hfi1_user_exp_rcv_setup()
415 hfi1_user_exp_rcv_clear(fd, tinfo); in hfi1_user_exp_rcv_setup()
427 unpin_rcv_pages(fd, tidbuf, NULL, mapped_pages, in hfi1_user_exp_rcv_setup()
437 int hfi1_user_exp_rcv_clear(struct hfi1_filedata *fd, in hfi1_user_exp_rcv_clear() argument
441 struct hfi1_ctxtdata *uctxt = fd->uctxt; in hfi1_user_exp_rcv_clear()
445 if (unlikely(tinfo->tidcnt > fd->tid_used)) in hfi1_user_exp_rcv_clear()
455 ret = unprogram_rcvarray(fd, tidinfo[tididx], NULL); in hfi1_user_exp_rcv_clear()
462 spin_lock(&fd->tid_lock); in hfi1_user_exp_rcv_clear()
463 fd->tid_used -= tididx; in hfi1_user_exp_rcv_clear()
464 spin_unlock(&fd->tid_lock); in hfi1_user_exp_rcv_clear()
472 int hfi1_user_exp_rcv_invalid(struct hfi1_filedata *fd, in hfi1_user_exp_rcv_invalid() argument
475 struct hfi1_ctxtdata *uctxt = fd->uctxt; in hfi1_user_exp_rcv_invalid()
477 (uctxt_offset(uctxt) + fd->subctxt); in hfi1_user_exp_rcv_invalid()
491 spin_lock(&fd->invalid_lock); in hfi1_user_exp_rcv_invalid()
492 if (fd->invalid_tid_idx) { in hfi1_user_exp_rcv_invalid()
493 memcpy(array, fd->invalid_tids, sizeof(*array) * in hfi1_user_exp_rcv_invalid()
494 fd->invalid_tid_idx); in hfi1_user_exp_rcv_invalid()
495 memset(fd->invalid_tids, 0, sizeof(*fd->invalid_tids) * in hfi1_user_exp_rcv_invalid()
496 fd->invalid_tid_idx); in hfi1_user_exp_rcv_invalid()
497 tinfo->tidcnt = fd->invalid_tid_idx; in hfi1_user_exp_rcv_invalid()
498 fd->invalid_tid_idx = 0; in hfi1_user_exp_rcv_invalid()
507 spin_unlock(&fd->invalid_lock); in hfi1_user_exp_rcv_invalid()
611 static int program_rcvarray(struct hfi1_filedata *fd, struct tid_user_buf *tbuf, in program_rcvarray() argument
617 struct hfi1_ctxtdata *uctxt = fd->uctxt; in program_rcvarray()
657 ret = set_rcvarray_entry(fd, tbuf, in program_rcvarray()
679 static int set_rcvarray_entry(struct hfi1_filedata *fd, in set_rcvarray_entry() argument
685 struct hfi1_ctxtdata *uctxt = fd->uctxt; in set_rcvarray_entry()
708 node->fdata = fd; in set_rcvarray_entry()
717 if (fd->use_mn) { in set_rcvarray_entry()
730 fd->entry_to_rb[node->rcventry - uctxt->expected_base] = node; in set_rcvarray_entry()
733 trace_hfi1_exp_tid_reg(uctxt->ctxt, fd->subctxt, rcventry, npages, in set_rcvarray_entry()
748 static int unprogram_rcvarray(struct hfi1_filedata *fd, u32 tidinfo, in unprogram_rcvarray() argument
751 struct hfi1_ctxtdata *uctxt = fd->uctxt; in unprogram_rcvarray()
768 node = fd->entry_to_rb[rcventry]; in unprogram_rcvarray()
775 if (fd->use_mn) in unprogram_rcvarray()
777 cacheless_tid_rb_remove(fd, node); in unprogram_rcvarray()
782 static void clear_tid_node(struct hfi1_filedata *fd, struct tid_rb_node *node) in clear_tid_node() argument
784 struct hfi1_ctxtdata *uctxt = fd->uctxt; in clear_tid_node()
787 trace_hfi1_exp_tid_unreg(uctxt->ctxt, fd->subctxt, node->rcventry, in clear_tid_node()
798 unpin_rcv_pages(fd, NULL, node, 0, node->npages, true); in clear_tid_node()
818 struct hfi1_filedata *fd) in unlock_exp_tids() argument
831 node = fd->entry_to_rb[rcventry - in unlock_exp_tids()
836 if (fd->use_mn) in unlock_exp_tids()
839 cacheless_tid_rb_remove(fd, node); in unlock_exp_tids()