aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2012-12-02 09:24:10 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-01-20 16:16:57 -0500
commitdac35663cef4ca7f572d430bb54b14be8f03cb10 (patch)
treed7b1c8b5717ff9efbf867535d493b308610af680
parentbfb899282f500eeb9dff2600729904aad0fd39e7 (diff)
drm: only take the crtc lock for ->cursor_move
->cursor_move uses mostly the same facilities in drivers as ->cursor_set, so pretty much nothing to fix up: - ast/gma500/i915: They all use per-crtc registers to update the cursor position. ast again touches the global cursor cache, but that's ok since there's only one crtc. - nouveau: nv50+ is again special, updates happen through the per-crtc channel (without pushbufs), so it's not protected by the new evo lock introduced earlier. But since this channel is per-crtc, we should be fine anyway. - radeon: A bit a mess: avivo asics need a workaround when both output pipes are enabled, which means it'll access the crtc list. Just reading that flag is ok though as long as radeon _always_ grabs all locks when changing the crtc configuration. Which means with the current scheme it cannot do an optimized modeset which only locks the relevant crtcs. This can be fixed though by introducing a bit of global state with separate locks and ensure in the modeset code that the cursor will be updated appropriately when enabling the 2nd pipe (on affected asics). - vmwgfx: I still don't understand what it's doing exactly, so apply the same trick for now. v2: Fixup unlocking for the error cases, spotted by Richard Wilbur. v3: Another error-case fixup. Reviewed-by: Rob Clark <rob@ti.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/drm_crtc.c10
-rw-r--r--drivers/gpu/drm/radeon/radeon_cursor.c8
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.c13
3 files changed, 24 insertions, 7 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 58fa69e5ff4c..4af6a3d5c9a1 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2039,34 +2039,32 @@ int drm_mode_cursor_ioctl(struct drm_device *dev,
2039 obj = drm_mode_object_find(dev, req->crtc_id, DRM_MODE_OBJECT_CRTC); 2039 obj = drm_mode_object_find(dev, req->crtc_id, DRM_MODE_OBJECT_CRTC);
2040 if (!obj) { 2040 if (!obj) {
2041 DRM_DEBUG_KMS("Unknown CRTC ID %d\n", req->crtc_id); 2041 DRM_DEBUG_KMS("Unknown CRTC ID %d\n", req->crtc_id);
2042 ret = -EINVAL; 2042 return -EINVAL;
2043 goto out;
2044 } 2043 }
2045 crtc = obj_to_crtc(obj); 2044 crtc = obj_to_crtc(obj);
2046 2045
2046 mutex_lock(&crtc->mutex);
2047 if (req->flags & DRM_MODE_CURSOR_BO) { 2047 if (req->flags & DRM_MODE_CURSOR_BO) {
2048 if (!crtc->funcs->cursor_set) { 2048 if (!crtc->funcs->cursor_set) {
2049 ret = -ENXIO; 2049 ret = -ENXIO;
2050 goto out; 2050 goto out;
2051 } 2051 }
2052 /* Turns off the cursor if handle is 0 */ 2052 /* Turns off the cursor if handle is 0 */
2053 mutex_lock(&crtc->mutex);
2054 ret = crtc->funcs->cursor_set(crtc, file_priv, req->handle, 2053 ret = crtc->funcs->cursor_set(crtc, file_priv, req->handle,
2055 req->width, req->height); 2054 req->width, req->height);
2056 mutex_unlock(&crtc->mutex);
2057 } 2055 }
2058 2056
2059 if (req->flags & DRM_MODE_CURSOR_MOVE) { 2057 if (req->flags & DRM_MODE_CURSOR_MOVE) {
2060 if (crtc->funcs->cursor_move) { 2058 if (crtc->funcs->cursor_move) {
2061 drm_modeset_lock_all(dev);
2062 ret = crtc->funcs->cursor_move(crtc, req->x, req->y); 2059 ret = crtc->funcs->cursor_move(crtc, req->x, req->y);
2063 drm_modeset_unlock_all(dev);
2064 } else { 2060 } else {
2065 ret = -EFAULT; 2061 ret = -EFAULT;
2066 goto out; 2062 goto out;
2067 } 2063 }
2068 } 2064 }
2069out: 2065out:
2066 mutex_unlock(&crtc->mutex);
2067
2070 return ret; 2068 return ret;
2071} 2069}
2072 2070
diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c b/drivers/gpu/drm/radeon/radeon_cursor.c
index ad6df625e8b8..c1680e6d76ad 100644
--- a/drivers/gpu/drm/radeon/radeon_cursor.c
+++ b/drivers/gpu/drm/radeon/radeon_cursor.c
@@ -245,8 +245,14 @@ int radeon_crtc_cursor_move(struct drm_crtc *crtc,
245 int i = 0; 245 int i = 0;
246 struct drm_crtc *crtc_p; 246 struct drm_crtc *crtc_p;
247 247
248 /* avivo cursor image can't end on 128 pixel boundary or 248 /*
249 * avivo cursor image can't end on 128 pixel boundary or
249 * go past the end of the frame if both crtcs are enabled 250 * go past the end of the frame if both crtcs are enabled
251 *
252 * NOTE: It is safe to access crtc->enabled of other crtcs
253 * without holding either the mode_config lock or the other
254 * crtc's lock as long as write access to this flag _always_
255 * grabs all locks.
250 */ 256 */
251 list_for_each_entry(crtc_p, &crtc->dev->mode_config.crtc_list, head) { 257 list_for_each_entry(crtc_p, &crtc->dev->mode_config.crtc_list, head) {
252 if (crtc_p->enabled) 258 if (crtc_p->enabled)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 8d82e631c305..3e3c7ab33ca2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -264,10 +264,23 @@ int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
264 du->cursor_x = x + crtc->x; 264 du->cursor_x = x + crtc->x;
265 du->cursor_y = y + crtc->y; 265 du->cursor_y = y + crtc->y;
266 266
267 /*
268 * FIXME: Unclear whether there's any global state touched by the
269 * cursor_set function, especially vmw_cursor_update_position looks
270 * suspicious. For now take the easy route and reacquire all locks. We
271 * can do this since the caller in the drm core doesn't check anything
272 * which is protected by any looks.
273 */
274 mutex_unlock(&crtc->mutex);
275 drm_modeset_lock_all(dev_priv->dev);
276
267 vmw_cursor_update_position(dev_priv, shown, 277 vmw_cursor_update_position(dev_priv, shown,
268 du->cursor_x + du->hotspot_x, 278 du->cursor_x + du->hotspot_x,
269 du->cursor_y + du->hotspot_y); 279 du->cursor_y + du->hotspot_y);
270 280
281 drm_modeset_unlock_all(dev_priv->dev);
282 mutex_lock(&crtc->mutex);
283
271 return 0; 284 return 0;
272} 285}
273 286