Skip to content

Commit

Permalink
drm/gem: Add a flag to control whether objects can be exported
Browse files Browse the repository at this point in the history
Drivers may want to support driver-private objects, which cannot be
shared. This allows them to share a single lock and enables other
optimizations.

Add an `exportable` field to drm_gem_object, which blocks PRIME export
if set to false. It is initialized to true in
drm_gem_private_object_init.

Signed-off-by: Asahi Lina <lina@asahilina.net>
  • Loading branch information
asahilina authored and jannau committed Dec 21, 2024
1 parent 750079d commit 0d2ab4b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/gpu/drm/drm_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ void drm_gem_private_object_init(struct drm_device *dev,

drm_vma_node_reset(&obj->vma_node);
INIT_LIST_HEAD(&obj->lru_node);
obj->exportable = true;
}
EXPORT_SYMBOL(drm_gem_private_object_init);

Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/drm_prime.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@ static struct dma_buf *export_and_register_object(struct drm_device *dev,
return dmabuf;
}

if (!obj->exportable) {
dmabuf = ERR_PTR(-EINVAL);
return dmabuf;
}

if (obj->funcs && obj->funcs->export)
dmabuf = obj->funcs->export(obj, flags);
else
Expand Down
8 changes: 8 additions & 0 deletions include/drm/drm_gem.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,14 @@ struct drm_gem_object {
* The current LRU list that the GEM object is on.
*/
struct drm_gem_lru *lru;

/**
* @exportable:
*
* Whether this GEM object can be exported via the drm_gem_object_funcs->export
* callback. Defaults to true.
*/
bool exportable;
};

/**
Expand Down

0 comments on commit 0d2ab4b

Please sign in to comment.