Commit e8fa5671 authored by Tomeu Vizoso's avatar Tomeu Vizoso Committed by Daniel Vetter

drm: crc: Wait for a frame before returning from open()

Don't return from the open() call on the crc/data file until the HW has
produced a first frame, as there's great variability in when the HW is
able to do that and userspace shouldn't have to guess when this specific
HW is ready to start giving frame CRCs.
Signed-off-by: default avatarTomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20170102125912.22305-3-tomeu.vizoso@collabora.com
parent 1aa81be3
...@@ -125,6 +125,12 @@ static const struct file_operations drm_crtc_crc_control_fops = { ...@@ -125,6 +125,12 @@ static const struct file_operations drm_crtc_crc_control_fops = {
.write = crc_control_write .write = crc_control_write
}; };
static int crtc_crc_data_count(struct drm_crtc_crc *crc)
{
assert_spin_locked(&crc->lock);
return CIRC_CNT(crc->head, crc->tail, DRM_CRC_ENTRIES_NR);
}
static int crtc_crc_open(struct inode *inode, struct file *filep) static int crtc_crc_open(struct inode *inode, struct file *filep)
{ {
struct drm_crtc *crtc = inode->i_private; struct drm_crtc *crtc = inode->i_private;
...@@ -160,8 +166,19 @@ static int crtc_crc_open(struct inode *inode, struct file *filep) ...@@ -160,8 +166,19 @@ static int crtc_crc_open(struct inode *inode, struct file *filep)
crc->entries = entries; crc->entries = entries;
crc->values_cnt = values_cnt; crc->values_cnt = values_cnt;
crc->opened = true; crc->opened = true;
/*
* Only return once we got a first frame, so userspace doesn't have to
* guess when this particular piece of HW will be ready to start
* generating CRCs.
*/
ret = wait_event_interruptible_lock_irq(crc->wq,
crtc_crc_data_count(crc),
crc->lock);
spin_unlock_irq(&crc->lock); spin_unlock_irq(&crc->lock);
WARN_ON(ret);
return 0; return 0;
err_disable: err_disable:
...@@ -189,12 +206,6 @@ static int crtc_crc_release(struct inode *inode, struct file *filep) ...@@ -189,12 +206,6 @@ static int crtc_crc_release(struct inode *inode, struct file *filep)
return 0; return 0;
} }
static int crtc_crc_data_count(struct drm_crtc_crc *crc)
{
assert_spin_locked(&crc->lock);
return CIRC_CNT(crc->head, crc->tail, DRM_CRC_ENTRIES_NR);
}
/* /*
* 1 frame field of 10 chars plus a number of CRC fields of 10 chars each, space * 1 frame field of 10 chars plus a number of CRC fields of 10 chars each, space
* separated, with a newline at the end and null-terminated. * separated, with a newline at the end and null-terminated.
......
Markdown is supported
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