Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E62C8C636D6 for ; Wed, 22 Feb 2023 15:45:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232622AbjBVPo7 (ORCPT ); Wed, 22 Feb 2023 10:44:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231235AbjBVPoz (ORCPT ); Wed, 22 Feb 2023 10:44:55 -0500 Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F64934C23 for ; Wed, 22 Feb 2023 07:44:54 -0800 (PST) Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-1720600a5f0so10340004fac.11 for ; Wed, 22 Feb 2023 07:44:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bw/o2d2K7rGx8jIRXoMyh485ogBh3CzQ8lHjHQHgP88=; b=nVtplwpYOrpmv5auHphbThsB5vUI0Ms3ZskUvJ5lbu1bIFUs5qUoFjhQTperidUve1 qkG6ep1wQh8TVXb6pD0amaDuhJtZV/bE1KauKv3c47O547/gyeePedUjF+vp26chdjCU 40vUbKDpkkxBVku3mGZcuuj77kzSFMsYuj/rnCgUut7CtyVk4XMq/mOZ9dDrRYQlMGjM E+kybYipPTshCzloe6tzbxCsSb5pTldvUwqfmvbRDYOt9UqDlBZrtMtHZeJTt+YU/B7O nL38eEKt3L5d3z31wWvYYd8UiXeHUDPmEXyNirUrk3n25ZPBqsIzVNk5FhfpQ5e2homG mGOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bw/o2d2K7rGx8jIRXoMyh485ogBh3CzQ8lHjHQHgP88=; b=icUCfjpgOlyW44p68lXudfil62gbCZ9yyU8FbZOH8rrFGpG4hAMKZjwmojQZvJPOYX MaUyJLzIdOsc+fMJRK/7LDkAZNemhLQonQgaHyz6/Lli/KtHPhIWfRWQ9Ec/QwPLV7+Z ouOywCP+1o3AHoMqvMFm6RI3Hg3evXHoJuSUOC2QHIUb4tT4FY9kxHvMQnKK5lG227rF cdsFLrgnVEQM/LdLPJd8TDvgH6AE+oX87uVbcOzWR+f+0JIsySVhWI5r4UBQi445DaRn DXTy0GKQPR72QxrXjQd6STfs0xn+jxq6l/IiQoRQRM7EjPjeOKlyKUb7h9QoPOBinOJz NvQQ== X-Gm-Message-State: AO0yUKWAjltSBpz9T91ivhELijQ+ZmV1oPaZjigv92Uig+ofcTU8rppr KIRkPwPZ7yYAuySFx2FcACxlEeWrM+ocKaGI/As= X-Google-Smtp-Source: AK7set8HctSnN91X1d+M6rIyfQjt2yhgJ7jTxiClAmw/r44291CstgYZiuPPwA1K5zp2sg+pYAvmX8Bhb4Hlrw+N0Qg= X-Received: by 2002:a05:6870:808d:b0:16e:8a56:d0d2 with SMTP id q13-20020a056870808d00b0016e8a56d0d2mr1362645oab.38.1677080693513; Wed, 22 Feb 2023 07:44:53 -0800 (PST) MIME-Version: 1.0 References: <20230218211608.1630586-1-robdclark@gmail.com> <20230218211608.1630586-11-robdclark@gmail.com> <20230220110820.595cfa37@eldfell> <20230221104551.60d44d1c@eldfell> <20230222115700.138d824c@eldfell> In-Reply-To: <20230222115700.138d824c@eldfell> From: Rob Clark Date: Wed, 22 Feb 2023 07:44:42 -0800 Message-ID: Subject: Re: [PATCH v4 10/14] drm/vblank: Add helper to get next vblank time To: Pekka Paalanen Cc: =?UTF-8?B?VmlsbGUgU3lyasOkbMOk?= , Rob Clark , Thomas Zimmermann , Tvrtko Ursulin , =?UTF-8?Q?Christian_K=C3=B6nig?= , =?UTF-8?Q?Michel_D=C3=A4nzer?= , open list , dri-devel@lists.freedesktop.org, Rodrigo Vivi , Alex Deucher , freedreno@lists.freedesktop.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 22, 2023 at 1:57 AM Pekka Paalanen wrote: > > On Tue, 21 Feb 2023 09:50:20 -0800 > Rob Clark wrote: > > > On Tue, Feb 21, 2023 at 5:01 AM Ville Syrj=C3=A4l=C3=A4 > > wrote: > > > > > > On Tue, Feb 21, 2023 at 10:45:51AM +0200, Pekka Paalanen wrote: > > > > On Mon, 20 Feb 2023 07:55:41 -0800 > > > > Rob Clark wrote: > > > > > > > > > On Mon, Feb 20, 2023 at 1:08 AM Pekka Paalanen wrote: > > > > > > > > > > > > On Sat, 18 Feb 2023 13:15:53 -0800 > > > > > > Rob Clark wrote: > > > > > > > > > > > > > From: Rob Clark > > > > > > > > > > > > > > Will be used in the next commit to set a deadline on fences t= hat an > > > > > > > atomic update is waiting on. > > > > > > > > > > > > > > Signed-off-by: Rob Clark > > > > > > > --- > > > > > > > drivers/gpu/drm/drm_vblank.c | 32 ++++++++++++++++++++++++++= ++++++ > > > > > > > include/drm/drm_vblank.h | 1 + > > > > > > > 2 files changed, 33 insertions(+) > > > > > > > > > > > > > > diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/d= rm_vblank.c > > > > > > > index 2ff31717a3de..caf25ebb34c5 100644 > > > > > > > --- a/drivers/gpu/drm/drm_vblank.c > > > > > > > +++ b/drivers/gpu/drm/drm_vblank.c > > > > > > > @@ -980,6 +980,38 @@ u64 drm_crtc_vblank_count_and_time(struc= t drm_crtc *crtc, > > > > > > > } > > > > > > > EXPORT_SYMBOL(drm_crtc_vblank_count_and_time); > > > > > > > > > > > > > > +/** > > > > > > > + * drm_crtc_next_vblank_time - calculate the time of the nex= t vblank > > > > > > > + * @crtc: the crtc for which to calculate next vblank time > > > > > > > + * @vblanktime: pointer to time to receive the next vblank t= imestamp. > > > > > > > + * > > > > > > > + * Calculate the expected time of the next vblank based on t= ime of previous > > > > > > > + * vblank and frame duration > > > > > > > > > > > > Hi, > > > > > > > > > > > > for VRR this targets the highest frame rate possible for the cu= rrent > > > > > > VRR mode, right? > > > > > > > > > > > > > > > > It is based on vblank->framedur_ns which is in turn based on > > > > > mode->crtc_clock. Presumably for VRR that ends up being a maximu= m? > > > > > > > > I don't know. :-) > > > > > > At least for i915 this will give you the maximum frame > > > duration. > > > > I suppose one could argue that maximum frame duration is the actual > > deadline. Anything less is just moar fps, but not going to involve > > stalling until vblank N+1, AFAIU > > > > > Also this does not calculate the the start of vblank, it > > > calculates the start of active video. > > > > Probably something like end of previous frame's video.. might not be > > _exactly_ correct (because some buffering involved), but OTOH on the > > GPU side, I expect the driver to set a timer for a few ms or so before > > the deadline. So there is some wiggle room. > > The vblank timestamp is defined to be the time of the first active > pixel of the frame in the video signal. At least that's the one that > UAPI carries (when not tearing?). It is not the start of vblank period. > > With VRR, the front porch before the first active pixel can be multiple > milliseconds. The difference between 144 Hz and 60 Hz is 9.7 ms for > example. What we really want is the deadline for the hw to latch for the next frame.. which as Ville pointed out is definitely before the end of vblank. Honestly this sort of feature is a lot more critical for the non-VRR case, and VRR is kind of a minority edge case. So I'd prefer not to get too hung up on VRR. If there is an easy way for the helpers to detect VRR, I'd be perfectly fine not setting a deadline hint in that case, and let someone who actually has a VRR display figure out how to handle that case. BR, -R