[PATCH 1/5] drm/xe: Move part of xe_file cleanup to a helper
Umesh Nerlige Ramappa
umesh.nerlige.ramappa at intel.com
Mon Jul 8 20:20:59 UTC 2024
In order to make xe_file ref counted, move destruction of xe_file
members to a helper.
Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com>
---
drivers/gpu/drm/xe/xe_device.c | 36 +++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index cfda7cb5df2c..babb697652d5 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -90,24 +90,12 @@ static int xe_file_open(struct drm_device *dev, struct drm_file *file)
return 0;
}
-static void xe_file_close(struct drm_device *dev, struct drm_file *file)
+static void xe_file_destroy(struct xe_file *xef)
{
- struct xe_device *xe = to_xe_device(dev);
- struct xe_file *xef = file->driver_priv;
+ struct xe_device *xe = xef->xe;
struct xe_vm *vm;
- struct xe_exec_queue *q;
unsigned long idx;
- /*
- * No need for exec_queue.lock here as there is no contention for it
- * when FD is closing as IOCTLs presumably can't be modifying the
- * xarray. Taking exec_queue.lock here causes undue dependency on
- * vm->lock taken during xe_exec_queue_kill().
- */
- xa_for_each(&xef->exec_queue.xa, idx, q) {
- xe_exec_queue_kill(q);
- xe_exec_queue_put(q);
- }
xa_destroy(&xef->exec_queue.xa);
mutex_destroy(&xef->exec_queue.lock);
mutex_lock(&xef->vm.lock);
@@ -125,6 +113,26 @@ static void xe_file_close(struct drm_device *dev, struct drm_file *file)
kfree(xef);
}
+static void xe_file_close(struct drm_device *dev, struct drm_file *file)
+{
+ struct xe_file *xef = file->driver_priv;
+ struct xe_exec_queue *q;
+ unsigned long idx;
+
+ /*
+ * No need for exec_queue.lock here as there is no contention for it
+ * when FD is closing as IOCTLs presumably can't be modifying the
+ * xarray. Taking exec_queue.lock here causes undue dependency on
+ * vm->lock taken during xe_exec_queue_kill().
+ */
+ xa_for_each(&xef->exec_queue.xa, idx, q) {
+ xe_exec_queue_kill(q);
+ xe_exec_queue_put(q);
+ }
+
+ xe_file_destroy(xef);
+}
+
static const struct drm_ioctl_desc xe_ioctls[] = {
DRM_IOCTL_DEF_DRV(XE_DEVICE_QUERY, xe_query_ioctl, DRM_RENDER_ALLOW),
DRM_IOCTL_DEF_DRV(XE_GEM_CREATE, xe_gem_create_ioctl, DRM_RENDER_ALLOW),
--
2.38.1
More information about the Intel-xe
mailing list