From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032653AbdAEOOR (ORCPT ); Thu, 5 Jan 2017 09:14:17 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34963 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032590AbdAEOOG (ORCPT ); Thu, 5 Jan 2017 09:14:06 -0500 Date: Thu, 5 Jan 2017 15:14:02 +0100 From: Daniel Vetter To: Tomeu Vizoso Cc: linux-kernel@vger.kernel.org, Emil Velikov , dri-devel@lists.freedesktop.org, Daniel Vetter Subject: Re: [PATCH v14 2/4] drm: crc: Wait for a frame before returning from open() Message-ID: <20170105141401.sgpoosdlaawcudcz@phenom.ffwll.local> Mail-Followup-To: Tomeu Vizoso , linux-kernel@vger.kernel.org, Emil Velikov , dri-devel@lists.freedesktop.org, Daniel Vetter References: <20170102125912.22305-1-tomeu.vizoso@collabora.com> <20170102125912.22305-3-tomeu.vizoso@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170102125912.22305-3-tomeu.vizoso@collabora.com> X-Operating-System: Linux phenom 4.8.0-1-amd64 User-Agent: NeoMutt/20161126 (1.7.1) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 02, 2017 at 01:59:10PM +0100, Tomeu Vizoso wrote: > 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 Merged the first 2, I guess the 2 i915 patches need to wait for Dave to be back so that we can resync the trees ... -Daniel > --- > > drivers/gpu/drm/drm_debugfs_crc.c | 23 +++++++++++++++++------ > 1 file changed, 17 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/drm_debugfs_crc.c b/drivers/gpu/drm/drm_debugfs_crc.c > index 68b171af237b..8b0eeeed4d78 100644 > --- a/drivers/gpu/drm/drm_debugfs_crc.c > +++ b/drivers/gpu/drm/drm_debugfs_crc.c > @@ -125,6 +125,12 @@ static const struct file_operations drm_crtc_crc_control_fops = { > .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) > { > struct drm_crtc *crtc = inode->i_private; > @@ -160,8 +166,19 @@ static int crtc_crc_open(struct inode *inode, struct file *filep) > crc->entries = entries; > crc->values_cnt = values_cnt; > 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); > > + WARN_ON(ret); > + > return 0; > > err_disable: > @@ -189,12 +206,6 @@ static int crtc_crc_release(struct inode *inode, struct file *filep) > 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 > * separated, with a newline at the end and null-terminated. > -- > 2.9.3 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch