]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.6/drm-amdgpu-fix-error-handling-in-amdgpu_flip_work_func.patch
drop queue-4.14/mips-make-sure-dt-memory-regions-are-valid.patch
[thirdparty/kernel/stable-queue.git] / releases / 4.4.6 / drm-amdgpu-fix-error-handling-in-amdgpu_flip_work_func.patch
1 From 90e94b160c7f647ddffda707f5e3c0c66c170df8 Mon Sep 17 00:00:00 2001
2 From: Mario Kleiner <mario.kleiner.de@gmail.com>
3 Date: Tue, 1 Mar 2016 21:31:16 +0100
4 Subject: drm/amdgpu: Fix error handling in amdgpu_flip_work_func.
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Mario Kleiner <mario.kleiner.de@gmail.com>
10
11 commit 90e94b160c7f647ddffda707f5e3c0c66c170df8 upstream.
12
13 The patch e1d09dc0ccc6: "drm/amdgpu: Don't hang in
14 amdgpu_flip_work_func on disabled crtc." from Feb 19, 2016, leads to
15 the following static checker warning, as reported by Dan Carpenter in
16 https://lists.freedesktop.org/archives/dri-devel/2016-February/101987.html
17
18 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c:127 amdgpu_flip_work_func() warn: should this be 'repcnt == -1'
19 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c:136 amdgpu_flip_work_func() error: double unlock 'spin_lock:&crtc->dev->event_lock'
20 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c:136 amdgpu_flip_work_func() error: double unlock 'irqsave:flags'
21
22 This patch fixes both reported problems:
23
24 Change post-decrement of repcnt to pre-decrement, so
25 it can't underflow anymore, but still performs up to
26 three repetitions - three is the maximum one could
27 expect in practice.
28
29 Move the spin_unlock_irqrestore to where it actually
30 belongs.
31
32 Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
33 Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
34 Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
35 Cc: Michel Dänzer <michel.daenzer@amd.com>
36 Cc: Alex Deucher <alexander.deucher@amd.com>
37 Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
38 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
39
40 ---
41 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 ++--
42 1 file changed, 2 insertions(+), 2 deletions(-)
43
44 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
45 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
46 @@ -96,7 +96,7 @@ static void amdgpu_flip_work_func(struct
47 * In practice this won't execute very often unless on very fast
48 * machines because the time window for this to happen is very small.
49 */
50 - while (amdgpuCrtc->enabled && repcnt--) {
51 + while (amdgpuCrtc->enabled && --repcnt) {
52 /* GET_DISTANCE_TO_VBLANKSTART returns distance to real vblank
53 * start in hpos, and to the "fudged earlier" vblank start in
54 * vpos.
55 @@ -112,13 +112,13 @@ static void amdgpu_flip_work_func(struct
56 break;
57
58 /* Sleep at least until estimated real start of hw vblank */
59 - spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
60 min_udelay = (-hpos + 1) * max(vblank->linedur_ns / 1000, 5);
61 if (min_udelay > vblank->framedur_ns / 2000) {
62 /* Don't wait ridiculously long - something is wrong */
63 repcnt = 0;
64 break;
65 }
66 + spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
67 usleep_range(min_udelay, 2 * min_udelay);
68 spin_lock_irqsave(&crtc->dev->event_lock, flags);
69 };