Commit 8ac80733 authored by Ville Syrjälä's avatar Ville Syrjälä
Browse files

drm/i915: Split update_plane() into update_noarm() + update_arm()



The amount of plane registers we have to write has been steadily
increasing, putting more pressure on the vblank evasion mechanism
and forcing us to increase its time budget. Let's try to take some
of the pressure off by splitting plane updates into two parts:
1) write all non-self arming plane registers, ie. the registers
   where the write actually does nothing until a separate arming
   register is also written which will cause the hardware to latch
   the new register values at the next start of vblank
2) write all self arming plane registers, ie. registers which always
   just latch at the next start of vblank, and registers which also
   arm other registers to do so

Here we just provide the mechanism, but don't actually implement
the split on any platform yet. so everything stays now in the _arm()
hooks. Subsequently we can move a whole bunch of stuff into the
_noarm() part, especially in more modern platforms where the number
of registers we have to write is also the greatest. On older
platforms this is less beneficial probably, but no real reason
to deviate from a common behaviour.

And let's sprinkle some TODOs around the areas that will need
adapting.

Cc: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211018115030.3547-5-ville.syrjala@linux.intel.com


Reviewed-by: default avatarStanislav Lisovskiy <stanislav.lisovskiy@intel.com>
parent e56b80d9
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -402,7 +402,8 @@ static int i9xx_plane_min_cdclk(const struct intel_crtc_state *crtc_state,
	return DIV_ROUND_UP(pixel_rate * num, den);
}

static void i9xx_update_plane(struct intel_plane *plane,
/* TODO: split into noarm+arm pair */
static void i9xx_plane_update_arm(struct intel_plane *plane,
				  const struct intel_crtc_state *crtc_state,
				  const struct intel_plane_state *plane_state)
{
@@ -477,7 +478,7 @@ static void i9xx_update_plane(struct intel_plane *plane,
	spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
}

static void i9xx_disable_plane(struct intel_plane *plane,
static void i9xx_plane_disable_arm(struct intel_plane *plane,
				   const struct intel_crtc_state *crtc_state)
{
	struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
@@ -836,8 +837,8 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe)
			plane->max_stride = ilk_primary_max_stride;
	}

	plane->update_plane = i9xx_update_plane;
	plane->disable_plane = i9xx_disable_plane;
	plane->update_arm = i9xx_plane_update_arm;
	plane->disable_arm = i9xx_plane_disable_arm;
	plane->get_hw_state = i9xx_plane_get_hw_state;
	plane->check_plane = i9xx_plane_check;

+68 −20
Original line number Diff line number Diff line
@@ -470,30 +470,71 @@ skl_next_plane_to_commit(struct intel_atomic_state *state,
	return NULL;
}

void intel_update_plane(struct intel_plane *plane,
void intel_plane_update_noarm(struct intel_plane *plane,
			      const struct intel_crtc_state *crtc_state,
			      const struct intel_plane_state *plane_state)
{
	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);

	trace_intel_update_plane(&plane->base, crtc);
	trace_intel_plane_update_noarm(&plane->base, crtc);

	if (plane->update_noarm)
		plane->update_noarm(plane, crtc_state, plane_state);
}

void intel_plane_update_arm(struct intel_plane *plane,
			    const struct intel_crtc_state *crtc_state,
			    const struct intel_plane_state *plane_state)
{
	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);

	trace_intel_plane_update_arm(&plane->base, crtc);

	if (crtc_state->uapi.async_flip && plane->async_flip)
		plane->async_flip(plane, crtc_state, plane_state, true);
	else
		plane->update_plane(plane, crtc_state, plane_state);
		plane->update_arm(plane, crtc_state, plane_state);
}

void intel_disable_plane(struct intel_plane *plane,
void intel_plane_disable_arm(struct intel_plane *plane,
			     const struct intel_crtc_state *crtc_state)
{
	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);

	trace_intel_disable_plane(&plane->base, crtc);
	plane->disable_plane(plane, crtc_state);
	trace_intel_plane_disable_arm(&plane->base, crtc);
	plane->disable_arm(plane, crtc_state);
}

void skl_update_planes_on_crtc(struct intel_atomic_state *state,
void intel_update_planes_on_crtc(struct intel_atomic_state *state,
				 struct intel_crtc *crtc)
{
	struct intel_crtc_state *new_crtc_state =
		intel_atomic_get_new_crtc_state(state, crtc);
	u32 update_mask = new_crtc_state->update_planes;
	struct intel_plane_state *new_plane_state;
	struct intel_plane *plane;
	int i;

	if (new_crtc_state->uapi.async_flip)
		return;

	/*
	 * Since we only write non-arming registers here,
	 * the order does not matter even for skl+.
	 */
	for_each_new_intel_plane_in_state(state, plane, new_plane_state, i) {
		if (crtc->pipe != plane->pipe ||
		    !(update_mask & BIT(plane->id)))
			continue;

		/* TODO: for mailbox updates this should be skipped */
		if (new_plane_state->uapi.visible ||
		    new_plane_state->planar_slave)
			intel_plane_update_noarm(plane, new_crtc_state, new_plane_state);
	}
}

void skl_arm_planes_on_crtc(struct intel_atomic_state *state,
			    struct intel_crtc *crtc)
{
	struct intel_crtc_state *old_crtc_state =
@@ -516,16 +557,19 @@ void skl_update_planes_on_crtc(struct intel_atomic_state *state,
		struct intel_plane_state *new_plane_state =
			intel_atomic_get_new_plane_state(state, plane);

		/*
		 * TODO: for mailbox updates intel_plane_update_noarm()
		 * would have to be called here as well.
		 */
		if (new_plane_state->uapi.visible ||
		    new_plane_state->planar_slave) {
			intel_update_plane(plane, new_crtc_state, new_plane_state);
		} else {
			intel_disable_plane(plane, new_crtc_state);
		}
		    new_plane_state->planar_slave)
			intel_plane_update_arm(plane, new_crtc_state, new_plane_state);
		else
			intel_plane_disable_arm(plane, new_crtc_state);
	}
}

void i9xx_update_planes_on_crtc(struct intel_atomic_state *state,
void i9xx_arm_planes_on_crtc(struct intel_atomic_state *state,
			     struct intel_crtc *crtc)
{
	struct intel_crtc_state *new_crtc_state =
@@ -540,10 +584,14 @@ void i9xx_update_planes_on_crtc(struct intel_atomic_state *state,
		    !(update_mask & BIT(plane->id)))
			continue;

		/*
		 * TODO: for mailbox updates intel_plane_update_noarm()
		 * would have to be called here as well.
		 */
		if (new_plane_state->uapi.visible)
			intel_update_plane(plane, new_crtc_state, new_plane_state);
			intel_plane_update_arm(plane, new_crtc_state, new_plane_state);
		else
			intel_disable_plane(plane, new_crtc_state);
			intel_plane_disable_arm(plane, new_crtc_state);
	}
}

+14 −9
Original line number Diff line number Diff line
@@ -30,19 +30,24 @@ void intel_plane_copy_uapi_to_hw_state(struct intel_plane_state *plane_state,
				       struct intel_crtc *crtc);
void intel_plane_copy_hw_state(struct intel_plane_state *plane_state,
			       const struct intel_plane_state *from_plane_state);
void intel_update_plane(struct intel_plane *plane,
void intel_plane_update_noarm(struct intel_plane *plane,
			      const struct intel_crtc_state *crtc_state,
			      const struct intel_plane_state *plane_state);
void intel_disable_plane(struct intel_plane *plane,
void intel_plane_update_arm(struct intel_plane *plane,
			    const struct intel_crtc_state *crtc_state,
			    const struct intel_plane_state *plane_state);
void intel_plane_disable_arm(struct intel_plane *plane,
			     const struct intel_crtc_state *crtc_state);
struct intel_plane *intel_plane_alloc(void);
void intel_plane_free(struct intel_plane *plane);
struct drm_plane_state *intel_plane_duplicate_state(struct drm_plane *plane);
void intel_plane_destroy_state(struct drm_plane *plane,
			       struct drm_plane_state *state);
void skl_update_planes_on_crtc(struct intel_atomic_state *state,
void intel_update_planes_on_crtc(struct intel_atomic_state *state,
				 struct intel_crtc *crtc);
void skl_arm_planes_on_crtc(struct intel_atomic_state *state,
			    struct intel_crtc *crtc);
void i9xx_update_planes_on_crtc(struct intel_atomic_state *state,
void i9xx_arm_planes_on_crtc(struct intel_atomic_state *state,
			     struct intel_crtc *crtc);
int intel_plane_atomic_check_with_state(const struct intel_crtc_state *old_crtc_state,
					struct intel_crtc_state *crtc_state,
+24 −20
Original line number Diff line number Diff line
@@ -248,7 +248,8 @@ static int i845_check_cursor(struct intel_crtc_state *crtc_state,
	return 0;
}

static void i845_update_cursor(struct intel_plane *plane,
/* TODO: split into noarm+arm pair */
static void i845_cursor_update_arm(struct intel_plane *plane,
				   const struct intel_crtc_state *crtc_state,
				   const struct intel_plane_state *plane_state)
{
@@ -293,10 +294,10 @@ static void i845_update_cursor(struct intel_plane *plane,
	spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
}

static void i845_disable_cursor(struct intel_plane *plane,
static void i845_cursor_disable_arm(struct intel_plane *plane,
				    const struct intel_crtc_state *crtc_state)
{
	i845_update_cursor(plane, crtc_state, NULL);
	i845_cursor_update_arm(plane, crtc_state, NULL);
}

static bool i845_cursor_get_hw_state(struct intel_plane *plane,
@@ -483,7 +484,8 @@ static int i9xx_check_cursor(struct intel_crtc_state *crtc_state,
	return 0;
}

static void i9xx_update_cursor(struct intel_plane *plane,
/* TODO: split into noarm+arm pair */
static void i9xx_cursor_update_arm(struct intel_plane *plane,
				   const struct intel_crtc_state *crtc_state,
				   const struct intel_plane_state *plane_state)
{
@@ -557,10 +559,10 @@ static void i9xx_update_cursor(struct intel_plane *plane,
	spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
}

static void i9xx_disable_cursor(struct intel_plane *plane,
static void i9xx_cursor_disable_arm(struct intel_plane *plane,
				    const struct intel_crtc_state *crtc_state)
{
	i9xx_update_cursor(plane, crtc_state, NULL);
	i9xx_cursor_update_arm(plane, crtc_state, NULL);
}

static bool i9xx_cursor_get_hw_state(struct intel_plane *plane,
@@ -714,10 +716,12 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
	 */
	crtc_state->active_planes = new_crtc_state->active_planes;

	if (new_plane_state->uapi.visible)
		intel_update_plane(plane, crtc_state, new_plane_state);
	else
		intel_disable_plane(plane, crtc_state);
	if (new_plane_state->uapi.visible) {
		intel_plane_update_noarm(plane, crtc_state, new_plane_state);
		intel_plane_update_arm(plane, crtc_state, new_plane_state);
	} else {
		intel_plane_disable_arm(plane, crtc_state);
	}

	intel_plane_unpin_fb(old_plane_state);

@@ -764,14 +768,14 @@ intel_cursor_plane_create(struct drm_i915_private *dev_priv,

	if (IS_I845G(dev_priv) || IS_I865G(dev_priv)) {
		cursor->max_stride = i845_cursor_max_stride;
		cursor->update_plane = i845_update_cursor;
		cursor->disable_plane = i845_disable_cursor;
		cursor->update_arm = i845_cursor_update_arm;
		cursor->disable_arm = i845_cursor_disable_arm;
		cursor->get_hw_state = i845_cursor_get_hw_state;
		cursor->check_plane = i845_check_cursor;
	} else {
		cursor->max_stride = i9xx_cursor_max_stride;
		cursor->update_plane = i9xx_update_cursor;
		cursor->disable_plane = i9xx_disable_cursor;
		cursor->update_arm = i9xx_cursor_update_arm;
		cursor->disable_arm = i9xx_cursor_disable_arm;
		cursor->get_hw_state = i9xx_cursor_get_hw_state;
		cursor->check_plane = i9xx_check_cursor;
	}
+7 −5
Original line number Diff line number Diff line
@@ -781,7 +781,7 @@ void intel_plane_disable_noatomic(struct intel_crtc *crtc,
	if (DISPLAY_VER(dev_priv) == 2 && !crtc_state->active_planes)
		intel_set_cpu_fifo_underrun_reporting(dev_priv, crtc->pipe, false);

	intel_disable_plane(plane, crtc_state);
	intel_plane_disable_arm(plane, crtc_state);
	intel_wait_for_vblank(dev_priv, crtc->pipe);
}

@@ -1563,7 +1563,7 @@ static void intel_crtc_disable_planes(struct intel_atomic_state *state,
		    !(update_mask & BIT(plane->id)))
			continue;

		intel_disable_plane(plane, new_crtc_state);
		intel_plane_disable_arm(plane, new_crtc_state);

		if (old_plane_state->uapi.visible)
			fb_bits |= plane->frontbuffer_bit;
@@ -1808,7 +1808,7 @@ static void intel_disable_primary_plane(const struct intel_crtc_state *crtc_stat
	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
	struct intel_plane *plane = to_intel_plane(crtc->base.primary);

	plane->disable_plane(plane, crtc_state);
	plane->disable_arm(plane, crtc_state);
}

static void ilk_crtc_enable(struct intel_atomic_state *state,
@@ -8278,15 +8278,17 @@ static void intel_update_crtc(struct intel_atomic_state *state,

	intel_fbc_update(state, crtc);

	intel_update_planes_on_crtc(state, crtc);

	/* Perform vblank evasion around commit operation */
	intel_pipe_update_start(new_crtc_state);

	commit_pipe_pre_planes(state, crtc);

	if (DISPLAY_VER(dev_priv) >= 9)
		skl_update_planes_on_crtc(state, crtc);
		skl_arm_planes_on_crtc(state, crtc);
	else
		i9xx_update_planes_on_crtc(state, crtc);
		i9xx_arm_planes_on_crtc(state, crtc);

	commit_pipe_post_planes(state, crtc);

Loading