diff options
author | Mitko Haralanov <mitko.haralanov@intel.com> | 2016-03-08 11:14:48 -0800 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2016-03-21 15:55:22 -0400 |
commit | 909e2cd004b639276678c195760efeea6c173626 (patch) | |
tree | 0b01ddca0e0eec9972888160608e01a6d7da8f51 /drivers/staging | |
parent | 368f2b59d024fbb58015dfd0e09c54c424cda979 (diff) | |
download | linux-909e2cd004b639276678c195760efeea6c173626.tar.gz linux-909e2cd004b639276678c195760efeea6c173626.tar.bz2 linux-909e2cd004b639276678c195760efeea6c173626.zip |
IB/hfi1: Notify remove MMU/RB callback of calling context
Tell the remove MMU/RB callback if it's being called as
part of a memory invalidation or not. This can be important
in preventing a deadlock if the remove callback attempts to
take the map_sem semaphore because the kernel's MMU
invalidation functions have already taken it.
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>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/rdma/hfi1/mmu_rb.c | 10 | ||||
-rw-r--r-- | drivers/staging/rdma/hfi1/mmu_rb.h | 2 | ||||
-rw-r--r-- | drivers/staging/rdma/hfi1/user_exp_rcv.c | 9 |
3 files changed, 11 insertions, 10 deletions
diff --git a/drivers/staging/rdma/hfi1/mmu_rb.c b/drivers/staging/rdma/hfi1/mmu_rb.c index a3515d7f6354..29d6d3e0694d 100644 --- a/drivers/staging/rdma/hfi1/mmu_rb.c +++ b/drivers/staging/rdma/hfi1/mmu_rb.c @@ -122,7 +122,7 @@ void hfi1_mmu_rb_unregister(struct rb_root *root) rbnode = rb_entry(node, struct mmu_rb_node, node); rb_erase(node, root); if (handler->ops->remove) - handler->ops->remove(root, rbnode); + handler->ops->remove(root, rbnode, false); } } @@ -196,12 +196,12 @@ static struct mmu_rb_node *__mmu_rb_search(struct mmu_rb_handler *handler, } static void __mmu_rb_remove(struct mmu_rb_handler *handler, - struct mmu_rb_node *node) + struct mmu_rb_node *node, bool arg) { /* Validity of handler and node pointers has been checked by caller. */ rb_erase(&node->node, handler->root); if (handler->ops->remove) - handler->ops->remove(handler->root, node); + handler->ops->remove(handler->root, node, arg); } struct mmu_rb_node *hfi1_mmu_rb_search(struct rb_root *root, unsigned long addr, @@ -230,7 +230,7 @@ void hfi1_mmu_rb_remove(struct rb_root *root, struct mmu_rb_node *node) return; spin_lock_irqsave(&handler->lock, flags); - __mmu_rb_remove(handler, node); + __mmu_rb_remove(handler, node, false); spin_unlock_irqrestore(&handler->lock, flags); } @@ -299,7 +299,7 @@ static void mmu_notifier_mem_invalidate(struct mmu_notifier *mn, naddr = node->addr; nlen = node->len; if (handler->ops->invalidate(root, node)) - __mmu_rb_remove(handler, node); + __mmu_rb_remove(handler, node, true); /* * The next address to be looked up is computed based diff --git a/drivers/staging/rdma/hfi1/mmu_rb.h b/drivers/staging/rdma/hfi1/mmu_rb.h index 9fe1076ab39d..fdd978757b90 100644 --- a/drivers/staging/rdma/hfi1/mmu_rb.h +++ b/drivers/staging/rdma/hfi1/mmu_rb.h @@ -59,7 +59,7 @@ struct mmu_rb_ops { int (*compare)(struct mmu_rb_node *, unsigned long, unsigned long); int (*insert)(struct rb_root *, struct mmu_rb_node *); - void (*remove)(struct rb_root *, struct mmu_rb_node *); + void (*remove)(struct rb_root *, struct mmu_rb_node *, bool); int (*invalidate)(struct rb_root *, struct mmu_rb_node *); }; diff --git a/drivers/staging/rdma/hfi1/user_exp_rcv.c b/drivers/staging/rdma/hfi1/user_exp_rcv.c index b0b193f30fac..1d971c0fedd6 100644 --- a/drivers/staging/rdma/hfi1/user_exp_rcv.c +++ b/drivers/staging/rdma/hfi1/user_exp_rcv.c @@ -89,7 +89,7 @@ static int set_rcvarray_entry(struct file *, unsigned long, u32, static inline int mmu_addr_cmp(struct mmu_rb_node *, unsigned long, unsigned long); static int mmu_rb_insert(struct rb_root *, struct mmu_rb_node *); -static void mmu_rb_remove(struct rb_root *, struct mmu_rb_node *); +static void mmu_rb_remove(struct rb_root *, struct mmu_rb_node *, bool); static int mmu_rb_invalidate(struct rb_root *, struct mmu_rb_node *); static int program_rcvarray(struct file *, unsigned long, struct tid_group *, struct tid_pageset *, unsigned, u16, struct page **, @@ -897,7 +897,7 @@ static int unprogram_rcvarray(struct file *fp, u32 tidinfo, if (!node || node->rcventry != (uctxt->expected_base + rcventry)) return -EBADF; if (HFI1_CAP_IS_USET(TID_UNMAP)) - mmu_rb_remove(&fd->tid_rb_root, &node->mmu); + mmu_rb_remove(&fd->tid_rb_root, &node->mmu, false); else hfi1_mmu_rb_remove(&fd->tid_rb_root, &node->mmu); @@ -962,7 +962,7 @@ static void unlock_exp_tids(struct hfi1_ctxtdata *uctxt, continue; if (HFI1_CAP_IS_USET(TID_UNMAP)) mmu_rb_remove(&fd->tid_rb_root, - &node->mmu); + &node->mmu, false); else hfi1_mmu_rb_remove(&fd->tid_rb_root, &node->mmu); @@ -1039,7 +1039,8 @@ static int mmu_rb_insert(struct rb_root *root, struct mmu_rb_node *node) return 0; } -static void mmu_rb_remove(struct rb_root *root, struct mmu_rb_node *node) +static void mmu_rb_remove(struct rb_root *root, struct mmu_rb_node *node, + bool notifier) { struct hfi1_filedata *fdata = container_of(root, struct hfi1_filedata, tid_rb_root); |