]> git.baikalelectronics.ru Git - kernel.git/commit
drm/scheduler: Avoid accessing freed bad job.
authorAndrey Grodzovsky <andrey.grodzovsky@amd.com>
Mon, 25 Nov 2019 20:51:29 +0000 (15:51 -0500)
committerChristian König <christian.koenig@amd.com>
Wed, 27 Nov 2019 15:05:49 +0000 (16:05 +0100)
commitf348fdccc5411b3fdc2c8e0dd264417ed2d4de79
treee10a1fff61256e4d62bfa192f659e0b8f300b251
parent010512f9dafe819978a2971329bcc7ea394af14f
drm/scheduler: Avoid accessing freed bad job.

Problem:
Due to a race between drm_sched_cleanup_jobs in sched thread and
drm_sched_job_timedout in timeout work there is a possiblity that
bad job was already freed while still being accessed from the
timeout thread.

Fix:
Instead of just peeking at the bad job in the mirror list
remove it from the list under lock and then put it back later when
we are garanteed no race with main sched thread is possible which
is after the thread is parked.

v2: Lock around processing ring_mirror_list in drm_sched_cleanup_jobs.

v3: Rebase on top of drm-misc-next. v2 is not needed anymore as
drm_sched_get_cleanup_job already has a lock there.

v4: Fix comments to relfect latest code in drm-misc.

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Emily Deng <Emily.Deng@amd.com>
Tested-by: Emily Deng <Emily.Deng@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/342356
drivers/gpu/drm/scheduler/sched_main.c