rbinregion.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef _RBIN_REGION_H
  2. #define _RBIN_REGION_H
  3. #include <linux/atomic.h>
  4. #include <linux/kernel.h>
  5. #include <linux/types.h>
  6. #include <linux/mm.h>
  7. #include <linux/genalloc.h>
  8. #include <linux/highmem.h>
  9. #include "page_pool.h"
  10. #define E_NOREGION 55 // returned when region is disabled
  11. struct rr_handle {
  12. int pool_id; /* Pool index : corresponds to filesystem */
  13. int rb_index; /* Redblack tree index: value equals inode number */
  14. int ra_index; /* Radix tree index : value equals page->index */
  15. int usage; /* indicates current usage of corresponding page */
  16. struct list_head lru; /* use lru of struct page instead */
  17. };
  18. enum usage {
  19. RC_FREED,
  20. RC_INUSE,
  21. DMABUF_FREED,
  22. DMABUF_INUSE,
  23. };
  24. struct region_ops {
  25. void (*evict)(unsigned long);
  26. };
  27. struct rbin_region {
  28. unsigned long start_pfn;
  29. unsigned long nr_pages;
  30. struct rr_handle *handles;
  31. struct list_head freelist; /* protected by lru_lock. handle->lru */
  32. struct list_head usedlist; /* protected by lru_lock. handle->lru */
  33. const struct region_ops *ops;
  34. spinlock_t lru_lock;
  35. spinlock_t region_lock;
  36. struct gen_pool *pool;
  37. int dmabuf_inflight;
  38. int rc_inflight;
  39. bool rc_disabled;
  40. unsigned long timeout; /* timeout for rbincache enable */
  41. };
  42. extern atomic_t rbin_allocated_pages;
  43. extern atomic_t rbin_cached_pages;
  44. extern atomic_t rbin_free_pages;
  45. extern atomic_t rbin_pool_pages;
  46. extern struct kobject *rbin_kobject;
  47. struct rr_handle *region_store_cache(struct page *, int, int, int);
  48. int region_load_cache(struct rr_handle *, struct page *, int, int, int);
  49. int region_flush_cache(struct rr_handle *);
  50. phys_addr_t dmabuf_rbin_allocate(unsigned long);
  51. void dmabuf_rbin_free(phys_addr_t, unsigned long);
  52. void wake_dmabuf_rbin_heap_prereclaim(void);
  53. void wake_dmabuf_rbin_heap_shrink(void);
  54. void init_region(unsigned long, unsigned long, const struct region_ops *);
  55. int init_rbincache(unsigned long, unsigned long);
  56. int init_rbinregion(unsigned long, unsigned long);
  57. #endif /* _RBIN_REGION_H*/