Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4442889pxv; Tue, 27 Jul 2021 07:30:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOW9YVY4jUGVedLqcSl/o+5GUAnAsNx3qFJJrECKt4gICwI99jcYcfc4bT8WGNScdHObFY X-Received: by 2002:a92:c150:: with SMTP id b16mr16367755ilh.54.1627396234114; Tue, 27 Jul 2021 07:30:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627396234; cv=none; d=google.com; s=arc-20160816; b=uDfmk+0x3InoXkie+KYEuCskmhTmii3/WfZg4Wvm+ue595QU8Sya86/PTbGoLvEZiW q/WYOVX75H/GuCZ5m6yJDr6OoXtvzohoqI6vAzjKiprPRre5w1cGz9E1I4ErPXGWjm+D uvA0HU6KPXISNEWO3sWIC6SwFaNdHXQ5lEzB6OJFjolMkxRHdpNoB2sDzQfo4JCy0Pze +kxsfYJjDdIKf8QgjwqCPiQZKIYSeqTuTAsOQCAY0DCQWPf0F6R522o1r7iN4iw/WrT3 ojbey9YpRwv/i7j2j7DPxG0DIuxuBIUmLBVEcAxZ2fb6aL8hpQrAZGPgbfJfyIYWxKqy t6Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=9Prx0Bs3bi2Iedu+a31xFuqWG2tgHJduHwRz4ZIFies=; b=i/P9ubXTJCWF8FENibBDEFK+SSXu4S0qTYOVx6XYbttG+ALTItF/lRk1z2UXSwYhKl c6OJ1zBMCgSWLMODJI6zaqQIXQDLM0/XPk07SVfJ6sh5yxNttHBL86egW383MaD/sexB SjQWJHbPxGXAhPqDXtYqRpMwWEslUlR3aW0rMQYnC+OT0UVMb31nuuGeEKe8bDcdd5yN yfhEpZn2ikTbIN6xp9UbFDsrixFN3iN9wLBg9eVewUsQiQkqoD72Tns1x87vdDfQ9XRk PiRuRV08RpLv7bMsbNqWrQH4dGDAW2akqsef0TLnW4rMbmC3xr778C2PhBIKasoG5vdB cZlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iwg3INet; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g6si3645186ilf.57.2021.07.27.07.30.21; Tue, 27 Jul 2021 07:30:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iwg3INet; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236732AbhG0O2w (ORCPT + 99 others); Tue, 27 Jul 2021 10:28:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232356AbhG0O2w (ORCPT ); Tue, 27 Jul 2021 10:28:52 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CFA9C061757 for ; Tue, 27 Jul 2021 07:28:51 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id u7so9008513ilj.8 for ; Tue, 27 Jul 2021 07:28:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=9Prx0Bs3bi2Iedu+a31xFuqWG2tgHJduHwRz4ZIFies=; b=iwg3INetBSvSrA2PFYqyLYPB7PI8YxE5YBgzSCjQ63DsueVurjkfTnHSKQEF6hucc3 lFDNFSEZz98jxNKhV8ssutp8hNDO8ukVScHrxzMfINjJzxgaxtgKRX0AGiR0DvW78tMd OP2U76sZRXONyVQpFCrlDKn8QBC5427e/FOgY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=9Prx0Bs3bi2Iedu+a31xFuqWG2tgHJduHwRz4ZIFies=; b=tLkfQRyGOPyxCIh8adYGMGYupYmrOewPD0vBZEXZYY4d32R1vvnaOuiZ1fvLoXrBtb 5hPQoQgg4Y7prk+XaGG28kPpE2dVFCcQPA4nIdk6iC6DuFgS96hivlnwLRU/AZm/MA2A vP4gTEa3Ny5fUnfy6c5z2RWCcuBEKRZJ6omukIyQ/UDU65OsGGS80wiABjXVL5tPztn+ AHFa+1Mr987yb+JGogZXtmCdLWsJnmKYeV2IlMmXcCweFooQbQm5yCix32wXK6V9jYR0 nmcEIqWlZb1osQeNuqQQA7K7UHfwmbkWC6jTTTtFG5/vqY6S7Q0Gndxd6Xkf7AozUyXi XebA== X-Gm-Message-State: AOAM530djPCcz8qiDY7aViFp61KI2T2KrLlh+hPpNBI+xIkyz6egSCoV gHypv7eiV/gZXbDyhEae9mC3H+mOIDB/Tj+uiwVoLg== X-Received: by 2002:a92:3206:: with SMTP id z6mr16785042ile.201.1627396130923; Tue, 27 Jul 2021 07:28:50 -0700 (PDT) MIME-Version: 1.0 References: <20210726233854.2453899-1-robdclark@gmail.com> <20210726233854.2453899-4-robdclark@gmail.com> In-Reply-To: From: Rob Clark Date: Tue, 27 Jul 2021 07:33:01 -0700 Message-ID: Subject: Re: [RFC 3/4] drm/atomic-helper: Set fence deadline for vblank To: =?UTF-8?Q?Michel_D=C3=A4nzer?= Cc: Rob Clark , Matthew Brost , Thomas Zimmermann , David Airlie , =?UTF-8?Q?Christian_K=C3=B6nig?= , open list , dri-devel 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 Tue, Jul 27, 2021 at 3:44 AM Michel D=C3=A4nzer wro= te: > > On 2021-07-27 1:38 a.m., Rob Clark wrote: > > From: Rob Clark > > > > For an atomic commit updating a single CRTC (ie. a pageflip) calculate > > the next vblank time, and inform the fence(s) of that deadline. > > > > Signed-off-by: Rob Clark > > --- > > drivers/gpu/drm/drm_atomic_helper.c | 36 +++++++++++++++++++++++++++++ > > 1 file changed, 36 insertions(+) > > > > diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_= atomic_helper.c > > index bc3487964fb5..f81b20775b15 100644 > > --- a/drivers/gpu/drm/drm_atomic_helper.c > > +++ b/drivers/gpu/drm/drm_atomic_helper.c > > @@ -1406,6 +1406,40 @@ void drm_atomic_helper_commit_modeset_enables(st= ruct drm_device *dev, > > } > > EXPORT_SYMBOL(drm_atomic_helper_commit_modeset_enables); > > > > +/* > > + * For atomic updates which touch just a single CRTC, calculate the ti= me of the > > + * next vblank, and inform all the fences of the of the deadline. > > + */ > > +static void set_fence_deadline(struct drm_device *dev, > > + struct drm_atomic_state *state) > > +{ > > + struct drm_crtc *crtc, *wait_crtc =3D NULL; > > + struct drm_crtc_state *new_crtc_state; > > + struct drm_plane *plane; > > + struct drm_plane_state *new_plane_state; > > + ktime_t vbltime; > > + int i; > > + > > + for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) { > > + if (!wait_crtc) > > + return; > > Either this return or the next one below would always be taken, I doubt t= his was intended. oops, the condition here is mistakenly inverted, it was meant to bail if there is more than a single CRTC > > > + wait_crtc =3D crtc; > > + } > > + > > + /* If no CRTCs updated, then nothing to do: */ > > + if (!wait_crtc) > > + return; > > + > > + if (drm_crtc_next_vblank_time(wait_crtc, &vbltime)) > > + return; > > + > > + for_each_new_plane_in_state (state, plane, new_plane_state, i) { > > + if (!new_plane_state->fence) > > + continue; > > + dma_fence_set_deadline(new_plane_state->fence, vbltime); > > + } > > vblank timestamps correspond to the end of vertical blank, the deadline s= hould be the start of vertical blank though. > hmm, I suppose this depends on whether the hw actually has separate irq's for frame-done and vblank (and whether the driver differentiates).. and if the display controller is doing some buffering, the point at which it wants to flip could be a bit earlier still. Maybe we just want a kms driver provided offset for how early it wants the deadline relative to vblank? BR, -R > > -- > Earthling Michel D=C3=A4nzer | https://redhat= .com > Libre software enthusiast | Mesa and X developer