]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
IB/hfi1: Notify remove MMU/RB callback of calling context
authorMitko Haralanov <mitko.haralanov@intel.com>
Tue, 8 Mar 2016 19:14:48 +0000 (11:14 -0800)
committerDoug Ledford <dledford@redhat.com>
Mon, 21 Mar 2016 19:55:22 +0000 (15:55 -0400)
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>
drivers/staging/rdma/hfi1/mmu_rb.c
drivers/staging/rdma/hfi1/mmu_rb.h
drivers/staging/rdma/hfi1/user_exp_rcv.c

index a3515d7f6354f497f81a60aac440833bf5035f61..29d6d3e0694d0c673c7d3afa8b6e66167d41227d 100644 (file)
@@ -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
index 9fe1076ab39dea8b90557f2bd6bb65d870eaebde..fdd978757b908d2f724f88dea4fc62412f9aa453 100644 (file)
@@ -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 *);
 };
 
index b0b193f30fac2bf1740da0e344d346236a40a35a..1d971c0fedd6c3f770d8aad6b2392f3c48401249 100644 (file)
@@ -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);