diff options
author | Mario Kleiner <mario.kleiner.de@gmail.com> | 2016-03-01 15:31:16 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-03-05 12:31:45 -0500 |
commit | 90e94b160c7f647ddffda707f5e3c0c66c170df8 (patch) | |
tree | 36a50d847b90bf8108d2f00584a8abd154ce5780 /drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | |
parent | f0511e66114a6414cfca92d7b94118913a0c11ff (diff) |
drm/amdgpu: Fix error handling in amdgpu_flip_work_func.
The patch e1d09dc0ccc6: "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>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_display.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index 8297bc319369..1846d65b7285 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | |||
@@ -96,7 +96,7 @@ static void amdgpu_flip_work_func(struct work_struct *__work) | |||
96 | * In practice this won't execute very often unless on very fast | 96 | * In practice this won't execute very often unless on very fast |
97 | * machines because the time window for this to happen is very small. | 97 | * machines because the time window for this to happen is very small. |
98 | */ | 98 | */ |
99 | while (amdgpuCrtc->enabled && repcnt--) { | 99 | while (amdgpuCrtc->enabled && --repcnt) { |
100 | /* GET_DISTANCE_TO_VBLANKSTART returns distance to real vblank | 100 | /* GET_DISTANCE_TO_VBLANKSTART returns distance to real vblank |
101 | * start in hpos, and to the "fudged earlier" vblank start in | 101 | * start in hpos, and to the "fudged earlier" vblank start in |
102 | * vpos. | 102 | * vpos. |
@@ -112,13 +112,13 @@ static void amdgpu_flip_work_func(struct work_struct *__work) | |||
112 | break; | 112 | break; |
113 | 113 | ||
114 | /* Sleep at least until estimated real start of hw vblank */ | 114 | /* Sleep at least until estimated real start of hw vblank */ |
115 | spin_unlock_irqrestore(&crtc->dev->event_lock, flags); | ||
116 | min_udelay = (-hpos + 1) * max(vblank->linedur_ns / 1000, 5); | 115 | min_udelay = (-hpos + 1) * max(vblank->linedur_ns / 1000, 5); |
117 | if (min_udelay > vblank->framedur_ns / 2000) { | 116 | if (min_udelay > vblank->framedur_ns / 2000) { |
118 | /* Don't wait ridiculously long - something is wrong */ | 117 | /* Don't wait ridiculously long - something is wrong */ |
119 | repcnt = 0; | 118 | repcnt = 0; |
120 | break; | 119 | break; |
121 | } | 120 | } |
121 | spin_unlock_irqrestore(&crtc->dev->event_lock, flags); | ||
122 | usleep_range(min_udelay, 2 * min_udelay); | 122 | usleep_range(min_udelay, 2 * min_udelay); |
123 | spin_lock_irqsave(&crtc->dev->event_lock, flags); | 123 | spin_lock_irqsave(&crtc->dev->event_lock, flags); |
124 | }; | 124 | }; |