Skip to content

Commit e98a032

Browse files
unerligerodrigovivi
authored andcommitted
drm/xe: Move part of xe_file cleanup to a helper
In order to make xe_file ref counted, move destruction of xe_file members to a helper. v2: Move xe_vm_close_and_put back into xe_file_close (Matt) Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240718210548.3580382-2-umesh.nerlige.ramappa@intel.com Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> (cherry picked from commit 3d0c4a6) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent ddeb798 commit e98a032

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

drivers/gpu/drm/xe/xe_device.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,25 @@ static int xe_file_open(struct drm_device *dev, struct drm_file *file)
9090
return 0;
9191
}
9292

93+
static void xe_file_destroy(struct xe_file *xef)
94+
{
95+
struct xe_device *xe = xef->xe;
96+
97+
xa_destroy(&xef->exec_queue.xa);
98+
mutex_destroy(&xef->exec_queue.lock);
99+
xa_destroy(&xef->vm.xa);
100+
mutex_destroy(&xef->vm.lock);
101+
102+
spin_lock(&xe->clients.lock);
103+
xe->clients.count--;
104+
spin_unlock(&xe->clients.lock);
105+
106+
xe_drm_client_put(xef->client);
107+
kfree(xef);
108+
}
109+
93110
static void xe_file_close(struct drm_device *dev, struct drm_file *file)
94111
{
95-
struct xe_device *xe = to_xe_device(dev);
96112
struct xe_file *xef = file->driver_priv;
97113
struct xe_vm *vm;
98114
struct xe_exec_queue *q;
@@ -108,21 +124,12 @@ static void xe_file_close(struct drm_device *dev, struct drm_file *file)
108124
xe_exec_queue_kill(q);
109125
xe_exec_queue_put(q);
110126
}
111-
xa_destroy(&xef->exec_queue.xa);
112-
mutex_destroy(&xef->exec_queue.lock);
113127
mutex_lock(&xef->vm.lock);
114128
xa_for_each(&xef->vm.xa, idx, vm)
115129
xe_vm_close_and_put(vm);
116130
mutex_unlock(&xef->vm.lock);
117-
xa_destroy(&xef->vm.xa);
118-
mutex_destroy(&xef->vm.lock);
119131

120-
spin_lock(&xe->clients.lock);
121-
xe->clients.count--;
122-
spin_unlock(&xe->clients.lock);
123-
124-
xe_drm_client_put(xef->client);
125-
kfree(xef);
132+
xe_file_destroy(xef);
126133
}
127134

128135
static const struct drm_ioctl_desc xe_ioctls[] = {

0 commit comments

Comments
 (0)