[RFC v4 20/25] drm/prime: Don't pin module on export for in-kernel clients

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
---
 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

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux