drm/gpuvm: export drm_gpuvm_range_valid()
[linux-2.6-microblaze.git] / include / drm / drm_gpuvm.h
1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
2
3 #ifndef __DRM_GPUVM_H__
4 #define __DRM_GPUVM_H__
5
6 /*
7  * Copyright (c) 2022 Red Hat.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included in
17  * all copies or substantial portions 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 NONINFRINGEMENT.  IN NO EVENT SHALL
22  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  */
27
28 #include <linux/list.h>
29 #include <linux/rbtree.h>
30 #include <linux/types.h>
31
32 #include <drm/drm_device.h>
33 #include <drm/drm_gem.h>
34
35 struct drm_gpuvm;
36 struct drm_gpuvm_ops;
37
38 /**
39  * enum drm_gpuva_flags - flags for struct drm_gpuva
40  */
41 enum drm_gpuva_flags {
42         /**
43          * @DRM_GPUVA_INVALIDATED:
44          *
45          * Flag indicating that the &drm_gpuva's backing GEM is invalidated.
46          */
47         DRM_GPUVA_INVALIDATED = (1 << 0),
48
49         /**
50          * @DRM_GPUVA_SPARSE:
51          *
52          * Flag indicating that the &drm_gpuva is a sparse mapping.
53          */
54         DRM_GPUVA_SPARSE = (1 << 1),
55
56         /**
57          * @DRM_GPUVA_USERBITS: user defined bits
58          */
59         DRM_GPUVA_USERBITS = (1 << 2),
60 };
61
62 /**
63  * struct drm_gpuva - structure to track a GPU VA mapping
64  *
65  * This structure represents a GPU VA mapping and is associated with a
66  * &drm_gpuvm.
67  *
68  * Typically, this structure is embedded in bigger driver structures.
69  */
70 struct drm_gpuva {
71         /**
72          * @vm: the &drm_gpuvm this object is associated with
73          */
74         struct drm_gpuvm *vm;
75
76         /**
77          * @flags: the &drm_gpuva_flags for this mapping
78          */
79         enum drm_gpuva_flags flags;
80
81         /**
82          * @va: structure containing the address and range of the &drm_gpuva
83          */
84         struct {
85                 /**
86                  * @addr: the start address
87                  */
88                 u64 addr;
89
90                 /*
91                  * @range: the range
92                  */
93                 u64 range;
94         } va;
95
96         /**
97          * @gem: structure containing the &drm_gem_object and it's offset
98          */
99         struct {
100                 /**
101                  * @offset: the offset within the &drm_gem_object
102                  */
103                 u64 offset;
104
105                 /**
106                  * @obj: the mapped &drm_gem_object
107                  */
108                 struct drm_gem_object *obj;
109
110                 /**
111                  * @entry: the &list_head to attach this object to a &drm_gem_object
112                  */
113                 struct list_head entry;
114         } gem;
115
116         /**
117          * @rb: structure containing data to store &drm_gpuvas in a rb-tree
118          */
119         struct {
120                 /**
121                  * @rb: the rb-tree node
122                  */
123                 struct rb_node node;
124
125                 /**
126                  * @entry: The &list_head to additionally connect &drm_gpuvas
127                  * in the same order they appear in the interval tree. This is
128                  * useful to keep iterating &drm_gpuvas from a start node found
129                  * through the rb-tree while doing modifications on the rb-tree
130                  * itself.
131                  */
132                 struct list_head entry;
133
134                 /**
135                  * @__subtree_last: needed by the interval tree, holding last-in-subtree
136                  */
137                 u64 __subtree_last;
138         } rb;
139 };
140
141 int drm_gpuva_insert(struct drm_gpuvm *gpuvm, struct drm_gpuva *va);
142 void drm_gpuva_remove(struct drm_gpuva *va);
143
144 void drm_gpuva_link(struct drm_gpuva *va);
145 void drm_gpuva_unlink(struct drm_gpuva *va);
146
147 struct drm_gpuva *drm_gpuva_find(struct drm_gpuvm *gpuvm,
148                                  u64 addr, u64 range);
149 struct drm_gpuva *drm_gpuva_find_first(struct drm_gpuvm *gpuvm,
150                                        u64 addr, u64 range);
151 struct drm_gpuva *drm_gpuva_find_prev(struct drm_gpuvm *gpuvm, u64 start);
152 struct drm_gpuva *drm_gpuva_find_next(struct drm_gpuvm *gpuvm, u64 end);
153
154 static inline void drm_gpuva_init(struct drm_gpuva *va, u64 addr, u64 range,
155                                   struct drm_gem_object *obj, u64 offset)
156 {
157         va->va.addr = addr;
158         va->va.range = range;
159         va->gem.obj = obj;
160         va->gem.offset = offset;
161 }
162
163 /**
164  * drm_gpuva_invalidate() - sets whether the backing GEM of this &drm_gpuva is
165  * invalidated
166  * @va: the &drm_gpuva to set the invalidate flag for
167  * @invalidate: indicates whether the &drm_gpuva is invalidated
168  */
169 static inline void drm_gpuva_invalidate(struct drm_gpuva *va, bool invalidate)
170 {
171         if (invalidate)
172                 va->flags |= DRM_GPUVA_INVALIDATED;
173         else
174                 va->flags &= ~DRM_GPUVA_INVALIDATED;
175 }
176
177 /**
178  * drm_gpuva_invalidated() - indicates whether the backing BO of this &drm_gpuva
179  * is invalidated
180  * @va: the &drm_gpuva to check
181  */
182 static inline bool drm_gpuva_invalidated(struct drm_gpuva *va)
183 {
184         return va->flags & DRM_GPUVA_INVALIDATED;
185 }
186
187 /**
188  * struct drm_gpuvm - DRM GPU VA Manager
189  *
190  * The DRM GPU VA Manager keeps track of a GPU's virtual address space by using
191  * &maple_tree structures. Typically, this structure is embedded in bigger
192  * driver structures.
193  *
194  * Drivers can pass addresses and ranges in an arbitrary unit, e.g. bytes or
195  * pages.
196  *
197  * There should be one manager instance per GPU virtual address space.
198  */
199 struct drm_gpuvm {
200         /**
201          * @name: the name of the DRM GPU VA space
202          */
203         const char *name;
204
205         /**
206          * @drm: the &drm_device this VM lives in
207          */
208         struct drm_device *drm;
209
210         /**
211          * @mm_start: start of the VA space
212          */
213         u64 mm_start;
214
215         /**
216          * @mm_range: length of the VA space
217          */
218         u64 mm_range;
219
220         /**
221          * @rb: structures to track &drm_gpuva entries
222          */
223         struct {
224                 /**
225                  * @tree: the rb-tree to track GPU VA mappings
226                  */
227                 struct rb_root_cached tree;
228
229                 /**
230                  * @list: the &list_head to track GPU VA mappings
231                  */
232                 struct list_head list;
233         } rb;
234
235         /**
236          * @kernel_alloc_node:
237          *
238          * &drm_gpuva representing the address space cutout reserved for
239          * the kernel
240          */
241         struct drm_gpuva kernel_alloc_node;
242
243         /**
244          * @ops: &drm_gpuvm_ops providing the split/merge steps to drivers
245          */
246         const struct drm_gpuvm_ops *ops;
247 };
248
249 void drm_gpuvm_init(struct drm_gpuvm *gpuvm, const char *name,
250                     struct drm_device *drm,
251                     u64 start_offset, u64 range,
252                     u64 reserve_offset, u64 reserve_range,
253                     const struct drm_gpuvm_ops *ops);
254 void drm_gpuvm_destroy(struct drm_gpuvm *gpuvm);
255
256 bool drm_gpuvm_range_valid(struct drm_gpuvm *gpuvm, u64 addr, u64 range);
257 bool drm_gpuvm_interval_empty(struct drm_gpuvm *gpuvm, u64 addr, u64 range);
258
259 static inline struct drm_gpuva *
260 __drm_gpuva_next(struct drm_gpuva *va)
261 {
262         if (va && !list_is_last(&va->rb.entry, &va->vm->rb.list))
263                 return list_next_entry(va, rb.entry);
264
265         return NULL;
266 }
267
268 /**
269  * drm_gpuvm_for_each_va_range() - iterate over a range of &drm_gpuvas
270  * @va__: &drm_gpuva structure to assign to in each iteration step
271  * @gpuvm__: &drm_gpuvm to walk over
272  * @start__: starting offset, the first gpuva will overlap this
273  * @end__: ending offset, the last gpuva will start before this (but may
274  * overlap)
275  *
276  * This iterator walks over all &drm_gpuvas in the &drm_gpuvm that lie
277  * between @start__ and @end__. It is implemented similarly to list_for_each(),
278  * but is using the &drm_gpuvm's internal interval tree to accelerate
279  * the search for the starting &drm_gpuva, and hence isn't safe against removal
280  * of elements. It assumes that @end__ is within (or is the upper limit of) the
281  * &drm_gpuvm. This iterator does not skip over the &drm_gpuvm's
282  * @kernel_alloc_node.
283  */
284 #define drm_gpuvm_for_each_va_range(va__, gpuvm__, start__, end__) \
285         for (va__ = drm_gpuva_find_first((gpuvm__), (start__), (end__) - (start__)); \
286              va__ && (va__->va.addr < (end__)); \
287              va__ = __drm_gpuva_next(va__))
288
289 /**
290  * drm_gpuvm_for_each_va_range_safe() - safely iterate over a range of
291  * &drm_gpuvas
292  * @va__: &drm_gpuva to assign to in each iteration step
293  * @next__: another &drm_gpuva to use as temporary storage
294  * @gpuvm__: &drm_gpuvm to walk over
295  * @start__: starting offset, the first gpuva will overlap this
296  * @end__: ending offset, the last gpuva will start before this (but may
297  * overlap)
298  *
299  * This iterator walks over all &drm_gpuvas in the &drm_gpuvm that lie
300  * between @start__ and @end__. It is implemented similarly to
301  * list_for_each_safe(), but is using the &drm_gpuvm's internal interval
302  * tree to accelerate the search for the starting &drm_gpuva, and hence is safe
303  * against removal of elements. It assumes that @end__ is within (or is the
304  * upper limit of) the &drm_gpuvm. This iterator does not skip over the
305  * &drm_gpuvm's @kernel_alloc_node.
306  */
307 #define drm_gpuvm_for_each_va_range_safe(va__, next__, gpuvm__, start__, end__) \
308         for (va__ = drm_gpuva_find_first((gpuvm__), (start__), (end__) - (start__)), \
309              next__ = __drm_gpuva_next(va__); \
310              va__ && (va__->va.addr < (end__)); \
311              va__ = next__, next__ = __drm_gpuva_next(va__))
312
313 /**
314  * drm_gpuvm_for_each_va() - iterate over all &drm_gpuvas
315  * @va__: &drm_gpuva to assign to in each iteration step
316  * @gpuvm__: &drm_gpuvm to walk over
317  *
318  * This iterator walks over all &drm_gpuva structures associated with the given
319  * &drm_gpuvm.
320  */
321 #define drm_gpuvm_for_each_va(va__, gpuvm__) \
322         list_for_each_entry(va__, &(gpuvm__)->rb.list, rb.entry)
323
324 /**
325  * drm_gpuvm_for_each_va_safe() - safely iterate over all &drm_gpuvas
326  * @va__: &drm_gpuva to assign to in each iteration step
327  * @next__: another &drm_gpuva to use as temporary storage
328  * @gpuvm__: &drm_gpuvm to walk over
329  *
330  * This iterator walks over all &drm_gpuva structures associated with the given
331  * &drm_gpuvm. It is implemented with list_for_each_entry_safe(), and
332  * hence safe against the removal of elements.
333  */
334 #define drm_gpuvm_for_each_va_safe(va__, next__, gpuvm__) \
335         list_for_each_entry_safe(va__, next__, &(gpuvm__)->rb.list, rb.entry)
336
337 /**
338  * enum drm_gpuva_op_type - GPU VA operation type
339  *
340  * Operations to alter the GPU VA mappings tracked by the &drm_gpuvm.
341  */
342 enum drm_gpuva_op_type {
343         /**
344          * @DRM_GPUVA_OP_MAP: the map op type
345          */
346         DRM_GPUVA_OP_MAP,
347
348         /**
349          * @DRM_GPUVA_OP_REMAP: the remap op type
350          */
351         DRM_GPUVA_OP_REMAP,
352
353         /**
354          * @DRM_GPUVA_OP_UNMAP: the unmap op type
355          */
356         DRM_GPUVA_OP_UNMAP,
357
358         /**
359          * @DRM_GPUVA_OP_PREFETCH: the prefetch op type
360          */
361         DRM_GPUVA_OP_PREFETCH,
362 };
363
364 /**
365  * struct drm_gpuva_op_map - GPU VA map operation
366  *
367  * This structure represents a single map operation generated by the
368  * DRM GPU VA manager.
369  */
370 struct drm_gpuva_op_map {
371         /**
372          * @va: structure containing address and range of a map
373          * operation
374          */
375         struct {
376                 /**
377                  * @addr: the base address of the new mapping
378                  */
379                 u64 addr;
380
381                 /**
382                  * @range: the range of the new mapping
383                  */
384                 u64 range;
385         } va;
386
387         /**
388          * @gem: structure containing the &drm_gem_object and it's offset
389          */
390         struct {
391                 /**
392                  * @offset: the offset within the &drm_gem_object
393                  */
394                 u64 offset;
395
396                 /**
397                  * @obj: the &drm_gem_object to map
398                  */
399                 struct drm_gem_object *obj;
400         } gem;
401 };
402
403 /**
404  * struct drm_gpuva_op_unmap - GPU VA unmap operation
405  *
406  * This structure represents a single unmap operation generated by the
407  * DRM GPU VA manager.
408  */
409 struct drm_gpuva_op_unmap {
410         /**
411          * @va: the &drm_gpuva to unmap
412          */
413         struct drm_gpuva *va;
414
415         /**
416          * @keep:
417          *
418          * Indicates whether this &drm_gpuva is physically contiguous with the
419          * original mapping request.
420          *
421          * Optionally, if &keep is set, drivers may keep the actual page table
422          * mappings for this &drm_gpuva, adding the missing page table entries
423          * only and update the &drm_gpuvm accordingly.
424          */
425         bool keep;
426 };
427
428 /**
429  * struct drm_gpuva_op_remap - GPU VA remap operation
430  *
431  * This represents a single remap operation generated by the DRM GPU VA manager.
432  *
433  * A remap operation is generated when an existing GPU VA mmapping is split up
434  * by inserting a new GPU VA mapping or by partially unmapping existent
435  * mapping(s), hence it consists of a maximum of two map and one unmap
436  * operation.
437  *
438  * The @unmap operation takes care of removing the original existing mapping.
439  * @prev is used to remap the preceding part, @next the subsequent part.
440  *
441  * If either a new mapping's start address is aligned with the start address
442  * of the old mapping or the new mapping's end address is aligned with the
443  * end address of the old mapping, either @prev or @next is NULL.
444  *
445  * Note, the reason for a dedicated remap operation, rather than arbitrary
446  * unmap and map operations, is to give drivers the chance of extracting driver
447  * specific data for creating the new mappings from the unmap operations's
448  * &drm_gpuva structure which typically is embedded in larger driver specific
449  * structures.
450  */
451 struct drm_gpuva_op_remap {
452         /**
453          * @prev: the preceding part of a split mapping
454          */
455         struct drm_gpuva_op_map *prev;
456
457         /**
458          * @next: the subsequent part of a split mapping
459          */
460         struct drm_gpuva_op_map *next;
461
462         /**
463          * @unmap: the unmap operation for the original existing mapping
464          */
465         struct drm_gpuva_op_unmap *unmap;
466 };
467
468 /**
469  * struct drm_gpuva_op_prefetch - GPU VA prefetch operation
470  *
471  * This structure represents a single prefetch operation generated by the
472  * DRM GPU VA manager.
473  */
474 struct drm_gpuva_op_prefetch {
475         /**
476          * @va: the &drm_gpuva to prefetch
477          */
478         struct drm_gpuva *va;
479 };
480
481 /**
482  * struct drm_gpuva_op - GPU VA operation
483  *
484  * This structure represents a single generic operation.
485  *
486  * The particular type of the operation is defined by @op.
487  */
488 struct drm_gpuva_op {
489         /**
490          * @entry:
491          *
492          * The &list_head used to distribute instances of this struct within
493          * &drm_gpuva_ops.
494          */
495         struct list_head entry;
496
497         /**
498          * @op: the type of the operation
499          */
500         enum drm_gpuva_op_type op;
501
502         union {
503                 /**
504                  * @map: the map operation
505                  */
506                 struct drm_gpuva_op_map map;
507
508                 /**
509                  * @remap: the remap operation
510                  */
511                 struct drm_gpuva_op_remap remap;
512
513                 /**
514                  * @unmap: the unmap operation
515                  */
516                 struct drm_gpuva_op_unmap unmap;
517
518                 /**
519                  * @prefetch: the prefetch operation
520                  */
521                 struct drm_gpuva_op_prefetch prefetch;
522         };
523 };
524
525 /**
526  * struct drm_gpuva_ops - wraps a list of &drm_gpuva_op
527  */
528 struct drm_gpuva_ops {
529         /**
530          * @list: the &list_head
531          */
532         struct list_head list;
533 };
534
535 /**
536  * drm_gpuva_for_each_op() - iterator to walk over &drm_gpuva_ops
537  * @op: &drm_gpuva_op to assign in each iteration step
538  * @ops: &drm_gpuva_ops to walk
539  *
540  * This iterator walks over all ops within a given list of operations.
541  */
542 #define drm_gpuva_for_each_op(op, ops) list_for_each_entry(op, &(ops)->list, entry)
543
544 /**
545  * drm_gpuva_for_each_op_safe() - iterator to safely walk over &drm_gpuva_ops
546  * @op: &drm_gpuva_op to assign in each iteration step
547  * @next: &next &drm_gpuva_op to store the next step
548  * @ops: &drm_gpuva_ops to walk
549  *
550  * This iterator walks over all ops within a given list of operations. It is
551  * implemented with list_for_each_safe(), so save against removal of elements.
552  */
553 #define drm_gpuva_for_each_op_safe(op, next, ops) \
554         list_for_each_entry_safe(op, next, &(ops)->list, entry)
555
556 /**
557  * drm_gpuva_for_each_op_from_reverse() - iterate backwards from the given point
558  * @op: &drm_gpuva_op to assign in each iteration step
559  * @ops: &drm_gpuva_ops to walk
560  *
561  * This iterator walks over all ops within a given list of operations beginning
562  * from the given operation in reverse order.
563  */
564 #define drm_gpuva_for_each_op_from_reverse(op, ops) \
565         list_for_each_entry_from_reverse(op, &(ops)->list, entry)
566
567 /**
568  * drm_gpuva_first_op() - returns the first &drm_gpuva_op from &drm_gpuva_ops
569  * @ops: the &drm_gpuva_ops to get the fist &drm_gpuva_op from
570  */
571 #define drm_gpuva_first_op(ops) \
572         list_first_entry(&(ops)->list, struct drm_gpuva_op, entry)
573
574 /**
575  * drm_gpuva_last_op() - returns the last &drm_gpuva_op from &drm_gpuva_ops
576  * @ops: the &drm_gpuva_ops to get the last &drm_gpuva_op from
577  */
578 #define drm_gpuva_last_op(ops) \
579         list_last_entry(&(ops)->list, struct drm_gpuva_op, entry)
580
581 /**
582  * drm_gpuva_prev_op() - previous &drm_gpuva_op in the list
583  * @op: the current &drm_gpuva_op
584  */
585 #define drm_gpuva_prev_op(op) list_prev_entry(op, entry)
586
587 /**
588  * drm_gpuva_next_op() - next &drm_gpuva_op in the list
589  * @op: the current &drm_gpuva_op
590  */
591 #define drm_gpuva_next_op(op) list_next_entry(op, entry)
592
593 struct drm_gpuva_ops *
594 drm_gpuvm_sm_map_ops_create(struct drm_gpuvm *gpuvm,
595                             u64 addr, u64 range,
596                             struct drm_gem_object *obj, u64 offset);
597 struct drm_gpuva_ops *
598 drm_gpuvm_sm_unmap_ops_create(struct drm_gpuvm *gpuvm,
599                               u64 addr, u64 range);
600
601 struct drm_gpuva_ops *
602 drm_gpuvm_prefetch_ops_create(struct drm_gpuvm *gpuvm,
603                                  u64 addr, u64 range);
604
605 struct drm_gpuva_ops *
606 drm_gpuvm_gem_unmap_ops_create(struct drm_gpuvm *gpuvm,
607                                struct drm_gem_object *obj);
608
609 void drm_gpuva_ops_free(struct drm_gpuvm *gpuvm,
610                         struct drm_gpuva_ops *ops);
611
612 static inline void drm_gpuva_init_from_op(struct drm_gpuva *va,
613                                           struct drm_gpuva_op_map *op)
614 {
615         drm_gpuva_init(va, op->va.addr, op->va.range,
616                        op->gem.obj, op->gem.offset);
617 }
618
619 /**
620  * struct drm_gpuvm_ops - callbacks for split/merge steps
621  *
622  * This structure defines the callbacks used by &drm_gpuvm_sm_map and
623  * &drm_gpuvm_sm_unmap to provide the split/merge steps for map and unmap
624  * operations to drivers.
625  */
626 struct drm_gpuvm_ops {
627         /**
628          * @op_alloc: called when the &drm_gpuvm allocates
629          * a struct drm_gpuva_op
630          *
631          * Some drivers may want to embed struct drm_gpuva_op into driver
632          * specific structures. By implementing this callback drivers can
633          * allocate memory accordingly.
634          *
635          * This callback is optional.
636          */
637         struct drm_gpuva_op *(*op_alloc)(void);
638
639         /**
640          * @op_free: called when the &drm_gpuvm frees a
641          * struct drm_gpuva_op
642          *
643          * Some drivers may want to embed struct drm_gpuva_op into driver
644          * specific structures. By implementing this callback drivers can
645          * free the previously allocated memory accordingly.
646          *
647          * This callback is optional.
648          */
649         void (*op_free)(struct drm_gpuva_op *op);
650
651         /**
652          * @sm_step_map: called from &drm_gpuvm_sm_map to finally insert the
653          * mapping once all previous steps were completed
654          *
655          * The &priv pointer matches the one the driver passed to
656          * &drm_gpuvm_sm_map or &drm_gpuvm_sm_unmap, respectively.
657          *
658          * Can be NULL if &drm_gpuvm_sm_map is used.
659          */
660         int (*sm_step_map)(struct drm_gpuva_op *op, void *priv);
661
662         /**
663          * @sm_step_remap: called from &drm_gpuvm_sm_map and
664          * &drm_gpuvm_sm_unmap to split up an existent mapping
665          *
666          * This callback is called when existent mapping needs to be split up.
667          * This is the case when either a newly requested mapping overlaps or
668          * is enclosed by an existent mapping or a partial unmap of an existent
669          * mapping is requested.
670          *
671          * The &priv pointer matches the one the driver passed to
672          * &drm_gpuvm_sm_map or &drm_gpuvm_sm_unmap, respectively.
673          *
674          * Can be NULL if neither &drm_gpuvm_sm_map nor &drm_gpuvm_sm_unmap is
675          * used.
676          */
677         int (*sm_step_remap)(struct drm_gpuva_op *op, void *priv);
678
679         /**
680          * @sm_step_unmap: called from &drm_gpuvm_sm_map and
681          * &drm_gpuvm_sm_unmap to unmap an existent mapping
682          *
683          * This callback is called when existent mapping needs to be unmapped.
684          * This is the case when either a newly requested mapping encloses an
685          * existent mapping or an unmap of an existent mapping is requested.
686          *
687          * The &priv pointer matches the one the driver passed to
688          * &drm_gpuvm_sm_map or &drm_gpuvm_sm_unmap, respectively.
689          *
690          * Can be NULL if neither &drm_gpuvm_sm_map nor &drm_gpuvm_sm_unmap is
691          * used.
692          */
693         int (*sm_step_unmap)(struct drm_gpuva_op *op, void *priv);
694 };
695
696 int drm_gpuvm_sm_map(struct drm_gpuvm *gpuvm, void *priv,
697                      u64 addr, u64 range,
698                      struct drm_gem_object *obj, u64 offset);
699
700 int drm_gpuvm_sm_unmap(struct drm_gpuvm *gpuvm, void *priv,
701                        u64 addr, u64 range);
702
703 void drm_gpuva_map(struct drm_gpuvm *gpuvm,
704                    struct drm_gpuva *va,
705                    struct drm_gpuva_op_map *op);
706
707 void drm_gpuva_remap(struct drm_gpuva *prev,
708                      struct drm_gpuva *next,
709                      struct drm_gpuva_op_remap *op);
710
711 void drm_gpuva_unmap(struct drm_gpuva_op_unmap *op);
712
713 #endif /* __DRM_GPUVM_H__ */