diff options
author | Mitko Haralanov <mitko.haralanov@intel.com> | 2016-03-08 14:15:39 -0500 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2016-03-21 15:55:25 -0400 |
commit | a7922f7ddf023c93b0c409d7a3557fdf0b5ce343 (patch) | |
tree | 7a08a061e16ef47368ef221d7cb0c8252fb6f9cb | |
parent | bd3a8947de916534722b0861d865d3a809c0743c (diff) |
IB/hfi1: Switch to using the pin query function
Use the new function to query whether the expected receive
user buffer can be pinned successfully. This requires that
a new variable be added to the hfi1_filedata structure used
to hold the number of pages pinned by the expected receive
code.
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: Dean Luick <dean.luick@intel.com>
Signed-off-by: Mitko Haralanov <mitko.haralanov@intel.com>
Signed-off-by: Jubin John <jubin.john@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r-- | drivers/staging/rdma/hfi1/hfi.h | 1 | ||||
-rw-r--r-- | drivers/staging/rdma/hfi1/user_exp_rcv.c | 8 |
2 files changed, 8 insertions, 1 deletions
diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1/hfi.h index 3dc644d92e3a..16cbdc4073e0 100644 --- a/drivers/staging/rdma/hfi1/hfi.h +++ b/drivers/staging/rdma/hfi1/hfi.h | |||
@@ -1190,6 +1190,7 @@ struct hfi1_filedata { | |||
1190 | struct hfi1_user_sdma_pkt_q *pq; | 1190 | struct hfi1_user_sdma_pkt_q *pq; |
1191 | /* for cpu affinity; -1 if none */ | 1191 | /* for cpu affinity; -1 if none */ |
1192 | int rec_cpu_num; | 1192 | int rec_cpu_num; |
1193 | u32 tid_n_pinned; | ||
1193 | struct rb_root tid_rb_root; | 1194 | struct rb_root tid_rb_root; |
1194 | struct tid_rb_node **entry_to_rb; | 1195 | struct tid_rb_node **entry_to_rb; |
1195 | spinlock_t tid_lock; /* protect tid_[limit,used] counters */ | 1196 | spinlock_t tid_lock; /* protect tid_[limit,used] counters */ |
diff --git a/drivers/staging/rdma/hfi1/user_exp_rcv.c b/drivers/staging/rdma/hfi1/user_exp_rcv.c index 591605a13243..0861e095df8d 100644 --- a/drivers/staging/rdma/hfi1/user_exp_rcv.c +++ b/drivers/staging/rdma/hfi1/user_exp_rcv.c | |||
@@ -396,11 +396,14 @@ int hfi1_user_exp_rcv_setup(struct file *fp, struct hfi1_tid_info *tinfo) | |||
396 | * pages, accept the amount pinned so far and program only that. | 396 | * pages, accept the amount pinned so far and program only that. |
397 | * User space knows how to deal with partially programmed buffers. | 397 | * User space knows how to deal with partially programmed buffers. |
398 | */ | 398 | */ |
399 | if (!hfi1_can_pin_pages(dd, fd->tid_n_pinned, npages)) | ||
400 | return -ENOMEM; | ||
399 | pinned = hfi1_acquire_user_pages(vaddr, npages, true, pages); | 401 | pinned = hfi1_acquire_user_pages(vaddr, npages, true, pages); |
400 | if (pinned <= 0) { | 402 | if (pinned <= 0) { |
401 | ret = pinned; | 403 | ret = pinned; |
402 | goto bail; | 404 | goto bail; |
403 | } | 405 | } |
406 | fd->tid_n_pinned += npages; | ||
404 | 407 | ||
405 | /* Find sets of physically contiguous pages */ | 408 | /* Find sets of physically contiguous pages */ |
406 | npagesets = find_phys_blocks(pages, pinned, pagesets); | 409 | npagesets = find_phys_blocks(pages, pinned, pagesets); |
@@ -549,10 +552,12 @@ nomem: | |||
549 | * If not everything was mapped (due to insufficient RcvArray entries, | 552 | * If not everything was mapped (due to insufficient RcvArray entries, |
550 | * for example), unpin all unmapped pages so we can pin them nex time. | 553 | * for example), unpin all unmapped pages so we can pin them nex time. |
551 | */ | 554 | */ |
552 | if (mapped_pages != pinned) | 555 | if (mapped_pages != pinned) { |
553 | hfi1_release_user_pages(current->mm, &pages[mapped_pages], | 556 | hfi1_release_user_pages(current->mm, &pages[mapped_pages], |
554 | pinned - mapped_pages, | 557 | pinned - mapped_pages, |
555 | false); | 558 | false); |
559 | fd->tid_n_pinned -= pinned - mapped_pages; | ||
560 | } | ||
556 | bail: | 561 | bail: |
557 | kfree(pagesets); | 562 | kfree(pagesets); |
558 | kfree(pages); | 563 | kfree(pages); |
@@ -924,6 +929,7 @@ static void clear_tid_node(struct hfi1_filedata *fd, u16 subctxt, | |||
924 | pci_unmap_single(dd->pcidev, node->dma_addr, node->mmu.len, | 929 | pci_unmap_single(dd->pcidev, node->dma_addr, node->mmu.len, |
925 | PCI_DMA_FROMDEVICE); | 930 | PCI_DMA_FROMDEVICE); |
926 | hfi1_release_user_pages(current->mm, node->pages, node->npages, true); | 931 | hfi1_release_user_pages(current->mm, node->pages, node->npages, true); |
932 | fd->tid_n_pinned -= node->npages; | ||
927 | 933 | ||
928 | node->grp->used--; | 934 | node->grp->used--; |
929 | node->grp->map &= ~(1 << (node->rcventry - node->grp->base)); | 935 | node->grp->map &= ~(1 << (node->rcventry - node->grp->base)); |