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

drm/gem-ttm-helper: Provide helper for struct drm_driver.dumb_map_offset

Provides an implementation of struct drm_driver.dumb_map_offset that
can be used by TTM-based GEM drivers.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20210408140139.27731-2-tzimmermann@suse.de

+37 -1
+33
drivers/gpu/drm/drm_gem_ttm_helper.c
··· 114 114 } 115 115 EXPORT_SYMBOL(drm_gem_ttm_mmap); 116 116 117 + /** 118 + * drm_gem_ttm_dumb_map_offset() - Implements struct &drm_driver.dumb_map_offset 119 + * @file: DRM file pointer. 120 + * @dev: DRM device. 121 + * @handle: GEM handle 122 + * @offset: Returns the mapping's memory offset on success 123 + * 124 + * Provides an implementation of struct &drm_driver.dumb_map_offset for 125 + * TTM-based GEM drivers. TTM allocates the offset internally and 126 + * drm_gem_ttm_dumb_map_offset() returns it for dumb-buffer implementations. 127 + * 128 + * See struct &drm_driver.dumb_map_offset. 129 + * 130 + * Returns: 131 + * 0 on success, or a negative errno code otherwise. 132 + */ 133 + int drm_gem_ttm_dumb_map_offset(struct drm_file *file, struct drm_device *dev, 134 + uint32_t handle, uint64_t *offset) 135 + { 136 + struct drm_gem_object *gem; 137 + 138 + gem = drm_gem_object_lookup(file, handle); 139 + if (!gem) 140 + return -ENOENT; 141 + 142 + *offset = drm_vma_node_offset_addr(&gem->vma_node); 143 + 144 + drm_gem_object_put(gem); 145 + 146 + return 0; 147 + } 148 + EXPORT_SYMBOL(drm_gem_ttm_dumb_map_offset); 149 + 117 150 MODULE_DESCRIPTION("DRM gem ttm helpers"); 118 151 MODULE_LICENSE("GPL");
+4 -1
include/drm/drm_gem_ttm_helper.h
··· 5 5 6 6 #include <linux/kernel.h> 7 7 8 - #include <drm/drm_gem.h> 9 8 #include <drm/drm_device.h> 9 + #include <drm/drm_gem.h> 10 10 #include <drm/ttm/ttm_bo_api.h> 11 11 #include <drm/ttm/ttm_bo_driver.h> 12 12 ··· 23 23 struct dma_buf_map *map); 24 24 int drm_gem_ttm_mmap(struct drm_gem_object *gem, 25 25 struct vm_area_struct *vma); 26 + 27 + int drm_gem_ttm_dumb_map_offset(struct drm_file *file, struct drm_device *dev, 28 + uint32_t handle, uint64_t *offset); 26 29 27 30 #endif