aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/msm
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2014-11-25 12:41:18 -0500
committerRob Clark <robdclark@gmail.com>2014-12-18 14:32:14 -0500
commitf86afecf0defbc8d046bc7a7c5fc19a8c9ba1364 (patch)
tree1522a0b086298ed21cda7ea41cd74fa3e0b4ee2f /drivers/gpu/drm/msm
parent5acb07ea802c3a06bbe22cba32fbb8eb97b6b3ae (diff)
drm/msm: block incoming update on pending updates
We can't have multiple updates pending on a given CRTC, and we don't want a sync update to race w/ an async update that preceeded it. So keep track of which CRTCs have updates in flight, and block later updates that would conflict. Signed-off-by: Rob Clark <robdclark@gmail.com>
Diffstat (limited to 'drivers/gpu/drm/msm')
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c11
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c7
-rw-r--r--drivers/gpu/drm/msm/msm_atomic.c69
-rw-r--r--drivers/gpu/drm/msm/msm_drv.c1
-rw-r--r--drivers/gpu/drm/msm/msm_drv.h4
5 files changed, 75 insertions, 17 deletions
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
index a7672e100d8b..3449213f1e76 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
@@ -331,17 +331,8 @@ static int mdp4_crtc_atomic_check(struct drm_crtc *crtc,
331 struct drm_crtc_state *state) 331 struct drm_crtc_state *state)
332{ 332{
333 struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc); 333 struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
334 struct drm_device *dev = crtc->dev;
335
336 DBG("%s: check", mdp4_crtc->name); 334 DBG("%s: check", mdp4_crtc->name);
337
338 if (mdp4_crtc->event) {
339 dev_err(dev->dev, "already pending flip!\n");
340 return -EBUSY;
341 }
342
343 // TODO anything else to check? 335 // TODO anything else to check?
344
345 return 0; 336 return 0;
346} 337}
347 338
@@ -357,7 +348,7 @@ static void mdp4_crtc_atomic_flush(struct drm_crtc *crtc)
357 struct drm_device *dev = crtc->dev; 348 struct drm_device *dev = crtc->dev;
358 unsigned long flags; 349 unsigned long flags;
359 350
360 DBG("%s: flush", mdp4_crtc->name); 351 DBG("%s: event: %p", mdp4_crtc->name, crtc->state->event);
361 352
362 WARN_ON(mdp4_crtc->event); 353 WARN_ON(mdp4_crtc->event);
363 354
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
index 0e9a2e3a82d7..930bcec7067f 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
@@ -303,11 +303,6 @@ static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
303 303
304 DBG("%s: check", mdp5_crtc->name); 304 DBG("%s: check", mdp5_crtc->name);
305 305
306 if (mdp5_crtc->event) {
307 dev_err(dev->dev, "already pending flip!\n");
308 return -EBUSY;
309 }
310
311 /* request a free CTL, if none is already allocated for this CRTC */ 306 /* request a free CTL, if none is already allocated for this CRTC */
312 if (state->enable && !mdp5_crtc->ctl) { 307 if (state->enable && !mdp5_crtc->ctl) {
313 mdp5_crtc->ctl = mdp5_ctlm_request(mdp5_kms->ctlm, crtc); 308 mdp5_crtc->ctl = mdp5_ctlm_request(mdp5_kms->ctlm, crtc);
@@ -364,7 +359,7 @@ static void mdp5_crtc_atomic_flush(struct drm_crtc *crtc)
364 struct drm_device *dev = crtc->dev; 359 struct drm_device *dev = crtc->dev;
365 unsigned long flags; 360 unsigned long flags;
366 361
367 DBG("%s: flush", mdp5_crtc->name); 362 DBG("%s: event: %p", mdp5_crtc->name, crtc->state->event);
368 363
369 WARN_ON(mdp5_crtc->event); 364 WARN_ON(mdp5_crtc->event);
370 365
diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c
index f0de412e13dc..191968256c58 100644
--- a/drivers/gpu/drm/msm/msm_atomic.c
+++ b/drivers/gpu/drm/msm/msm_atomic.c
@@ -23,10 +23,41 @@ struct msm_commit {
23 struct drm_atomic_state *state; 23 struct drm_atomic_state *state;
24 uint32_t fence; 24 uint32_t fence;
25 struct msm_fence_cb fence_cb; 25 struct msm_fence_cb fence_cb;
26 uint32_t crtc_mask;
26}; 27};
27 28
28static void fence_cb(struct msm_fence_cb *cb); 29static void fence_cb(struct msm_fence_cb *cb);
29 30
31/* block until specified crtcs are no longer pending update, and
32 * atomically mark them as pending update
33 */
34static int start_atomic(struct msm_drm_private *priv, uint32_t crtc_mask)
35{
36 int ret;
37
38 spin_lock(&priv->pending_crtcs_event.lock);
39 ret = wait_event_interruptible_locked(priv->pending_crtcs_event,
40 !(priv->pending_crtcs & crtc_mask));
41 if (ret == 0) {
42 DBG("start: %08x", crtc_mask);
43 priv->pending_crtcs |= crtc_mask;
44 }
45 spin_unlock(&priv->pending_crtcs_event.lock);
46
47 return ret;
48}
49
50/* clear specified crtcs (no longer pending update)
51 */
52static void end_atomic(struct msm_drm_private *priv, uint32_t crtc_mask)
53{
54 spin_lock(&priv->pending_crtcs_event.lock);
55 DBG("end: %08x", crtc_mask);
56 priv->pending_crtcs &= ~crtc_mask;
57 wake_up_all_locked(&priv->pending_crtcs_event);
58 spin_unlock(&priv->pending_crtcs_event.lock);
59}
60
30static struct msm_commit *new_commit(struct drm_atomic_state *state) 61static struct msm_commit *new_commit(struct drm_atomic_state *state)
31{ 62{
32 struct msm_commit *c = kzalloc(sizeof(*c), GFP_KERNEL); 63 struct msm_commit *c = kzalloc(sizeof(*c), GFP_KERNEL);
@@ -58,12 +89,27 @@ static void complete_commit(struct msm_commit *c)
58 89
59 drm_atomic_helper_commit_post_planes(dev, state); 90 drm_atomic_helper_commit_post_planes(dev, state);
60 91
92 /* NOTE: _wait_for_vblanks() only waits for vblank on
93 * enabled CRTCs. So we end up faulting when disabling
94 * due to (potentially) unref'ing the outgoing fb's
95 * before the vblank when the disable has latched.
96 *
97 * But if it did wait on disabled (or newly disabled)
98 * CRTCs, that would be racy (ie. we could have missed
99 * the irq. We need some way to poll for pipe shut
100 * down. Or just live with occasionally hitting the
101 * timeout in the CRTC disable path (which really should
102 * not be critical path)
103 */
104
61 drm_atomic_helper_wait_for_vblanks(dev, state); 105 drm_atomic_helper_wait_for_vblanks(dev, state);
62 106
63 drm_atomic_helper_cleanup_planes(dev, state); 107 drm_atomic_helper_cleanup_planes(dev, state);
64 108
65 drm_atomic_state_free(state); 109 drm_atomic_state_free(state);
66 110
111 end_atomic(dev->dev_private, c->crtc_mask);
112
67 kfree(c); 113 kfree(c);
68} 114}
69 115
@@ -97,8 +143,9 @@ static void add_fb(struct msm_commit *c, struct drm_framebuffer *fb)
97int msm_atomic_commit(struct drm_device *dev, 143int msm_atomic_commit(struct drm_device *dev,
98 struct drm_atomic_state *state, bool async) 144 struct drm_atomic_state *state, bool async)
99{ 145{
100 struct msm_commit *c;
101 int nplanes = dev->mode_config.num_total_plane; 146 int nplanes = dev->mode_config.num_total_plane;
147 int ncrtcs = dev->mode_config.num_crtc;
148 struct msm_commit *c;
102 int i, ret; 149 int i, ret;
103 150
104 ret = drm_atomic_helper_prepare_planes(dev, state); 151 ret = drm_atomic_helper_prepare_planes(dev, state);
@@ -106,6 +153,18 @@ int msm_atomic_commit(struct drm_device *dev,
106 return ret; 153 return ret;
107 154
108 c = new_commit(state); 155 c = new_commit(state);
156 if (!c)
157 return -ENOMEM;
158
159 /*
160 * Figure out what crtcs we have:
161 */
162 for (i = 0; i < ncrtcs; i++) {
163 struct drm_crtc *crtc = state->crtcs[i];
164 if (!crtc)
165 continue;
166 c->crtc_mask |= (1 << drm_crtc_index(crtc));
167 }
109 168
110 /* 169 /*
111 * Figure out what fence to wait for: 170 * Figure out what fence to wait for:
@@ -122,6 +181,14 @@ int msm_atomic_commit(struct drm_device *dev,
122 } 181 }
123 182
124 /* 183 /*
184 * Wait for pending updates on any of the same crtc's and then
185 * mark our set of crtc's as busy:
186 */
187 ret = start_atomic(dev->dev_private, c->crtc_mask);
188 if (ret)
189 return ret;
190
191 /*
125 * This is the point of no return - everything below never fails except 192 * This is the point of no return - everything below never fails except
126 * when the hw goes bonghits. Which means we can commit the new state on 193 * when the hw goes bonghits. Which means we can commit the new state on
127 * the software side now. 194 * the software side now.
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index d3b791b7ddef..7e1c71e51cb4 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -193,6 +193,7 @@ static int msm_load(struct drm_device *dev, unsigned long flags)
193 193
194 priv->wq = alloc_ordered_workqueue("msm", 0); 194 priv->wq = alloc_ordered_workqueue("msm", 0);
195 init_waitqueue_head(&priv->fence_event); 195 init_waitqueue_head(&priv->fence_event);
196 init_waitqueue_head(&priv->pending_crtcs_event);
196 197
197 INIT_LIST_HEAD(&priv->inactive_list); 198 INIT_LIST_HEAD(&priv->inactive_list);
198 INIT_LIST_HEAD(&priv->fence_cbs); 199 INIT_LIST_HEAD(&priv->fence_cbs);
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 136303818436..b69ef2d5a26c 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -96,6 +96,10 @@ struct msm_drm_private {
96 /* callbacks deferred until bo is inactive: */ 96 /* callbacks deferred until bo is inactive: */
97 struct list_head fence_cbs; 97 struct list_head fence_cbs;
98 98
99 /* crtcs pending async atomic updates: */
100 uint32_t pending_crtcs;
101 wait_queue_head_t pending_crtcs_event;
102
99 /* registered MMUs: */ 103 /* registered MMUs: */
100 unsigned int num_mmus; 104 unsigned int num_mmus;
101 struct msm_mmu *mmus[NUM_DOMAINS]; 105 struct msm_mmu *mmus[NUM_DOMAINS];