18c2ecf20Sopenharmony_ci#ifndef __DRM_GEM_H__ 28c2ecf20Sopenharmony_ci#define __DRM_GEM_H__ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci/* 58c2ecf20Sopenharmony_ci * GEM Graphics Execution Manager Driver Interfaces 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 88c2ecf20Sopenharmony_ci * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 98c2ecf20Sopenharmony_ci * Copyright (c) 2009-2010, Code Aurora Forum. 108c2ecf20Sopenharmony_ci * All rights reserved. 118c2ecf20Sopenharmony_ci * Copyright © 2014 Intel Corporation 128c2ecf20Sopenharmony_ci * Daniel Vetter <daniel.vetter@ffwll.ch> 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * Author: Rickard E. (Rik) Faith <faith@valinux.com> 158c2ecf20Sopenharmony_ci * Author: Gareth Hughes <gareth@valinux.com> 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 188c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 198c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 208c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 218c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 228c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice (including the next 258c2ecf20Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 268c2ecf20Sopenharmony_ci * Software. 278c2ecf20Sopenharmony_ci * 288c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 298c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 308c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 318c2ecf20Sopenharmony_ci * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 328c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 338c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 348c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 358c2ecf20Sopenharmony_ci */ 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#include <linux/kref.h> 388c2ecf20Sopenharmony_ci#include <linux/dma-resv.h> 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#include <drm/drm_vma_manager.h> 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistruct drm_gem_object; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/** 458c2ecf20Sopenharmony_ci * struct drm_gem_object_funcs - GEM object functions 468c2ecf20Sopenharmony_ci */ 478c2ecf20Sopenharmony_cistruct drm_gem_object_funcs { 488c2ecf20Sopenharmony_ci /** 498c2ecf20Sopenharmony_ci * @free: 508c2ecf20Sopenharmony_ci * 518c2ecf20Sopenharmony_ci * Deconstructor for drm_gem_objects. 528c2ecf20Sopenharmony_ci * 538c2ecf20Sopenharmony_ci * This callback is mandatory. 548c2ecf20Sopenharmony_ci */ 558c2ecf20Sopenharmony_ci void (*free)(struct drm_gem_object *obj); 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci /** 588c2ecf20Sopenharmony_ci * @open: 598c2ecf20Sopenharmony_ci * 608c2ecf20Sopenharmony_ci * Called upon GEM handle creation. 618c2ecf20Sopenharmony_ci * 628c2ecf20Sopenharmony_ci * This callback is optional. 638c2ecf20Sopenharmony_ci */ 648c2ecf20Sopenharmony_ci int (*open)(struct drm_gem_object *obj, struct drm_file *file); 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci /** 678c2ecf20Sopenharmony_ci * @close: 688c2ecf20Sopenharmony_ci * 698c2ecf20Sopenharmony_ci * Called upon GEM handle release. 708c2ecf20Sopenharmony_ci * 718c2ecf20Sopenharmony_ci * This callback is optional. 728c2ecf20Sopenharmony_ci */ 738c2ecf20Sopenharmony_ci void (*close)(struct drm_gem_object *obj, struct drm_file *file); 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci /** 768c2ecf20Sopenharmony_ci * @print_info: 778c2ecf20Sopenharmony_ci * 788c2ecf20Sopenharmony_ci * If driver subclasses struct &drm_gem_object, it can implement this 798c2ecf20Sopenharmony_ci * optional hook for printing additional driver specific info. 808c2ecf20Sopenharmony_ci * 818c2ecf20Sopenharmony_ci * drm_printf_indent() should be used in the callback passing it the 828c2ecf20Sopenharmony_ci * indent argument. 838c2ecf20Sopenharmony_ci * 848c2ecf20Sopenharmony_ci * This callback is called from drm_gem_print_info(). 858c2ecf20Sopenharmony_ci * 868c2ecf20Sopenharmony_ci * This callback is optional. 878c2ecf20Sopenharmony_ci */ 888c2ecf20Sopenharmony_ci void (*print_info)(struct drm_printer *p, unsigned int indent, 898c2ecf20Sopenharmony_ci const struct drm_gem_object *obj); 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci /** 928c2ecf20Sopenharmony_ci * @export: 938c2ecf20Sopenharmony_ci * 948c2ecf20Sopenharmony_ci * Export backing buffer as a &dma_buf. 958c2ecf20Sopenharmony_ci * If this is not set drm_gem_prime_export() is used. 968c2ecf20Sopenharmony_ci * 978c2ecf20Sopenharmony_ci * This callback is optional. 988c2ecf20Sopenharmony_ci */ 998c2ecf20Sopenharmony_ci struct dma_buf *(*export)(struct drm_gem_object *obj, int flags); 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci /** 1028c2ecf20Sopenharmony_ci * @pin: 1038c2ecf20Sopenharmony_ci * 1048c2ecf20Sopenharmony_ci * Pin backing buffer in memory. Used by the drm_gem_map_attach() helper. 1058c2ecf20Sopenharmony_ci * 1068c2ecf20Sopenharmony_ci * This callback is optional. 1078c2ecf20Sopenharmony_ci */ 1088c2ecf20Sopenharmony_ci int (*pin)(struct drm_gem_object *obj); 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci /** 1118c2ecf20Sopenharmony_ci * @unpin: 1128c2ecf20Sopenharmony_ci * 1138c2ecf20Sopenharmony_ci * Unpin backing buffer. Used by the drm_gem_map_detach() helper. 1148c2ecf20Sopenharmony_ci * 1158c2ecf20Sopenharmony_ci * This callback is optional. 1168c2ecf20Sopenharmony_ci */ 1178c2ecf20Sopenharmony_ci void (*unpin)(struct drm_gem_object *obj); 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci /** 1208c2ecf20Sopenharmony_ci * @get_sg_table: 1218c2ecf20Sopenharmony_ci * 1228c2ecf20Sopenharmony_ci * Returns a Scatter-Gather table representation of the buffer. 1238c2ecf20Sopenharmony_ci * Used when exporting a buffer by the drm_gem_map_dma_buf() helper. 1248c2ecf20Sopenharmony_ci * Releasing is done by calling dma_unmap_sg_attrs() and sg_free_table() 1258c2ecf20Sopenharmony_ci * in drm_gem_unmap_buf(), therefore these helpers and this callback 1268c2ecf20Sopenharmony_ci * here cannot be used for sg tables pointing at driver private memory 1278c2ecf20Sopenharmony_ci * ranges. 1288c2ecf20Sopenharmony_ci * 1298c2ecf20Sopenharmony_ci * See also drm_prime_pages_to_sg(). 1308c2ecf20Sopenharmony_ci */ 1318c2ecf20Sopenharmony_ci struct sg_table *(*get_sg_table)(struct drm_gem_object *obj); 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci /** 1348c2ecf20Sopenharmony_ci * @vmap: 1358c2ecf20Sopenharmony_ci * 1368c2ecf20Sopenharmony_ci * Returns a virtual address for the buffer. Used by the 1378c2ecf20Sopenharmony_ci * drm_gem_dmabuf_vmap() helper. 1388c2ecf20Sopenharmony_ci * 1398c2ecf20Sopenharmony_ci * This callback is optional. 1408c2ecf20Sopenharmony_ci */ 1418c2ecf20Sopenharmony_ci void *(*vmap)(struct drm_gem_object *obj); 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci /** 1448c2ecf20Sopenharmony_ci * @vunmap: 1458c2ecf20Sopenharmony_ci * 1468c2ecf20Sopenharmony_ci * Releases the address previously returned by @vmap. Used by the 1478c2ecf20Sopenharmony_ci * drm_gem_dmabuf_vunmap() helper. 1488c2ecf20Sopenharmony_ci * 1498c2ecf20Sopenharmony_ci * This callback is optional. 1508c2ecf20Sopenharmony_ci */ 1518c2ecf20Sopenharmony_ci void (*vunmap)(struct drm_gem_object *obj, void *vaddr); 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci /** 1548c2ecf20Sopenharmony_ci * @mmap: 1558c2ecf20Sopenharmony_ci * 1568c2ecf20Sopenharmony_ci * Handle mmap() of the gem object, setup vma accordingly. 1578c2ecf20Sopenharmony_ci * 1588c2ecf20Sopenharmony_ci * This callback is optional. 1598c2ecf20Sopenharmony_ci * 1608c2ecf20Sopenharmony_ci * The callback is used by both drm_gem_mmap_obj() and 1618c2ecf20Sopenharmony_ci * drm_gem_prime_mmap(). When @mmap is present @vm_ops is not 1628c2ecf20Sopenharmony_ci * used, the @mmap callback must set vma->vm_ops instead. 1638c2ecf20Sopenharmony_ci */ 1648c2ecf20Sopenharmony_ci int (*mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma); 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci /** 1678c2ecf20Sopenharmony_ci * @vm_ops: 1688c2ecf20Sopenharmony_ci * 1698c2ecf20Sopenharmony_ci * Virtual memory operations used with mmap. 1708c2ecf20Sopenharmony_ci * 1718c2ecf20Sopenharmony_ci * This is optional but necessary for mmap support. 1728c2ecf20Sopenharmony_ci */ 1738c2ecf20Sopenharmony_ci const struct vm_operations_struct *vm_ops; 1748c2ecf20Sopenharmony_ci}; 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci/** 1778c2ecf20Sopenharmony_ci * struct drm_gem_object - GEM buffer object 1788c2ecf20Sopenharmony_ci * 1798c2ecf20Sopenharmony_ci * This structure defines the generic parts for GEM buffer objects, which are 1808c2ecf20Sopenharmony_ci * mostly around handling mmap and userspace handles. 1818c2ecf20Sopenharmony_ci * 1828c2ecf20Sopenharmony_ci * Buffer objects are often abbreviated to BO. 1838c2ecf20Sopenharmony_ci */ 1848c2ecf20Sopenharmony_cistruct drm_gem_object { 1858c2ecf20Sopenharmony_ci /** 1868c2ecf20Sopenharmony_ci * @refcount: 1878c2ecf20Sopenharmony_ci * 1888c2ecf20Sopenharmony_ci * Reference count of this object 1898c2ecf20Sopenharmony_ci * 1908c2ecf20Sopenharmony_ci * Please use drm_gem_object_get() to acquire and drm_gem_object_put_locked() 1918c2ecf20Sopenharmony_ci * or drm_gem_object_put() to release a reference to a GEM 1928c2ecf20Sopenharmony_ci * buffer object. 1938c2ecf20Sopenharmony_ci */ 1948c2ecf20Sopenharmony_ci struct kref refcount; 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci /** 1978c2ecf20Sopenharmony_ci * @handle_count: 1988c2ecf20Sopenharmony_ci * 1998c2ecf20Sopenharmony_ci * This is the GEM file_priv handle count of this object. 2008c2ecf20Sopenharmony_ci * 2018c2ecf20Sopenharmony_ci * Each handle also holds a reference. Note that when the handle_count 2028c2ecf20Sopenharmony_ci * drops to 0 any global names (e.g. the id in the flink namespace) will 2038c2ecf20Sopenharmony_ci * be cleared. 2048c2ecf20Sopenharmony_ci * 2058c2ecf20Sopenharmony_ci * Protected by &drm_device.object_name_lock. 2068c2ecf20Sopenharmony_ci */ 2078c2ecf20Sopenharmony_ci unsigned handle_count; 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci /** 2108c2ecf20Sopenharmony_ci * @dev: DRM dev this object belongs to. 2118c2ecf20Sopenharmony_ci */ 2128c2ecf20Sopenharmony_ci struct drm_device *dev; 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci /** 2158c2ecf20Sopenharmony_ci * @filp: 2168c2ecf20Sopenharmony_ci * 2178c2ecf20Sopenharmony_ci * SHMEM file node used as backing storage for swappable buffer objects. 2188c2ecf20Sopenharmony_ci * GEM also supports driver private objects with driver-specific backing 2198c2ecf20Sopenharmony_ci * storage (contiguous CMA memory, special reserved blocks). In this 2208c2ecf20Sopenharmony_ci * case @filp is NULL. 2218c2ecf20Sopenharmony_ci */ 2228c2ecf20Sopenharmony_ci struct file *filp; 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci /** 2258c2ecf20Sopenharmony_ci * @vma_node: 2268c2ecf20Sopenharmony_ci * 2278c2ecf20Sopenharmony_ci * Mapping info for this object to support mmap. Drivers are supposed to 2288c2ecf20Sopenharmony_ci * allocate the mmap offset using drm_gem_create_mmap_offset(). The 2298c2ecf20Sopenharmony_ci * offset itself can be retrieved using drm_vma_node_offset_addr(). 2308c2ecf20Sopenharmony_ci * 2318c2ecf20Sopenharmony_ci * Memory mapping itself is handled by drm_gem_mmap(), which also checks 2328c2ecf20Sopenharmony_ci * that userspace is allowed to access the object. 2338c2ecf20Sopenharmony_ci */ 2348c2ecf20Sopenharmony_ci struct drm_vma_offset_node vma_node; 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci /** 2378c2ecf20Sopenharmony_ci * @size: 2388c2ecf20Sopenharmony_ci * 2398c2ecf20Sopenharmony_ci * Size of the object, in bytes. Immutable over the object's 2408c2ecf20Sopenharmony_ci * lifetime. 2418c2ecf20Sopenharmony_ci */ 2428c2ecf20Sopenharmony_ci size_t size; 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci /** 2458c2ecf20Sopenharmony_ci * @name: 2468c2ecf20Sopenharmony_ci * 2478c2ecf20Sopenharmony_ci * Global name for this object, starts at 1. 0 means unnamed. 2488c2ecf20Sopenharmony_ci * Access is covered by &drm_device.object_name_lock. This is used by 2498c2ecf20Sopenharmony_ci * the GEM_FLINK and GEM_OPEN ioctls. 2508c2ecf20Sopenharmony_ci */ 2518c2ecf20Sopenharmony_ci int name; 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_ci /** 2548c2ecf20Sopenharmony_ci * @dma_buf: 2558c2ecf20Sopenharmony_ci * 2568c2ecf20Sopenharmony_ci * dma-buf associated with this GEM object. 2578c2ecf20Sopenharmony_ci * 2588c2ecf20Sopenharmony_ci * Pointer to the dma-buf associated with this gem object (either 2598c2ecf20Sopenharmony_ci * through importing or exporting). We break the resulting reference 2608c2ecf20Sopenharmony_ci * loop when the last gem handle for this object is released. 2618c2ecf20Sopenharmony_ci * 2628c2ecf20Sopenharmony_ci * Protected by &drm_device.object_name_lock. 2638c2ecf20Sopenharmony_ci */ 2648c2ecf20Sopenharmony_ci struct dma_buf *dma_buf; 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci /** 2678c2ecf20Sopenharmony_ci * @import_attach: 2688c2ecf20Sopenharmony_ci * 2698c2ecf20Sopenharmony_ci * dma-buf attachment backing this object. 2708c2ecf20Sopenharmony_ci * 2718c2ecf20Sopenharmony_ci * Any foreign dma_buf imported as a gem object has this set to the 2728c2ecf20Sopenharmony_ci * attachment point for the device. This is invariant over the lifetime 2738c2ecf20Sopenharmony_ci * of a gem object. 2748c2ecf20Sopenharmony_ci * 2758c2ecf20Sopenharmony_ci * The &drm_driver.gem_free_object_unlocked callback is responsible for 2768c2ecf20Sopenharmony_ci * cleaning up the dma_buf attachment and references acquired at import 2778c2ecf20Sopenharmony_ci * time. 2788c2ecf20Sopenharmony_ci * 2798c2ecf20Sopenharmony_ci * Note that the drm gem/prime core does not depend upon drivers setting 2808c2ecf20Sopenharmony_ci * this field any more. So for drivers where this doesn't make sense 2818c2ecf20Sopenharmony_ci * (e.g. virtual devices or a displaylink behind an usb bus) they can 2828c2ecf20Sopenharmony_ci * simply leave it as NULL. 2838c2ecf20Sopenharmony_ci */ 2848c2ecf20Sopenharmony_ci struct dma_buf_attachment *import_attach; 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci /** 2878c2ecf20Sopenharmony_ci * @resv: 2888c2ecf20Sopenharmony_ci * 2898c2ecf20Sopenharmony_ci * Pointer to reservation object associated with the this GEM object. 2908c2ecf20Sopenharmony_ci * 2918c2ecf20Sopenharmony_ci * Normally (@resv == &@_resv) except for imported GEM objects. 2928c2ecf20Sopenharmony_ci */ 2938c2ecf20Sopenharmony_ci struct dma_resv *resv; 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ci /** 2968c2ecf20Sopenharmony_ci * @_resv: 2978c2ecf20Sopenharmony_ci * 2988c2ecf20Sopenharmony_ci * A reservation object for this GEM object. 2998c2ecf20Sopenharmony_ci * 3008c2ecf20Sopenharmony_ci * This is unused for imported GEM objects. 3018c2ecf20Sopenharmony_ci */ 3028c2ecf20Sopenharmony_ci struct dma_resv _resv; 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci /** 3058c2ecf20Sopenharmony_ci * @funcs: 3068c2ecf20Sopenharmony_ci * 3078c2ecf20Sopenharmony_ci * Optional GEM object functions. If this is set, it will be used instead of the 3088c2ecf20Sopenharmony_ci * corresponding &drm_driver GEM callbacks. 3098c2ecf20Sopenharmony_ci * 3108c2ecf20Sopenharmony_ci * New drivers should use this. 3118c2ecf20Sopenharmony_ci * 3128c2ecf20Sopenharmony_ci */ 3138c2ecf20Sopenharmony_ci const struct drm_gem_object_funcs *funcs; 3148c2ecf20Sopenharmony_ci}; 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci/** 3178c2ecf20Sopenharmony_ci * DEFINE_DRM_GEM_FOPS() - macro to generate file operations for GEM drivers 3188c2ecf20Sopenharmony_ci * @name: name for the generated structure 3198c2ecf20Sopenharmony_ci * 3208c2ecf20Sopenharmony_ci * This macro autogenerates a suitable &struct file_operations for GEM based 3218c2ecf20Sopenharmony_ci * drivers, which can be assigned to &drm_driver.fops. Note that this structure 3228c2ecf20Sopenharmony_ci * cannot be shared between drivers, because it contains a reference to the 3238c2ecf20Sopenharmony_ci * current module using THIS_MODULE. 3248c2ecf20Sopenharmony_ci * 3258c2ecf20Sopenharmony_ci * Note that the declaration is already marked as static - if you need a 3268c2ecf20Sopenharmony_ci * non-static version of this you're probably doing it wrong and will break the 3278c2ecf20Sopenharmony_ci * THIS_MODULE reference by accident. 3288c2ecf20Sopenharmony_ci */ 3298c2ecf20Sopenharmony_ci#define DEFINE_DRM_GEM_FOPS(name) \ 3308c2ecf20Sopenharmony_ci static const struct file_operations name = {\ 3318c2ecf20Sopenharmony_ci .owner = THIS_MODULE,\ 3328c2ecf20Sopenharmony_ci .open = drm_open,\ 3338c2ecf20Sopenharmony_ci .release = drm_release,\ 3348c2ecf20Sopenharmony_ci .unlocked_ioctl = drm_ioctl,\ 3358c2ecf20Sopenharmony_ci .compat_ioctl = drm_compat_ioctl,\ 3368c2ecf20Sopenharmony_ci .poll = drm_poll,\ 3378c2ecf20Sopenharmony_ci .read = drm_read,\ 3388c2ecf20Sopenharmony_ci .llseek = noop_llseek,\ 3398c2ecf20Sopenharmony_ci .mmap = drm_gem_mmap,\ 3408c2ecf20Sopenharmony_ci } 3418c2ecf20Sopenharmony_ci 3428c2ecf20Sopenharmony_civoid drm_gem_object_release(struct drm_gem_object *obj); 3438c2ecf20Sopenharmony_civoid drm_gem_object_free(struct kref *kref); 3448c2ecf20Sopenharmony_ciint drm_gem_object_init(struct drm_device *dev, 3458c2ecf20Sopenharmony_ci struct drm_gem_object *obj, size_t size); 3468c2ecf20Sopenharmony_civoid drm_gem_private_object_init(struct drm_device *dev, 3478c2ecf20Sopenharmony_ci struct drm_gem_object *obj, size_t size); 3488c2ecf20Sopenharmony_civoid drm_gem_vm_open(struct vm_area_struct *vma); 3498c2ecf20Sopenharmony_civoid drm_gem_vm_close(struct vm_area_struct *vma); 3508c2ecf20Sopenharmony_ciint drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, 3518c2ecf20Sopenharmony_ci struct vm_area_struct *vma); 3528c2ecf20Sopenharmony_ciint drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ci/** 3558c2ecf20Sopenharmony_ci * drm_gem_object_get - acquire a GEM buffer object reference 3568c2ecf20Sopenharmony_ci * @obj: GEM buffer object 3578c2ecf20Sopenharmony_ci * 3588c2ecf20Sopenharmony_ci * This function acquires an additional reference to @obj. It is illegal to 3598c2ecf20Sopenharmony_ci * call this without already holding a reference. No locks required. 3608c2ecf20Sopenharmony_ci */ 3618c2ecf20Sopenharmony_cistatic inline void drm_gem_object_get(struct drm_gem_object *obj) 3628c2ecf20Sopenharmony_ci{ 3638c2ecf20Sopenharmony_ci kref_get(&obj->refcount); 3648c2ecf20Sopenharmony_ci} 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci__attribute__((nonnull)) 3678c2ecf20Sopenharmony_cistatic inline void 3688c2ecf20Sopenharmony_ci__drm_gem_object_put(struct drm_gem_object *obj) 3698c2ecf20Sopenharmony_ci{ 3708c2ecf20Sopenharmony_ci kref_put(&obj->refcount, drm_gem_object_free); 3718c2ecf20Sopenharmony_ci} 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_ci/** 3748c2ecf20Sopenharmony_ci * drm_gem_object_put - drop a GEM buffer object reference 3758c2ecf20Sopenharmony_ci * @obj: GEM buffer object 3768c2ecf20Sopenharmony_ci * 3778c2ecf20Sopenharmony_ci * This releases a reference to @obj. 3788c2ecf20Sopenharmony_ci */ 3798c2ecf20Sopenharmony_cistatic inline void 3808c2ecf20Sopenharmony_cidrm_gem_object_put(struct drm_gem_object *obj) 3818c2ecf20Sopenharmony_ci{ 3828c2ecf20Sopenharmony_ci if (obj) 3838c2ecf20Sopenharmony_ci __drm_gem_object_put(obj); 3848c2ecf20Sopenharmony_ci} 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_civoid drm_gem_object_put_locked(struct drm_gem_object *obj); 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_ciint drm_gem_handle_create(struct drm_file *file_priv, 3898c2ecf20Sopenharmony_ci struct drm_gem_object *obj, 3908c2ecf20Sopenharmony_ci u32 *handlep); 3918c2ecf20Sopenharmony_ciint drm_gem_handle_delete(struct drm_file *filp, u32 handle); 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_civoid drm_gem_free_mmap_offset(struct drm_gem_object *obj); 3958c2ecf20Sopenharmony_ciint drm_gem_create_mmap_offset(struct drm_gem_object *obj); 3968c2ecf20Sopenharmony_ciint drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size); 3978c2ecf20Sopenharmony_ci 3988c2ecf20Sopenharmony_cistruct page **drm_gem_get_pages(struct drm_gem_object *obj); 3998c2ecf20Sopenharmony_civoid drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages, 4008c2ecf20Sopenharmony_ci bool dirty, bool accessed); 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_ciint drm_gem_objects_lookup(struct drm_file *filp, void __user *bo_handles, 4038c2ecf20Sopenharmony_ci int count, struct drm_gem_object ***objs_out); 4048c2ecf20Sopenharmony_cistruct drm_gem_object *drm_gem_object_lookup(struct drm_file *filp, u32 handle); 4058c2ecf20Sopenharmony_cilong drm_gem_dma_resv_wait(struct drm_file *filep, u32 handle, 4068c2ecf20Sopenharmony_ci bool wait_all, unsigned long timeout); 4078c2ecf20Sopenharmony_ciint drm_gem_lock_reservations(struct drm_gem_object **objs, int count, 4088c2ecf20Sopenharmony_ci struct ww_acquire_ctx *acquire_ctx); 4098c2ecf20Sopenharmony_civoid drm_gem_unlock_reservations(struct drm_gem_object **objs, int count, 4108c2ecf20Sopenharmony_ci struct ww_acquire_ctx *acquire_ctx); 4118c2ecf20Sopenharmony_ciint drm_gem_fence_array_add(struct xarray *fence_array, 4128c2ecf20Sopenharmony_ci struct dma_fence *fence); 4138c2ecf20Sopenharmony_ciint drm_gem_fence_array_add_implicit(struct xarray *fence_array, 4148c2ecf20Sopenharmony_ci struct drm_gem_object *obj, 4158c2ecf20Sopenharmony_ci bool write); 4168c2ecf20Sopenharmony_ciint drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev, 4178c2ecf20Sopenharmony_ci u32 handle, u64 *offset); 4188c2ecf20Sopenharmony_ciint drm_gem_dumb_destroy(struct drm_file *file, 4198c2ecf20Sopenharmony_ci struct drm_device *dev, 4208c2ecf20Sopenharmony_ci uint32_t handle); 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_ci#endif /* __DRM_GEM_H__ */ 423