Lines Matching refs:handler
22 static void do_remove(struct mmu_rb_handler *handler,
46 struct mmu_rb_handler **handler) in hfi1_mmu_rb_register() argument
72 *handler = h; in hfi1_mmu_rb_register()
76 void hfi1_mmu_rb_unregister(struct mmu_rb_handler *handler) in hfi1_mmu_rb_unregister() argument
84 mmu_notifier_unregister(&handler->mn, handler->mn.mm); in hfi1_mmu_rb_unregister()
90 flush_work(&handler->del_work); in hfi1_mmu_rb_unregister()
94 spin_lock_irqsave(&handler->lock, flags); in hfi1_mmu_rb_unregister()
95 while ((node = rb_first_cached(&handler->root))) { in hfi1_mmu_rb_unregister()
97 rb_erase_cached(node, &handler->root); in hfi1_mmu_rb_unregister()
101 spin_unlock_irqrestore(&handler->lock, flags); in hfi1_mmu_rb_unregister()
103 do_remove(handler, &del_list); in hfi1_mmu_rb_unregister()
105 kfree(handler); in hfi1_mmu_rb_unregister()
108 int hfi1_mmu_rb_insert(struct mmu_rb_handler *handler, in hfi1_mmu_rb_insert() argument
117 if (current->mm != handler->mn.mm) in hfi1_mmu_rb_insert()
120 spin_lock_irqsave(&handler->lock, flags); in hfi1_mmu_rb_insert()
121 node = __mmu_rb_search(handler, mnode->addr, mnode->len); in hfi1_mmu_rb_insert()
126 __mmu_int_rb_insert(mnode, &handler->root); in hfi1_mmu_rb_insert()
127 list_add(&mnode->list, &handler->lru_list); in hfi1_mmu_rb_insert()
129 ret = handler->ops->insert(handler->ops_arg, mnode); in hfi1_mmu_rb_insert()
131 __mmu_int_rb_remove(mnode, &handler->root); in hfi1_mmu_rb_insert()
134 mnode->handler = handler; in hfi1_mmu_rb_insert()
136 spin_unlock_irqrestore(&handler->lock, flags); in hfi1_mmu_rb_insert()
141 static struct mmu_rb_node *__mmu_rb_search(struct mmu_rb_handler *handler, in __mmu_rb_search() argument
148 if (!handler->ops->filter) { in __mmu_rb_search()
149 node = __mmu_int_rb_iter_first(&handler->root, addr, in __mmu_rb_search()
152 for (node = __mmu_int_rb_iter_first(&handler->root, addr, in __mmu_rb_search()
157 if (handler->ops->filter(node, addr, len)) in __mmu_rb_search()
164 bool hfi1_mmu_rb_remove_unless_exact(struct mmu_rb_handler *handler, in hfi1_mmu_rb_remove_unless_exact() argument
172 if (current->mm != handler->mn.mm) in hfi1_mmu_rb_remove_unless_exact()
175 spin_lock_irqsave(&handler->lock, flags); in hfi1_mmu_rb_remove_unless_exact()
176 node = __mmu_rb_search(handler, addr, len); in hfi1_mmu_rb_remove_unless_exact()
180 __mmu_int_rb_remove(node, &handler->root); in hfi1_mmu_rb_remove_unless_exact()
185 spin_unlock_irqrestore(&handler->lock, flags); in hfi1_mmu_rb_remove_unless_exact()
190 void hfi1_mmu_rb_evict(struct mmu_rb_handler *handler, void *evict_arg) in hfi1_mmu_rb_evict() argument
197 if (current->mm != handler->mn.mm) in hfi1_mmu_rb_evict()
202 spin_lock_irqsave(&handler->lock, flags); in hfi1_mmu_rb_evict()
203 list_for_each_entry_safe_reverse(rbnode, ptr, &handler->lru_list, in hfi1_mmu_rb_evict()
205 if (handler->ops->evict(handler->ops_arg, rbnode, evict_arg, in hfi1_mmu_rb_evict()
207 __mmu_int_rb_remove(rbnode, &handler->root); in hfi1_mmu_rb_evict()
214 spin_unlock_irqrestore(&handler->lock, flags); in hfi1_mmu_rb_evict()
219 handler->ops->remove(handler->ops_arg, rbnode); in hfi1_mmu_rb_evict()
228 void hfi1_mmu_rb_remove(struct mmu_rb_handler *handler, in hfi1_mmu_rb_remove() argument
233 if (current->mm != handler->mn.mm) in hfi1_mmu_rb_remove()
238 spin_lock_irqsave(&handler->lock, flags); in hfi1_mmu_rb_remove()
239 __mmu_int_rb_remove(node, &handler->root); in hfi1_mmu_rb_remove()
241 spin_unlock_irqrestore(&handler->lock, flags); in hfi1_mmu_rb_remove()
243 handler->ops->remove(handler->ops_arg, node); in hfi1_mmu_rb_remove()
249 struct mmu_rb_handler *handler = in mmu_notifier_range_start() local
251 struct rb_root_cached *root = &handler->root; in mmu_notifier_range_start()
256 spin_lock_irqsave(&handler->lock, flags); in mmu_notifier_range_start()
263 if (handler->ops->invalidate(handler->ops_arg, node)) { in mmu_notifier_range_start()
266 list_move(&node->list, &handler->del_list); in mmu_notifier_range_start()
270 spin_unlock_irqrestore(&handler->lock, flags); in mmu_notifier_range_start()
273 queue_work(handler->wq, &handler->del_work); in mmu_notifier_range_start()
283 static void do_remove(struct mmu_rb_handler *handler, in do_remove() argument
291 handler->ops->remove(handler->ops_arg, node); in do_remove()
302 struct mmu_rb_handler *handler = container_of(work, in handle_remove() local
309 spin_lock_irqsave(&handler->lock, flags); in handle_remove()
310 list_replace_init(&handler->del_list, &del_list); in handle_remove()
311 spin_unlock_irqrestore(&handler->lock, flags); in handle_remove()
313 do_remove(handler, &del_list); in handle_remove()