All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patches][nouveau/kms]: Precise Vblank and pageflip timestamping
@ 2012-02-15 22:55 Mario Kleiner
       [not found] ` <1329346511-27433-1-git-send-email-mario.kleiner-TdbV1Z3I5XE0NhjG498hmQ@public.gmane.org>
  2012-02-15 22:55 ` [PATCH 2/2] nouveau: implement precise vblank timestamping Mario Kleiner
  0 siblings, 2 replies; 7+ messages in thread
From: Mario Kleiner @ 2012-02-15 22:55 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	bskeggs-H+wXaHxf7aLQT0dZR+AlfA,
	mario.kleiner-TdbV1Z3I5XE0NhjG498hmQ

Hi,

these are two patches against the nouveau kms driver. The first patch
makes sure that pageflip completion events get their vblank count and
timestamp from the drm. The second patch from Lucas Stach, here included
with his permission, makes sure that the timestamps of vblanks are
calculated with high precision and robustness. Both patches together
make sure that all timestamps returned by the kms driver are consistent
with each other and conform to the OML_sync_control specification.

With Lucas permission i've already integrated my feedback from
reviewing his patch into the patch. The patches have been applied
against Linux 3.2 and tested with special measurement equipment on
a GeForce 7800, a GeForce 8800 and some QuadroFX 570 and 370. The
timestamps are accurate to less than 30 usecs deviation from the
ground truth measured with the external equipment.

I'll send out a couple of nouveau ddx patches that make use of
these timestamps.

It would be great if these could be reviewed and possibly included
for the Linux 3.4 merge window.

Thanks,
-mario

^ permalink raw reply	[flat|nested] 7+ messages in thread
[parent not found: <[Patches][nouveau/kms]: Precise Vblank and pageflip timestamping>]
[parent not found: <[Patches][nouveau/kms]: Precise Vblank and pageflip timestamping v2>]
* [PATCH 1/2] drm/nouveau: Use drm_vblank_count_and_time() for pageflip completion events.
@ 2012-04-25 22:26 Lucas Stach
  0 siblings, 0 replies; 7+ messages in thread
From: Lucas Stach @ 2012-04-25 22:26 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Ben Skeggs, Mario Kleiner

From: Mario Kleiner <mario.kleiner-TdbV1Z3I5XE0NhjG498hmQ@public.gmane.org>

Emit kms pageflip completion events with proper vblank count
and timestamp for the vblank interval in which the pageflip
completed. This makes the timestamps and counts consistent with
what the OML_sync_control spec defines.

v2 Lucas Stach: rebased on top of nouveau tree and resolved trivial
conflict.

Signed-off-by: Mario Kleiner <mario.kleiner-TdbV1Z3I5XE0NhjG498hmQ@public.gmane.org>

Conflicts:

	drivers/gpu/drm/nouveau/nouveau_display.c
---
 drivers/gpu/drm/nouveau/nouveau_display.c |   29 +++++++++++++++++++++++------
 drivers/gpu/drm/nouveau/nouveau_drv.h     |    1 +
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 71379f8..2c0f415 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -504,7 +504,7 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 	*s = (struct nouveau_page_flip_state)
 		{ { }, event, nouveau_crtc(crtc)->index,
 		  fb->bits_per_pixel, fb->pitches[0], crtc->x, crtc->y,
-		  new_bo->bo.offset };
+		  new_bo->bo.offset, crtc->framedur_ns };
 
 	/* Choose the channel the flip will be handled in */
 	chan = nouveau_fence_channel(new_bo->bo.sync_obj);
@@ -550,6 +550,9 @@ nouveau_finish_page_flip(struct nouveau_channel *chan,
 	struct drm_device *dev = chan->dev;
 	struct nouveau_page_flip_state *s;
 	unsigned long flags;
+	struct timeval tnow, tvbl;
+
+	do_gettimeofday(&tnow);
 
 	spin_lock_irqsave(&dev->event_lock, flags);
 
@@ -563,12 +566,26 @@ nouveau_finish_page_flip(struct nouveau_channel *chan,
 			     struct nouveau_page_flip_state, head);
 	if (s->event) {
 		struct drm_pending_vblank_event *e = s->event;
-		struct timeval now;
 
-		do_gettimeofday(&now);
-		e->event.sequence = 0;
-		e->event.tv_sec = now.tv_sec;
-		e->event.tv_usec = now.tv_usec;
+		e->event.sequence = drm_vblank_count_and_time(dev, s->crtc, &tvbl);
+
+		/* Called before vblank count and timestamp have
+		 * been updated for the vblank interval of flip
+		 * completion? If so, need to increment vblank count and
+		 * add one videorefresh duration to returned timestamp
+		 * to account for this. We assume this happened if we
+		 * get called over 0.9 frame durations after the last
+		 * timestamped vblank.
+		 */
+		if (10 * (timeval_to_ns(&tnow) - timeval_to_ns(&tvbl)) >
+		     9 * s->framedur_ns) {
+			e->event.sequence++;
+			tvbl = ns_to_timeval(timeval_to_ns(&tvbl) +
+			s->framedur_ns);
+		}
+
+		e->event.tv_sec = tvbl.tv_sec;
+		e->event.tv_usec = tvbl.tv_usec;
 		list_add_tail(&e->base.link, &e->base.file_priv->event_list);
 		wake_up_interruptible(&e->base.file_priv->event_wait);
 	}
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index ab9f9e0..ba10ad7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -203,6 +203,7 @@ struct nouveau_page_flip_state {
 	struct drm_pending_vblank_event *event;
 	int crtc, bpp, pitch, x, y;
 	uint64_t offset;
+	s64 framedur_ns;
 };
 
 enum nouveau_channel_mutex_class {
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-04-25 22:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-15 22:55 [Patches][nouveau/kms]: Precise Vblank and pageflip timestamping Mario Kleiner
     [not found] ` <1329346511-27433-1-git-send-email-mario.kleiner-TdbV1Z3I5XE0NhjG498hmQ@public.gmane.org>
2012-02-15 22:55   ` [PATCH 1/2] drm/nouveau: Use drm_vblank_count_and_time() for pageflip completion events Mario Kleiner
2012-02-15 22:55 ` [PATCH 2/2] nouveau: implement precise vblank timestamping Mario Kleiner
2012-02-16  4:28   ` Ben Skeggs
     [not found] <[Patches][nouveau/kms]: Precise Vblank and pageflip timestamping>
2012-02-16 23:28 ` [Patches][nouveau/kms]: Precise Vblank and pageflip timestamping v2 Lucas Stach
     [not found]   ` <1329434903-19977-1-git-send-email-dev-8ppwABl0HbeELgA04lAiVw@public.gmane.org>
2012-02-16 23:28     ` [PATCH 1/2] drm/nouveau: Use drm_vblank_count_and_time() for pageflip completion events Lucas Stach
     [not found] <[Patches][nouveau/kms]: Precise Vblank and pageflip timestamping v2>
2012-02-20  7:24 ` [Patches][nouveau/kms]: Precise Vblank and pageflip timestamping v2 Lucas Stach
     [not found]   ` <1329722667-2240-1-git-send-email-dev-8ppwABl0HbeELgA04lAiVw@public.gmane.org>
2012-02-20  7:24     ` [PATCH 1/2] drm/nouveau: Use drm_vblank_count_and_time() for pageflip completion events Lucas Stach
2012-04-25 22:26 Lucas Stach

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.