All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tina Zhang <tina.zhang@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	intel-gfx@lists.freedesktop.org,
	Gustavo Padovan <gustavo.padovan@collabora.com>,
	Helen Koike <helen.koike@collabora.com>,
	Enric Balletbo i Serra <enric.balletbo@collabora.com>,
	kalyan.kondapally@intel.com, intel-gvt-dev@lists.freedesktop.org
Subject: [RFC PATCH 3/7] drm/i915: Introduce async plane update to i915
Date: Mon,  3 Dec 2018 15:35:18 +0800	[thread overview]
Message-ID: <1543822522-3413-4-git-send-email-tina.zhang@intel.com> (raw)
In-Reply-To: <1543822522-3413-1-git-send-email-tina.zhang@intel.com>

This patch is separated from the following patch:
https://lists.freedesktop.org/archives/dri-devel/2018-June/179592.html

This patch introduces the implementation async plane update callbacks
to i915. The original idea is to use async plane update framework to
update cursors.

The next patch of this series try to extend this idea to support other
planes.

Signed-off-by: Tina Zhang <tina.zhang@intel.com>
Cc: Gustavo Padovan <gustavo.padovan@collabora.com>
Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Cc: Helen Koike <helen.koike@collabora.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_atomic_plane.c | 69 +++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_display.c      | 11 +++++
 2 files changed, 80 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
index 905f8ef..dddd3a7 100644
--- a/drivers/gpu/drm/i915/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
@@ -217,10 +217,79 @@ void intel_update_planes_on_crtc(struct intel_atomic_state *old_state,
 	}
 }
 
+static int intel_plane_atomic_async_check(struct drm_plane *plane,
+					  struct drm_plane_state *state)
+{
+	struct drm_crtc_state *crtc_state;
+
+	if (plane->type != DRM_PLANE_TYPE_CURSOR)
+		return -EINVAL;
+
+	crtc_state = drm_atomic_get_existing_crtc_state(state->state,
+							state->crtc);
+	if (WARN_ON(!crtc_state))
+		return -EINVAL;
+
+	/*
+	 * When crtc is inactive or there is a modeset pending,
+	 * wait for it to complete in the slowpath
+	 */
+	if (!crtc_state->active || to_intel_crtc_state(crtc_state)->update_pipe)
+		return -EINVAL;
+
+	/*
+	 * If any parameters change that may affect watermarks,
+	 * take the slowpath. Only changing fb or position should be
+	 * in the fastpath.
+	 */
+	if (plane->state->crtc != state->crtc ||
+	    plane->state->src_w != state->src_w ||
+	    plane->state->src_h != state->src_h ||
+	    plane->state->crtc_w != state->crtc_w ||
+	    plane->state->crtc_h != state->crtc_h ||
+	    !plane->state->fb != !state->fb)
+		return -EINVAL;
+
+	return 0;
+}
+
+static void intel_plane_atomic_async_update(struct drm_plane *plane,
+					    struct drm_plane_state *new_state)
+{
+	struct intel_plane *intel_plane = to_intel_plane(plane);
+	struct drm_crtc *crtc = plane->state->crtc;
+	struct drm_framebuffer *old_fb;
+
+	old_fb = plane->state->fb;
+
+	i915_gem_track_fb(intel_fb_obj(old_fb), intel_fb_obj(new_state->fb),
+			  intel_plane->frontbuffer_bit);
+
+	plane->state->src_x = new_state->src_x;
+	plane->state->src_y = new_state->src_y;
+	plane->state->crtc_x = new_state->crtc_x;
+	plane->state->crtc_y = new_state->crtc_y;
+	plane->state->fb = new_state->fb;
+
+	new_state->fb = old_fb;
+
+	if (plane->state->visible) {
+		trace_intel_update_plane(plane, to_intel_crtc(crtc));
+		intel_plane->update_plane(intel_plane,
+					  to_intel_crtc_state(crtc->state),
+					  to_intel_plane_state(plane->state));
+	} else {
+		trace_intel_disable_plane(plane, to_intel_crtc(crtc));
+		intel_plane->disable_plane(intel_plane, to_intel_crtc(crtc));
+	}
+}
+
 const struct drm_plane_helper_funcs intel_plane_helper_funcs = {
 	.prepare_fb = intel_prepare_plane_fb,
 	.cleanup_fb = intel_cleanup_plane_fb,
 	.atomic_check = intel_plane_atomic_check,
+	.atomic_async_check = intel_plane_atomic_async_check,
+	.atomic_async_update = intel_plane_atomic_async_update,
 };
 
 /**
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 132e978..b64708b 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13050,6 +13050,14 @@ static int intel_atomic_commit(struct drm_device *dev,
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	int ret = 0;
 
+	if (state->async_update) {
+		ret = drm_atomic_helper_prepare_planes(dev, state);
+		if (ret)
+			return ret;
+		drm_atomic_helper_async_commit(dev, state);
+		return 0;
+	}
+
 	drm_atomic_state_get(state);
 	i915_sw_fence_init(&intel_state->commit_ready,
 			   intel_atomic_commit_ready);
@@ -13275,6 +13283,9 @@ intel_prepare_plane_fb(struct drm_plane *plane,
 	struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->state->fb);
 	int ret;
 
+	if (new_state->state->async_update)
+		return 0;
+
 	if (old_obj) {
 		struct drm_crtc_state *crtc_state =
 			drm_atomic_get_new_crtc_state(new_state->state,
-- 
2.7.4

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

  parent reply	other threads:[~2018-12-03  7:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-03  7:35 [RFC PATCH 0/7] drm/i915/gvt: Enable vGPU local display direct flip Tina Zhang
2018-12-03  7:35 ` [RFC PATCH 1/7] drm/i915: Introduce meta framebuffer Tina Zhang
2018-12-03  7:35 ` [RFC PATCH 2/7] drm/i915/gvt: Use meta fbs to stand for vGPU's planes Tina Zhang
2018-12-03  8:21   ` Zhenyu Wang
2018-12-03  8:35     ` Zhenyu Wang
2018-12-03  8:58       ` Zhang, Tina
2018-12-03  8:53     ` Zhang, Tina
2018-12-03  8:55     ` Zhang, Tina
2018-12-03  7:35 ` Tina Zhang [this message]
2018-12-03  7:35 ` [RFC PATCH 4/7] drm/i915: Extend async plane update to other planes Tina Zhang
2018-12-03  7:35 ` [RFC PATCH 5/7] drm/i915/gvt: Introduce vGPU plane page flip framework Tina Zhang
2018-12-03  7:35 ` [RFC PATCH 6/7] drm/i915/gvt: Enable guest direct page flip Tina Zhang
2018-12-03  7:35 ` [RFC PATCH 7/7] drm/i915/gvt: Introduce HW Vblank interrupt to vGPU Tina Zhang
2018-12-03  7:53 ` ✗ Fi.CI.BAT: failure for drm/i915/gvt: Enable vGPU local display direct flip Patchwork

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=1543822522-3413-4-git-send-email-tina.zhang@intel.com \
    --to=tina.zhang@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=enric.balletbo@collabora.com \
    --cc=gustavo.padovan@collabora.com \
    --cc=helen.koike@collabora.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-gvt-dev@lists.freedesktop.org \
    --cc=kalyan.kondapally@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.