linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC/PATCH] drm/rockchip: don't wait for vblank if fb hasn't changed
@ 2016-01-13 12:53 John Keeping
  2016-01-13 14:23 ` Daniel Vetter
  2016-01-17 15:21 ` [RFC/PATCH] drm/rockchip: don't wait for vblank if fb hasn't changed Heiko Stuebner
  0 siblings, 2 replies; 28+ messages in thread
From: John Keeping @ 2016-01-13 12:53 UTC (permalink / raw)
  To: linux-arm-kernel

As commented in drm_atomic_helper_wait_for_vblanks(), userspace relies
on cursor ioctls being unsynced.  Converting the rockchip driver to
atomic has significantly impacted cursor performance by making every
cursor update wait for vblank.

By skipping the vblank sync when the framebuffer has not changed (as is
done in drm_atomic_helper_wait_for_vblanks()) we can avoid this for the
common case of moving the cursor and only need to delay the cursor ioctl
when the cursor icon changes.

I originally inserted a check on legacy_cursor_update as well, but that
caused a storm of iommu page faults.  I didn't investigate the cause of
those since this change gives enough of a performance improvement for my
use case.

This is RFC because of that and because the framebuffer_changed()
function is copied from drm_atomic_helper.c as a quick way to test the
result.

Signed-off-by: John Keeping <john@metanate.com>
---
 drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
index f784488..8fd9821 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
@@ -177,8 +177,28 @@ static void rockchip_crtc_wait_for_update(struct drm_crtc *crtc)
 		crtc_funcs->wait_for_update(crtc);
 }
 
+static bool framebuffer_changed(struct drm_device *dev,
+				struct drm_atomic_state *old_state,
+				struct drm_crtc *crtc)
+{
+	struct drm_plane *plane;
+	struct drm_plane_state *old_plane_state;
+	int i;
+
+	for_each_plane_in_state(old_state, plane, old_plane_state, i) {
+		if (plane->state->crtc != crtc &&
+		    old_plane_state->crtc != crtc)
+			continue;
+
+		if (plane->state->fb != old_plane_state->fb)
+			return true;
+	}
+
+	return false;
+}
+
 static void
-rockchip_atomic_wait_for_complete(struct drm_atomic_state *old_state)
+rockchip_atomic_wait_for_complete(struct drm_device *dev, struct drm_atomic_state *old_state)
 {
 	struct drm_crtc_state *old_crtc_state;
 	struct drm_crtc *crtc;
@@ -194,6 +214,9 @@ rockchip_atomic_wait_for_complete(struct drm_atomic_state *old_state)
 		if (!crtc->state->active)
 			continue;
 
+		if (!framebuffer_changed(dev, old_state, crtc))
+			continue;
+
 		ret = drm_crtc_vblank_get(crtc);
 		if (ret != 0)
 			continue;
@@ -241,7 +264,7 @@ rockchip_atomic_commit_complete(struct rockchip_atomic_commit *commit)
 
 	drm_atomic_helper_commit_planes(dev, state, true);
 
-	rockchip_atomic_wait_for_complete(state);
+	rockchip_atomic_wait_for_complete(dev, state);
 
 	drm_atomic_helper_cleanup_planes(dev, state);
 
-- 
2.7.0.rc3.140.g520a093

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

end of thread, other threads:[~2016-01-21  0:51 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-13 12:53 [RFC/PATCH] drm/rockchip: don't wait for vblank if fb hasn't changed John Keeping
2016-01-13 14:23 ` Daniel Vetter
2016-01-13 14:34   ` John Keeping
2016-01-13 15:40     ` Daniel Vetter
2016-01-13 15:55       ` John Keeping
2016-01-13 16:21         ` Daniel Vetter
2016-01-13 16:40           ` John Keeping
2016-01-13 17:19             ` Daniel Vetter
2016-01-13 17:39               ` John Keeping
2016-01-14  1:16                 ` Mark yao
2016-01-14  8:32                   ` Daniel Vetter
2016-01-14  8:46                     ` Mark yao
2016-01-14 14:20                       ` Daniel Vetter
2016-01-14 14:39                         ` [PATCH 0/3] drm/rockchip: fix cursor performance with atomic John Keeping
2016-01-14 14:39                           ` [PATCH 1/3] drm/atomic-helper: Export framebuffer_changed() John Keeping
2016-01-14 14:56                             ` Daniel Vetter
2016-01-14 14:39                           ` [PATCH 2/3] drm/rockchip: don't wait for vblank if fb hasn't changed John Keeping
2016-01-14 14:39                           ` [PATCH 3/3] drm/rockchip: explain why we can't wait_for_vblanks John Keeping
2016-01-14 14:57                             ` Thierry Reding
2016-01-14 16:26                               ` John Keeping
2016-01-18  1:40                                 ` Mark yao
2016-01-19 10:46                           ` [PATCH v2 0/3] drm/rockchip: fix cursor performance with atomic John Keeping
2016-01-19 10:46                             ` [PATCH v2 1/3] drm/atomic-helper: Export framebuffer_changed() John Keeping
2016-01-19 11:03                               ` Daniel Vetter
2016-01-19 10:46                             ` [PATCH v2 2/3] drm/rockchip: don't wait for vblank if fb hasn't changed John Keeping
2016-01-19 10:47                             ` [PATCH v2 3/3] drm/rockchip: explain why we can't wait_for_vblanks John Keeping
2016-01-21  0:51                             ` [PATCH v2 0/3] drm/rockchip: fix cursor performance with atomic Mark yao
2016-01-17 15:21 ` [RFC/PATCH] drm/rockchip: don't wait for vblank if fb hasn't changed Heiko Stuebner

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).