Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v5.3-rc1 102 lines 2.9 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2 3#ifndef DRM_VRAM_MM_HELPER_H 4#define DRM_VRAM_MM_HELPER_H 5 6#include <drm/ttm/ttm_bo_driver.h> 7 8struct drm_device; 9 10/** 11 * struct drm_vram_mm_funcs - Callback functions for &struct drm_vram_mm 12 * @evict_flags: Provides an implementation for struct \ 13 &ttm_bo_driver.evict_flags 14 * @verify_access: Provides an implementation for \ 15 struct &ttm_bo_driver.verify_access 16 * 17 * These callback function integrate VRAM MM with TTM buffer objects. New 18 * functions can be added if necessary. 19 */ 20struct drm_vram_mm_funcs { 21 void (*evict_flags)(struct ttm_buffer_object *bo, 22 struct ttm_placement *placement); 23 int (*verify_access)(struct ttm_buffer_object *bo, struct file *filp); 24}; 25 26/** 27 * struct drm_vram_mm - An instance of VRAM MM 28 * @vram_base: Base address of the managed video memory 29 * @vram_size: Size of the managed video memory in bytes 30 * @bdev: The TTM BO device. 31 * @funcs: TTM BO functions 32 * 33 * The fields &struct drm_vram_mm.vram_base and 34 * &struct drm_vram_mm.vrm_size are managed by VRAM MM, but are 35 * available for public read access. Use the field 36 * &struct drm_vram_mm.bdev to access the TTM BO device. 37 */ 38struct drm_vram_mm { 39 uint64_t vram_base; 40 size_t vram_size; 41 42 struct ttm_bo_device bdev; 43 44 const struct drm_vram_mm_funcs *funcs; 45}; 46 47/** 48 * drm_vram_mm_of_bdev() - \ 49 Returns the container of type &struct ttm_bo_device for field bdev. 50 * @bdev: the TTM BO device 51 * 52 * Returns: 53 * The containing instance of &struct drm_vram_mm 54 */ 55static inline struct drm_vram_mm *drm_vram_mm_of_bdev( 56 struct ttm_bo_device *bdev) 57{ 58 return container_of(bdev, struct drm_vram_mm, bdev); 59} 60 61int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev, 62 uint64_t vram_base, size_t vram_size, 63 const struct drm_vram_mm_funcs *funcs); 64void drm_vram_mm_cleanup(struct drm_vram_mm *vmm); 65 66int drm_vram_mm_mmap(struct file *filp, struct vm_area_struct *vma, 67 struct drm_vram_mm *vmm); 68 69/* 70 * Helpers for integration with struct drm_device 71 */ 72 73struct drm_vram_mm *drm_vram_helper_alloc_mm( 74 struct drm_device *dev, uint64_t vram_base, size_t vram_size, 75 const struct drm_vram_mm_funcs *funcs); 76void drm_vram_helper_release_mm(struct drm_device *dev); 77 78/* 79 * Helpers for &struct file_operations 80 */ 81 82int drm_vram_mm_file_operations_mmap( 83 struct file *filp, struct vm_area_struct *vma); 84 85/** 86 * define DRM_VRAM_MM_FILE_OPERATIONS - default callback functions for \ 87 &struct file_operations 88 * 89 * Drivers that use VRAM MM can use this macro to initialize 90 * &struct file_operations with default functions. 91 */ 92#define DRM_VRAM_MM_FILE_OPERATIONS \ 93 .llseek = no_llseek, \ 94 .read = drm_read, \ 95 .poll = drm_poll, \ 96 .unlocked_ioctl = drm_ioctl, \ 97 .compat_ioctl = drm_compat_ioctl, \ 98 .mmap = drm_vram_mm_file_operations_mmap, \ 99 .open = drm_open, \ 100 .release = drm_release \ 101 102#endif