Skip to content

Commit 43f69d9

Browse files
hoshinolinamarcan
authored andcommitted
drm/gem: Add a flag to control whether objects can be exported
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 <[email protected]>
1 parent 255bcb2 commit 43f69d9

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

drivers/gpu/drm/drm_gem.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ void drm_gem_private_object_init(struct drm_device *dev,
166166

167167
drm_vma_node_reset(&obj->vma_node);
168168
INIT_LIST_HEAD(&obj->lru_node);
169+
obj->exportable = true;
169170
}
170171
EXPORT_SYMBOL(drm_gem_private_object_init);
171172

drivers/gpu/drm/drm_prime.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,11 @@ static struct dma_buf *export_and_register_object(struct drm_device *dev,
391391
return dmabuf;
392392
}
393393

394+
if (!obj->exportable) {
395+
dmabuf = ERR_PTR(-EINVAL);
396+
return dmabuf;
397+
}
398+
394399
if (obj->funcs && obj->funcs->export)
395400
dmabuf = obj->funcs->export(obj, flags);
396401
else

include/drm/drm_gem.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,14 @@ struct drm_gem_object {
371371
* The current LRU list that the GEM object is on.
372372
*/
373373
struct drm_gem_lru *lru;
374+
375+
/**
376+
* @exportable:
377+
*
378+
* Whether this GEM object can be exported via the drm_gem_object_funcs->export
379+
* callback. Defaults to true.
380+
*/
381+
bool exportable;
374382
};
375383

376384
/**

0 commit comments

Comments
 (0)