@@ -567,6 +567,30 @@ struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
.flags = flags,
.priv = obj,
};
+ bool is_internal = false;
+ struct drm_file *file;
+
+ mutex_lock(&dev->filelist_mutex);
+ list_for_each_entry(file, &dev->filelist_internal, lhead) {
+ struct drm_gem_object *iter;
+ int id;
+
+ spin_lock(&file->table_lock);
+ idr_for_each_entry(&file->object_idr, iter, id) {
+ if (iter == obj) {
+ is_internal = true;
+ break;
+ }
+ }
+ spin_unlock(&file->table_lock);
+
+ if (is_internal)
+ break;
+ }
+ mutex_unlock(&dev->filelist_mutex);
+
+ if (is_internal)
+ exp_info.owner = NULL;
if (dev->driver->gem_prime_res_obj)
exp_info.resv = dev->driver->gem_prime_res_obj(obj);
Avoid pinning the module when exporting a GEM object as a dmabuf. This makes it possible to unload drivers that has in-kernel clients using it. The client is removed on drm_dev_unregister() so no need to pin the driver. Signed-off-by: Noralf Trønnes <noralf@tronnes.org> --- drivers/gpu/drm/drm_prime.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)