aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/drm_mm.h
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2011-02-22 21:07:27 -0500
committerDave Airlie <airlied@redhat.com>2011-02-22 21:07:27 -0500
commit63871f89d158e3f3e469dde00dd15763d474cb3c (patch)
tree0872202dbe52d6a8160215487ae0386c8e475a44 /include/drm/drm_mm.h
parentde1e7cd63a8ec26a3bd3740708cfd72dd76509e2 (diff)
parent4546b2c1d6e256c716e5240f5d6198a078fd7a22 (diff)
Merge branch 'drm-mm-cleanup' into drm-next
* drm-mm-cleanup: radeon: move blit functions to radeon_asic.h radeon: kill decls for inline functions radeon: consolidate asic-specific function decls for r600 & later drm/radeon: kill radeon_bo->gobj pointer drm/radeon: introduce gem_to_radeon_bo helper drm/radeon: embed struct drm_gem_object drm: mm: add helper to unwind scan state drm: mm: add api for embedding struct drm_mm_node drm: mm: extract node insert helper functions drm: mm: track free areas implicitly drm/nouveau: don't munge in drm_mm internals
Diffstat (limited to 'include/drm/drm_mm.h')
-rw-r--r--include/drm/drm_mm.h49
1 files changed, 37 insertions, 12 deletions
diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
index e39177778601..b1e7809e5e15 100644
--- a/include/drm/drm_mm.h
+++ b/include/drm/drm_mm.h
@@ -42,23 +42,25 @@
42#endif 42#endif
43 43
44struct drm_mm_node { 44struct drm_mm_node {
45 struct list_head free_stack;
46 struct list_head node_list; 45 struct list_head node_list;
47 unsigned free : 1; 46 struct list_head hole_stack;
47 unsigned hole_follows : 1;
48 unsigned scanned_block : 1; 48 unsigned scanned_block : 1;
49 unsigned scanned_prev_free : 1; 49 unsigned scanned_prev_free : 1;
50 unsigned scanned_next_free : 1; 50 unsigned scanned_next_free : 1;
51 unsigned scanned_preceeds_hole : 1;
52 unsigned allocated : 1;
51 unsigned long start; 53 unsigned long start;
52 unsigned long size; 54 unsigned long size;
53 struct drm_mm *mm; 55 struct drm_mm *mm;
54}; 56};
55 57
56struct drm_mm { 58struct drm_mm {
57 /* List of free memory blocks, most recently freed ordered. */ 59 /* List of all memory nodes that immediatly preceed a free hole. */
58 struct list_head free_stack; 60 struct list_head hole_stack;
59 /* List of all memory nodes, ordered according to the (increasing) start 61 /* head_node.node_list is the list of all memory nodes, ordered
60 * address of the memory node. */ 62 * according to the (increasing) start address of the memory node. */
61 struct list_head node_list; 63 struct drm_mm_node head_node;
62 struct list_head unused_nodes; 64 struct list_head unused_nodes;
63 int num_unused; 65 int num_unused;
64 spinlock_t unused_lock; 66 spinlock_t unused_lock;
@@ -70,8 +72,28 @@ struct drm_mm {
70 unsigned scanned_blocks; 72 unsigned scanned_blocks;
71 unsigned long scan_start; 73 unsigned long scan_start;
72 unsigned long scan_end; 74 unsigned long scan_end;
75 struct drm_mm_node *prev_scanned_node;
73}; 76};
74 77
78static inline bool drm_mm_node_allocated(struct drm_mm_node *node)
79{
80 return node->allocated;
81}
82
83static inline bool drm_mm_initialized(struct drm_mm *mm)
84{
85 return mm->hole_stack.next;
86}
87#define drm_mm_for_each_node(entry, mm) list_for_each_entry(entry, \
88 &(mm)->head_node.node_list, \
89 node_list);
90#define drm_mm_for_each_scanned_node_reverse(entry, n, mm) \
91 for (entry = (mm)->prev_scanned_node, \
92 next = entry ? list_entry(entry->node_list.next, \
93 struct drm_mm_node, node_list) : NULL; \
94 entry != NULL; entry = next, \
95 next = entry ? list_entry(entry->node_list.next, \
96 struct drm_mm_node, node_list) : NULL) \
75/* 97/*
76 * Basic range manager support (drm_mm.c) 98 * Basic range manager support (drm_mm.c)
77 */ 99 */
@@ -118,7 +140,15 @@ static inline struct drm_mm_node *drm_mm_get_block_atomic_range(
118 return drm_mm_get_block_range_generic(parent, size, alignment, 140 return drm_mm_get_block_range_generic(parent, size, alignment,
119 start, end, 1); 141 start, end, 1);
120} 142}
143extern int drm_mm_insert_node(struct drm_mm *mm, struct drm_mm_node *node,
144 unsigned long size, unsigned alignment);
145extern int drm_mm_insert_node_in_range(struct drm_mm *mm,
146 struct drm_mm_node *node,
147 unsigned long size, unsigned alignment,
148 unsigned long start, unsigned long end);
121extern void drm_mm_put_block(struct drm_mm_node *cur); 149extern void drm_mm_put_block(struct drm_mm_node *cur);
150extern void drm_mm_remove_node(struct drm_mm_node *node);
151extern void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new);
122extern struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm, 152extern struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm,
123 unsigned long size, 153 unsigned long size,
124 unsigned alignment, 154 unsigned alignment,
@@ -134,11 +164,6 @@ extern int drm_mm_init(struct drm_mm *mm, unsigned long start,
134 unsigned long size); 164 unsigned long size);
135extern void drm_mm_takedown(struct drm_mm *mm); 165extern void drm_mm_takedown(struct drm_mm *mm);
136extern int drm_mm_clean(struct drm_mm *mm); 166extern int drm_mm_clean(struct drm_mm *mm);
137extern unsigned long drm_mm_tail_space(struct drm_mm *mm);
138extern int drm_mm_remove_space_from_tail(struct drm_mm *mm,
139 unsigned long size);
140extern int drm_mm_add_space_to_tail(struct drm_mm *mm,
141 unsigned long size, int atomic);
142extern int drm_mm_pre_get(struct drm_mm *mm); 167extern int drm_mm_pre_get(struct drm_mm *mm);
143 168
144static inline struct drm_mm *drm_get_mm(struct drm_mm_node *block) 169static inline struct drm_mm *drm_get_mm(struct drm_mm_node *block)