Lines Matching refs:mm
118 static void show_leaks(struct drm_mm *mm) in show_leaks() argument
127 list_for_each_entry(node, drm_mm_nodes(mm), node_list) { in show_leaks()
146 static void show_leaks(struct drm_mm *mm) { } in show_leaks() argument
157 __drm_mm_interval_first(const struct drm_mm *mm, u64 start, u64 last) in INTERVAL_TREE_DEFINE()
159 return drm_mm_interval_tree_iter_first((struct rb_root_cached *)&mm->interval_tree, in INTERVAL_TREE_DEFINE()
160 start, last) ?: (struct drm_mm_node *)&mm->head_node; in INTERVAL_TREE_DEFINE()
167 struct drm_mm *mm = hole_node->mm; in drm_mm_interval_tree_add_node() local
190 link = &mm->interval_tree.rb_root.rb_node; in drm_mm_interval_tree_add_node()
208 rb_insert_augmented_cached(&node->rb, &mm->interval_tree, leftmost, in drm_mm_interval_tree_add_node()
268 struct drm_mm *mm = node->mm; in add_hole() local
275 insert_hole_size(&mm->holes_size, node); in add_hole()
276 insert_hole_addr(&mm->holes_addr, node); in add_hole()
278 list_add(&node->hole_stack, &mm->hole_stack); in add_hole()
286 rb_erase_cached(&node->rb_hole_size, &node->mm->holes_size); in rm_hole()
287 rb_erase_augmented(&node->rb_hole_addr, &node->mm->holes_addr, in rm_hole()
305 static struct drm_mm_node *best_hole(struct drm_mm *mm, u64 size) in best_hole() argument
307 struct rb_node *rb = mm->holes_size.rb_root.rb_node; in best_hole()
330 static struct drm_mm_node *find_hole_addr(struct drm_mm *mm, u64 addr, u64 size) in find_hole_addr() argument
332 struct rb_node *rb = mm->holes_addr.rb_node; in find_hole_addr()
356 first_hole(struct drm_mm *mm, in first_hole() argument
363 return best_hole(mm, size); in first_hole()
366 return find_hole_addr(mm, start, size); in first_hole()
369 return find_hole_addr(mm, end, size); in first_hole()
372 return list_first_entry_or_null(&mm->hole_stack, in first_hole()
414 next_hole(struct drm_mm *mm, in DECLARE_NEXT_HOLE_ADDR()
432 return &node->hole_stack == &mm->hole_stack ? NULL : node; in DECLARE_NEXT_HOLE_ADDR()
450 int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node) in drm_mm_reserve_node() argument
462 hole = find_hole_addr(mm, node->start, 0); in drm_mm_reserve_node()
469 if (mm->color_adjust) in drm_mm_reserve_node()
470 mm->color_adjust(hole, node->color, &adj_start, &adj_end); in drm_mm_reserve_node()
475 node->mm = mm; in drm_mm_reserve_node()
514 int drm_mm_insert_node_in_range(struct drm_mm * const mm, in drm_mm_insert_node_in_range() argument
530 if (rb_to_hole_size_or_zero(rb_first_cached(&mm->holes_size)) < size) in drm_mm_insert_node_in_range()
540 for (hole = first_hole(mm, range_start, range_end, size, mode); in drm_mm_insert_node_in_range()
542 hole = once ? NULL : next_hole(mm, hole, size, mode)) { in drm_mm_insert_node_in_range()
556 if (mm->color_adjust) in drm_mm_insert_node_in_range()
557 mm->color_adjust(hole, color, &col_start, &col_end); in drm_mm_insert_node_in_range()
590 node->mm = mm; in drm_mm_insert_node_in_range()
629 struct drm_mm *mm = node->mm; in drm_mm_remove_node() local
640 drm_mm_interval_tree_remove(node, &mm->interval_tree); in drm_mm_remove_node()
662 struct drm_mm *mm = old->mm; in drm_mm_replace_node() local
670 rb_replace_node_cached(&old->rb, &new->rb, &mm->interval_tree); in drm_mm_replace_node()
676 &mm->holes_size); in drm_mm_replace_node()
679 &mm->holes_addr); in drm_mm_replace_node()
737 struct drm_mm *mm, in drm_mm_scan_init_with_range() argument
747 DRM_MM_BUG_ON(mm->scan_active); in drm_mm_scan_init_with_range()
749 scan->mm = mm; in drm_mm_scan_init_with_range()
783 struct drm_mm *mm = scan->mm; in drm_mm_scan_add_block() local
789 DRM_MM_BUG_ON(node->mm != mm); in drm_mm_scan_add_block()
793 mm->scan_active++; in drm_mm_scan_add_block()
809 if (mm->color_adjust) in drm_mm_scan_add_block()
810 mm->color_adjust(hole, scan->color, &col_start, &col_end); in drm_mm_scan_add_block()
876 DRM_MM_BUG_ON(node->mm != scan->mm); in drm_mm_scan_remove_block()
880 DRM_MM_BUG_ON(!node->mm->scan_active); in drm_mm_scan_remove_block()
881 node->mm->scan_active--; in drm_mm_scan_remove_block()
914 struct drm_mm *mm = scan->mm; in drm_mm_scan_color_evict() local
918 DRM_MM_BUG_ON(list_empty(&mm->hole_stack)); in drm_mm_scan_color_evict()
920 if (!mm->color_adjust) in drm_mm_scan_color_evict()
928 list_for_each_entry(hole, &mm->hole_stack, hole_stack) { in drm_mm_scan_color_evict()
938 DRM_MM_BUG_ON(&hole->hole_stack == &mm->hole_stack); in drm_mm_scan_color_evict()
939 if (unlikely(&hole->hole_stack == &mm->hole_stack)) in drm_mm_scan_color_evict()
945 mm->color_adjust(hole, scan->color, &hole_start, &hole_end); in drm_mm_scan_color_evict()
963 void drm_mm_init(struct drm_mm *mm, u64 start, u64 size) in drm_mm_init() argument
967 mm->color_adjust = NULL; in drm_mm_init()
969 INIT_LIST_HEAD(&mm->hole_stack); in drm_mm_init()
970 mm->interval_tree = RB_ROOT_CACHED; in drm_mm_init()
971 mm->holes_size = RB_ROOT_CACHED; in drm_mm_init()
972 mm->holes_addr = RB_ROOT; in drm_mm_init()
975 INIT_LIST_HEAD(&mm->head_node.node_list); in drm_mm_init()
976 mm->head_node.flags = 0; in drm_mm_init()
977 mm->head_node.mm = mm; in drm_mm_init()
978 mm->head_node.start = start + size; in drm_mm_init()
979 mm->head_node.size = -size; in drm_mm_init()
980 add_hole(&mm->head_node); in drm_mm_init()
982 mm->scan_active = 0; in drm_mm_init()
997 void drm_mm_takedown(struct drm_mm *mm) in drm_mm_takedown() argument
999 if (WARN(!drm_mm_clean(mm), in drm_mm_takedown()
1001 show_leaks(mm); in drm_mm_takedown()
1023 void drm_mm_print(const struct drm_mm *mm, struct drm_printer *p) in drm_mm_print() argument
1028 total_free += drm_mm_dump_hole(p, &mm->head_node); in drm_mm_print()
1030 drm_mm_for_each_node(entry, mm) { in drm_mm_print()