Commit d18ee06b authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/shmem-helper: Add .gem_create_object helper that sets map_cached flag

The helper drm_gem_shmem_create_object_cached() allocates an GEM SHMEM
object and sets the map_cached flag. Useful for drivers that want cached
mappings.

v3:
	* style fixes
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarEmil Velikov <emil.l.velikov@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200609090820.20256-2-tzimmermann@suse.de
parent ad0f449b
...@@ -460,6 +460,33 @@ bool drm_gem_shmem_purge(struct drm_gem_object *obj) ...@@ -460,6 +460,33 @@ bool drm_gem_shmem_purge(struct drm_gem_object *obj)
} }
EXPORT_SYMBOL(drm_gem_shmem_purge); EXPORT_SYMBOL(drm_gem_shmem_purge);
/**
* drm_gem_shmem_create_object_cached - Create a shmem buffer object with
* cached mappings
* @dev: DRM device
* @size: Size of the object to allocate
*
* By default, shmem buffer objects use writecombine mappings. This
* function implements struct drm_driver.gem_create_object for shmem
* buffer objects with cached mappings.
*
* Returns:
* A struct drm_gem_shmem_object * on success or NULL negative on failure.
*/
struct drm_gem_object *
drm_gem_shmem_create_object_cached(struct drm_device *dev, size_t size)
{
struct drm_gem_shmem_object *shmem;
shmem = kzalloc(sizeof(*shmem), GFP_KERNEL);
if (!shmem)
return NULL;
shmem->map_cached = true;
return &shmem->base;
}
EXPORT_SYMBOL(drm_gem_shmem_create_object_cached);
/** /**
* drm_gem_shmem_dumb_create - Create a dumb shmem buffer object * drm_gem_shmem_dumb_create - Create a dumb shmem buffer object
* @file: DRM file structure to create the dumb buffer for * @file: DRM file structure to create the dumb buffer for
......
...@@ -132,6 +132,10 @@ struct drm_gem_shmem_object * ...@@ -132,6 +132,10 @@ struct drm_gem_shmem_object *
drm_gem_shmem_create_with_handle(struct drm_file *file_priv, drm_gem_shmem_create_with_handle(struct drm_file *file_priv,
struct drm_device *dev, size_t size, struct drm_device *dev, size_t size,
uint32_t *handle); uint32_t *handle);
struct drm_gem_object *
drm_gem_shmem_create_object_cached(struct drm_device *dev, size_t size);
int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev, int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev,
struct drm_mode_create_dumb *args); struct drm_mode_create_dumb *args);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment