From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88FA6C4338F for ; Tue, 27 Jul 2021 10:45:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 643C7611C5 for ; Tue, 27 Jul 2021 10:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236397AbhG0KpC (ORCPT ); Tue, 27 Jul 2021 06:45:02 -0400 Received: from mail.netline.ch ([148.251.143.180]:34028 "EHLO netline-mail3.netline.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236337AbhG0Ko7 (ORCPT ); Tue, 27 Jul 2021 06:44:59 -0400 Received: from localhost (localhost [127.0.0.1]) by netline-mail3.netline.ch (Postfix) with ESMTP id E485D20201B; Tue, 27 Jul 2021 12:44:57 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at netline-mail3.netline.ch Received: from netline-mail3.netline.ch ([127.0.0.1]) by localhost (netline-mail3.netline.ch [127.0.0.1]) (amavisd-new, port 10024) with LMTP id p2PTXK-_M2ZX; Tue, 27 Jul 2021 12:44:57 +0200 (CEST) Received: from thor (24.99.2.85.dynamic.wline.res.cust.swisscom.ch [85.2.99.24]) by netline-mail3.netline.ch (Postfix) with ESMTPA id 11A9F20201A; Tue, 27 Jul 2021 12:44:57 +0200 (CEST) Received: from localhost ([::1]) by thor with esmtp (Exim 4.94.2) (envelope-from ) id 1m8KZz-000lIP-GV; Tue, 27 Jul 2021 12:44:55 +0200 To: Rob Clark Cc: Matthew Brost , Rob Clark , Thomas Zimmermann , David Airlie , =?UTF-8?Q?Christian_K=c3=b6nig?= , open list , dri-devel@lists.freedesktop.org References: <20210726233854.2453899-1-robdclark@gmail.com> <20210726233854.2453899-4-robdclark@gmail.com> From: =?UTF-8?Q?Michel_D=c3=a4nzer?= Subject: Re: [RFC 3/4] drm/atomic-helper: Set fence deadline for vblank Message-ID: Date: Tue, 27 Jul 2021 12:44:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210726233854.2453899-4-robdclark@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(struct drm_device *dev, > } > EXPORT_SYMBOL(drm_atomic_helper_commit_modeset_enables); > > +/* > + * For atomic updates which touch just a single CRTC, calculate the time 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 = 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 this was intended. > + wait_crtc = 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 should be the start of vertical blank though. -- Earthling Michel Dänzer | https://redhat.com Libre software enthusiast | Mesa and X developer