Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752286AbdIANgb (ORCPT ); Fri, 1 Sep 2017 09:36:31 -0400 Received: from mga05.intel.com ([192.55.52.43]:29574 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752108AbdIANga (ORCPT ); Fri, 1 Sep 2017 09:36:30 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,458,1498546800"; d="scan'208";a="1168244971" Date: Fri, 1 Sep 2017 16:36:25 +0300 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Hoegeun Kwon Cc: daniel.vetter@intel.com, jani.nikula@linux.intel.com, seanpaul@chromium.org, airlied@linux.ie, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: Re: [PATCH] drm/vblank: Fix delta_ns to an absolute value Message-ID: <20170901133625.GT4914@intel.com> References: <1504249636-11681-1-git-send-email-hoegeun.kwon@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1504249636-11681-1-git-send-email-hoegeun.kwon@samsung.com> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1869 Lines: 54 On Fri, Sep 01, 2017 at 04:07:16PM +0900, Hoegeun Kwon wrote: > If scanout started, we should reduce etime by delta_ns. But delta_ns > is negative if scanout has not started. If delta_ns is negative, > subtraction of delta_ns from etime increases etime. This is wrong, the > etime should not be increased, so you have to make delta_ns an > absolute value. > > Signed-off-by: Hoegeun Kwon > --- > > Hello all, > > I think that the etime should not be increased. > In cases where delta_ns is negative, if you get time again after an > interrupt call, there is a problem that the time obtained from the > interrupt becomes the future time instead of the past time. > > Please let me know if this patch is wrong. It is wrong. The timestamp corresponds to the first active pixel of the frame/field. So while between vblank start and active start we expect to get a timestamp that is in the future. > > Best regards, > Hoegeun > > drivers/gpu/drm/drm_vblank.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c > index 70f2b95..a3e0176 100644 > --- a/drivers/gpu/drm/drm_vblank.c > +++ b/drivers/gpu/drm/drm_vblank.c > @@ -684,7 +684,7 @@ bool drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, > /* Subtract time delta from raw timestamp to get final > * vblank_time timestamp for end of vblank. > */ > - etime = ktime_sub_ns(etime, delta_ns); > + etime = ktime_sub_ns(etime, abs(delta_ns)); > *vblank_time = ktime_to_timeval(etime); > > DRM_DEBUG_VBL("crtc %u : v p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d rep]\n", > -- > 1.9.1 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Ville Syrj?l? Intel OTC