aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/ttm/ttm_bo_driver.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/drm/ttm/ttm_bo_driver.h')
-rw-r--r--include/drm/ttm/ttm_bo_driver.h100
1 files changed, 96 insertions, 4 deletions
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index b87504235f18..8e0c848326b6 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -203,7 +203,92 @@ struct ttm_tt {
203 * It's set up by the ttm_bo_driver::init_mem_type method. 203 * It's set up by the ttm_bo_driver::init_mem_type method.
204 */ 204 */
205 205
206struct ttm_mem_type_manager;
207
208struct ttm_mem_type_manager_func {
209 /**
210 * struct ttm_mem_type_manager member init
211 *
212 * @man: Pointer to a memory type manager.
213 * @p_size: Implementation dependent, but typically the size of the
214 * range to be managed in pages.
215 *
216 * Called to initialize a private range manager. The function is
217 * expected to initialize the man::priv member.
218 * Returns 0 on success, negative error code on failure.
219 */
220 int (*init)(struct ttm_mem_type_manager *man, unsigned long p_size);
221
222 /**
223 * struct ttm_mem_type_manager member takedown
224 *
225 * @man: Pointer to a memory type manager.
226 *
227 * Called to undo the setup done in init. All allocated resources
228 * should be freed.
229 */
230 int (*takedown)(struct ttm_mem_type_manager *man);
231
232 /**
233 * struct ttm_mem_type_manager member get_node
234 *
235 * @man: Pointer to a memory type manager.
236 * @bo: Pointer to the buffer object we're allocating space for.
237 * @placement: Placement details.
238 * @mem: Pointer to a struct ttm_mem_reg to be filled in.
239 *
240 * This function should allocate space in the memory type managed
241 * by @man. Placement details if
242 * applicable are given by @placement. If successful,
243 * @mem::mm_node should be set to a non-null value, and
244 * @mem::start should be set to a value identifying the beginning
245 * of the range allocated, and the function should return zero.
246 * If the memory region accomodate the buffer object, @mem::mm_node
247 * should be set to NULL, and the function should return 0.
248 * If a system error occured, preventing the request to be fulfilled,
249 * the function should return a negative error code.
250 *
251 * Note that @mem::mm_node will only be dereferenced by
252 * struct ttm_mem_type_manager functions and optionally by the driver,
253 * which has knowledge of the underlying type.
254 *
255 * This function may not be called from within atomic context, so
256 * an implementation can and must use either a mutex or a spinlock to
257 * protect any data structures managing the space.
258 */
259 int (*get_node)(struct ttm_mem_type_manager *man,
260 struct ttm_buffer_object *bo,
261 struct ttm_placement *placement,
262 struct ttm_mem_reg *mem);
263
264 /**
265 * struct ttm_mem_type_manager member put_node
266 *
267 * @man: Pointer to a memory type manager.
268 * @mem: Pointer to a struct ttm_mem_reg to be filled in.
269 *
270 * This function frees memory type resources previously allocated
271 * and that are identified by @mem::mm_node and @mem::start. May not
272 * be called from within atomic context.
273 */
274 void (*put_node)(struct ttm_mem_type_manager *man,
275 struct ttm_mem_reg *mem);
276
277 /**
278 * struct ttm_mem_type_manager member debug
279 *
280 * @man: Pointer to a memory type manager.
281 * @prefix: Prefix to be used in printout to identify the caller.
282 *
283 * This function is called to print out the state of the memory
284 * type manager to aid debugging of out-of-memory conditions.
285 * It may not be called from within atomic context.
286 */
287 void (*debug)(struct ttm_mem_type_manager *man, const char *prefix);
288};
289
206struct ttm_mem_type_manager { 290struct ttm_mem_type_manager {
291 struct ttm_bo_device *bdev;
207 292
208 /* 293 /*
209 * No protection. Constant from start. 294 * No protection. Constant from start.
@@ -216,14 +301,13 @@ struct ttm_mem_type_manager {
216 uint64_t size; 301 uint64_t size;
217 uint32_t available_caching; 302 uint32_t available_caching;
218 uint32_t default_caching; 303 uint32_t default_caching;
304 const struct ttm_mem_type_manager_func *func;
305 void *priv;
219 306
220 /* 307 /*
221 * Protected by the bdev->lru_lock. 308 * Protected by the global->lru_lock.
222 * TODO: Consider one lru_lock per ttm_mem_type_manager.
223 * Plays ill with list removal, though.
224 */ 309 */
225 310
226 struct drm_mm manager;
227 struct list_head lru; 311 struct list_head lru;
228}; 312};
229 313
@@ -649,6 +733,12 @@ extern int ttm_bo_mem_space(struct ttm_buffer_object *bo,
649 struct ttm_mem_reg *mem, 733 struct ttm_mem_reg *mem,
650 bool interruptible, 734 bool interruptible,
651 bool no_wait_reserve, bool no_wait_gpu); 735 bool no_wait_reserve, bool no_wait_gpu);
736
737extern void ttm_bo_mem_put(struct ttm_buffer_object *bo,
738 struct ttm_mem_reg *mem);
739extern void ttm_bo_mem_put_locked(struct ttm_buffer_object *bo,
740 struct ttm_mem_reg *mem);
741
652/** 742/**
653 * ttm_bo_wait_for_cpu 743 * ttm_bo_wait_for_cpu
654 * 744 *
@@ -891,6 +981,8 @@ extern int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
891 */ 981 */
892extern pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp); 982extern pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);
893 983
984extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;
985
894#if (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))) 986#if (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
895#define TTM_HAS_AGP 987#define TTM_HAS_AGP
896#include <linux/agp_backend.h> 988#include <linux/agp_backend.h>