summaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorDean Luick <dean.luick@intel.com>2016-07-28 15:21:21 -0400
committerDoug Ledford <dledford@redhat.com>2016-08-02 22:46:21 -0400
commit622c202c4a4697636334761d7ca295ebd35074e4 (patch)
tree16e3c5e172bcd85b95ca30eeadd168f7e3ab5ef0 /drivers/infiniband
parente0b09ac55d51bb9bf6a4a320bf4029e40bdabd6c (diff)
IB/hfi1: Fix TID caching actions
Per file descriptor TID caching actions depend on a global that can change midway through the lifetime of that file descriptor. Make the use of caching consistent for the life of the file descriptor by using the presence of the cache handler to decide when to use the cache functions. Reviewed-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Dean Luick <dean.luick@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/hw/hfi1/file_ops.c4
-rw-r--r--drivers/infiniband/hw/hfi1/user_exp_rcv.c16
2 files changed, 11 insertions, 9 deletions
diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c
index 302f0cdd8119..4f39bffad74a 100644
--- a/drivers/infiniband/hw/hfi1/file_ops.c
+++ b/drivers/infiniband/hw/hfi1/file_ops.c
@@ -1132,6 +1132,10 @@ static int get_ctxt_info(struct file *fp, void __user *ubase, __u32 len)
1132 HFI1_CAP_MISC_MASK) << HFI1_CAP_USER_SHIFT) | 1132 HFI1_CAP_MISC_MASK) << HFI1_CAP_USER_SHIFT) |
1133 HFI1_CAP_UGET_MASK(uctxt->flags, MASK) | 1133 HFI1_CAP_UGET_MASK(uctxt->flags, MASK) |
1134 HFI1_CAP_KGET_MASK(uctxt->flags, K2U); 1134 HFI1_CAP_KGET_MASK(uctxt->flags, K2U);
1135 /* adjust flag if this fd is not able to cache */
1136 if (!fd->handler)
1137 cinfo.runtime_flags |= HFI1_CAP_TID_UNMAP; /* no caching */
1138
1135 cinfo.num_active = hfi1_count_active_units(); 1139 cinfo.num_active = hfi1_count_active_units();
1136 cinfo.unit = uctxt->dd->unit; 1140 cinfo.unit = uctxt->dd->unit;
1137 cinfo.ctxt = uctxt->ctxt; 1141 cinfo.ctxt = uctxt->ctxt;
diff --git a/drivers/infiniband/hw/hfi1/user_exp_rcv.c b/drivers/infiniband/hw/hfi1/user_exp_rcv.c
index 269a948189e0..9b740db34963 100644
--- a/drivers/infiniband/hw/hfi1/user_exp_rcv.c
+++ b/drivers/infiniband/hw/hfi1/user_exp_rcv.c
@@ -196,7 +196,7 @@ int hfi1_user_exp_rcv_init(struct file *fp)
196 if (!fd->entry_to_rb) 196 if (!fd->entry_to_rb)
197 return -ENOMEM; 197 return -ENOMEM;
198 198
199 if (!HFI1_CAP_IS_USET(TID_UNMAP)) { 199 if (!HFI1_CAP_UGET_MASK(uctxt->flags, TID_UNMAP)) {
200 fd->invalid_tid_idx = 0; 200 fd->invalid_tid_idx = 0;
201 fd->invalid_tids = kzalloc(uctxt->expected_count * 201 fd->invalid_tids = kzalloc(uctxt->expected_count *
202 sizeof(u32), GFP_KERNEL); 202 sizeof(u32), GFP_KERNEL);
@@ -207,15 +207,13 @@ int hfi1_user_exp_rcv_init(struct file *fp)
207 207
208 /* 208 /*
209 * Register MMU notifier callbacks. If the registration 209 * Register MMU notifier callbacks. If the registration
210 * fails, continue but turn off the TID caching for 210 * fails, continue without TID caching for this context.
211 * all user contexts.
212 */ 211 */
213 ret = hfi1_mmu_rb_register(fd, fd->mm, &tid_rb_ops, &fd->handler); 212 ret = hfi1_mmu_rb_register(fd, fd->mm, &tid_rb_ops, &fd->handler);
214 if (ret) { 213 if (ret) {
215 dd_dev_info(dd, 214 dd_dev_info(dd,
216 "Failed MMU notifier registration %d\n", 215 "Failed MMU notifier registration %d\n",
217 ret); 216 ret);
218 HFI1_CAP_USET(TID_UNMAP);
219 ret = 0; 217 ret = 0;
220 } 218 }
221 } 219 }
@@ -234,7 +232,7 @@ int hfi1_user_exp_rcv_init(struct file *fp)
234 * init. 232 * init.
235 */ 233 */
236 spin_lock(&fd->tid_lock); 234 spin_lock(&fd->tid_lock);
237 if (uctxt->subctxt_cnt && !HFI1_CAP_IS_USET(TID_UNMAP)) { 235 if (uctxt->subctxt_cnt && fd->handler) {
238 u16 remainder; 236 u16 remainder;
239 237
240 fd->tid_limit = uctxt->expected_count / uctxt->subctxt_cnt; 238 fd->tid_limit = uctxt->expected_count / uctxt->subctxt_cnt;
@@ -260,7 +258,7 @@ int hfi1_user_exp_rcv_free(struct hfi1_filedata *fd)
260 * The notifier would have been removed when the process'es mm 258 * The notifier would have been removed when the process'es mm
261 * was freed. 259 * was freed.
262 */ 260 */
263 if (!HFI1_CAP_IS_USET(TID_UNMAP)) 261 if (fd->handler)
264 hfi1_mmu_rb_unregister(fd->handler); 262 hfi1_mmu_rb_unregister(fd->handler);
265 263
266 kfree(fd->invalid_tids); 264 kfree(fd->invalid_tids);
@@ -857,7 +855,7 @@ static int set_rcvarray_entry(struct file *fp, unsigned long vaddr,
857 node->freed = false; 855 node->freed = false;
858 memcpy(node->pages, pages, sizeof(struct page *) * npages); 856 memcpy(node->pages, pages, sizeof(struct page *) * npages);
859 857
860 if (HFI1_CAP_IS_USET(TID_UNMAP)) 858 if (!fd->handler)
861 ret = tid_rb_insert(fd, &node->mmu); 859 ret = tid_rb_insert(fd, &node->mmu);
862 else 860 else
863 ret = hfi1_mmu_rb_insert(fd->handler, &node->mmu); 861 ret = hfi1_mmu_rb_insert(fd->handler, &node->mmu);
@@ -900,7 +898,7 @@ static int unprogram_rcvarray(struct file *fp, u32 tidinfo,
900 node = fd->entry_to_rb[rcventry]; 898 node = fd->entry_to_rb[rcventry];
901 if (!node || node->rcventry != (uctxt->expected_base + rcventry)) 899 if (!node || node->rcventry != (uctxt->expected_base + rcventry))
902 return -EBADF; 900 return -EBADF;
903 if (HFI1_CAP_IS_USET(TID_UNMAP)) 901 if (!fd->handler)
904 tid_rb_remove(fd, &node->mmu, fd->mm); 902 tid_rb_remove(fd, &node->mmu, fd->mm);
905 else 903 else
906 hfi1_mmu_rb_remove(fd->handler, &node->mmu); 904 hfi1_mmu_rb_remove(fd->handler, &node->mmu);
@@ -963,7 +961,7 @@ static void unlock_exp_tids(struct hfi1_ctxtdata *uctxt,
963 uctxt->expected_base]; 961 uctxt->expected_base];
964 if (!node || node->rcventry != rcventry) 962 if (!node || node->rcventry != rcventry)
965 continue; 963 continue;
966 if (HFI1_CAP_IS_USET(TID_UNMAP)) 964 if (!fd->handler)
967 tid_rb_remove(fd, &node->mmu, fd->mm); 965 tid_rb_remove(fd, &node->mmu, fd->mm);
968 else 966 else
969 hfi1_mmu_rb_remove(fd->handler, 967 hfi1_mmu_rb_remove(fd->handler,