blob: ff120b7d0f853642c0a9fa66b1a7a1de3d07c8bb [file] [log] [blame]
Jerome Glisse249d6042009-04-08 17:11:16 +02001/**************************************************************************
2 *
3 * Copyright 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX. USA.
Chris Wilsonba004e32016-12-22 08:36:25 +00004 * Copyright 2016 Intel Corporation
Jerome Glisse249d6042009-04-08 17:11:16 +02005 * All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
14 *
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
17 * of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
22 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
23 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25 * USE OR OTHER DEALINGS IN THE SOFTWARE.
26 *
27 *
28 **************************************************************************/
29/*
30 * Authors:
31 * Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
32 */
33
34#ifndef _DRM_MM_H_
35#define _DRM_MM_H_
36
37/*
38 * Generic range manager structs
39 */
David Herrmann86e81f0e2013-07-25 18:02:31 +020040#include <linux/bug.h>
Chris Wilson202b52b2016-08-03 16:04:09 +010041#include <linux/rbtree.h>
David Herrmann86e81f0e2013-07-25 18:02:31 +020042#include <linux/kernel.h>
Jerome Glisse249d6042009-04-08 17:11:16 +020043#include <linux/list.h>
David Herrmann86e81f0e2013-07-25 18:02:31 +020044#include <linux/spinlock.h>
Dave Airlief1938cd2009-09-08 11:32:08 +100045#ifdef CONFIG_DEBUG_FS
46#include <linux/seq_file.h>
47#endif
Chris Wilson57056702016-10-31 09:08:06 +000048#ifdef CONFIG_DRM_DEBUG_MM
49#include <linux/stackdepot.h>
50#endif
Jerome Glisse249d6042009-04-08 17:11:16 +020051
Chris Wilsonb3ee9632016-12-22 08:36:06 +000052#ifdef CONFIG_DRM_DEBUG_MM
53#define DRM_MM_BUG_ON(expr) BUG_ON(expr)
54#else
55#define DRM_MM_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
56#endif
57
David Herrmann31e5d7c2013-07-27 13:36:27 +020058enum drm_mm_search_flags {
59 DRM_MM_SEARCH_DEFAULT = 0,
60 DRM_MM_SEARCH_BEST = 1 << 0,
Lauri Kasanen62347f92014-04-02 20:03:57 +030061 DRM_MM_SEARCH_BELOW = 1 << 1,
David Herrmann31e5d7c2013-07-27 13:36:27 +020062};
63
Lauri Kasanen62347f92014-04-02 20:03:57 +030064enum drm_mm_allocator_flags {
65 DRM_MM_CREATE_DEFAULT = 0,
66 DRM_MM_CREATE_TOP = 1 << 0,
67};
68
69#define DRM_MM_BOTTOMUP DRM_MM_SEARCH_DEFAULT, DRM_MM_CREATE_DEFAULT
70#define DRM_MM_TOPDOWN DRM_MM_SEARCH_BELOW, DRM_MM_CREATE_TOP
71
Jerome Glisse249d6042009-04-08 17:11:16 +020072struct drm_mm_node {
Daniel Vetterd1024ce2010-07-02 15:02:14 +010073 struct list_head node_list;
Daniel Vetterea7b1dd2011-02-18 17:59:12 +010074 struct list_head hole_stack;
Chris Wilson202b52b2016-08-03 16:04:09 +010075 struct rb_node rb;
Daniel Vetterea7b1dd2011-02-18 17:59:12 +010076 unsigned hole_follows : 1;
Daniel Vetterb0b7af12011-02-18 17:59:14 +010077 unsigned allocated : 1;
Chris Wilsonf29051f2016-12-22 08:36:35 +000078 bool scanned_block : 1;
Chris Wilson6b9d89b2012-07-10 11:15:23 +010079 unsigned long color;
Thierry Reding440fd522015-01-23 09:05:06 +010080 u64 start;
81 u64 size;
Chris Wilson202b52b2016-08-03 16:04:09 +010082 u64 __subtree_last;
Jerome Glisse249d6042009-04-08 17:11:16 +020083 struct drm_mm *mm;
Chris Wilson57056702016-10-31 09:08:06 +000084#ifdef CONFIG_DRM_DEBUG_MM
85 depot_stack_handle_t stack;
86#endif
Jerome Glisse249d6042009-04-08 17:11:16 +020087};
88
89struct drm_mm {
Lucas De Marchi25985ed2011-03-30 22:57:33 -030090 /* List of all memory nodes that immediately precede a free hole. */
Daniel Vetterea7b1dd2011-02-18 17:59:12 +010091 struct list_head hole_stack;
92 /* head_node.node_list is the list of all memory nodes, ordered
93 * according to the (increasing) start address of the memory node. */
94 struct drm_mm_node head_node;
Chris Wilson202b52b2016-08-03 16:04:09 +010095 /* Keep an interval_tree for fast lookup of drm_mm_nodes by address. */
96 struct rb_root interval_tree;
97
Chris Wilson45b186f2016-12-16 07:46:42 +000098 void (*color_adjust)(const struct drm_mm_node *node,
99 unsigned long color,
Thierry Reding440fd522015-01-23 09:05:06 +0100100 u64 *start, u64 *end);
Chris Wilson9a71e272016-12-22 08:36:29 +0000101
102 unsigned long scan_active;
103};
104
105struct drm_mm_scan {
106 struct drm_mm *mm;
107
108 u64 size;
109 u64 alignment;
Chris Wilson9a956b12016-12-22 08:36:34 +0000110 u64 remainder_mask;
Chris Wilson9a71e272016-12-22 08:36:29 +0000111
112 u64 range_start;
113 u64 range_end;
114
115 u64 hit_start;
116 u64 hit_end;
117
Chris Wilson9a71e272016-12-22 08:36:29 +0000118 unsigned long color;
Chris Wilson0b04d472016-12-22 08:36:33 +0000119 unsigned int flags;
Jerome Glisse249d6042009-04-08 17:11:16 +0200120};
121
Daniel Vettere18c0412014-01-23 00:39:13 +0100122/**
123 * drm_mm_node_allocated - checks whether a node is allocated
124 * @node: drm_mm_node to check
125 *
Chris Wilsonba004e32016-12-22 08:36:25 +0000126 * Drivers are required to clear a node prior to using it with the
127 * drm_mm range manager.
128 *
129 * Drivers should use this helper for proper encapsulation of drm_mm
Daniel Vettere18c0412014-01-23 00:39:13 +0100130 * internals.
131 *
132 * Returns:
133 * True if the @node is allocated.
134 */
Chris Wilson45b186f2016-12-16 07:46:42 +0000135static inline bool drm_mm_node_allocated(const struct drm_mm_node *node)
Daniel Vetterb0b7af12011-02-18 17:59:14 +0100136{
137 return node->allocated;
138}
139
Daniel Vettere18c0412014-01-23 00:39:13 +0100140/**
141 * drm_mm_initialized - checks whether an allocator is initialized
142 * @mm: drm_mm to check
143 *
Chris Wilsonba004e32016-12-22 08:36:25 +0000144 * Drivers should clear the struct drm_mm prior to initialisation if they
145 * want to use this function.
146 *
147 * Drivers should use this helper for proper encapsulation of drm_mm
Daniel Vettere18c0412014-01-23 00:39:13 +0100148 * internals.
149 *
150 * Returns:
151 * True if the @mm is initialized.
152 */
Chris Wilson45b186f2016-12-16 07:46:42 +0000153static inline bool drm_mm_initialized(const struct drm_mm *mm)
Daniel Vetter31a5b8ce2011-02-18 17:59:11 +0100154{
Daniel Vetterea7b1dd2011-02-18 17:59:12 +0100155 return mm->hole_stack.next;
Daniel Vetter31a5b8ce2011-02-18 17:59:11 +0100156}
Chris Wilson9e8944a2012-11-15 11:32:17 +0000157
Chris Wilson45b186f2016-12-16 07:46:42 +0000158static inline u64 __drm_mm_hole_node_start(const struct drm_mm_node *hole_node)
Chris Wilson9e8944a2012-11-15 11:32:17 +0000159{
160 return hole_node->start + hole_node->size;
161}
162
Daniel Vettere18c0412014-01-23 00:39:13 +0100163/**
164 * drm_mm_hole_node_start - computes the start of the hole following @node
165 * @hole_node: drm_mm_node which implicitly tracks the following hole
166 *
Chris Wilsonba004e32016-12-22 08:36:25 +0000167 * This is useful for driver-specific debug dumpers. Otherwise drivers should
168 * not inspect holes themselves. Drivers must check first whether a hole indeed
Daniel Vettere18c0412014-01-23 00:39:13 +0100169 * follows by looking at node->hole_follows.
170 *
171 * Returns:
172 * Start of the subsequent hole.
173 */
Chris Wilson45b186f2016-12-16 07:46:42 +0000174static inline u64 drm_mm_hole_node_start(const struct drm_mm_node *hole_node)
Chris Wilson9e8944a2012-11-15 11:32:17 +0000175{
Chris Wilsonb3ee9632016-12-22 08:36:06 +0000176 DRM_MM_BUG_ON(!hole_node->hole_follows);
Chris Wilson9e8944a2012-11-15 11:32:17 +0000177 return __drm_mm_hole_node_start(hole_node);
178}
179
Chris Wilson45b186f2016-12-16 07:46:42 +0000180static inline u64 __drm_mm_hole_node_end(const struct drm_mm_node *hole_node)
Chris Wilson9e8944a2012-11-15 11:32:17 +0000181{
Geliang Tang87069f42015-11-25 21:23:07 +0800182 return list_next_entry(hole_node, node_list)->start;
Chris Wilson9e8944a2012-11-15 11:32:17 +0000183}
184
Daniel Vettere18c0412014-01-23 00:39:13 +0100185/**
186 * drm_mm_hole_node_end - computes the end of the hole following @node
187 * @hole_node: drm_mm_node which implicitly tracks the following hole
188 *
Chris Wilsonba004e32016-12-22 08:36:25 +0000189 * This is useful for driver-specific debug dumpers. Otherwise drivers should
190 * not inspect holes themselves. Drivers must check first whether a hole indeed
Daniel Vettere18c0412014-01-23 00:39:13 +0100191 * follows by looking at node->hole_follows.
192 *
193 * Returns:
194 * End of the subsequent hole.
195 */
Chris Wilson45b186f2016-12-16 07:46:42 +0000196static inline u64 drm_mm_hole_node_end(const struct drm_mm_node *hole_node)
Chris Wilson9e8944a2012-11-15 11:32:17 +0000197{
198 return __drm_mm_hole_node_end(hole_node);
199}
200
Chris Wilson2bc98c82016-12-22 08:36:05 +0000201/**
202 * drm_mm_nodes - list of nodes under the drm_mm range manager
203 * @mm: the struct drm_mm range manger
204 *
205 * As the drm_mm range manager hides its node_list deep with its
206 * structure, extracting it looks painful and repetitive. This is
207 * not expected to be used outside of the drm_mm_for_each_node()
208 * macros and similar internal functions.
209 *
210 * Returns:
211 * The node list, may be empty.
212 */
213#define drm_mm_nodes(mm) (&(mm)->head_node.node_list)
Chris Wilsonad579002016-12-16 07:46:41 +0000214
Daniel Vettere18c0412014-01-23 00:39:13 +0100215/**
216 * drm_mm_for_each_node - iterator to walk over all allocated nodes
217 * @entry: drm_mm_node structure to assign to in each iteration step
218 * @mm: drm_mm allocator to walk
219 *
220 * This iterator walks over all nodes in the range allocator. It is implemented
221 * with list_for_each, so not save against removal of elements.
222 */
Chris Wilsonad579002016-12-16 07:46:41 +0000223#define drm_mm_for_each_node(entry, mm) \
Chris Wilson2bc98c82016-12-22 08:36:05 +0000224 list_for_each_entry(entry, drm_mm_nodes(mm), node_list)
Chris Wilsonad579002016-12-16 07:46:41 +0000225
226/**
227 * drm_mm_for_each_node_safe - iterator to walk over all allocated nodes
228 * @entry: drm_mm_node structure to assign to in each iteration step
229 * @next: drm_mm_node structure to store the next step
230 * @mm: drm_mm allocator to walk
231 *
232 * This iterator walks over all nodes in the range allocator. It is implemented
233 * with list_for_each_safe, so save against removal of elements.
234 */
235#define drm_mm_for_each_node_safe(entry, next, mm) \
Chris Wilson2bc98c82016-12-22 08:36:05 +0000236 list_for_each_entry_safe(entry, next, drm_mm_nodes(mm), node_list)
Chris Wilson9e8944a2012-11-15 11:32:17 +0000237
Geliang Tang18b40c52015-11-21 22:04:04 +0800238#define __drm_mm_for_each_hole(entry, mm, hole_start, hole_end, backwards) \
239 for (entry = list_entry((backwards) ? (mm)->hole_stack.prev : (mm)->hole_stack.next, struct drm_mm_node, hole_stack); \
240 &entry->hole_stack != &(mm)->hole_stack ? \
241 hole_start = drm_mm_hole_node_start(entry), \
242 hole_end = drm_mm_hole_node_end(entry), \
243 1 : 0; \
244 entry = list_entry((backwards) ? entry->hole_stack.prev : entry->hole_stack.next, struct drm_mm_node, hole_stack))
245
Daniel Vettere18c0412014-01-23 00:39:13 +0100246/**
247 * drm_mm_for_each_hole - iterator to walk over all holes
248 * @entry: drm_mm_node used internally to track progress
249 * @mm: drm_mm allocator to walk
250 * @hole_start: ulong variable to assign the hole start to on each iteration
251 * @hole_end: ulong variable to assign the hole end to on each iteration
252 *
253 * This iterator walks over all holes in the range allocator. It is implemented
254 * with list_for_each, so not save against removal of elements. @entry is used
255 * internally and will not reflect a real drm_mm_node for the very first hole.
256 * Hence users of this iterator may not access it.
257 *
258 * Implementation Note:
259 * We need to inline list_for_each_entry in order to be able to set hole_start
260 * and hole_end on each iteration while keeping the macro sane.
Lauri Kasanen62347f92014-04-02 20:03:57 +0300261 *
262 * The __drm_mm_for_each_hole version is similar, but with added support for
263 * going backwards.
Chris Wilson9e8944a2012-11-15 11:32:17 +0000264 */
265#define drm_mm_for_each_hole(entry, mm, hole_start, hole_end) \
Geliang Tang18b40c52015-11-21 22:04:04 +0800266 __drm_mm_for_each_hole(entry, mm, hole_start, hole_end, 0)
Lauri Kasanen62347f92014-04-02 20:03:57 +0300267
Jerome Glisse249d6042009-04-08 17:11:16 +0200268/*
269 * Basic range manager support (drm_mm.c)
270 */
Daniel Vettere18c0412014-01-23 00:39:13 +0100271int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node);
Chris Wilsonb8103452012-12-07 20:37:06 +0000272
Daniel Vettere18c0412014-01-23 00:39:13 +0100273int drm_mm_insert_node_generic(struct drm_mm *mm,
274 struct drm_mm_node *node,
Thierry Reding440fd522015-01-23 09:05:06 +0100275 u64 size,
Chris Wilson71733202016-12-22 08:36:24 +0000276 u64 alignment,
Daniel Vettere18c0412014-01-23 00:39:13 +0100277 unsigned long color,
Lauri Kasanen62347f92014-04-02 20:03:57 +0300278 enum drm_mm_search_flags sflags,
279 enum drm_mm_allocator_flags aflags);
Daniel Vettere18c0412014-01-23 00:39:13 +0100280/**
281 * drm_mm_insert_node - search for space and insert @node
282 * @mm: drm_mm to allocate from
283 * @node: preallocate node to insert
284 * @size: size of the allocation
285 * @alignment: alignment of the allocation
286 * @flags: flags to fine-tune the allocation
287 *
288 * This is a simplified version of drm_mm_insert_node_generic() with @color set
289 * to 0.
290 *
291 * The preallocated node must be cleared to 0.
292 *
293 * Returns:
294 * 0 on success, -ENOSPC if there's no suitable hole.
295 */
David Herrmann31e5d7c2013-07-27 13:36:27 +0200296static inline int drm_mm_insert_node(struct drm_mm *mm,
297 struct drm_mm_node *node,
Thierry Reding440fd522015-01-23 09:05:06 +0100298 u64 size,
Chris Wilson71733202016-12-22 08:36:24 +0000299 u64 alignment,
David Herrmann31e5d7c2013-07-27 13:36:27 +0200300 enum drm_mm_search_flags flags)
301{
Lauri Kasanen62347f92014-04-02 20:03:57 +0300302 return drm_mm_insert_node_generic(mm, node, size, alignment, 0, flags,
303 DRM_MM_CREATE_DEFAULT);
David Herrmann31e5d7c2013-07-27 13:36:27 +0200304}
305
Daniel Vettere18c0412014-01-23 00:39:13 +0100306int drm_mm_insert_node_in_range_generic(struct drm_mm *mm,
307 struct drm_mm_node *node,
Thierry Reding440fd522015-01-23 09:05:06 +0100308 u64 size,
Chris Wilson71733202016-12-22 08:36:24 +0000309 u64 alignment,
Daniel Vettere18c0412014-01-23 00:39:13 +0100310 unsigned long color,
Thierry Reding440fd522015-01-23 09:05:06 +0100311 u64 start,
312 u64 end,
Lauri Kasanen62347f92014-04-02 20:03:57 +0300313 enum drm_mm_search_flags sflags,
314 enum drm_mm_allocator_flags aflags);
Daniel Vettere18c0412014-01-23 00:39:13 +0100315/**
316 * drm_mm_insert_node_in_range - ranged search for space and insert @node
317 * @mm: drm_mm to allocate from
318 * @node: preallocate node to insert
319 * @size: size of the allocation
320 * @alignment: alignment of the allocation
321 * @start: start of the allowed range for this node
322 * @end: end of the allowed range for this node
323 * @flags: flags to fine-tune the allocation
324 *
325 * This is a simplified version of drm_mm_insert_node_in_range_generic() with
326 * @color set to 0.
327 *
328 * The preallocated node must be cleared to 0.
329 *
330 * Returns:
331 * 0 on success, -ENOSPC if there's no suitable hole.
332 */
David Herrmann31e5d7c2013-07-27 13:36:27 +0200333static inline int drm_mm_insert_node_in_range(struct drm_mm *mm,
334 struct drm_mm_node *node,
Thierry Reding440fd522015-01-23 09:05:06 +0100335 u64 size,
Chris Wilson71733202016-12-22 08:36:24 +0000336 u64 alignment,
Thierry Reding440fd522015-01-23 09:05:06 +0100337 u64 start,
338 u64 end,
David Herrmann31e5d7c2013-07-27 13:36:27 +0200339 enum drm_mm_search_flags flags)
340{
341 return drm_mm_insert_node_in_range_generic(mm, node, size, alignment,
Lauri Kasanen62347f92014-04-02 20:03:57 +0300342 0, start, end, flags,
343 DRM_MM_CREATE_DEFAULT);
David Herrmann31e5d7c2013-07-27 13:36:27 +0200344}
345
Daniel Vettere18c0412014-01-23 00:39:13 +0100346void drm_mm_remove_node(struct drm_mm_node *node);
347void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new);
Chris Wilson45b186f2016-12-16 07:46:42 +0000348void drm_mm_init(struct drm_mm *mm, u64 start, u64 size);
Daniel Vettere18c0412014-01-23 00:39:13 +0100349void drm_mm_takedown(struct drm_mm *mm);
Chris Wilsonac9bb7b2016-12-22 08:36:27 +0000350
351/**
352 * drm_mm_clean - checks whether an allocator is clean
353 * @mm: drm_mm allocator to check
354 *
355 * Returns:
356 * True if the allocator is completely free, false if there's still a node
357 * allocated in it.
358 */
359static inline bool drm_mm_clean(const struct drm_mm *mm)
360{
361 return list_empty(drm_mm_nodes(mm));
362}
Jerome Glisse249d6042009-04-08 17:11:16 +0200363
Chris Wilson202b52b2016-08-03 16:04:09 +0100364struct drm_mm_node *
Chris Wilson45b186f2016-12-16 07:46:42 +0000365__drm_mm_interval_first(const struct drm_mm *mm, u64 start, u64 last);
Chris Wilson202b52b2016-08-03 16:04:09 +0100366
Chris Wilson522e85d2016-11-23 14:11:14 +0000367/**
368 * drm_mm_for_each_node_in_range - iterator to walk over a range of
369 * allocated nodes
Chris Wilson8b2fb7b2016-11-27 11:16:23 +0000370 * @node__: drm_mm_node structure to assign to in each iteration step
371 * @mm__: drm_mm allocator to walk
372 * @start__: starting offset, the first node will overlap this
373 * @end__: ending offset, the last node will start before this (but may overlap)
Chris Wilson522e85d2016-11-23 14:11:14 +0000374 *
375 * This iterator walks over all nodes in the range allocator that lie
376 * between @start and @end. It is implemented similarly to list_for_each(),
377 * but using the internal interval tree to accelerate the search for the
378 * starting node, and so not safe against removal of elements. It assumes
379 * that @end is within (or is the upper limit of) the drm_mm allocator.
380 */
Chris Wilson8b2fb7b2016-11-27 11:16:23 +0000381#define drm_mm_for_each_node_in_range(node__, mm__, start__, end__) \
382 for (node__ = __drm_mm_interval_first((mm__), (start__), (end__)-1); \
383 node__ && node__->start < (end__); \
384 node__ = list_next_entry(node__, node_list))
Chris Wilson202b52b2016-08-03 16:04:09 +0100385
Chris Wilson9a71e272016-12-22 08:36:29 +0000386void drm_mm_scan_init_with_range(struct drm_mm_scan *scan,
387 struct drm_mm *mm,
Chris Wilson0b04d472016-12-22 08:36:33 +0000388 u64 size, u64 alignment, unsigned long color,
389 u64 start, u64 end,
390 unsigned int flags);
Chris Wilson2c4b3892016-12-22 08:36:31 +0000391
392/**
393 * drm_mm_scan_init - initialize lru scanning
394 * @scan: scan state
395 * @mm: drm_mm to scan
396 * @size: size of the allocation
397 * @alignment: alignment of the allocation
398 * @color: opaque tag value to use for the allocation
Chris Wilson0b04d472016-12-22 08:36:33 +0000399 * @flags: flags to specify how the allocation will be performed afterwards
Chris Wilson2c4b3892016-12-22 08:36:31 +0000400 *
401 * This simply sets up the scanning routines with the parameters for the desired
Chris Wilson0b04d472016-12-22 08:36:33 +0000402 * hole.
Chris Wilson2c4b3892016-12-22 08:36:31 +0000403 *
404 * Warning:
405 * As long as the scan list is non-empty, no other operations than
406 * adding/removing nodes to/from the scan list are allowed.
407 */
408static inline void drm_mm_scan_init(struct drm_mm_scan *scan,
409 struct drm_mm *mm,
410 u64 size,
411 u64 alignment,
Chris Wilson0b04d472016-12-22 08:36:33 +0000412 unsigned long color,
413 unsigned int flags)
Chris Wilson2c4b3892016-12-22 08:36:31 +0000414{
Chris Wilson0b04d472016-12-22 08:36:33 +0000415 drm_mm_scan_init_with_range(scan, mm,
416 size, alignment, color,
417 0, U64_MAX,
418 flags);
Chris Wilson2c4b3892016-12-22 08:36:31 +0000419}
420
Chris Wilson9a71e272016-12-22 08:36:29 +0000421bool drm_mm_scan_add_block(struct drm_mm_scan *scan,
422 struct drm_mm_node *node);
423bool drm_mm_scan_remove_block(struct drm_mm_scan *scan,
424 struct drm_mm_node *node);
Daniel Vetter709ea972010-07-02 15:02:16 +0100425
Chris Wilson45b186f2016-12-16 07:46:42 +0000426void drm_mm_debug_table(const struct drm_mm *mm, const char *prefix);
Dave Airliefa8a1232009-08-26 13:13:37 +1000427#ifdef CONFIG_DEBUG_FS
Chris Wilson45b186f2016-12-16 07:46:42 +0000428int drm_mm_dump_table(struct seq_file *m, const struct drm_mm *mm);
Dave Airliefa8a1232009-08-26 13:13:37 +1000429#endif
430
Jerome Glisse249d6042009-04-08 17:11:16 +0200431#endif