Lines Matching refs:mm
52 unsigned long drm_mm_tail_space(struct drm_mm *mm)
57 tail_node = mm->ml_entry.prev;
65 int drm_mm_remove_space_from_tail(struct drm_mm *mm, unsigned long size)
70 tail_node = mm->ml_entry.prev;
82 static struct drm_mm_node *drm_mm_kmalloc(struct drm_mm *mm, int atomic)
92 mutex_enter(&mm->unused_lock);
93 if (list_empty(&mm->unused_nodes))
97 list_entry(mm->unused_nodes.next,
100 --mm->num_unused;
102 mutex_exit(&mm->unused_lock);
107 int drm_mm_pre_get(struct drm_mm *mm)
111 mutex_enter(&mm->unused_lock);
112 while (mm->num_unused < MM_UNUSED_TARGET) {
113 mutex_exit(&mm->unused_lock);
115 mutex_enter(&mm->unused_lock);
118 int ret = (mm->num_unused < 2) ? -ENOMEM : 0;
119 mutex_exit(&mm->unused_lock);
122 ++mm->num_unused;
123 list_add_tail(&node->fl_entry, &mm->unused_nodes);
125 mutex_exit(&mm->unused_lock);
129 static int drm_mm_create_tail_node(struct drm_mm *mm,
135 child = drm_mm_kmalloc(mm, atomic);
142 child->mm = mm;
144 list_add_tail(&child->ml_entry, &mm->ml_entry);
145 list_add_tail(&child->fl_entry, &mm->fl_entry);
150 int drm_mm_add_space_to_tail(struct drm_mm *mm, unsigned long size, int atomic)
155 tail_node = mm->ml_entry.prev;
158 return drm_mm_create_tail_node(mm, entry->start + entry->size,
171 child = drm_mm_kmalloc(parent->mm, atomic);
180 child->mm = parent->mm;
231 struct drm_mm *mm = cur->mm;
233 struct list_head *root_head = &mm->ml_entry;
255 if (mm->num_unused < MM_UNUSED_TARGET) {
257 &mm->unused_nodes);
258 ++mm->num_unused;
270 list_add(&cur->fl_entry, &mm->fl_entry);
273 if (mm->num_unused < MM_UNUSED_TARGET) {
274 list_add(&cur->fl_entry, &mm->unused_nodes);
275 ++mm->num_unused;
281 struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm,
286 const struct list_head *free_stack = &mm->fl_entry;
321 int drm_mm_clean(struct drm_mm * mm)
323 struct list_head *head = &mm->ml_entry;
328 int drm_mm_init(struct drm_mm * mm, unsigned long start, unsigned long size)
330 INIT_LIST_HEAD(&mm->ml_entry);
331 INIT_LIST_HEAD(&mm->fl_entry);
332 INIT_LIST_HEAD(&mm->unused_nodes);
333 mm->num_unused = 0;
334 mutex_init(&mm->unused_lock, MUTEX_DEFAULT, IPL_NONE);
337 return drm_mm_create_tail_node(mm, start, size, 1);
340 void drm_mm_takedown(struct drm_mm * mm)
342 struct list_head *bnode = mm->fl_entry.next;
348 if (entry->ml_entry.next != &mm->ml_entry ||
349 entry->fl_entry.next != &mm->fl_entry) {
358 mutex_enter(&mm->unused_lock);
359 list_for_each_entry_safe(entry, next, &mm->unused_nodes, fl_entry) {
362 --mm->num_unused;
364 mutex_exit(&mm->unused_lock);
366 mutex_destroy(&mm->unused_lock);
368 KASSERT(mm->num_unused == 0);