From: Ville Syrjälä Date: Tue, 1 Oct 2013 15:02:12 +0000 (+0300) Subject: drm/i915: Reduce the time we hold struct mutex in sprite update_plane code X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=82284b6becdbef6d8cd3fb43e8698510833a5129;p=openwrt%2Fstaging%2Fblogic.git drm/i915: Reduce the time we hold struct mutex in sprite update_plane code We used to call the entire intel specific update_plane hook while holding struct_mutex. Actually we only need to hold struct_mutex while pinning/unpinning the obj. The plane state itself is protected by the kms locks, and as the object is pinned we can dig out the offset and tiling information from it without fearing that it would change underneath us. So now we don't need to drop and reacquire the lock around the wait_for_vblank. Also we will need another wait_for_vblank in the IVB specific update_plane hook, and this way we don't need to worry about struct_mutex there either. Also move the intel_plane->obj=NULL assignment outside strut_mutex in disable_plane to make it clear that it's not protected by struct_mutex. Signed-off-by: Ville Syrjälä Reviewed-by: Chris Wilson Signed-off-by: Daniel Vetter --- diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index 9161a1db8dff..b859f944b53b 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -525,7 +525,10 @@ intel_enable_primary(struct drm_crtc *crtc) return; intel_crtc->primary_disabled = false; + + mutex_lock(&dev->struct_mutex); intel_update_fbc(dev); + mutex_unlock(&dev->struct_mutex); I915_WRITE(reg, I915_READ(reg) | DISPLAY_PLANE_ENABLE); } @@ -544,7 +547,10 @@ intel_disable_primary(struct drm_crtc *crtc) I915_WRITE(reg, I915_READ(reg) & ~DISPLAY_PLANE_ENABLE); intel_crtc->primary_disabled = true; + + mutex_lock(&dev->struct_mutex); intel_update_fbc(dev); + mutex_unlock(&dev->struct_mutex); } static int @@ -810,8 +816,11 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, * the sprite planes only require 128KiB alignment and 32 PTE padding. */ ret = intel_pin_and_fence_fb_obj(dev, obj, NULL); + + mutex_unlock(&dev->struct_mutex); + if (ret) - goto out_unlock; + return ret; intel_plane->obj = obj; @@ -842,18 +851,15 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, * wait for vblank to avoid ugliness, we only need to * do the pin & ref bookkeeping. */ - if (old_obj != obj) { - mutex_unlock(&dev->struct_mutex); - if (intel_crtc->active) - intel_wait_for_vblank(dev, to_intel_crtc(crtc)->pipe); - mutex_lock(&dev->struct_mutex); - } + if (old_obj != obj && intel_crtc->active) + intel_wait_for_vblank(dev, to_intel_crtc(crtc)->pipe); + + mutex_lock(&dev->struct_mutex); intel_unpin_fb_obj(old_obj); + mutex_unlock(&dev->struct_mutex); } -out_unlock: - mutex_unlock(&dev->struct_mutex); - return ret; + return 0; } static int @@ -885,8 +891,9 @@ intel_disable_plane(struct drm_plane *plane) mutex_lock(&dev->struct_mutex); intel_unpin_fb_obj(intel_plane->obj); - intel_plane->obj = NULL; mutex_unlock(&dev->struct_mutex); + + intel_plane->obj = NULL; out: return ret;