0001
0002
0003
0004
0005
0006
0007 #ifndef _HFI1_MMU_RB_H
0008 #define _HFI1_MMU_RB_H
0009
0010 #include "hfi.h"
0011
0012 struct mmu_rb_node {
0013 unsigned long addr;
0014 unsigned long len;
0015 unsigned long __last;
0016 struct rb_node node;
0017 struct mmu_rb_handler *handler;
0018 struct list_head list;
0019 };
0020
0021
0022
0023
0024
0025 struct mmu_rb_ops {
0026 bool (*filter)(struct mmu_rb_node *node, unsigned long addr,
0027 unsigned long len);
0028 int (*insert)(void *ops_arg, struct mmu_rb_node *mnode);
0029 void (*remove)(void *ops_arg, struct mmu_rb_node *mnode);
0030 int (*invalidate)(void *ops_arg, struct mmu_rb_node *node);
0031 int (*evict)(void *ops_arg, struct mmu_rb_node *mnode,
0032 void *evict_arg, bool *stop);
0033 };
0034
0035 struct mmu_rb_handler {
0036 struct mmu_notifier mn;
0037 struct rb_root_cached root;
0038 void *ops_arg;
0039 spinlock_t lock;
0040 struct mmu_rb_ops *ops;
0041 struct list_head lru_list;
0042 struct work_struct del_work;
0043 struct list_head del_list;
0044 struct workqueue_struct *wq;
0045 };
0046
0047 int hfi1_mmu_rb_register(void *ops_arg,
0048 struct mmu_rb_ops *ops,
0049 struct workqueue_struct *wq,
0050 struct mmu_rb_handler **handler);
0051 void hfi1_mmu_rb_unregister(struct mmu_rb_handler *handler);
0052 int hfi1_mmu_rb_insert(struct mmu_rb_handler *handler,
0053 struct mmu_rb_node *mnode);
0054 void hfi1_mmu_rb_evict(struct mmu_rb_handler *handler, void *evict_arg);
0055 void hfi1_mmu_rb_remove(struct mmu_rb_handler *handler,
0056 struct mmu_rb_node *mnode);
0057 bool hfi1_mmu_rb_remove_unless_exact(struct mmu_rb_handler *handler,
0058 unsigned long addr, unsigned long len,
0059 struct mmu_rb_node **rb_node);
0060
0061 #endif