From: Rob Clark <robdclark@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: "Rob Clark" <robdclark@chromium.org>,
"Christian König" <ckoenig.leichtzumerken@gmail.com>,
intel-gfx@lists.freedesktop.org,
"open list" <linux-kernel@vger.kernel.org>,
"Daniel Vetter" <daniel.vetter@ffwll.ch>,
"Luben Tuikov" <luben.tuikov@amd.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Matt Turner" <mattst88@gmail.com>,
freedreno@lists.freedesktop.org
Subject: [PATCH v10 11/15] drm/atomic-helper: Set fence deadline for vblank
Date: Wed, 8 Mar 2023 07:53:02 -0800 [thread overview]
Message-ID: <20230308155322.344664-12-robdclark@gmail.com> (raw)
In-Reply-To: <20230308155322.344664-1-robdclark@gmail.com>
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)
v3: If there are multiple CRTCs, consider the time of the soonest vblank
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 | 37 +++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index d579fd8f7cb8..28e3f2c8917e 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1511,6 +1511,41 @@ 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;
+ struct drm_crtc_state *new_crtc_state;
+ struct drm_plane *plane;
+ struct drm_plane_state *new_plane_state;
+ ktime_t vbltime = 0;
+ int i;
+
+ for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) {
+ ktime_t v;
+
+ if (drm_crtc_next_vblank_start(crtc, &v))
+ continue;
+
+ if (!vbltime || ktime_before(v, vbltime))
+ vbltime = v;
+ }
+
+ /* If no CRTCs updated, then nothing to do: */
+ if (!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 +1575,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;
--
2.39.2
next prev parent reply other threads:[~2023-03-08 15:54 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-08 15:52 [PATCH v10 00/15] dma-fence: Deadline awareness Rob Clark
2023-03-08 15:52 ` [PATCH v10 01/15] dma-buf/dma-fence: Add deadline awareness Rob Clark
2023-03-10 15:45 ` Jonas Ådahl
2023-03-10 17:38 ` Rob Clark
2023-03-15 13:53 ` Jonas Ådahl
2023-03-15 16:19 ` Rob Clark
2023-03-16 9:26 ` Jonas Ådahl
2023-03-16 16:28 ` Rob Clark
2023-03-16 22:22 ` Sebastian Wick
2023-03-16 22:59 ` Rob Clark
2023-03-17 15:07 ` Sebastian Wick
2023-03-17 9:09 ` Pekka Paalanen
2023-03-17 9:17 ` Pekka Paalanen
2023-03-17 9:59 ` Pekka Paalanen
2023-03-17 9:10 ` Michel Dänzer
2023-03-17 10:23 ` Jonas Ådahl
2023-03-17 15:59 ` Rob Clark
2023-03-21 13:24 ` Jonas Ådahl
2023-03-21 14:34 ` Rob Clark
2023-03-08 15:52 ` [PATCH v10 02/15] dma-buf/fence-array: Add fence deadline support Rob Clark
2023-03-08 15:52 ` [PATCH v10 03/15] dma-buf/fence-chain: " Rob Clark
2023-03-08 15:52 ` [PATCH v10 04/15] dma-buf/dma-resv: Add a way to set fence deadline Rob Clark
2023-03-08 15:52 ` [PATCH v10 05/15] dma-buf/sync_file: Surface sync-file uABI Rob Clark
2023-03-08 15:52 ` [PATCH v10 06/15] dma-buf/sync_file: Add SET_DEADLINE ioctl Rob Clark
2023-03-08 15:52 ` [PATCH v10 07/15] dma-buf/sw_sync: Add fence deadline support Rob Clark
2023-03-28 13:57 ` Tvrtko Ursulin
2023-03-08 15:52 ` [PATCH v10 08/15] drm/scheduler: " Rob Clark
2023-03-08 15:53 ` [PATCH v10 09/15] drm/syncobj: Add deadline support for syncobj waits Rob Clark
2023-03-17 19:08 ` [Intel-gfx] " Faith Ekstrand
2023-03-17 19:38 ` Rob Clark
2023-03-18 16:07 ` Rob Clark
2023-03-28 14:24 ` Tvrtko Ursulin
2023-03-08 15:53 ` [PATCH v10 10/15] drm/vblank: Add helper to get next vblank time Rob Clark
2023-03-08 15:53 ` Rob Clark [this message]
2023-03-31 20:44 ` [PATCH v10 11/15] drm/atomic-helper: Set fence deadline for vblank Nathan Chancellor
2023-03-31 22:14 ` Rob Clark
2023-03-31 23:30 ` Nathan Chancellor
2023-04-01 15:39 ` Rob Clark
2023-04-04 17:22 ` Dmitry Baryshkov
2023-04-04 19:16 ` Daniel Vetter
2023-04-04 21:53 ` Dmitry Baryshkov
2023-04-05 7:58 ` Daniel Vetter
2023-03-08 15:53 ` [PATCH v10 12/15] drm/msm: Add deadline based boost support Rob Clark
2023-03-08 15:53 ` [PATCH v10 13/15] drm/msm: Add wait-boost support Rob Clark
2023-03-08 15:53 ` [PATCH v10 14/15] drm/msm/atomic: Switch to vblank_start helper Rob Clark
2023-03-08 15:53 ` [PATCH v10 15/15] drm/i915: Add deadline based boost support Rob Clark
2023-03-09 10:21 ` [PATCH v10 00/15] dma-fence: Deadline awareness Pekka Paalanen
2023-03-16 21:22 ` Rob Clark
2023-03-27 19:05 ` Matt Turner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230308155322.344664-12-robdclark@gmail.com \
--to=robdclark@gmail.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luben.tuikov@amd.com \
--cc=mattst88@gmail.com \
--cc=robdclark@chromium.org \
--cc=rodrigo.vivi@intel.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).