Skip to content

Commit 270b77a

Browse files
committed
Merge tag 'drm-fixes-2018-10-20-1' of git://anongit.freedesktop.org/drm/drm
Dave writes: "drm fixes for 4.19 final (part 2) Looked like two stragglers snuck in, one very urgent the pageflipping was missing a reference that could result in a GPF on non-i915 drivers, the other is an overflow in the sun4i dotclock calcs resulting in a mode not getting set." * tag 'drm-fixes-2018-10-20-1' of git://anongit.freedesktop.org/drm/drm: drm/sun4i: Fix an ulong overflow in the dotclock driver drm: Get ref on CRTC commit object when waiting for flip_done
2 parents 6b5201c + fe7acd1 commit 270b77a

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

drivers/gpu/drm/drm_atomic.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state)
174174
state->crtcs[i].state = NULL;
175175
state->crtcs[i].old_state = NULL;
176176
state->crtcs[i].new_state = NULL;
177+
178+
if (state->crtcs[i].commit) {
179+
drm_crtc_commit_put(state->crtcs[i].commit);
180+
state->crtcs[i].commit = NULL;
181+
}
177182
}
178183

179184
for (i = 0; i < config->num_total_plane; i++) {

drivers/gpu/drm/drm_atomic_helper.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,15 +1408,16 @@ EXPORT_SYMBOL(drm_atomic_helper_wait_for_vblanks);
14081408
void drm_atomic_helper_wait_for_flip_done(struct drm_device *dev,
14091409
struct drm_atomic_state *old_state)
14101410
{
1411-
struct drm_crtc_state *new_crtc_state;
14121411
struct drm_crtc *crtc;
14131412
int i;
14141413

1415-
for_each_new_crtc_in_state(old_state, crtc, new_crtc_state, i) {
1416-
struct drm_crtc_commit *commit = new_crtc_state->commit;
1414+
for (i = 0; i < dev->mode_config.num_crtc; i++) {
1415+
struct drm_crtc_commit *commit = old_state->crtcs[i].commit;
14171416
int ret;
14181417

1419-
if (!commit)
1418+
crtc = old_state->crtcs[i].ptr;
1419+
1420+
if (!crtc || !commit)
14201421
continue;
14211422

14221423
ret = wait_for_completion_timeout(&commit->flip_done, 10 * HZ);
@@ -1934,6 +1935,9 @@ int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
19341935
drm_crtc_commit_get(commit);
19351936

19361937
commit->abort_completion = true;
1938+
1939+
state->crtcs[i].commit = commit;
1940+
drm_crtc_commit_get(commit);
19371941
}
19381942

19391943
for_each_oldnew_connector_in_state(state, conn, old_conn_state, new_conn_state, i) {

drivers/gpu/drm/sun4i/sun4i_dotclock.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,19 @@ static long sun4i_dclk_round_rate(struct clk_hw *hw, unsigned long rate,
8181
int i;
8282

8383
for (i = tcon->dclk_min_div; i <= tcon->dclk_max_div; i++) {
84-
unsigned long ideal = rate * i;
84+
u64 ideal = (u64)rate * i;
8585
unsigned long rounded;
8686

87+
/*
88+
* ideal has overflowed the max value that can be stored in an
89+
* unsigned long, and every clk operation we might do on a
90+
* truncated u64 value will give us incorrect results.
91+
* Let's just stop there since bigger dividers will result in
92+
* the same overflow issue.
93+
*/
94+
if (ideal > ULONG_MAX)
95+
goto out;
96+
8797
rounded = clk_hw_round_rate(clk_hw_get_parent(hw),
8898
ideal);
8999

include/drm/drm_atomic.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,17 @@ struct __drm_planes_state {
153153
struct __drm_crtcs_state {
154154
struct drm_crtc *ptr;
155155
struct drm_crtc_state *state, *old_state, *new_state;
156+
157+
/**
158+
* @commit:
159+
*
160+
* A reference to the CRTC commit object that is kept for use by
161+
* drm_atomic_helper_wait_for_flip_done() after
162+
* drm_atomic_helper_commit_hw_done() is called. This ensures that a
163+
* concurrent commit won't free a commit object that is still in use.
164+
*/
165+
struct drm_crtc_commit *commit;
166+
156167
s32 __user *out_fence_ptr;
157168
u64 last_vblank_count;
158169
};

0 commit comments

Comments
 (0)