Skip to content

Commit 1e1490a

Browse files
kleinermalexdeucher
authored andcommitted
drm/radeon: Fix error handling in radeon_flip_work_func.
This is a port of the patch "drm/amdgpu: Fix error handling in amdgpu_flip_work_func." to fix the following problem for radeon as well which was reported against amdgpu: The patch e1d09dc: "drm/amdgpu: Don't hang in amdgpu_flip_work_func on disabled crtc." from Feb 19, 2016, leads to the following static checker warning, as reported by Dan Carpenter in https://lists.freedesktop.org/archives/dri-devel/2016-February/101987.html drivers/gpu/drm/amd/amdgpu/amdgpu_display.c:127 amdgpu_flip_work_func() warn: should this be 'repcnt == -1' drivers/gpu/drm/amd/amdgpu/amdgpu_display.c:136 amdgpu_flip_work_func() error: double unlock 'spin_lock:&crtc->dev->event_lock' drivers/gpu/drm/amd/amdgpu/amdgpu_display.c:136 amdgpu_flip_work_func() error: double unlock 'irqsave:flags' This patch fixes both reported problems: Change post-decrement of repcnt to pre-decrement, so it can't underflow anymore, but still performs up to three repetitions - three is the maximum one could expect in practice. Move the spin_unlock_irqrestore to where it actually belongs. Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com> Cc: <stable@vger.kernel.org> # 4.4+ Cc: Michel Dänzer <michel.daenzer@amd.com> Cc: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 90e94b1 commit 1e1490a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/gpu/drm/radeon/radeon_display.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ static void radeon_flip_work_func(struct work_struct *__work)
455455
* In practice this won't execute very often unless on very fast
456456
* machines because the time window for this to happen is very small.
457457
*/
458-
while (radeon_crtc->enabled && repcnt--) {
458+
while (radeon_crtc->enabled && --repcnt) {
459459
/* GET_DISTANCE_TO_VBLANKSTART returns distance to real vblank
460460
* start in hpos, and to the "fudged earlier" vblank start in
461461
* vpos.
@@ -471,13 +471,13 @@ static void radeon_flip_work_func(struct work_struct *__work)
471471
break;
472472

473473
/* Sleep at least until estimated real start of hw vblank */
474-
spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
475474
min_udelay = (-hpos + 1) * max(vblank->linedur_ns / 1000, 5);
476475
if (min_udelay > vblank->framedur_ns / 2000) {
477476
/* Don't wait ridiculously long - something is wrong */
478477
repcnt = 0;
479478
break;
480479
}
480+
spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
481481
usleep_range(min_udelay, 2 * min_udelay);
482482
spin_lock_irqsave(&crtc->dev->event_lock, flags);
483483
};

0 commit comments

Comments
 (0)