/** * drm_gem_cma_prime_mmap - memory-map an exported CMA GEM object * @obj: GEM object * @vma: VMA for the area to be mapped * * This function maps a buffer imported via DRM PRIME into a userspace * process's address space. Drivers that use the CMA helpers should set this * as their DRM driver's ->gem_prime_mmap() callback. * * Returns: * 0 on success or a negative error code on failure. */ int drm_gem_cma_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) { struct drm_gem_cma_object *cma_obj; int ret; ret = drm_gem_mmap_obj(obj, obj->size, vma); if (ret < 0) return ret; cma_obj = to_drm_gem_cma_obj(obj); return drm_gem_cma_mmap_obj(cma_obj, vma); }
/** * drm_gem_cma_mmap - memory-map a CMA GEM object * @filp: file object * @vma: VMA for the area to be mapped * * This function implements an augmented version of the GEM DRM file mmap * operation for CMA objects: In addition to the usual GEM VMA setup it * immediately faults in the entire object instead of using on-demaind * faulting. Drivers which employ the CMA helpers should use this function * as their ->mmap() handler in the DRM device file's file_operations * structure. * * Returns: * 0 on success or a negative error code on failure. */ int drm_gem_cma_mmap(struct file *filp, struct vm_area_struct *vma) { struct drm_gem_cma_object *cma_obj; struct drm_gem_object *gem_obj; int ret; ret = drm_gem_mmap(filp, vma); if (ret) return ret; gem_obj = vma->vm_private_data; cma_obj = to_drm_gem_cma_obj(gem_obj); return drm_gem_cma_mmap_obj(cma_obj, vma); }
/** * drm_gem_cma_prime_mmap - memory-map an exported CMA GEM object * @obj: GEM object * @vma: VMA for the area to be mapped * * This function maps a buffer imported via DRM PRIME into a userspace * process's address space. Drivers that use the CMA helpers should set this * as their DRM driver's ->gem_prime_mmap() callback. * * Returns: * 0 on success or a negative error code on failure. */ int drm_gem_cma_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) { struct drm_gem_cma_object *cma_obj; struct drm_device *dev = obj->dev; int ret; mutex_lock(&dev->struct_mutex); ret = drm_gem_mmap_obj(obj, obj->size, vma); mutex_unlock(&dev->struct_mutex); if (ret < 0) return ret; cma_obj = to_drm_gem_cma_obj(obj); return drm_gem_cma_mmap_obj(cma_obj, vma); }