Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/vmwgfx: Kill some lockdep warnings

Some global KMS state that is elsewhere protected by the mode_config
mutex here needs to be protected with a local mutex. Remove corresponding
lockdep checks and introduce a new driver-private global_kms_state_mutex,
and make sure its locking order is *after* the crtc locks in order to
avoid having to release those when the new mutex is taken.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Cc: <stable@vger.kernel.org> # 4.6

+21 -14
+1
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
··· 628 628 mutex_init(&dev_priv->cmdbuf_mutex); 629 629 mutex_init(&dev_priv->release_mutex); 630 630 mutex_init(&dev_priv->binding_mutex); 631 + mutex_init(&dev_priv->global_kms_state_mutex); 631 632 rwlock_init(&dev_priv->resource_lock); 632 633 ttm_lock_init(&dev_priv->reservation_sem); 633 634 spin_lock_init(&dev_priv->hw_lock);
+1
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
··· 412 412 struct drm_property *implicit_placement_property; 413 413 unsigned num_implicit; 414 414 struct vmw_framebuffer *implicit_fb; 415 + struct mutex global_kms_state_mutex; 415 416 416 417 /* 417 418 * Context and surface management.
+13 -14
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
··· 2143 2143 void vmw_kms_del_active(struct vmw_private *dev_priv, 2144 2144 struct vmw_display_unit *du) 2145 2145 { 2146 - lockdep_assert_held_once(&dev_priv->dev->mode_config.mutex); 2147 - 2146 + mutex_lock(&dev_priv->global_kms_state_mutex); 2148 2147 if (du->active_implicit) { 2149 2148 if (--(dev_priv->num_implicit) == 0) 2150 2149 dev_priv->implicit_fb = NULL; 2151 2150 du->active_implicit = false; 2152 2151 } 2152 + mutex_unlock(&dev_priv->global_kms_state_mutex); 2153 2153 } 2154 2154 2155 2155 /** ··· 2165 2165 struct vmw_display_unit *du, 2166 2166 struct vmw_framebuffer *vfb) 2167 2167 { 2168 - lockdep_assert_held_once(&dev_priv->dev->mode_config.mutex); 2169 - 2168 + mutex_lock(&dev_priv->global_kms_state_mutex); 2170 2169 WARN_ON_ONCE(!dev_priv->num_implicit && dev_priv->implicit_fb); 2171 2170 2172 2171 if (!du->active_implicit && du->is_implicit) { ··· 2173 2174 du->active_implicit = true; 2174 2175 dev_priv->num_implicit++; 2175 2176 } 2177 + mutex_unlock(&dev_priv->global_kms_state_mutex); 2176 2178 } 2177 2179 2178 2180 /** ··· 2190 2190 struct drm_crtc *crtc) 2191 2191 { 2192 2192 struct vmw_display_unit *du = vmw_crtc_to_du(crtc); 2193 + bool ret; 2193 2194 2194 - lockdep_assert_held_once(&dev_priv->dev->mode_config.mutex); 2195 + mutex_lock(&dev_priv->global_kms_state_mutex); 2196 + ret = !du->is_implicit || dev_priv->num_implicit == 1; 2197 + mutex_unlock(&dev_priv->global_kms_state_mutex); 2195 2198 2196 - if (!du->is_implicit) 2197 - return true; 2198 - 2199 - if (dev_priv->num_implicit != 1) 2200 - return false; 2201 - 2202 - return true; 2199 + return ret; 2203 2200 } 2204 2201 2205 2202 /** ··· 2211 2214 struct vmw_display_unit *du = vmw_crtc_to_du(crtc); 2212 2215 struct vmw_framebuffer *vfb; 2213 2216 2214 - lockdep_assert_held_once(&dev_priv->dev->mode_config.mutex); 2217 + mutex_lock(&dev_priv->global_kms_state_mutex); 2215 2218 2216 2219 if (!du->is_implicit) 2217 - return; 2220 + goto out_unlock; 2218 2221 2219 2222 vfb = vmw_framebuffer_to_vfb(crtc->primary->fb); 2220 2223 WARN_ON_ONCE(dev_priv->num_implicit != 1 && 2221 2224 dev_priv->implicit_fb != vfb); 2222 2225 2223 2226 dev_priv->implicit_fb = vfb; 2227 + out_unlock: 2228 + mutex_unlock(&dev_priv->global_kms_state_mutex); 2224 2229 } 2225 2230 2226 2231 /**
+3
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
··· 285 285 } 286 286 287 287 /* Only one active implicit frame-buffer at a time. */ 288 + mutex_lock(&dev_priv->global_kms_state_mutex); 288 289 if (sou->base.is_implicit && 289 290 dev_priv->implicit_fb && vfb && 290 291 !(dev_priv->num_implicit == 1 && 291 292 sou->base.active_implicit) && 292 293 dev_priv->implicit_fb != vfb) { 294 + mutex_unlock(&dev_priv->global_kms_state_mutex); 293 295 DRM_ERROR("Multiple implicit framebuffers not supported.\n"); 294 296 return -EINVAL; 295 297 } 298 + mutex_unlock(&dev_priv->global_kms_state_mutex); 296 299 297 300 /* since they always map one to one these are safe */ 298 301 connector = &sou->base.connector;
+3
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
··· 553 553 } 554 554 555 555 /* Only one active implicit frame-buffer at a time. */ 556 + mutex_lock(&dev_priv->global_kms_state_mutex); 556 557 if (!turning_off && stdu->base.is_implicit && dev_priv->implicit_fb && 557 558 !(dev_priv->num_implicit == 1 && stdu->base.active_implicit) 558 559 && dev_priv->implicit_fb != vfb) { 560 + mutex_unlock(&dev_priv->global_kms_state_mutex); 559 561 DRM_ERROR("Multiple implicit framebuffers not supported.\n"); 560 562 return -EINVAL; 561 563 } 564 + mutex_unlock(&dev_priv->global_kms_state_mutex); 562 565 563 566 /* Since they always map one to one these are safe */ 564 567 connector = &stdu->base.connector;