Skip to contentSkip to conversation

drm/atomic-helpers: Stall on the right commit

PATCH In review Daniel Vetter 2 participants 2 messages Jun 14, 2016 – Jun 15, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/atomic-helpers: Stall on the right commit

stall_checks carefully picked out the right commit to stall on, then promptly used the wrong variable. Due to the break in the next loop iteration this could be the 3rd commit, or if the list only has 2 entries commit would now point into the struct drm_crtc itself, at some offset. Hilarity eventually ensues.

For added safety, also break right away instead of iterating once more, but the real fix is waiting on stall_commit instead of commit.

---
 drivers/gpu/drm/drm_atomic_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +2 -2
index 6a13df8691d4..716aa535eb98 100644
@@ -1324,8 +1324,8 @@ static int stall_checks(struct drm_crtc *crtc, bool nonblock)
 		} else if (i == 1) {
 			stall_commit = commit;
 			drm_crtc_commit_get(stall_commit);
-		} else
 			break;
+		}
 
 		i++;
 	}
@@ -1337,7 +1337,7 @@ static int stall_checks(struct drm_crtc *crtc, bool nonblock)
 	/* We don't want to let commits get ahead of cleanup work too much,
 	 * stalling on 2nd previous commit means triple-buffer won't ever stall.
 	 */
-	ret = wait_for_completion_interruptible_timeout(&commit->cleanup_done,
+	ret = wait_for_completion_interruptible_timeout(&stall_commit->cleanup_done,
 							10*HZ);
 	if (ret == 0)
 		DRM_ERROR("[CRTC:%d:%s] cleanup_done timed out\n",
Signature · 6 lines
2.8.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Daniel Vetter

stall_checks carefully picked out the right commit to stall on, then promptly used the wrong variable. Due to the break in the next loop iteration this could be the 3rd commit, or if the list only has 2 entries commit would now point into the struct drm_crtc itself, at some offset. Hilarity eventually ensues.

For added safety, also break right away instead of iterating once more, but the real fix is waiting on stall_commit instead of commit.

Reported-and-tested-by Liviu Dudau <[email protected]>
Cc Liviu Dudau <[email protected]>
Quoted 31 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +2 -2
index 6a13df8691d4..716aa535eb98 100644
@@ -1324,8 +1324,8 @@ static int stall_checks(struct drm_crtc *crtc, bool nonblock)
 		} else if (i == 1) {
 			stall_commit = commit;
 			drm_crtc_commit_get(stall_commit);
-		} else
 			break;
+		}
 
 		i++;
 	}
@@ -1337,7 +1337,7 @@ static int stall_checks(struct drm_crtc *crtc, bool nonblock)
 	/* We don't want to let commits get ahead of cleanup work too much,
 	 * stalling on 2nd previous commit means triple-buffer won't ever stall.
 	 */
-	ret = wait_for_completion_interruptible_timeout(&commit->cleanup_done,
+	ret = wait_for_completion_interruptible_timeout(&stall_commit->cleanup_done,
 							10*HZ);
 	if (ret == 0)
 		DRM_ERROR("[CRTC:%d:%s] cleanup_done timed out\n",
Signature · 1 line
2.8.1
Signature · 12 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel