drm/xe: Do not access xe file when updating exec queue run_ticks
authorUmesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Fri, 24 May 2024 23:47:44 +0000 (16:47 -0700)
committerUmesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Mon, 27 May 2024 21:07:46 +0000 (14:07 -0700)
commitce62827bc294ba5f8b3909bfa5d7dbf9de8aab6b
treeca16037bc11ef13d5357f8a88628e1a9200cc390
parent45bb564de0a6f87e9f502ceb4ff4d9f936365c85
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
drivers/gpu/drm/xe/xe_drm_client.c
drivers/gpu/drm/xe/xe_exec_queue.c
drivers/gpu/drm/xe/xe_exec_queue_types.h