include/drm/drm_gem.h

Source file repositories/reference/linux-study-clean/include/drm/drm_gem.h

File Facts

System
Linux kernel
Corpus path
include/drm/drm_gem.h
Extension
.h
Size
20756 bytes
Lines
700
Domain
Repository Root And Misc
Bucket
include
Inferred role
Repository Root And Misc: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Top-level or miscellaneous repository surface. Use this as map coverage unless a later manual pass promotes the file into a deeper subsystem dossier.

Dependency Surface

Detected Declarations

Annotated Snippet

* This macro autogenerates a suitable &struct file_operations for GEM based
 * drivers, which can be assigned to &drm_driver.fops. Note that this structure
 * cannot be shared between drivers, because it contains a reference to the
 * current module using THIS_MODULE.
 *
 * Note that the declaration is already marked as static - if you need a
 * non-static version of this you're probably doing it wrong and will break the
 * THIS_MODULE reference by accident.
 */
#define DEFINE_DRM_GEM_FOPS(name) \
	static const struct file_operations name = {\
		.owner		= THIS_MODULE,\
		DRM_GEM_FOPS,\
	}

#ifdef CONFIG_TRANSPARENT_HUGEPAGE
int drm_gem_huge_mnt_create(struct drm_device *dev, const char *value);
#else
static inline int drm_gem_huge_mnt_create(struct drm_device *dev,
					  const char *value)
{
	return 0;
}
#endif

/**
 * drm_gem_get_huge_mnt - Get the huge tmpfs mountpoint used by a DRM device
 * @dev: DRM device
 *
 * This function gets the huge tmpfs mountpoint used by DRM device @dev. A huge
 * tmpfs mountpoint is used instead of `shm_mnt` after a successful call to
 * drm_gem_huge_mnt_create() when CONFIG_TRANSPARENT_HUGEPAGE is enabled.
 *
 * Returns:
 * The huge tmpfs mountpoint in use, NULL otherwise.
 */
static inline struct vfsmount *drm_gem_get_huge_mnt(struct drm_device *dev)
{
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
	return dev->huge_mnt;
#else
	return NULL;
#endif
}

void drm_gem_object_release(struct drm_gem_object *obj);
void drm_gem_object_free(struct kref *kref);
int drm_gem_object_init(struct drm_device *dev,
			struct drm_gem_object *obj, size_t size);
void drm_gem_private_object_init(struct drm_device *dev,
				 struct drm_gem_object *obj, size_t size);
void drm_gem_private_object_fini(struct drm_gem_object *obj);
void drm_gem_vm_open(struct vm_area_struct *vma);
void drm_gem_vm_close(struct vm_area_struct *vma);
int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
		     struct vm_area_struct *vma);
int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);

#ifdef CONFIG_MMU
unsigned long drm_gem_get_unmapped_area(struct file *filp, unsigned long uaddr,
					unsigned long len, unsigned long pgoff,
					unsigned long flags);
#else
#define drm_gem_get_unmapped_area NULL
#endif

/**
 * drm_gem_object_get - acquire a GEM buffer object reference
 * @obj: GEM buffer object
 *
 * This function acquires an additional reference to @obj. It is illegal to
 * call this without already holding a reference. No locks required.
 */
static inline void drm_gem_object_get(struct drm_gem_object *obj)
{
	kref_get(&obj->refcount);
}

__attribute__((nonnull))
static inline void
__drm_gem_object_put(struct drm_gem_object *obj)
{
	kref_put(&obj->refcount, drm_gem_object_free);
}

/**
 * drm_gem_object_put - drop a GEM buffer object reference
 * @obj: GEM buffer object
 *
 * This releases a reference to @obj.

Annotation

Implementation Notes