From: Mario Kleiner <mario.kleiner.de@gmail.com>
To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: Alex Deucher <alexander.deucher@amd.com>,
michel@daenzer.net,
Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Subject: [PATCH 3/3] drm/amd/display: Provide more accurate pageflip timestamps in vrr mode.
Date: Mon, 11 Feb 2019 04:22:25 +0100 [thread overview]
Message-ID: <20190211032225.9488-4-mario.kleiner.de@gmail.com> (raw)
In-Reply-To: <20190211032225.9488-1-mario.kleiner.de@gmail.com>
This implements more accurate pageflip completion timestamps
for crtc's running in variable refresh rate mode.
In vrr mode, the pageflip completion interrupt handler takes
a ktime_get() timestamp of pageflip completion as a at least
roughly correct lower estimate of when the vblank of flip
completion will end and thereby display of the new scanout
buffer will start.
It submits this proposed timestamp via the new helper function
drm_crtc_set_vrr_pageflip_timestamp(). The DRM core will decide
when sending out pageflip events, if the regular vblank timestamp
gets sent out, or this alternate later timestamp, following the
rule that a post-flip buffer can't start displaying earlier than
the vblank timestamp, which corresponds to the end of the shortest
possible vblank interval under vrr mode.
This is a crude first implementation, but it should reduce
pageflip timestamp errors from potentially dozens of milliseconds
to probably less than 2 msecs in the common case, given the fixed
and short back-porch duration and the usually low interrupt dispatch
delay from pageflip interrupt.
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Cc: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index d4da331aa349..49c5a044297f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -280,7 +280,9 @@ static void dm_pflip_high_irq(void *interrupt_params)
struct amdgpu_crtc *amdgpu_crtc;
struct common_irq_params *irq_params = interrupt_params;
struct amdgpu_device *adev = irq_params->adev;
+ struct dm_crtc_state *acrtc_state;
unsigned long flags;
+ ktime_t t_onset = ktime_get();
amdgpu_crtc = get_crtc_by_otg_inst(adev, irq_params->irq_src - IRQ_TYPE_PFLIP);
@@ -306,6 +308,24 @@ static void dm_pflip_high_irq(void *interrupt_params)
/* Update to correct count(s) if racing with vblank irq */
amdgpu_crtc->last_flip_vblank = drm_crtc_accurate_vblank_count(&amdgpu_crtc->base);
+ /* VRR pageflip timestamp handling: In VRR mode, compute alternate flip
+ * timestamp for flip completion in extended front porch, ie. estimating
+ * the time of the end of a longer than minimum vblank interval. DRM
+ * will decide to use this alternate timestamp, or the standard vblank
+ * timestamp for minimum duration vblank. The later timestamp is the one
+ * chosen for the pageflip event.
+ */
+ acrtc_state = to_dm_crtc_state(amdgpu_crtc->base.state);
+ if (acrtc_state->freesync_config.state == VRR_STATE_ACTIVE_VARIABLE) {
+ /* FIXME: t_onset is just a pflip irq timestamp taken above.
+ * Add the fixed back-porch duration? Or even better use some
+ * hardware trickery to get a more precise estimate of true
+ * end of vblank?
+ */
+ /* Propose "late" vblank end timestamp for consideration. */
+ drm_crtc_set_vrr_pageflip_timestamp(&amdgpu_crtc->base, t_onset);
+ }
+
/* wake up userspace */
if (amdgpu_crtc->event) {
drm_crtc_send_vblank_event(&amdgpu_crtc->base, amdgpu_crtc->event);
--
2.17.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
prev parent reply other threads:[~2019-02-11 3:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-11 3:22 Some VRR vblank/pageflip timestamping fixes Mario Kleiner
2019-02-11 3:22 ` [PATCH 1/3] drm/amdgpu: Fix get_crtc_scanoutpos behavior in vrr when vpos >= vtotal Mario Kleiner
[not found] ` <20190211032225.9488-1-mario.kleiner.de-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-02-11 3:22 ` [PATCH 2/3] drm: Add basic helper to allow precise pageflip timestamps in vrr Mario Kleiner
2019-02-11 8:35 ` Daniel Vetter
[not found] ` <20190211083540.GR23159-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2019-02-11 15:01 ` Kazlauskas, Nicholas
[not found] ` <41354dd1-e3fe-58cc-9c10-1a8cd05b2a40-5C7GfCeVMHo@public.gmane.org>
2019-02-11 17:04 ` Daniel Vetter
2019-02-12 21:32 ` Mario Kleiner via dri-devel
[not found] ` <CAEsyxyiT-k5LecWs1=Zyj9J=GPjbQFQSPzYQpDxFzjwwRvFS-A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-02-13 9:50 ` Daniel Vetter
[not found] ` <20190213095055.GF23159-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2019-02-13 9:55 ` Chris Wilson
2019-02-13 11:05 ` Mario Kleiner via amd-gfx
[not found] ` <CAEsyxygzqwWGJLBZ5M_AkGQ7HFgzS=rxRgZ+dCFK0QG7Ek63Zw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-02-13 12:46 ` Daniel Vetter
2019-02-13 11:22 ` Mario Kleiner via amd-gfx
2019-02-13 14:33 ` Kazlauskas, Nicholas
[not found] ` <f1680226-4123-8fd6-374c-e639595f7dd6-5C7GfCeVMHo@public.gmane.org>
2019-02-13 15:14 ` Daniel Vetter
2019-02-13 15:41 ` Kazlauskas, Nicholas
[not found] ` <b65833b3-5f68-87b7-7fe6-d89fd58a83ef-5C7GfCeVMHo@public.gmane.org>
2019-02-13 16:03 ` Daniel Vetter
[not found] ` <CAKMK7uGr8+zvRuTKo6ecDOFfGFnPRwxR8AWwhNAcqJat_vtk8w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-02-13 18:10 ` Mario Kleiner via amd-gfx
[not found] ` <CAEsyxygFmFDZWrmPXSa0qwc76trF9Cj-e1TOsJc7kDorxuGBqw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-02-13 18:34 ` Kazlauskas, Nicholas
2019-02-13 20:53 ` Daniel Vetter
2019-02-11 3:22 ` Mario Kleiner [this message]
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=20190211032225.9488-4-mario.kleiner.de@gmail.com \
--to=mario.kleiner.de@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=michel@daenzer.net \
--cc=nicholas.kazlauskas@amd.com \
/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