Skip to content

Commit e8fa567

Browse files
tomeuvdanvet
authored andcommitted
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: Tomeu Vizoso <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 1aa81be commit e8fa567

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

drivers/gpu/drm/drm_debugfs_crc.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ static const struct file_operations drm_crtc_crc_control_fops = {
125125
.write = crc_control_write
126126
};
127127

128+
static int crtc_crc_data_count(struct drm_crtc_crc *crc)
129+
{
130+
assert_spin_locked(&crc->lock);
131+
return CIRC_CNT(crc->head, crc->tail, DRM_CRC_ENTRIES_NR);
132+
}
133+
128134
static int crtc_crc_open(struct inode *inode, struct file *filep)
129135
{
130136
struct drm_crtc *crtc = inode->i_private;
@@ -160,8 +166,19 @@ static int crtc_crc_open(struct inode *inode, struct file *filep)
160166
crc->entries = entries;
161167
crc->values_cnt = values_cnt;
162168
crc->opened = true;
169+
170+
/*
171+
* Only return once we got a first frame, so userspace doesn't have to
172+
* guess when this particular piece of HW will be ready to start
173+
* generating CRCs.
174+
*/
175+
ret = wait_event_interruptible_lock_irq(crc->wq,
176+
crtc_crc_data_count(crc),
177+
crc->lock);
163178
spin_unlock_irq(&crc->lock);
164179

180+
WARN_ON(ret);
181+
165182
return 0;
166183

167184
err_disable:
@@ -189,12 +206,6 @@ static int crtc_crc_release(struct inode *inode, struct file *filep)
189206
return 0;
190207
}
191208

192-
static int crtc_crc_data_count(struct drm_crtc_crc *crc)
193-
{
194-
assert_spin_locked(&crc->lock);
195-
return CIRC_CNT(crc->head, crc->tail, DRM_CRC_ENTRIES_NR);
196-
}
197-
198209
/*
199210
* 1 frame field of 10 chars plus a number of CRC fields of 10 chars each, space
200211
* separated, with a newline at the end and null-terminated.

0 commit comments

Comments
 (0)