Merge 93f581d763 ("drm/gem: Test for imported GEM buffers with helper") into android16-6.12-lts

Steps on the way to 6.12.31

Change-Id: I27facbc82e0adde3212b510160346838c6982e1e
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman
2025-06-30 10:47:19 +00:00
2 changed files with 16 additions and 2 deletions

View File

@@ -322,7 +322,7 @@ int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
return -ENOENT;
/* Don't allow imported objects to be mapped */
if (obj->import_attach) {
if (drm_gem_is_imported(obj)) {
ret = -EINVAL;
goto out;
}
@@ -1152,7 +1152,7 @@ void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
drm_vma_node_start(&obj->vma_node));
drm_printf_indent(p, indent, "size=%zu\n", obj->size);
drm_printf_indent(p, indent, "imported=%s\n",
str_yes_no(obj->import_attach));
str_yes_no(drm_gem_is_imported(obj)));
if (obj->funcs->print_info)
obj->funcs->print_info(p, indent, obj);

View File

@@ -35,6 +35,7 @@
*/
#include <linux/kref.h>
#include <linux/dma-buf.h>
#include <linux/dma-resv.h>
#include <linux/list.h>
#include <linux/mutex.h>
@@ -570,6 +571,19 @@ static inline bool drm_gem_object_is_shared_for_memory_stats(struct drm_gem_obje
return (obj->handle_count > 1) || obj->dma_buf;
}
/**
* drm_gem_is_imported() - Tests if GEM object's buffer has been imported
* @obj: the GEM object
*
* Returns:
* True if the GEM object's buffer has been imported, false otherwise
*/
static inline bool drm_gem_is_imported(const struct drm_gem_object *obj)
{
/* The dma-buf's priv field points to the original GEM object. */
return obj->dma_buf && (obj->dma_buf->priv != obj);
}
#ifdef CONFIG_LOCKDEP
/**
* drm_gem_gpuva_set_lock() - Set the lock protecting accesses to the gpuva list.