Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4289449pxv; Tue, 27 Jul 2021 03:47:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvSclL/P/6w6UsZGNijXHR5+nJ69ozoaEjRP2ZEC/fJep7oXv3mJnnjPcXXNJnQF49nSN4 X-Received: by 2002:a05:6402:2283:: with SMTP id cw3mr18989171edb.87.1627382829117; Tue, 27 Jul 2021 03:47:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627382829; cv=none; d=google.com; s=arc-20160816; b=aoSYUHu1gDKxO+XkBqqrHxJjFC+tP/0qTdK23C5OxwHCC0a/36CTmqMcK/dL/41M3R oWvy4vvGiImLn6UaxrCYnSK9TFuWISgysk+jtQYDoLd/kE6f52Uf6ABRqND+jCSVN0I9 mXkk0lMen/UlUnqNqqKrCbF9EPXWaZqu4TvbpbN+xzNL9S1/zx7PeFw1bgthV3m5k31a XYhXiG6sl/gcCNaWsdq1uuZOoa5mqJ+OTqoKg0KTFLCzIu8cSnEvX8APU1J3tJvi7t5M i6tHHItd+PEkteV0dtJqMgSfoF8D3AKsx8yo+F/LJcze3rN5VC3+4Kuo7iu4tW+ILTN/ fwBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to; bh=+X2UH2q9d6Vir896thu3ATJdJ7y96UHu6gWXIPMLH10=; b=bCk92KYU7I1+SmHVlT4DuVNV/mjw/jilZEb4GqgNSVc+p1lzwJPjn206rLpxFsc9CT 0x0KXsaxFKIViGGogtluJI/mcrvyCz6gybYQpT76vV3q9NigwBWx86E74ZfNCV7xqPoQ Rxd7TK0f2Hejlq2ShlRUFZX0WPPUdC5Gk7k667tCAwQlFPeA2D5YiXuvHSp+Z1kQxUKS xtNPsbYhFmCmQFl4mE9InujdYMzf03ZWVH1ohuxHZy4pIICxX5QTaj2WdjwmXtWZdPTU ONUBWlgxxKjk9vyZ99jbhIpeFsvt2aINytGmIRsw91asLq5Ewen4LcmZBU2ep1yQSPo+ Jcdg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk7si3068111ejb.51.2021.07.27.03.46.46; Tue, 27 Jul 2021 03:47:09 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236386AbhG0KpA (ORCPT + 99 others); Tue, 27 Jul 2021 06:45:00 -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