drm/vkms: Fix race condition around accessing frame number
crtc_state is accessed by both vblank_handle() and the ordered work_struct handle vkms_crc_work_handle() to retrieve and or update the frame number for computed CRC. Since work_struct can fail, add frame_end to account for missing frame numbers. Use (frame_[start/end]) for synchronization between hrtimer callback and ordered work_struct handle. This patch passes the following subtests from igt kms_pipe_crc_basic test: bad-source, read-crc-pipe-A, read-crc-pipe-A-frame-sequence, nonblocking-crc-pipe-A, nonblocking-crc-pipe-A-frame-sequence Signed-off-by: Haneen Mohammed <hamohammed.sa@gmail.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20180903211743.GA2773@haneenDRM
This commit is contained in:

committed by
Daniel Vetter

parent
428e15cc41
commit
0ca33adb91
@@ -22,8 +22,19 @@ static void _vblank_handle(struct vkms_output *output)
|
||||
DRM_ERROR("vkms failure on handling vblank");
|
||||
|
||||
if (state && output->crc_enabled) {
|
||||
state->n_frame = drm_crtc_accurate_vblank_count(crtc);
|
||||
queue_work(output->crc_workq, &state->crc_work);
|
||||
u64 frame = drm_crtc_accurate_vblank_count(crtc);
|
||||
|
||||
/* update frame_start only if a queued vkms_crc_work_handle()
|
||||
* has read the data
|
||||
*/
|
||||
spin_lock(&output->state_lock);
|
||||
if (!state->frame_start)
|
||||
state->frame_start = frame;
|
||||
spin_unlock(&output->state_lock);
|
||||
|
||||
ret = queue_work(output->crc_workq, &state->crc_work);
|
||||
if (!ret)
|
||||
DRM_WARN("failed to queue vkms_crc_work_handle");
|
||||
}
|
||||
|
||||
spin_unlock(&output->lock);
|
||||
@@ -211,6 +222,7 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
|
||||
drm_crtc_helper_add(crtc, &vkms_crtc_helper_funcs);
|
||||
|
||||
spin_lock_init(&vkms_out->lock);
|
||||
spin_lock_init(&vkms_out->state_lock);
|
||||
|
||||
vkms_out->crc_workq = alloc_ordered_workqueue("vkms_crc_workq", 0);
|
||||
|
||||
|
Reference in New Issue
Block a user