All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ander Conselvan de Oliveira <conselvan2@gmail.com>
To: Matt Roper <matthew.d.roper@intel.com>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 4/9] drm/i915: Introduce intel_prepare_cursor_plane()
Date: Mon, 01 Dec 2014 10:26:35 +0200	[thread overview]
Message-ID: <547C263B.6000401@gmail.com> (raw)
In-Reply-To: <1416858786-25376-5-git-send-email-matthew.d.roper@intel.com>

On 11/24/2014 09:53 PM, Matt Roper wrote:
> Primary and sprite planes have already been refactored to include a
> 'prepare' step which handles all the commit-time operations that could
> fail (i.e., pinning buffers and such).  Refactor the cursor commit in a
> similar manner.
>
> For simplicity and consistency with other plane types, we also switch to
> using intel_pin_and_fence_fb_obj() to perform our pinning for
> non-physical cursors.  This will allow us to more easily migrate the
> code into the atomic 'begin' handler in a plane-agnostic manner in a
> future patchset.
>
> Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
> ---
>   drivers/gpu/drm/i915/intel_display.c | 114 ++++++++++++++---------------------
>   1 file changed, 44 insertions(+), 70 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 17788f8..ff94e43 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -11899,19 +11899,51 @@ intel_check_cursor_plane(struct drm_plane *plane,
>   }
>
>   static int
> +intel_prepare_cursor_plane(struct drm_plane *plane,
> +			   struct intel_plane_state *state)
> +{
> +	struct drm_device *dev = plane->dev;
> +	struct drm_framebuffer *fb = state->fb;
> +	struct intel_crtc *intel_crtc = to_intel_crtc(state->crtc);
> +	struct drm_i915_gem_object *obj = intel_fb_obj(fb);
> +	struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->fb);

I don't see where plane->fb is being updated. I think this needs to be 
done in intel_commit_cursor_plane().

Ander

> +	enum pipe pipe = intel_crtc->pipe;
> +	int ret = 0;
> +
> +	if (old_obj != obj) {
> +		/* we only need to pin inside GTT if cursor is non-phy */
> +		mutex_lock(&dev->struct_mutex);
> +		if (!INTEL_INFO(dev)->cursor_needs_physical) {
> +			if (obj)
> +				ret = intel_pin_and_fence_fb_obj(plane, fb, NULL);
> +			if (ret == 0)
> +				i915_gem_track_fb(intel_crtc->cursor_bo, obj,
> +						  INTEL_FRONTBUFFER_CURSOR(pipe));
> +		} else {
> +			int align = IS_I830(dev) ? 16 * 1024 : 256;
> +			if (obj)
> +				ret = i915_gem_object_attach_phys(obj, align);
> +			if (ret)
> +				DRM_DEBUG_KMS("failed to attach phys object\n");
> +		}
> +		mutex_unlock(&dev->struct_mutex);
> +	}
> +
> +	return ret;
> +}
> +
> +static void
>   intel_commit_cursor_plane(struct drm_plane *plane,
>   			  struct intel_plane_state *state)
>   {
>   	struct drm_crtc *crtc = state->crtc;
>   	struct drm_device *dev = crtc->dev;
> -	struct drm_i915_private *dev_priv = dev->dev_private;
>   	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>   	struct intel_plane *intel_plane = to_intel_plane(plane);
>   	struct drm_i915_gem_object *obj = intel_fb_obj(state->fb);
>   	enum pipe pipe = intel_crtc->pipe;
>   	unsigned old_width;
>   	uint32_t addr;
> -	int ret;
>
>   	crtc->cursor_x = state->orig_dst.x1;
>   	crtc->cursor_y = state->orig_dst.y1;
> @@ -11929,75 +11961,18 @@ intel_commit_cursor_plane(struct drm_plane *plane,
>   	if (intel_crtc->cursor_bo == obj)
>   		goto update;
>
> -	/* if we want to turn off the cursor ignore width and height */
> -	if (!obj) {
> -		DRM_DEBUG_KMS("cursor off\n");
> +	if (!obj)
>   		addr = 0;
> -		mutex_lock(&dev->struct_mutex);
> -		goto finish;
> -	}
> -
> -	/* we only need to pin inside GTT if cursor is non-phy */
> -	mutex_lock(&dev->struct_mutex);
> -	if (!INTEL_INFO(dev)->cursor_needs_physical) {
> -		unsigned alignment;
> -
> -		/*
> -		 * Global gtt pte registers are special registers which actually
> -		 * forward writes to a chunk of system memory. Which means that
> -		 * there is no risk that the register values disappear as soon
> -		 * as we call intel_runtime_pm_put(), so it is correct to wrap
> -		 * only the pin/unpin/fence and not more.
> -		 */
> -		intel_runtime_pm_get(dev_priv);
> -
> -		/* Note that the w/a also requires 2 PTE of padding following
> -		 * the bo. We currently fill all unused PTE with the shadow
> -		 * page and so we should always have valid PTE following the
> -		 * cursor preventing the VT-d warning.
> -		 */
> -		alignment = 0;
> -		if (need_vtd_wa(dev))
> -			alignment = 64*1024;
> -
> -		ret = i915_gem_object_pin_to_display_plane(obj, alignment, NULL);
> -		if (ret) {
> -			DRM_DEBUG_KMS("failed to move cursor bo into the GTT\n");
> -			intel_runtime_pm_put(dev_priv);
> -			goto fail_locked;
> -		}
> -
> -		ret = i915_gem_object_put_fence(obj);
> -		if (ret) {
> -			DRM_DEBUG_KMS("failed to release fence for cursor");
> -			intel_runtime_pm_put(dev_priv);
> -			goto fail_unpin;
> -		}
> -
> +	else if (!INTEL_INFO(dev)->cursor_needs_physical)
>   		addr = i915_gem_obj_ggtt_offset(obj);
> -
> -		intel_runtime_pm_put(dev_priv);
> -
> -	} else {
> -		int align = IS_I830(dev) ? 16 * 1024 : 256;
> -		ret = i915_gem_object_attach_phys(obj, align);
> -		if (ret) {
> -			DRM_DEBUG_KMS("failed to attach phys object\n");
> -			goto fail_locked;
> -		}
> +	else
>   		addr = obj->phys_handle->busaddr;
> -	}
>
> -finish:
>   	if (intel_crtc->cursor_bo) {
>   		if (!INTEL_INFO(dev)->cursor_needs_physical)
>   			i915_gem_object_unpin_from_display_plane(intel_crtc->cursor_bo);
>   	}
>
> -	i915_gem_track_fb(intel_crtc->cursor_bo, obj,
> -			  INTEL_FRONTBUFFER_CURSOR(pipe));
> -	mutex_unlock(&dev->struct_mutex);
> -
>   	intel_crtc->cursor_addr = addr;
>   	intel_crtc->cursor_bo = obj;
>   update:
> @@ -12013,13 +11988,6 @@ update:
>
>   		intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_CURSOR(pipe));
>   	}
> -
> -	return 0;
> -fail_unpin:
> -	i915_gem_object_unpin_from_display_plane(obj);
> -fail_locked:
> -	mutex_unlock(&dev->struct_mutex);
> -	return ret;
>   }
>
>   static int
> @@ -12060,7 +12028,13 @@ intel_cursor_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
>   	if (ret)
>   		return ret;
>
> -	return intel_commit_cursor_plane(plane, &state);
> +	ret = intel_prepare_cursor_plane(plane, &state);
> +	if (ret)
> +		return ret;
> +
> +	intel_commit_cursor_plane(plane, &state);
> +
> +	return 0;
>   }
>
>   static const struct drm_plane_funcs intel_cursor_plane_funcs = {
>

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2014-12-01  8:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-24 19:52 [PATCH 0/9] i915 display refactoring (v3) Matt Roper
2014-11-24 19:52 ` [PATCH 1/9] drm: add helper to get crtc timings (v4) Matt Roper
2014-11-27 14:19   ` [Intel-gfx] " Ander Conselvan de Oliveira
2014-11-24 19:52 ` [PATCH 2/9] drm/i915: remove intel_crtc_cursor_set_obj() (v5) Matt Roper
2014-11-24 19:53 ` [PATCH 3/9] drm/i915: remove intel_pipe_set_base() (v4) Matt Roper
2014-11-27 14:20   ` Ander Conselvan de Oliveira
2014-11-24 19:53 ` [PATCH 4/9] drm/i915: Introduce intel_prepare_cursor_plane() Matt Roper
2014-11-28 12:15   ` Ander Conselvan de Oliveira
2014-11-28 13:12     ` Ander Conselvan de Oliveira
2014-11-28 18:10     ` Daniel Vetter
2014-12-01  8:26   ` Ander Conselvan de Oliveira [this message]
2014-11-24 19:53 ` [PATCH 5/9] drm/i915: Make intel_plane_state subclass drm_plane_state Matt Roper
2014-11-24 19:53 ` [PATCH 6/9] drm/i915: Consolidate plane 'prepare' functions Matt Roper
2014-11-28 13:00   ` Ander Conselvan de Oliveira
2014-12-01  8:29   ` Ander Conselvan de Oliveira
2014-12-01 21:25     ` Matt Roper
2014-11-24 19:53 ` [PATCH 7/9] drm/i915: Consolidate plane 'cleanup' operations Matt Roper
2014-12-01 13:46   ` Ander Conselvan de Oliveira
2014-11-24 19:53 ` [PATCH 8/9] drm/i915: Consolidate top-level .update_plane() handlers Matt Roper
2014-11-24 19:53 ` [PATCH 9/9] drm/i915: Make all plane disables use 'update_plane' Matt Roper
2014-11-25  7:39   ` [PATCH 9/9] drm/i915: Make all plane disables use shuang.he
2014-11-27 15:57     ` Damien Lespiau
2014-11-28  0:53       ` He, Shuang
2014-11-28 12:21         ` Damien Lespiau
2014-11-28 12:55           ` Jani Nikula
2014-12-01 14:04   ` [PATCH 9/9] drm/i915: Make all plane disables use 'update_plane' Ander Conselvan de Oliveira
2014-12-01 16:46     ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=547C263B.6000401@gmail.com \
    --to=conselvan2@gmail.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.d.roper@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.