From: Daniel Vetter Subject: Re: [PATCH 3/3] drm/i915: Improve the accuracy of get_scanout_pos on CTG+ Date: Wed, 25 Sep 2013 10:46:27 +0200 Message-ID: <20130925084627.GJ12663@phenom.ffwll.local> References: <1379930527-19714-1-git-send-email-ville.syrjala@linux.intel.com> <1379930527-19714-4-git-send-email-ville.syrjala@linux.intel.com> <524254B6.4080709@tuebingen.mpg.de> <20130925081130.GJ4531@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail-ea0-f172.google.com (mail-ea0-f172.google.com [209.85.215.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 178FDE6C28 for ; Wed, 25 Sep 2013 01:46:10 -0700 (PDT) Received: by mail-ea0-f172.google.com with SMTP id r16so3057264ead.31 for ; Wed, 25 Sep 2013 01:46:10 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20130925081130.GJ4531@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= Cc: intel-gfx@lists.freedesktop.org, Mario Kleiner List-Id: intel-gfx@lists.freedesktop.org On Wed, Sep 25, 2013 at 11:11:30AM +0300, Ville Syrj=E4l=E4 wrote: > On Wed, Sep 25, 2013 at 05:12:54AM +0200, Mario Kleiner wrote: > > This one i don't know. I think i can't follow the logic, but i don't = > > know enough about the way the intel hw counts. > > = > > Do you mean the counter increments when the scanline is over, instead o= f = > > when it begins? > = > Let me draw a picture of the scanline (not to scale): > = > |XXXXXXXXXXXXX|-----|___________|---| > horiz. active horiz. sync > ^ ^ > | | > first pixel this is where the > of the line scanline counter increments > = > > With this correction by +1 at the edges of vblank, the scanlines at = > > vbl_start and vbl_end would be reported twice, for two successive = > > scanline durations, that seems a bit weird and asymmetric to the rest o= f = > > the scanline positions. Wouldn't it make more sense to simply always ad= d = > > 1 for a smaller overall error, given that hblank is shorter than the = > > active scanout part of a scanline? > = > Since the counter increments too late, drm_handle_vblank() > may get the wrong idea ie. something like this may happen: > = > 1. vblank irq triggered > 2. drm_handle_vblank() gets called > 3. i915_get_crtc_scanoutpos() returns vbl_start-1 as the scanline > 4. delta_ns calculation gets confused and tries to correct for it > = > Now, the correction you do for delta_ns should handle this, but > I don't like having such kludges in common code, and we can handle > it in the driver as I've demonstrated. But yeah, I suppose it can > make the error slightly less stable. > = > For some other uses (atomic page flip stuff) of the scanline position, > I definitely want this correction since I need accurate information > whether the position has passed vblank start. At least on modern platforms I think we should take a good look at the timestamp registers. With those the only thing we essentially need to do is to correct the spot where the timestamp is taken to make it suitable for OML_sync ... But doing such a switch is something for future work ;-) -Daniel -- = Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch