mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-10-26 10:57:38 +08:00
drm/sched: Lock drm_sched_entity_is_idle()
drm_sched_entity_is_idle() contains a badly documented memory barrier and an invalid lockless access to entity->stopped. Moreover, it also accesses entity->list which is at all other places protected by entity->lock. This function is in no way performance critical, so it is safer, more readable and more maintainable to take the spinlock. Add locking to drm_sched_entity_is_idle(). Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> Signed-off-by: Philipp Stanner <phasta@kernel.org> Link: https://patch.msgid.link/20260813094539.2407911-2-phasta@kernel.org
This commit is contained in:
1 parent
5d2584e2ff
commit
0e118b936d
1 file changed
+7
-3
@@ -179,14 +179,18 @@ EXPORT_SYMBOL(drm_sched_entity_modify_sched);
|
||||
|
||||
static bool drm_sched_entity_is_idle(struct drm_sched_entity *entity)
|
||||
{
|
||||
rmb(); /* for list_empty to work without lock */
|
||||
bool idle = false;
|
||||
|
||||
spin_lock(&entity->lock);
|
||||
|
||||
if (list_empty(&entity->list) ||
|
||||
spsc_queue_count(&entity->job_queue) == 0 ||
|
||||
entity->stopped)
|
||||
return true;
|
||||
idle = true;
|
||||
|
||||
return false;
|
||||
spin_unlock(&entity->lock);
|
||||
|
||||
return idle;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user