[RFC v4 20/25] drm/prime: Don't pin module on export for in-kernel clients
Noralf Trønnes
noralf at tronnes.org
Thu Apr 12 16:12:32 UTC 2018
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 at tronnes.org>
---
drivers/gpu/drm/drm_prime.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index e6052ab2bec4..f9dbe3b9db20 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -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);
--
2.15.1
More information about the dri-devel
mailing list