aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Reding <thierry.reding@avionic-design.de>2013-02-13 10:08:33 -0500
committerThierry Reding <thierry.reding@avionic-design.de>2013-02-22 02:21:07 -0500
commit8cf1e9811471f2910fa38dc1b28e1789080ba961 (patch)
tree45b779f761fba928171b9d8a9c1928398737a5d5
parentc976cb37a95a8dcaf23d04d6487fbacc33d3c913 (diff)
drm: Add consistency check for page-flipping
Driver implementations of the drm_crtc's .page_flip() function are required to update the crtc->fb field on success to reflect that the new framebuffer is now in use. This is important to keep reference counting on the framebuffers balanced. While at it, document this requirement to keep others from falling into the same trap. Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--Documentation/DocBook/drm.tmpl6
-rw-r--r--drivers/gpu/drm/drm_crtc.c7
2 files changed, 13 insertions, 0 deletions
diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 51e1904ac4c7..a6428ddfcfc2 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -1161,6 +1161,12 @@ int max_width, max_height;</synopsis>
1161 any new rendering to the frame buffer until the page flip completes. 1161 any new rendering to the frame buffer until the page flip completes.
1162 </para> 1162 </para>
1163 <para> 1163 <para>
1164 If a page flip can be successfully scheduled the driver must set the
1165 <code>drm_crtc-&lt;fb</code> field to the new framebuffer pointed to
1166 by <code>fb</code>. This is important so that the reference counting
1167 on framebuffers stays balanced.
1168 </para>
1169 <para>
1164 If a page flip is already pending, the 1170 If a page flip is already pending, the
1165 <methodname>page_flip</methodname> operation must return 1171 <methodname>page_flip</methodname> operation must return
1166 -<errorname>EBUSY</errorname>. 1172 -<errorname>EBUSY</errorname>.
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 781aef524b3b..3bdf2a650d9c 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -3792,6 +3792,13 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
3792 /* Keep the old fb, don't unref it. */ 3792 /* Keep the old fb, don't unref it. */
3793 old_fb = NULL; 3793 old_fb = NULL;
3794 } else { 3794 } else {
3795 /*
3796 * Warn if the driver hasn't properly updated the crtc->fb
3797 * field to reflect that the new framebuffer is now used.
3798 * Failing to do so will screw with the reference counting
3799 * on framebuffers.
3800 */
3801 WARN_ON(crtc->fb != fb);
3795 /* Unref only the old framebuffer. */ 3802 /* Unref only the old framebuffer. */
3796 fb = NULL; 3803 fb = NULL;
3797 } 3804 }