Skip to content
Commit cdd1cf79 authored by Chris Wilson's avatar Chris Wilson Committed by Daniel Vetter
Browse files

drm: Make drm_read() more robust against multithreaded races



The current implementation of drm_read() faces a number of issues:

1. Upon an error, it consumes the event which may lead to the client
blocking.
2. Upon an error, it forgets about events already copied
3. If it fails to copy a single event with O_NONBLOCK it falls into a
infinite loop of reporting EAGAIN.
3. There is a race between multiple waiters and blocking reads of the
events list.

Here, we inline drm_dequeue_event() into drm_read() so that we can take
the spinlock around the list walking and event copying, and importantly
reorder the error handling to avoid the issues above.

Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarTakashi Iwai <tiwai@suse.de>
Testcase: igt/drm_read
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 01934c2a
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment