linux_dsm_epyc7002/drivers/gpu/drm/vkms
Daniel Vetter 5ef8100a39 drm/vkms: flush crc workers earlier in commit flow
Currently, we flush pending CRC workers very late in the commit flow,
when we destroy all the old crtc states. Unfortunately, at that point,
the framebuffers are already unpinned (and our vaddr possible gone), so
this isn't good. Also, the plane_states we need might also already be
cleaned up, since cleanup order of state structures isn't well defined.

Fix this by waiting for all CRC workers of the old state to complete
before we start any of the cleanup work. For correct ordering and
avoiding races, we can only flush_work after
drm_atomic_helper_wait_for_vblanks() since we know that all subsequent
queue_work will be for the new state. Only once that's done is
flush_work() useful, before that we might flush the work, and then right
after the hrtimer that simulates vblank queues it again. Every time you
have a flush_work before cleaning up the work structure, the following
sequence must be obeyed, or it can go wrong:

1. Make sure no one else can re-queue the work anymore (in our case
that's done by a combination of first updating output->crc_state and
then waiting for the vblank to pass to make sure the hrtimer has noticed
that change).
2. flush_work()
3. Actually clean up stuff (which isn't done here).

Doing the flush_work before we even completed the output->state update,
much less waited for the vblank to make sure that's happened, missed the
point.

Note that this is not yet race-free because of the hrtimer and crc
worker look at the wrong state pointers, but that will be fixed in
subsequent patches.

Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Reviewed-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Tested-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190606222751.32567-7-daniel.vetter@ffwll.ch
2019-06-26 23:10:35 -03:00
..
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
vkms_crc.c drm/vkms: Rename vkms_output.state_lock to crc_lock 2019-06-26 23:00:55 -03:00
vkms_crtc.c drm/vkms: flush crc workers earlier in commit flow 2019-06-26 23:10:35 -03:00
vkms_drv.c drm/vkms: flush crc workers earlier in commit flow 2019-06-26 23:10:35 -03:00
vkms_drv.h drm/vkms: Rename vkms_output.state_lock to crc_lock 2019-06-26 23:00:55 -03:00
vkms_gem.c drm/vkms: fix use-after-free when drm_gem_handle_create() fails 2019-03-18 08:45:57 +01:00
vkms_output.c drm/vkms: Remove useless call to drm_connector_register/unregister() 2019-06-06 20:33:28 -03:00
vkms_plane.c drm/vkms: Move format arrays to vkms_plane.c 2019-06-18 22:49:17 -03:00