1*76f0c10cSriastradh /* $NetBSD: drm_gem.h,v 1.12 2021/12/19 10:38:23 riastradh Exp $ */
2efa246c0Sriastradh
3efa246c0Sriastradh #ifndef __DRM_GEM_H__
4efa246c0Sriastradh #define __DRM_GEM_H__
5efa246c0Sriastradh
6efa246c0Sriastradh /*
7efa246c0Sriastradh * GEM Graphics Execution Manager Driver Interfaces
8efa246c0Sriastradh *
9efa246c0Sriastradh * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
10efa246c0Sriastradh * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
11efa246c0Sriastradh * Copyright (c) 2009-2010, Code Aurora Forum.
12efa246c0Sriastradh * All rights reserved.
13efa246c0Sriastradh * Copyright © 2014 Intel Corporation
14efa246c0Sriastradh * Daniel Vetter <daniel.vetter@ffwll.ch>
15efa246c0Sriastradh *
16efa246c0Sriastradh * Author: Rickard E. (Rik) Faith <faith@valinux.com>
17efa246c0Sriastradh * Author: Gareth Hughes <gareth@valinux.com>
18efa246c0Sriastradh *
19efa246c0Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a
20efa246c0Sriastradh * copy of this software and associated documentation files (the "Software"),
21efa246c0Sriastradh * to deal in the Software without restriction, including without limitation
22efa246c0Sriastradh * the rights to use, copy, modify, merge, publish, distribute, sublicense,
23efa246c0Sriastradh * and/or sell copies of the Software, and to permit persons to whom the
24efa246c0Sriastradh * Software is furnished to do so, subject to the following conditions:
25efa246c0Sriastradh *
26efa246c0Sriastradh * The above copyright notice and this permission notice (including the next
27efa246c0Sriastradh * paragraph) shall be included in all copies or substantial portions of the
28efa246c0Sriastradh * Software.
29efa246c0Sriastradh *
30efa246c0Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31efa246c0Sriastradh * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32efa246c0Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
33efa246c0Sriastradh * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
34efa246c0Sriastradh * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
35efa246c0Sriastradh * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
36efa246c0Sriastradh * OTHER DEALINGS IN THE SOFTWARE.
37efa246c0Sriastradh */
38efa246c0Sriastradh
39e733144dSriastradh #ifdef __NetBSD__
40e733144dSriastradh #include <uvm/uvm.h>
41e733144dSriastradh #endif
420afbeadbSriastradh
430afbeadbSriastradh #include <linux/types.h>
4441ec0267Sriastradh #include <linux/kref.h>
4541ec0267Sriastradh #include <linux/dma-resv.h>
4641ec0267Sriastradh
47b8e5703dSriastradh #include <drm/drm_device.h>
48b8e5703dSriastradh #include <drm/drm_print.h>
4941ec0267Sriastradh #include <drm/drm_vma_manager.h>
509bacda90Sriastradh #undef free
5141ec0267Sriastradh
5241ec0267Sriastradh struct drm_gem_object;
534cf49d55Sriastradh struct xarray;
54e733144dSriastradh
55efa246c0Sriastradh /**
5641ec0267Sriastradh * struct drm_gem_object_funcs - GEM object functions
5741ec0267Sriastradh */
5841ec0267Sriastradh struct drm_gem_object_funcs {
5941ec0267Sriastradh /**
6041ec0267Sriastradh * @free:
6141ec0267Sriastradh *
6241ec0267Sriastradh * Deconstructor for drm_gem_objects.
6341ec0267Sriastradh *
6441ec0267Sriastradh * This callback is mandatory.
6541ec0267Sriastradh */
6641ec0267Sriastradh void (*free)(struct drm_gem_object *obj);
6741ec0267Sriastradh
6841ec0267Sriastradh /**
6941ec0267Sriastradh * @open:
7041ec0267Sriastradh *
7141ec0267Sriastradh * Called upon GEM handle creation.
7241ec0267Sriastradh *
7341ec0267Sriastradh * This callback is optional.
7441ec0267Sriastradh */
7541ec0267Sriastradh int (*open)(struct drm_gem_object *obj, struct drm_file *file);
7641ec0267Sriastradh
7741ec0267Sriastradh /**
7841ec0267Sriastradh * @close:
7941ec0267Sriastradh *
8041ec0267Sriastradh * Called upon GEM handle release.
8141ec0267Sriastradh *
8241ec0267Sriastradh * This callback is optional.
8341ec0267Sriastradh */
8441ec0267Sriastradh void (*close)(struct drm_gem_object *obj, struct drm_file *file);
8541ec0267Sriastradh
8641ec0267Sriastradh /**
8741ec0267Sriastradh * @print_info:
8841ec0267Sriastradh *
8941ec0267Sriastradh * If driver subclasses struct &drm_gem_object, it can implement this
9041ec0267Sriastradh * optional hook for printing additional driver specific info.
9141ec0267Sriastradh *
9241ec0267Sriastradh * drm_printf_indent() should be used in the callback passing it the
9341ec0267Sriastradh * indent argument.
9441ec0267Sriastradh *
9541ec0267Sriastradh * This callback is called from drm_gem_print_info().
9641ec0267Sriastradh *
9741ec0267Sriastradh * This callback is optional.
9841ec0267Sriastradh */
9941ec0267Sriastradh void (*print_info)(struct drm_printer *p, unsigned int indent,
10041ec0267Sriastradh const struct drm_gem_object *obj);
10141ec0267Sriastradh
10241ec0267Sriastradh /**
10341ec0267Sriastradh * @export:
10441ec0267Sriastradh *
10541ec0267Sriastradh * Export backing buffer as a &dma_buf.
10641ec0267Sriastradh * If this is not set drm_gem_prime_export() is used.
10741ec0267Sriastradh *
10841ec0267Sriastradh * This callback is optional.
10941ec0267Sriastradh */
11041ec0267Sriastradh struct dma_buf *(*export)(struct drm_gem_object *obj, int flags);
11141ec0267Sriastradh
11241ec0267Sriastradh /**
11341ec0267Sriastradh * @pin:
11441ec0267Sriastradh *
11541ec0267Sriastradh * Pin backing buffer in memory. Used by the drm_gem_map_attach() helper.
11641ec0267Sriastradh *
11741ec0267Sriastradh * This callback is optional.
11841ec0267Sriastradh */
11941ec0267Sriastradh int (*pin)(struct drm_gem_object *obj);
12041ec0267Sriastradh
12141ec0267Sriastradh /**
12241ec0267Sriastradh * @unpin:
12341ec0267Sriastradh *
12441ec0267Sriastradh * Unpin backing buffer. Used by the drm_gem_map_detach() helper.
12541ec0267Sriastradh *
12641ec0267Sriastradh * This callback is optional.
12741ec0267Sriastradh */
12841ec0267Sriastradh void (*unpin)(struct drm_gem_object *obj);
12941ec0267Sriastradh
13041ec0267Sriastradh /**
13141ec0267Sriastradh * @get_sg_table:
13241ec0267Sriastradh *
13341ec0267Sriastradh * Returns a Scatter-Gather table representation of the buffer.
13441ec0267Sriastradh * Used when exporting a buffer by the drm_gem_map_dma_buf() helper.
13541ec0267Sriastradh * Releasing is done by calling dma_unmap_sg_attrs() and sg_free_table()
13641ec0267Sriastradh * in drm_gem_unmap_buf(), therefore these helpers and this callback
13741ec0267Sriastradh * here cannot be used for sg tables pointing at driver private memory
13841ec0267Sriastradh * ranges.
13941ec0267Sriastradh *
14041ec0267Sriastradh * See also drm_prime_pages_to_sg().
14141ec0267Sriastradh */
14241ec0267Sriastradh struct sg_table *(*get_sg_table)(struct drm_gem_object *obj);
14341ec0267Sriastradh
14441ec0267Sriastradh /**
14541ec0267Sriastradh * @vmap:
14641ec0267Sriastradh *
14741ec0267Sriastradh * Returns a virtual address for the buffer. Used by the
14841ec0267Sriastradh * drm_gem_dmabuf_vmap() helper.
14941ec0267Sriastradh *
15041ec0267Sriastradh * This callback is optional.
15141ec0267Sriastradh */
15241ec0267Sriastradh void *(*vmap)(struct drm_gem_object *obj);
15341ec0267Sriastradh
15441ec0267Sriastradh /**
15541ec0267Sriastradh * @vunmap:
15641ec0267Sriastradh *
15741ec0267Sriastradh * Releases the the address previously returned by @vmap. Used by the
15841ec0267Sriastradh * drm_gem_dmabuf_vunmap() helper.
15941ec0267Sriastradh *
16041ec0267Sriastradh * This callback is optional.
16141ec0267Sriastradh */
16241ec0267Sriastradh void (*vunmap)(struct drm_gem_object *obj, void *vaddr);
16341ec0267Sriastradh
16441ec0267Sriastradh /**
16541ec0267Sriastradh * @mmap:
16641ec0267Sriastradh *
16741ec0267Sriastradh * Handle mmap() of the gem object, setup vma accordingly.
16841ec0267Sriastradh *
16941ec0267Sriastradh * This callback is optional.
17041ec0267Sriastradh *
17141ec0267Sriastradh * The callback is used by by both drm_gem_mmap_obj() and
17241ec0267Sriastradh * drm_gem_prime_mmap(). When @mmap is present @vm_ops is not
17341ec0267Sriastradh * used, the @mmap callback must set vma->vm_ops instead.
17441ec0267Sriastradh */
1751c6134cfSriastradh #ifdef __NetBSD__
176*76f0c10cSriastradh int (*mmap)(struct drm_gem_object *, off_t *, size_t, int,
177*76f0c10cSriastradh int *, int *, struct uvm_object **, int *);
1781c6134cfSriastradh #else
17941ec0267Sriastradh int (*mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma);
1801c6134cfSriastradh #endif
18141ec0267Sriastradh
18241ec0267Sriastradh /**
18341ec0267Sriastradh * @vm_ops:
18441ec0267Sriastradh *
18541ec0267Sriastradh * Virtual memory operations used with mmap.
18641ec0267Sriastradh *
18741ec0267Sriastradh * This is optional but necessary for mmap support.
18841ec0267Sriastradh */
18941ec0267Sriastradh const struct vm_operations_struct *vm_ops;
19041ec0267Sriastradh };
19141ec0267Sriastradh
19241ec0267Sriastradh /**
19341ec0267Sriastradh * struct drm_gem_object - GEM buffer object
19441ec0267Sriastradh *
19541ec0267Sriastradh * This structure defines the generic parts for GEM buffer objects, which are
19641ec0267Sriastradh * mostly around handling mmap and userspace handles.
19741ec0267Sriastradh *
19841ec0267Sriastradh * Buffer objects are often abbreviated to BO.
199efa246c0Sriastradh */
200efa246c0Sriastradh struct drm_gem_object {
20141ec0267Sriastradh /**
20241ec0267Sriastradh * @refcount:
20341ec0267Sriastradh *
20441ec0267Sriastradh * Reference count of this object
20541ec0267Sriastradh *
20641ec0267Sriastradh * Please use drm_gem_object_get() to acquire and drm_gem_object_put()
20741ec0267Sriastradh * or drm_gem_object_put_unlocked() to release a reference to a GEM
20841ec0267Sriastradh * buffer object.
20941ec0267Sriastradh */
210efa246c0Sriastradh struct kref refcount;
211efa246c0Sriastradh
212efa246c0Sriastradh /**
21341ec0267Sriastradh * @handle_count:
21441ec0267Sriastradh *
21541ec0267Sriastradh * This is the GEM file_priv handle count of this object.
216efa246c0Sriastradh *
217efa246c0Sriastradh * Each handle also holds a reference. Note that when the handle_count
218efa246c0Sriastradh * drops to 0 any global names (e.g. the id in the flink namespace) will
219efa246c0Sriastradh * be cleared.
220efa246c0Sriastradh *
22141ec0267Sriastradh * Protected by &drm_device.object_name_lock.
22241ec0267Sriastradh */
223efa246c0Sriastradh unsigned handle_count;
224efa246c0Sriastradh
22541ec0267Sriastradh /**
22641ec0267Sriastradh * @dev: DRM dev this object belongs to.
22741ec0267Sriastradh */
228efa246c0Sriastradh struct drm_device *dev;
229efa246c0Sriastradh
230d01ac146Sriastradh #ifdef __NetBSD__
231d01ac146Sriastradh /* UVM anonymous object for shared memory mappings. */
2325f39c899Sriastradh struct uvm_object *filp;
233d01ac146Sriastradh
234d01ac146Sriastradh /* UVM object with custom pager ops for device memory mappings. */
235d01ac146Sriastradh struct uvm_object gemo_uvmobj;
236d01ac146Sriastradh #else
23741ec0267Sriastradh /**
23841ec0267Sriastradh * @filp:
23941ec0267Sriastradh *
24041ec0267Sriastradh * SHMEM file node used as backing storage for swappable buffer objects.
24141ec0267Sriastradh * GEM also supports driver private objects with driver-specific backing
24241ec0267Sriastradh * storage (contiguous CMA memory, special reserved blocks). In this
24341ec0267Sriastradh * case @filp is NULL.
24441ec0267Sriastradh */
245efa246c0Sriastradh struct file *filp;
246d01ac146Sriastradh #endif
247efa246c0Sriastradh
24841ec0267Sriastradh /**
24941ec0267Sriastradh * @vma_node:
25041ec0267Sriastradh *
25141ec0267Sriastradh * Mapping info for this object to support mmap. Drivers are supposed to
25241ec0267Sriastradh * allocate the mmap offset using drm_gem_create_mmap_offset(). The
25341ec0267Sriastradh * offset itself can be retrieved using drm_vma_node_offset_addr().
25441ec0267Sriastradh *
25541ec0267Sriastradh * Memory mapping itself is handled by drm_gem_mmap(), which also checks
25641ec0267Sriastradh * that userspace is allowed to access the object.
25741ec0267Sriastradh */
258efa246c0Sriastradh struct drm_vma_offset_node vma_node;
259efa246c0Sriastradh
260efa246c0Sriastradh /**
26141ec0267Sriastradh * @size:
26241ec0267Sriastradh *
263efa246c0Sriastradh * Size of the object, in bytes. Immutable over the object's
264efa246c0Sriastradh * lifetime.
265efa246c0Sriastradh */
266efa246c0Sriastradh size_t size;
267efa246c0Sriastradh
268efa246c0Sriastradh /**
26941ec0267Sriastradh * @name:
27041ec0267Sriastradh *
271efa246c0Sriastradh * Global name for this object, starts at 1. 0 means unnamed.
27241ec0267Sriastradh * Access is covered by &drm_device.object_name_lock. This is used by
27341ec0267Sriastradh * the GEM_FLINK and GEM_OPEN ioctls.
274efa246c0Sriastradh */
275efa246c0Sriastradh int name;
276efa246c0Sriastradh
277efa246c0Sriastradh /**
27841ec0267Sriastradh * @dma_buf:
27941ec0267Sriastradh *
28041ec0267Sriastradh * dma-buf associated with this GEM object.
281efa246c0Sriastradh *
282efa246c0Sriastradh * Pointer to the dma-buf associated with this gem object (either
283efa246c0Sriastradh * through importing or exporting). We break the resulting reference
284efa246c0Sriastradh * loop when the last gem handle for this object is released.
285efa246c0Sriastradh *
28641ec0267Sriastradh * Protected by &drm_device.object_name_lock.
287efa246c0Sriastradh */
288efa246c0Sriastradh struct dma_buf *dma_buf;
289efa246c0Sriastradh
290efa246c0Sriastradh /**
29141ec0267Sriastradh * @import_attach:
29241ec0267Sriastradh *
29341ec0267Sriastradh * dma-buf attachment backing this object.
294efa246c0Sriastradh *
295efa246c0Sriastradh * Any foreign dma_buf imported as a gem object has this set to the
296efa246c0Sriastradh * attachment point for the device. This is invariant over the lifetime
297efa246c0Sriastradh * of a gem object.
298efa246c0Sriastradh *
29941ec0267Sriastradh * The &drm_driver.gem_free_object callback is responsible for cleaning
300efa246c0Sriastradh * up the dma_buf attachment and references acquired at import time.
301efa246c0Sriastradh *
302efa246c0Sriastradh * Note that the drm gem/prime core does not depend upon drivers setting
303efa246c0Sriastradh * this field any more. So for drivers where this doesn't make sense
304efa246c0Sriastradh * (e.g. virtual devices or a displaylink behind an usb bus) they can
305efa246c0Sriastradh * simply leave it as NULL.
306efa246c0Sriastradh */
307efa246c0Sriastradh struct dma_buf_attachment *import_attach;
30841ec0267Sriastradh
30941ec0267Sriastradh /**
31041ec0267Sriastradh * @resv:
31141ec0267Sriastradh *
31241ec0267Sriastradh * Pointer to reservation object associated with the this GEM object.
31341ec0267Sriastradh *
31441ec0267Sriastradh * Normally (@resv == &@_resv) except for imported GEM objects.
31541ec0267Sriastradh */
31641ec0267Sriastradh struct dma_resv *resv;
31741ec0267Sriastradh
31841ec0267Sriastradh /**
31941ec0267Sriastradh * @_resv:
32041ec0267Sriastradh *
32141ec0267Sriastradh * A reservation object for this GEM object.
32241ec0267Sriastradh *
32341ec0267Sriastradh * This is unused for imported GEM objects.
32441ec0267Sriastradh */
32541ec0267Sriastradh struct dma_resv _resv;
32641ec0267Sriastradh
32741ec0267Sriastradh /**
32841ec0267Sriastradh * @funcs:
32941ec0267Sriastradh *
33041ec0267Sriastradh * Optional GEM object functions. If this is set, it will be used instead of the
33141ec0267Sriastradh * corresponding &drm_driver GEM callbacks.
33241ec0267Sriastradh *
33341ec0267Sriastradh * New drivers should use this.
33441ec0267Sriastradh *
33541ec0267Sriastradh */
33641ec0267Sriastradh const struct drm_gem_object_funcs *funcs;
337efa246c0Sriastradh };
338efa246c0Sriastradh
33941ec0267Sriastradh /**
34041ec0267Sriastradh * DEFINE_DRM_GEM_FOPS() - macro to generate file operations for GEM drivers
34141ec0267Sriastradh * @name: name for the generated structure
34241ec0267Sriastradh *
34341ec0267Sriastradh * This macro autogenerates a suitable &struct file_operations for GEM based
34441ec0267Sriastradh * drivers, which can be assigned to &drm_driver.fops. Note that this structure
34541ec0267Sriastradh * cannot be shared between drivers, because it contains a reference to the
34641ec0267Sriastradh * current module using THIS_MODULE.
34741ec0267Sriastradh *
34841ec0267Sriastradh * Note that the declaration is already marked as static - if you need a
34941ec0267Sriastradh * non-static version of this you're probably doing it wrong and will break the
35041ec0267Sriastradh * THIS_MODULE reference by accident.
35141ec0267Sriastradh */
35241ec0267Sriastradh #define DEFINE_DRM_GEM_FOPS(name) \
35341ec0267Sriastradh static const struct file_operations name = {\
35441ec0267Sriastradh .owner = THIS_MODULE,\
35541ec0267Sriastradh .open = drm_open,\
35641ec0267Sriastradh .release = drm_release,\
35741ec0267Sriastradh .unlocked_ioctl = drm_ioctl,\
35841ec0267Sriastradh .compat_ioctl = drm_compat_ioctl,\
35941ec0267Sriastradh .poll = drm_poll,\
36041ec0267Sriastradh .read = drm_read,\
36141ec0267Sriastradh .llseek = noop_llseek,\
36241ec0267Sriastradh .mmap = drm_gem_mmap,\
36341ec0267Sriastradh }
36441ec0267Sriastradh
365efa246c0Sriastradh void drm_gem_object_release(struct drm_gem_object *obj);
366efa246c0Sriastradh void drm_gem_object_free(struct kref *kref);
367efa246c0Sriastradh int drm_gem_object_init(struct drm_device *dev,
368efa246c0Sriastradh struct drm_gem_object *obj, size_t size);
369efa246c0Sriastradh void drm_gem_private_object_init(struct drm_device *dev,
370efa246c0Sriastradh struct drm_gem_object *obj, size_t size);
371d01ac146Sriastradh #ifdef __NetBSD__
372d01ac146Sriastradh void drm_gem_pager_reference(struct uvm_object *);
373d01ac146Sriastradh void drm_gem_pager_detach(struct uvm_object *);
374d01ac146Sriastradh int drm_gem_mmap_object(struct drm_device *, off_t, size_t, int,
375d01ac146Sriastradh struct uvm_object **, voff_t *, struct file *);
376d01ac146Sriastradh int drm_gem_or_legacy_mmap_object(struct drm_device *, off_t, size_t, int,
377d01ac146Sriastradh struct uvm_object **, voff_t *, struct file *);
378d01ac146Sriastradh #else
379efa246c0Sriastradh void drm_gem_vm_open(struct vm_area_struct *vma);
380efa246c0Sriastradh void drm_gem_vm_close(struct vm_area_struct *vma);
381efa246c0Sriastradh int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
382efa246c0Sriastradh struct vm_area_struct *vma);
383efa246c0Sriastradh int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
384d01ac146Sriastradh #endif
385efa246c0Sriastradh
38641ec0267Sriastradh /**
38741ec0267Sriastradh * drm_gem_object_get - acquire a GEM buffer object reference
38841ec0267Sriastradh * @obj: GEM buffer object
38941ec0267Sriastradh *
39041ec0267Sriastradh * This function acquires an additional reference to @obj. It is illegal to
39141ec0267Sriastradh * call this without already holding a reference. No locks required.
39241ec0267Sriastradh */
drm_gem_object_get(struct drm_gem_object * obj)39341ec0267Sriastradh static inline void drm_gem_object_get(struct drm_gem_object *obj)
394efa246c0Sriastradh {
395efa246c0Sriastradh kref_get(&obj->refcount);
396efa246c0Sriastradh }
397efa246c0Sriastradh
39841ec0267Sriastradh /**
39941ec0267Sriastradh * __drm_gem_object_put - raw function to release a GEM buffer object reference
40041ec0267Sriastradh * @obj: GEM buffer object
40141ec0267Sriastradh *
40241ec0267Sriastradh * This function is meant to be used by drivers which are not encumbered with
40341ec0267Sriastradh * &drm_device.struct_mutex legacy locking and which are using the
40441ec0267Sriastradh * gem_free_object_unlocked callback. It avoids all the locking checks and
40541ec0267Sriastradh * locking overhead of drm_gem_object_put() and drm_gem_object_put_unlocked().
40641ec0267Sriastradh *
40741ec0267Sriastradh * Drivers should never call this directly in their code. Instead they should
40841ec0267Sriastradh * wrap it up into a ``driver_gem_object_put(struct driver_gem_object *obj)``
40941ec0267Sriastradh * wrapper function, and use that. Shared code should never call this, to
41041ec0267Sriastradh * avoid breaking drivers by accident which still depend upon
41141ec0267Sriastradh * &drm_device.struct_mutex locking.
41241ec0267Sriastradh */
413efa246c0Sriastradh static inline void
__drm_gem_object_put(struct drm_gem_object * obj)41441ec0267Sriastradh __drm_gem_object_put(struct drm_gem_object *obj)
415efa246c0Sriastradh {
416efa246c0Sriastradh kref_put(&obj->refcount, drm_gem_object_free);
417efa246c0Sriastradh }
418efa246c0Sriastradh
41941ec0267Sriastradh void drm_gem_object_put_unlocked(struct drm_gem_object *obj);
42041ec0267Sriastradh void drm_gem_object_put(struct drm_gem_object *obj);
421efa246c0Sriastradh
422efa246c0Sriastradh int drm_gem_handle_create(struct drm_file *file_priv,
423efa246c0Sriastradh struct drm_gem_object *obj,
424efa246c0Sriastradh u32 *handlep);
425efa246c0Sriastradh int drm_gem_handle_delete(struct drm_file *filp, u32 handle);
426efa246c0Sriastradh
427efa246c0Sriastradh
428efa246c0Sriastradh void drm_gem_free_mmap_offset(struct drm_gem_object *obj);
429efa246c0Sriastradh int drm_gem_create_mmap_offset(struct drm_gem_object *obj);
430efa246c0Sriastradh int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size);
431efa246c0Sriastradh
432efa246c0Sriastradh struct page **drm_gem_get_pages(struct drm_gem_object *obj);
433efa246c0Sriastradh void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages,
434efa246c0Sriastradh bool dirty, bool accessed);
435efa246c0Sriastradh
43641ec0267Sriastradh int drm_gem_objects_lookup(struct drm_file *filp, void __user *bo_handles,
43741ec0267Sriastradh int count, struct drm_gem_object ***objs_out);
43841ec0267Sriastradh struct drm_gem_object *drm_gem_object_lookup(struct drm_file *filp, u32 handle);
43941ec0267Sriastradh long drm_gem_dma_resv_wait(struct drm_file *filep, u32 handle,
44041ec0267Sriastradh bool wait_all, unsigned long timeout);
44141ec0267Sriastradh int drm_gem_lock_reservations(struct drm_gem_object **objs, int count,
44241ec0267Sriastradh struct ww_acquire_ctx *acquire_ctx);
44341ec0267Sriastradh void drm_gem_unlock_reservations(struct drm_gem_object **objs, int count,
44441ec0267Sriastradh struct ww_acquire_ctx *acquire_ctx);
44541ec0267Sriastradh int drm_gem_fence_array_add(struct xarray *fence_array,
44641ec0267Sriastradh struct dma_fence *fence);
44741ec0267Sriastradh int drm_gem_fence_array_add_implicit(struct xarray *fence_array,
44841ec0267Sriastradh struct drm_gem_object *obj,
44941ec0267Sriastradh bool write);
45041ec0267Sriastradh int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
45141ec0267Sriastradh u32 handle, u64 *offset);
452efa246c0Sriastradh int drm_gem_dumb_destroy(struct drm_file *file,
453efa246c0Sriastradh struct drm_device *dev,
454efa246c0Sriastradh uint32_t handle);
455efa246c0Sriastradh
456b8e5703dSriastradh #define free(addr, type) kern_free(addr)
457b8e5703dSriastradh
458efa246c0Sriastradh #endif /* __DRM_GEM_H__ */
459