drm/crc: Handle opening and closing crc better
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Wed, 21 Jun 2017 11:00:07 +0000 (13:00 +0200)
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Mon, 17 Jul 2017 14:32:43 +0000 (16:32 +0200)
commiteb42ea6d0b8ed9ca8e73cc24fa801f0d8ab28905
tree7ce017ebaa327a35fc70f34ae38122bd74fc7658
parentec878c0756a0c202e86256dca1de307ab1189ab8
drm/crc: Handle opening and closing crc better

When I was doing a grep . -r /sys/kernel/debug/dri/0 I noticed a WARN
appearing when I aborted the grep with ^C.

After investigating I've also noticed that the error handling was
lacking and there are race conditions involving multiple calls to
open/close simultaneously.

Fix this by setting the opened flag first and using crc->entries to
decide when crc can be collected.

Also call unset crc source before cleaning up, this way there is
no race with a future open().

This patch has been tested with all the tests in igt with CRC in their
name.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170621110007.11674-1-maarten.lankhorst@linux.intel.com
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
[mlankhorst: Add description that this patch has been tested with IGT,
based on tomeu's feedback]
drivers/gpu/drm/drm_debugfs_crc.c