Commit 44e921d4 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Optimize VLV/CHV display FIFO updates

Use I915_{READ,WRITE}_FW() for updating the DSPARB registers on
VLV/CHV. This is less expesive as we can grab the uncore.lock across
the entire sequence of reads and writes instead of each register
access grabbing it.

This also allows us to eliminate the dsparb lock entirely as the
uncore.lock now effectively protects the contents of the DSPARB
registers.

v2: Add a note that interrupts are already disabled (Chris)

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170309154434.29303-6-ville.syrjala@linux.intel.comReviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
parent dd584fc0
...@@ -825,7 +825,6 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv, ...@@ -825,7 +825,6 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv,
spin_lock_init(&dev_priv->mm.object_stat_lock); spin_lock_init(&dev_priv->mm.object_stat_lock);
spin_lock_init(&dev_priv->mmio_flip_lock); spin_lock_init(&dev_priv->mmio_flip_lock);
spin_lock_init(&dev_priv->wm.dsparb_lock);
mutex_init(&dev_priv->sb_lock); mutex_init(&dev_priv->sb_lock);
mutex_init(&dev_priv->modeset_restore_lock); mutex_init(&dev_priv->modeset_restore_lock);
mutex_init(&dev_priv->av_mutex); mutex_init(&dev_priv->av_mutex);
......
...@@ -2375,9 +2375,6 @@ struct drm_i915_private { ...@@ -2375,9 +2375,6 @@ struct drm_i915_private {
} sagv_status; } sagv_status;
struct { struct {
/* protects DSPARB registers on pre-g4x/vlv/chv */
spinlock_t dsparb_lock;
/* /*
* Raw watermark latency values: * Raw watermark latency values:
* in 0.1us units for WM0, * in 0.1us units for WM0,
......
...@@ -1358,13 +1358,22 @@ static void vlv_atomic_update_fifo(struct intel_atomic_state *state, ...@@ -1358,13 +1358,22 @@ static void vlv_atomic_update_fifo(struct intel_atomic_state *state,
trace_vlv_fifo_size(crtc, sprite0_start, sprite1_start, fifo_size); trace_vlv_fifo_size(crtc, sprite0_start, sprite1_start, fifo_size);
spin_lock(&dev_priv->wm.dsparb_lock); /*
* uncore.lock serves a double purpose here. It allows us to
* use the less expensive I915_{READ,WRITE}_FW() functions, and
* it protects the DSPARB registers from getting clobbered by
* parallel updates from multiple pipes.
*
* intel_pipe_update_start() has already disabled interrupts
* for us, so a plain spin_lock() is sufficient here.
*/
spin_lock(&dev_priv->uncore.lock);
switch (crtc->pipe) { switch (crtc->pipe) {
uint32_t dsparb, dsparb2, dsparb3; uint32_t dsparb, dsparb2, dsparb3;
case PIPE_A: case PIPE_A:
dsparb = I915_READ(DSPARB); dsparb = I915_READ_FW(DSPARB);
dsparb2 = I915_READ(DSPARB2); dsparb2 = I915_READ_FW(DSPARB2);
dsparb &= ~(VLV_FIFO(SPRITEA, 0xff) | dsparb &= ~(VLV_FIFO(SPRITEA, 0xff) |
VLV_FIFO(SPRITEB, 0xff)); VLV_FIFO(SPRITEB, 0xff));
...@@ -1376,12 +1385,12 @@ static void vlv_atomic_update_fifo(struct intel_atomic_state *state, ...@@ -1376,12 +1385,12 @@ static void vlv_atomic_update_fifo(struct intel_atomic_state *state,
dsparb2 |= (VLV_FIFO(SPRITEA_HI, sprite0_start >> 8) | dsparb2 |= (VLV_FIFO(SPRITEA_HI, sprite0_start >> 8) |
VLV_FIFO(SPRITEB_HI, sprite1_start >> 8)); VLV_FIFO(SPRITEB_HI, sprite1_start >> 8));
I915_WRITE(DSPARB, dsparb); I915_WRITE_FW(DSPARB, dsparb);
I915_WRITE(DSPARB2, dsparb2); I915_WRITE_FW(DSPARB2, dsparb2);
break; break;
case PIPE_B: case PIPE_B:
dsparb = I915_READ(DSPARB); dsparb = I915_READ_FW(DSPARB);
dsparb2 = I915_READ(DSPARB2); dsparb2 = I915_READ_FW(DSPARB2);
dsparb &= ~(VLV_FIFO(SPRITEC, 0xff) | dsparb &= ~(VLV_FIFO(SPRITEC, 0xff) |
VLV_FIFO(SPRITED, 0xff)); VLV_FIFO(SPRITED, 0xff));
...@@ -1393,12 +1402,12 @@ static void vlv_atomic_update_fifo(struct intel_atomic_state *state, ...@@ -1393,12 +1402,12 @@ static void vlv_atomic_update_fifo(struct intel_atomic_state *state,
dsparb2 |= (VLV_FIFO(SPRITEC_HI, sprite0_start >> 8) | dsparb2 |= (VLV_FIFO(SPRITEC_HI, sprite0_start >> 8) |
VLV_FIFO(SPRITED_HI, sprite1_start >> 8)); VLV_FIFO(SPRITED_HI, sprite1_start >> 8));
I915_WRITE(DSPARB, dsparb); I915_WRITE_FW(DSPARB, dsparb);
I915_WRITE(DSPARB2, dsparb2); I915_WRITE_FW(DSPARB2, dsparb2);
break; break;
case PIPE_C: case PIPE_C:
dsparb3 = I915_READ(DSPARB3); dsparb3 = I915_READ_FW(DSPARB3);
dsparb2 = I915_READ(DSPARB2); dsparb2 = I915_READ_FW(DSPARB2);
dsparb3 &= ~(VLV_FIFO(SPRITEE, 0xff) | dsparb3 &= ~(VLV_FIFO(SPRITEE, 0xff) |
VLV_FIFO(SPRITEF, 0xff)); VLV_FIFO(SPRITEF, 0xff));
...@@ -1410,16 +1419,16 @@ static void vlv_atomic_update_fifo(struct intel_atomic_state *state, ...@@ -1410,16 +1419,16 @@ static void vlv_atomic_update_fifo(struct intel_atomic_state *state,
dsparb2 |= (VLV_FIFO(SPRITEE_HI, sprite0_start >> 8) | dsparb2 |= (VLV_FIFO(SPRITEE_HI, sprite0_start >> 8) |
VLV_FIFO(SPRITEF_HI, sprite1_start >> 8)); VLV_FIFO(SPRITEF_HI, sprite1_start >> 8));
I915_WRITE(DSPARB3, dsparb3); I915_WRITE_FW(DSPARB3, dsparb3);
I915_WRITE(DSPARB2, dsparb2); I915_WRITE_FW(DSPARB2, dsparb2);
break; break;
default: default:
break; break;
} }
POSTING_READ(DSPARB); POSTING_READ_FW(DSPARB);
spin_unlock(&dev_priv->wm.dsparb_lock); spin_unlock(&dev_priv->uncore.lock);
} }
#undef VLV_FIFO #undef VLV_FIFO
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment