diff options
author | Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com> | 2024-05-24 16:47:44 -0700 |
---|---|---|
committer | Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com> | 2024-05-27 14:07:46 -0700 |
commit | ce62827bc294ba5f8b3909bfa5d7dbf9de8aab6b (patch) | |
tree | ca16037bc11ef13d5357f8a88628e1a9200cc390 /drivers/gpu/drm/xe/xe_drm_client.c | |
parent | 45bb564de0a6f87e9f502ceb4ff4d9f936365c85 (diff) |
drm/xe: Do not access xe file when updating exec queue run_ticks
The current code is running into a use after free case where xe file is
closed before the exec queue run_ticks can be updated. This is occurring
in the xe_file_close path. To fix that, do not access xe file when
updating the exec queue run_ticks. Instead store the exec queue run_ticks
locally in the exec queue object and accumulate it when the user dumps
the drm client stats. We know that the xe file is valid when user is
dumping the run_ticks for the drm client, so this effectively
removes the dependency on xe file object in
xe_exec_queue_update_run_ticks().
v2:
- Fix the accumulation of q->run_ticks delta into xe file run_ticks
- s/runtime/run_ticks/ (Rodrigo)
Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/1908
Fixes: 6109f24f87d7 ("drm/xe: Add helper to accumulate exec queue runtime")
Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240524234744.1352543-2-umesh.nerlige.ramappa@intel.com
Diffstat (limited to 'drivers/gpu/drm/xe/xe_drm_client.c')
-rw-r--r-- | drivers/gpu/drm/xe/xe_drm_client.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/gpu/drm/xe/xe_drm_client.c b/drivers/gpu/drm/xe/xe_drm_client.c index 1dcae0e6d66d..4a19b771e3a0 100644 --- a/drivers/gpu/drm/xe/xe_drm_client.c +++ b/drivers/gpu/drm/xe/xe_drm_client.c @@ -251,8 +251,11 @@ static void show_run_ticks(struct drm_printer *p, struct drm_file *file) /* Accumulate all the exec queues from this client */ mutex_lock(&xef->exec_queue.lock); - xa_for_each(&xef->exec_queue.xa, i, q) + xa_for_each(&xef->exec_queue.xa, i, q) { xe_exec_queue_update_run_ticks(q); + xef->run_ticks[q->class] += q->run_ticks - q->old_run_ticks; + q->old_run_ticks = q->run_ticks; + } mutex_unlock(&xef->exec_queue.lock); /* Get the total GPU cycles */ |