drm/sched: Barriers are needed for entity->last_scheduled
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 5 Aug 2021 10:46:48 +0000 (12:46 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 30 Aug 2021 08:53:48 +0000 (10:53 +0200)
commitb0a5303d4e140ed8e534e44b278ca5d07401851d
tree8e1c6590909bcaf227490fa2b948cf4385af1e74
parent357285a2d1c06f0667c81e4dda35b92788b4f20c
drm/sched: Barriers are needed for entity->last_scheduled

It might be good enough on x86 with just READ_ONCE, but the write side
should then at least be WRITE_ONCE because x86 has total store order.

It's definitely not enough on arm.

Fix this proplery, which means
- explain the need for the barrier in both places
- point at the other side in each comment

Also pull out the !sched_list case as the first check, so that the
code flow is clearer.

While at it sprinkle some comments around because it was very
non-obvious to me what's actually going on here and why.

Note that we really need full barriers here, at first I thought
store-release and load-acquire on ->last_scheduled would be enough,
but we actually requiring ordering between that and the queue state.

v2: Put smp_rmp() in the right place and fix up comment (Andrey)

Reviewed-by: Christian König <christian.koenig@amd.com>
Acked-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: Steven Price <steven.price@arm.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210805104705.862416-4-daniel.vetter@ffwll.ch
drivers/gpu/drm/scheduler/sched_entity.c