---
name: "drm_gem_mmap_obj"
section: "9"
platform: "linux"
package: "linux-manual-3.16"
version: "3.16.56-1+deb8u1"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/drm_gem_mmap_obj"
---

# drm\_gem\_mmap\_obj(9)

memory map a GEM object

## NAME

drm\_gem\_mmap\_obj - memory map a GEM object

## SYNOPSIS

**int drm\_gem\_mmap\_obj(struct drm\_gem\_object \*** *obj***, unsigned long** *obj\_size***, struct vm\_area\_struct \*** *vma***);**

## ARGUMENTS

*obj*

the GEM object to map

*obj\_size*

the object size to be mapped, in bytes

*vma*

VMA for the area to be mapped

## DESCRIPTION

Set up the VMA to prepare mapping of the GEM object using the gem\_vm\_ops provided by the driver. Depending on their requirements, drivers can either provide a fault handler in their gem\_vm\_ops (in which case any accesses to the object will be trapped, to perform migration, GTT binding, surface register allocation, or performance monitoring), or mmap the buffer memory synchronously after calling drm\_gem\_mmap\_obj.

This function is mainly intended to implement the DMABUF mmap operation, when the GEM object is not looked up based on its fake offset. To implement the DRM mmap operation, drivers should use the **drm\_gem\_mmap** function.

**drm\_gem\_mmap\_obj** assumes the user is granted access to the buffer while **drm\_gem\_mmap** prevents unprivileged users from mapping random objects. So callers must verify access restrictions before calling this helper.

## NOTE

This function has to be protected with dev-\>struct\_mutex

Return 0 or success or -EINVAL if the object size is smaller than the VMA size, or if no gem\_vm\_ops are provided.

## AUTHORS

**Jesse Barnes** \<jesse.barnes@intel.com\>\
 Intel Corporation,

Initial version

**Laurent Pinchart** \<laurent.pinchart@ideasonboard.com\>\
 Ideas on board SPRL,

Driver internals

**Daniel Vetter** \<daniel.vetter@ffwll.ch\>\
 Intel Corporation,

Contributions all over the place

## COPYRIGHT
