diff options
Diffstat (limited to 'include/drm/ttm/ttm_memory.h')
-rw-r--r-- | include/drm/ttm/ttm_memory.h | 75 |
1 files changed, 5 insertions, 70 deletions
diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h index 2c1e3598effe..8936285b6543 100644 --- a/include/drm/ttm/ttm_memory.h +++ b/include/drm/ttm/ttm_memory.h | |||
@@ -35,20 +35,7 @@ | |||
35 | #include <linux/errno.h> | 35 | #include <linux/errno.h> |
36 | #include <linux/kobject.h> | 36 | #include <linux/kobject.h> |
37 | #include <linux/mm.h> | 37 | #include <linux/mm.h> |
38 | 38 | #include "ttm_bo_api.h" | |
39 | /** | ||
40 | * struct ttm_mem_shrink - callback to shrink TTM memory usage. | ||
41 | * | ||
42 | * @do_shrink: The callback function. | ||
43 | * | ||
44 | * Arguments to the do_shrink functions are intended to be passed using | ||
45 | * inheritance. That is, the argument class derives from struct ttm_mem_shrink, | ||
46 | * and can be accessed using container_of(). | ||
47 | */ | ||
48 | |||
49 | struct ttm_mem_shrink { | ||
50 | int (*do_shrink) (struct ttm_mem_shrink *); | ||
51 | }; | ||
52 | 39 | ||
53 | /** | 40 | /** |
54 | * struct ttm_mem_global - Global memory accounting structure. | 41 | * struct ttm_mem_global - Global memory accounting structure. |
@@ -76,7 +63,7 @@ struct ttm_mem_shrink { | |||
76 | struct ttm_mem_zone; | 63 | struct ttm_mem_zone; |
77 | struct ttm_mem_global { | 64 | struct ttm_mem_global { |
78 | struct kobject kobj; | 65 | struct kobject kobj; |
79 | struct ttm_mem_shrink *shrink; | 66 | struct ttm_bo_global *bo_glob; |
80 | struct workqueue_struct *swap_queue; | 67 | struct workqueue_struct *swap_queue; |
81 | struct work_struct work; | 68 | struct work_struct work; |
82 | spinlock_t lock; | 69 | spinlock_t lock; |
@@ -90,67 +77,15 @@ struct ttm_mem_global { | |||
90 | #endif | 77 | #endif |
91 | }; | 78 | }; |
92 | 79 | ||
93 | /** | ||
94 | * ttm_mem_init_shrink - initialize a struct ttm_mem_shrink object | ||
95 | * | ||
96 | * @shrink: The object to initialize. | ||
97 | * @func: The callback function. | ||
98 | */ | ||
99 | |||
100 | static inline void ttm_mem_init_shrink(struct ttm_mem_shrink *shrink, | ||
101 | int (*func) (struct ttm_mem_shrink *)) | ||
102 | { | ||
103 | shrink->do_shrink = func; | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * ttm_mem_register_shrink - register a struct ttm_mem_shrink object. | ||
108 | * | ||
109 | * @glob: The struct ttm_mem_global object to register with. | ||
110 | * @shrink: An initialized struct ttm_mem_shrink object to register. | ||
111 | * | ||
112 | * Returns: | ||
113 | * -EBUSY: There's already a callback registered. (May change). | ||
114 | */ | ||
115 | |||
116 | static inline int ttm_mem_register_shrink(struct ttm_mem_global *glob, | ||
117 | struct ttm_mem_shrink *shrink) | ||
118 | { | ||
119 | spin_lock(&glob->lock); | ||
120 | if (glob->shrink != NULL) { | ||
121 | spin_unlock(&glob->lock); | ||
122 | return -EBUSY; | ||
123 | } | ||
124 | glob->shrink = shrink; | ||
125 | spin_unlock(&glob->lock); | ||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | /** | ||
130 | * ttm_mem_unregister_shrink - unregister a struct ttm_mem_shrink object. | ||
131 | * | ||
132 | * @glob: The struct ttm_mem_global object to unregister from. | ||
133 | * @shrink: A previously registert struct ttm_mem_shrink object. | ||
134 | * | ||
135 | */ | ||
136 | |||
137 | static inline void ttm_mem_unregister_shrink(struct ttm_mem_global *glob, | ||
138 | struct ttm_mem_shrink *shrink) | ||
139 | { | ||
140 | spin_lock(&glob->lock); | ||
141 | BUG_ON(glob->shrink != shrink); | ||
142 | glob->shrink = NULL; | ||
143 | spin_unlock(&glob->lock); | ||
144 | } | ||
145 | |||
146 | extern int ttm_mem_global_init(struct ttm_mem_global *glob); | 80 | extern int ttm_mem_global_init(struct ttm_mem_global *glob); |
147 | extern void ttm_mem_global_release(struct ttm_mem_global *glob); | 81 | extern void ttm_mem_global_release(struct ttm_mem_global *glob); |
148 | extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, | 82 | extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, |
149 | bool no_wait, bool interruptible); | 83 | struct ttm_operation_ctx *ctx); |
150 | extern void ttm_mem_global_free(struct ttm_mem_global *glob, | 84 | extern void ttm_mem_global_free(struct ttm_mem_global *glob, |
151 | uint64_t amount); | 85 | uint64_t amount); |
152 | extern int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, | 86 | extern int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, |
153 | struct page *page, uint64_t size); | 87 | struct page *page, uint64_t size, |
88 | struct ttm_operation_ctx *ctx); | ||
154 | extern void ttm_mem_global_free_page(struct ttm_mem_global *glob, | 89 | extern void ttm_mem_global_free_page(struct ttm_mem_global *glob, |
155 | struct page *page, uint64_t size); | 90 | struct page *page, uint64_t size); |
156 | extern size_t ttm_round_pot(size_t size); | 91 | extern size_t ttm_round_pot(size_t size); |