Message ID | 20230218211608.1630586-12-robdclark@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp554255wrn; Sat, 18 Feb 2023 13:17:57 -0800 (PST) X-Google-Smtp-Source: AK7set99F6MJbvZO3vFt/S+dakM1jy5qYxj7m8YQHbUkWSquXOZ3FTmIO+f43AND9uKSOOYTaSdF X-Received: by 2002:a17:90b:1d8a:b0:234:17b:ae2b with SMTP id pf10-20020a17090b1d8a00b00234017bae2bmr388349pjb.13.1676755076721; Sat, 18 Feb 2023 13:17:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676755076; cv=none; d=google.com; s=arc-20160816; b=EY8H1o01yZ3FJbuxERWBIR+qnGCNNoRYkrW5NjWnggTJgXI94Oz4IyFC7kbXeyf1m9 vpO1GGvPpfSxfkkZpskJO7Z5DbN+nXGEyEHuQkQ7lneW26hvFMajm7YRK+qt4EXjXs/D eA54bD0kqRi0eaIbxaffavAZaG+eeww0ThA+PZ0zbUOD8k7sTMiS5HWCb7Jc8BLMSdr1 +7IrRzeN16cJR8eVJMO9M1/LyHOIAJyVhqre+C/Moop6gLhj9qT0Dvd32XfisYXyz79n Hd9fXfcZILuyOgHXASZZehw/lrat3eiogs9k+gdGvx9FtTCTgyp+mbCS3DXGpCam2G/r BeKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9yF21jz9Wf1+ysDiZnumY8mp3PUToyh/n6nr/hm38/k=; b=nHrfVbWqIKUn9DBcWDe2YDoIKH5cC5DtNhu2h+brwraTuxi+J0MfT7VbK2EN2lnui6 a6MNjpwqnzxm7U8V0CuJSoFoibrIVwt0pdynyPpMG5oYZs7TQQVnaRub4s4SOuY8HtL+ DT3u4BPRV11DrmZMJ5hMkDqZhITG//+g7rhtIPJ02jl0iiASiZmhByOHF9A+KXxAHbPu yslV9HOaBFxbokBjfmZY+Wl6Icg/QfsheJkWMwaQR9QXHpu753Ayz15e6jMT+YXlGCz5 g7hsniF1SFWwcr6CKeNtImILPK0eWSlj0l148Q0L+YMdOIGx6GQPJxnId02FmSLZ22kY 3Xkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=o3KZu6xC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s4-20020a17090ad48400b0022bb99803d9si8978724pju.164.2023.02.18.13.17.44; Sat, 18 Feb 2023 13:17:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=o3KZu6xC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230018AbjBRVRJ (ORCPT <rfc822;assdfgzxcv4@gmail.com> + 99 others); Sat, 18 Feb 2023 16:17:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229912AbjBRVQO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 18 Feb 2023 16:16:14 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08BC416AF6 for <linux-kernel@vger.kernel.org>; Sat, 18 Feb 2023 13:16:03 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id a5-20020a17090a70c500b00236679bc70cso13890pjm.4 for <linux-kernel@vger.kernel.org>; Sat, 18 Feb 2023 13:16:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9yF21jz9Wf1+ysDiZnumY8mp3PUToyh/n6nr/hm38/k=; b=o3KZu6xCZhOx8yKLO3mCPTkTO6tIsRYmbOCGeJBqVniPc0jFqnNjoHWeefirhtUCQD TMs4eZTOs8KhFyvy1g7Y9zc5kpRNWaU+YjrhCI0IjZKJHAefvOW94v4Dvkm0LEbtvHuu vzxcd1WXm9wrdxUdbR7dY2ZQ2XClD6c5Gn77V1jB543GNPc7fQn2yq5/fobhwsvghKil 2LcGEX1LDJhLA9cS8/Eq6f+d05FvrxWhwhn9n4RxA6yLI8lNL9gy4vMuECMYp3adFLxY jFsUaLS6DZPqaOrW6zXMPOxhyfe3J7t7Zryk/soeD4VzpBWEKQhlxetBTVeAudYUDL07 N2HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9yF21jz9Wf1+ysDiZnumY8mp3PUToyh/n6nr/hm38/k=; b=ER5O0dccRNFodLe0PK7DA3sALzY2i3XSk+sLnXmc6H0fCTSopIt1zyoeZN24WsG6Bv EMrQQ8OrQQhB1X1tWf2KDaxU6bkk0vhDaUI6ySIJMRqdvhW697Vil8RH+xhfkM6bDfkn 6DbXEBHWjekDBBVfIQxZ6NJLFjRZUU4iQpl3uHOr0CWco1shjLDtCndHhVwrsbTpixQ5 h8tsOOnLOd5+R9AvmKkFMLdKb4nkaR/yYNFBe1YNyfgLRv8d5wavBDUrzgwvmoLNnLfx wdLtJIOLDgLbwaOWCqNTsj77paRTKYcOwnlb5r3B6Jmh2pMsZH9EoLUBxJ5lEMWn2Gck 6FWg== X-Gm-Message-State: AO0yUKVedwMJpd9AGFIyXgn8Bvx9VL/MPQCVU2O1YlCxS+1DGOvVNQEw 9cSFS3DjKDL6dP49gdMTRLaKL2rjYWI= X-Received: by 2002:a17:902:cf52:b0:19a:7c7d:7180 with SMTP id e18-20020a170902cf5200b0019a7c7d7180mr3479908plg.34.1676754963579; Sat, 18 Feb 2023 13:16:03 -0800 (PST) Received: from localhost (c-73-67-135-195.hsd1.or.comcast.net. [73.67.135.195]) by smtp.gmail.com with ESMTPSA id i3-20020a170902c28300b0019251e959b1sm5033341pld.262.2023.02.18.13.16.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 13:16:03 -0800 (PST) From: Rob Clark <robdclark@gmail.com> To: dri-devel@lists.freedesktop.org Cc: freedreno@lists.freedesktop.org, Daniel Vetter <daniel@ffwll.ch>, =?utf-8?q?Christian_K=C3=B6nig?= <ckoenig.leichtzumerken@gmail.com>, =?utf-8?q?Michel_D=C3=A4nzer?= <michel@daenzer.net>, Tvrtko Ursulin <tvrtko.ursulin@intel.com>, Rodrigo Vivi <rodrigo.vivi@intel.com>, Alex Deucher <alexander.deucher@amd.com>, Pekka Paalanen <ppaalanen@gmail.com>, Simon Ser <contact@emersion.fr>, Rob Clark <robdclark@chromium.org>, Daniel Vetter <daniel.vetter@ffwll.ch>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Maxime Ripard <mripard@kernel.org>, Thomas Zimmermann <tzimmermann@suse.de>, David Airlie <airlied@gmail.com>, linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 11/14] drm/atomic-helper: Set fence deadline for vblank Date: Sat, 18 Feb 2023 13:15:54 -0800 Message-Id: <20230218211608.1630586-12-robdclark@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230218211608.1630586-1-robdclark@gmail.com> References: <20230218211608.1630586-1-robdclark@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758205131321089787?= X-GMAIL-MSGID: =?utf-8?q?1758205131321089787?= |
Series |
dma-fence: Deadline awareness
|
|
Commit Message
Rob Clark
Feb. 18, 2023, 9:15 p.m. UTC
From: Rob Clark <robdclark@chromium.org> For an atomic commit updating a single CRTC (ie. a pageflip) calculate the next vblank time, and inform the fence(s) of that deadline. v2: Comment typo fix (danvet) Signed-off-by: Rob Clark <robdclark@chromium.org> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Rob Clark <robdclark@chromium.org> --- drivers/gpu/drm/drm_atomic_helper.c | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
Comments
On 2023-02-18 16:15, Rob Clark wrote: > From: Rob Clark <robdclark@chromium.org> > > For an atomic commit updating a single CRTC (ie. a pageflip) calculate > the next vblank time, and inform the fence(s) of that deadline. > > v2: Comment typo fix (danvet) > > Signed-off-by: Rob Clark <robdclark@chromium.org> > Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> > Signed-off-by: Rob Clark <robdclark@chromium.org> > --- > 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 d579fd8f7cb8..35a4dc714920 100644 > --- a/drivers/gpu/drm/drm_atomic_helper.c > +++ b/drivers/gpu/drm/drm_atomic_helper.c > @@ -1511,6 +1511,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 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; I've not looked at the latest language spec, but is AFAIR "vbltime" would be uninitialized here. Has this changed? > + int i; > + > + for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) { > + if (wait_crtc) > + return; > + 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; We have a problem here in that we're adding the time remaining to the next vblank event to an uninitialized local variable. As per my comment on patch 10, I'd rather drm_crtc_next_vblank_time() yield the time remaining to the vblank event, and we can do the arithmetic locally here in this function.
On Wed, Feb 22, 2023 at 2:46 AM Luben Tuikov <luben.tuikov@amd.com> wrote: > > On 2023-02-18 16:15, Rob Clark wrote: > > From: Rob Clark <robdclark@chromium.org> > > > > For an atomic commit updating a single CRTC (ie. a pageflip) calculate > > the next vblank time, and inform the fence(s) of that deadline. > > > > v2: Comment typo fix (danvet) > > > > Signed-off-by: Rob Clark <robdclark@chromium.org> > > Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> > > Signed-off-by: Rob Clark <robdclark@chromium.org> > > --- > > 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 d579fd8f7cb8..35a4dc714920 100644 > > --- a/drivers/gpu/drm/drm_atomic_helper.c > > +++ b/drivers/gpu/drm/drm_atomic_helper.c > > @@ -1511,6 +1511,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 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; > > I've not looked at the latest language spec, but is AFAIR "vbltime" > would be uninitialized here. Has this changed? > > > + int i; > > + > > + for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) { > > + if (wait_crtc) > > + return; > > + 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; > > We have a problem here in that we're adding the time remaining to the next > vblank event to an uninitialized local variable. As per my comment on patch 10, > I'd rather drm_crtc_next_vblank_time() yield the time remaining to the vblank event, > and we can do the arithmetic locally here in this function. if drm_crtc_next_vblank_time() returns 0 then it has initialized vbltime, so no problem here BR, -R > -- > Regards, > Luben > > > + > > + 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); > > + } > > +} > > + > > /** > > * drm_atomic_helper_wait_for_fences - wait for fences stashed in plane state > > * @dev: DRM device > > @@ -1540,6 +1574,8 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev, > > struct drm_plane_state *new_plane_state; > > int i, ret; > > > > + set_fence_deadline(dev, state); > > + > > for_each_new_plane_in_state(state, plane, new_plane_state, i) { > > if (!new_plane_state->fence) > > continue; >
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index d579fd8f7cb8..35a4dc714920 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -1511,6 +1511,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 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; + 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); + } +} + /** * drm_atomic_helper_wait_for_fences - wait for fences stashed in plane state * @dev: DRM device @@ -1540,6 +1574,8 @@ int drm_atomic_helper_wait_for_fences(struct drm_device *dev, struct drm_plane_state *new_plane_state; int i, ret; + set_fence_deadline(dev, state); + for_each_new_plane_in_state(state, plane, new_plane_state, i) { if (!new_plane_state->fence) continue;