Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3592974pxj; Tue, 1 Jun 2021 08:44:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweovN+w7/LOcaWaVDAk2IVJpBxjZT0wmDDtPGZb4KsAPV6WbZomfvv0Wnquyp5ICw0QUPZ X-Received: by 2002:a02:9109:: with SMTP id a9mr26418263jag.93.1622562272575; Tue, 01 Jun 2021 08:44:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622562272; cv=none; d=google.com; s=arc-20160816; b=Mi7jiuos17sf2AdHwtYy2P7CX6Zpg8ozGRNV5zfzt0LpRcf3Bj8WOWjkE0lmOPViC4 Hm37803M7RNPSZAgr9RXJeCRFQbo2EUDvCDmxfAjeFhfM27YoPW4n3gjHoPHEti0OWBP OuHzbwuvrEcvw5LW+NIPJ0682Cp/iXtdo+p881W2raMNfIsCOl+MBW64B6fQF8wt3Pm9 PIEkWo3vDNYk7wycF77xHH+8sT3Q/6qbyGN6euYKouKFrbLdR+Wbu08L1j5XUmRsRD/J oCADtnllxT38dZJf9bcXrFoxco4b1bsDr4lC4F6N1LxplEFE2g0kSxjwgRlrusTnydFv M2KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ej3vlHeKK1+uQ8+If+YtX+yV0AeomMPg/9tYvhXhlPE=; b=pPnA0xnTs/aOQIWzu+0hmcOjFDC1TxfOfJYAKVTHs7Y3XWlml88DxmElOpAlsPyrGf G07zGF8GgHwMAGXLndDlNgjBjCu/wTVI9Rb90T3tYLYrdqzamldxMHAiu8Lwvipj7Jmo dfjanrEEmZLwZUVt2i2uqV34RwG7oUyvjspjvSgAnSjqI3n4GA8d/yaPTRdXolqEgQRP 3RS4LIl0jVjDp3lj/LN1yK1M4OChERN2NfeInf13d0SNX10CAzVuWWHUCV0Sqx1zdgTK 0UwRHA8Ugq8RITfTe5nSN/orS3NOT4sVTir6zVBAiwSlSl2xWY9W33JupEiWgiSOyqSi kfVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CxMW+c3L; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v17si18433205jan.123.2021.06.01.08.44.18; Tue, 01 Jun 2021 08:44:32 -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=@gmail.com header.s=20161025 header.b=CxMW+c3L; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233059AbhFAPoH (ORCPT + 99 others); Tue, 1 Jun 2021 11:44:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230288AbhFAPoG (ORCPT ); Tue, 1 Jun 2021 11:44:06 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46B9BC061574; Tue, 1 Jun 2021 08:42:24 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id l18-20020a1ced120000b029014c1adff1edso1886860wmh.4; Tue, 01 Jun 2021 08:42:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ej3vlHeKK1+uQ8+If+YtX+yV0AeomMPg/9tYvhXhlPE=; b=CxMW+c3L3LN09Ja/Gp1nCIEMlaF9lzN1sjUuZlg7SuItpgg/3DTnB+FedhwxEQZh0Y qwQ55cSDvxXetARJDYA317Z72y/NcwOqs99DDzfsuAk3rsUcPNOy6ho/kd77pP3KJryO Z+fpP2KrQyJNy/whNf3NmFYq8vWRu0O+CraTKsj1M3EpEscqFxnQe2r7P42GKofrrDXl CoC3sZ6bVKaF2J50CtjISgqzYU5BCpuyBX2KN51MddYptEtcjxm1d1LR+LQT4ynqZs49 6kcxnxhcN9dovPl+V3iWC9khbuTw5SIFB5u2kvTe3XbdzW3kiBeFEMPf7ibPqIRJrmmh IQfA== 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; bh=ej3vlHeKK1+uQ8+If+YtX+yV0AeomMPg/9tYvhXhlPE=; b=AdPVeZb1U805zDsRIrGlj1o3NcfzUxLq5NLS1wK359H3b95VRSQdLLMGIsFgHTL2Xf 1x62ST489sGx3LHMSw5rArqTuRBwBC6DOQlCl36DaKbtOlq5QJBE+3FnpLgAzHlvHvQH 0fQIQ+8gd3nrx4NaQEQPQUJMi5s+nqb3q8JM/281nVwkqTIWa1rqYl4lEo6cB5fh/63K ljQFtKwB7+EGXMIZrXY08e/g/t/13dqHlQrBsioDzh6V7+bDfSMbYPekZLA8PL654Bod RNBbHn9vLHhZ512noymFGfpmKPu4cPpdkTxhkzx1Eyx8g4XrzGXGXShQSjfYg5D+0G7P HG6w== X-Gm-Message-State: AOAM531IgqoEl5qk6ypGIi3J4WLS0zgCXUL2RCHTRITf4KYXao8/MQ8N MDkkDlwL+us7DP1PQKWfvA77mheql+jYgMRc7/4= X-Received: by 2002:a1c:23d6:: with SMTP id j205mr564816wmj.94.1622562142833; Tue, 01 Jun 2021 08:42:22 -0700 (PDT) MIME-Version: 1.0 References: <20210519183855.1523927-1-robdclark@gmail.com> <20210519183855.1523927-3-robdclark@gmail.com> In-Reply-To: From: Rob Clark Date: Tue, 1 Jun 2021 08:46:14 -0700 Message-ID: Subject: Re: [RFC 2/3] drm/atomic: Call dma_fence_boost() when we've missed a vblank To: Rob Clark , dri-devel , freedreno , linux-arm-msm , Rob Clark , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , open list , Matthew Brost Cc: Daniel Vetter Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 1, 2021 at 7:18 AM Daniel Vetter wrote: > > On Sun, May 30, 2021 at 07:33:57AM -0700, Rob Clark wrote: > > On Thu, May 20, 2021 at 9:29 AM Daniel Vetter wrote: > > > > > > On Wed, May 19, 2021 at 11:38:53AM -0700, Rob Clark wrote: > > > > From: Rob Clark > > > > > > > > Signed-off-by: Rob Clark > > > > --- > > > > drivers/gpu/drm/drm_atomic_helper.c | 11 +++++++++++ > > > > 1 file changed, 11 insertions(+) > > > > > > > > diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c > > > > index 560aaecba31b..fe10fc2e7f86 100644 > > > > --- a/drivers/gpu/drm/drm_atomic_helper.c > > > > +++ b/drivers/gpu/drm/drm_atomic_helper.c > > > > @@ -1435,11 +1435,15 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev, > > > > int i, ret; > > > > > > > > for_each_new_plane_in_state(state, plane, new_plane_state, i) { > > > > + u64 vblank_count; > > > > + > > > > if (!new_plane_state->fence) > > > > continue; > > > > > > > > WARN_ON(!new_plane_state->fb); > > > > > > > > + vblank_count = drm_crtc_vblank_count(new_plane_state->crtc); > > > > + > > > > /* > > > > * If waiting for fences pre-swap (ie: nonblock), userspace can > > > > * still interrupt the operation. Instead of blocking until the > > > > @@ -1449,6 +1453,13 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev, > > > > if (ret) > > > > return ret; > > > > > > > > + /* > > > > + * Check if we've missed a vblank while waiting, and if we have > > > > + * signal the fence that it's signaler should be boosted > > > > + */ > > > > + if (vblank_count != drm_crtc_vblank_count(new_plane_state->crtc)) > > > > + dma_fence_boost(new_plane_state->fence); > > > > > > I think we should do a lot better here: > > > - maybe only bother doing this for single-crtc updates, and only if > > > modeset isn't set. No one else cares about latency. > > > > > > - We should boost _right_ when we've missed the frame, so I think we > > > should have a _timeout wait here that guesstimates when the vblank is > > > over (might need to throw in a vblank wait if we missed) and then boost > > > immediately. Not wait a bunch of frames (worst case) until we finally > > > decide to boost. > > > > I was thinking about this a bit more.. How about rather than calling > > some fence->op->boost() type thing when we are about to miss a vblank > > (IMO that is also already too late), we do something more like > > fence->ops->set_deadline() before we even wait? > > Hm yeah that sounds like a clean idea. > > Even more, why not add the deadline/waiter information to the callback > we're adding? That way drivers can inspect it whenever they feel like and > don't have to duplicate the tracking. And it's probably easier to > tune/adjust to the myriads of use-cases (flip target miss, userspace wait, > wakeup boost maybe too ...). You mean, enumerate the types of deadline? For userspace waits, we might have a timeout, but not really (currently) any more information than that? The vblank deadline is the only type of deadline that seems pretty clear to me. I suppose we could do something like: dma_fence_set_deadline(fence, &(struct dma_fence_deadline){ .type = DMA_FENCE_DEADLINE_VBLANK, .time = next_vblank_ktime, }); to make it a bit more extensible to add more deadline types or additional optional information BR, -R > > I like this direction a lot more than what we discussed with post-miss > hints thus far. > > > It's probably a bit impossible for a gpu driver to really predict how > > long some rendering will take, but other cases like video decoder are > > somewhat more predictable.. the fence provider could predict given the > > remaining time until the deadline what clk rates are required to get > > you there. > > Well if we do have a deadline the driver can note that in its scheduler > and arm a driver to kick the clocks. Or maybe use past history to do this > upfront. > -Daniel > > > > > BR, > > -R > > > > > > > > > > Otherwise I really like this, I think it's about the only real reason i915 > > > isn't using atomic helpers. > > > > > > Also adding Matt B for this topic. > > > -Daniel > > > > > > > + > > > > dma_fence_put(new_plane_state->fence); > > > > new_plane_state->fence = NULL; > > > > } > > > > -- > > > > 2.30.2 > > > > > > > > > > -- > > > Daniel Vetter > > > Software Engineer, Intel Corporation > > > http://blog.ffwll.ch > > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch