dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Fabien Dessenne <fabien.dessenne@st.com>
To: dri-devel@lists.freedesktop.org
Cc: Vincent Abriou <vincent.abriou@st.com>, kernel@stlinux.com
Subject: [PATCH 4/5] drm/sti: do not sync SETPROPERTY on vblank if not ATOMIC
Date: Tue, 3 Jan 2017 17:56:51 +0100	[thread overview]
Message-ID: <1483462612-29448-5-git-send-email-fabien.dessenne@st.com> (raw)
In-Reply-To: <1483462612-29448-1-git-send-email-fabien.dessenne@st.com>

If the client does not set the ATOMIC capability, do not wait for vblank
before returning an DRM_IOCTL_MODE_OBJ_SETPROPERTY call.

In this way, a legacy framework (eg non-atomic Weston) can call several
SETPROPERTY within the same Vsync cycle.

This is implemented by setting the legacy_cursor_update flag, to behave
the same way as DRM_IOCTL_MODE_CURSOR (not vblank synced).

Change-Id: I6b6134eca57eca399bdda006ab1cb8280d4002d4
Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
---
 drivers/gpu/drm/sti/sti_cursor.c |  2 +-
 drivers/gpu/drm/sti/sti_gdp.c    |  2 +-
 drivers/gpu/drm/sti/sti_hqvdp.c  |  2 +-
 drivers/gpu/drm/sti/sti_plane.c  | 54 ++++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/sti/sti_plane.h  |  2 ++
 5 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_cursor.c b/drivers/gpu/drm/sti/sti_cursor.c
index ea0dbae..d7e9f8a 100644
--- a/drivers/gpu/drm/sti/sti_cursor.c
+++ b/drivers/gpu/drm/sti/sti_cursor.c
@@ -349,7 +349,7 @@ static const struct drm_plane_funcs sti_cursor_plane_helpers_funcs = {
 	.update_plane = sti_plane_update_plane,
 	.disable_plane = sti_plane_disable_plane,
 	.destroy = sti_cursor_destroy,
-	.set_property = drm_atomic_helper_plane_set_property,
+	.set_property = sti_plane_set_property,
 	.reset = sti_plane_reset,
 	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
index a379bbe..6fa5042 100644
--- a/drivers/gpu/drm/sti/sti_gdp.c
+++ b/drivers/gpu/drm/sti/sti_gdp.c
@@ -885,7 +885,7 @@ static const struct drm_plane_funcs sti_gdp_plane_helpers_funcs = {
 	.update_plane = sti_plane_update_plane,
 	.disable_plane = sti_plane_disable_plane,
 	.destroy = sti_gdp_destroy,
-	.set_property = drm_atomic_helper_plane_set_property,
+	.set_property = sti_plane_set_property,
 	.reset = sti_plane_reset,
 	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c
index 65ca43f..3fd6f3a 100644
--- a/drivers/gpu/drm/sti/sti_hqvdp.c
+++ b/drivers/gpu/drm/sti/sti_hqvdp.c
@@ -1255,7 +1255,7 @@ static const struct drm_plane_funcs sti_hqvdp_plane_helpers_funcs = {
 	.update_plane = sti_plane_update_plane,
 	.disable_plane = sti_plane_disable_plane,
 	.destroy = sti_hqvdp_destroy,
-	.set_property = drm_atomic_helper_plane_set_property,
+	.set_property = sti_plane_set_property,
 	.reset = sti_plane_reset,
 	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
diff --git a/drivers/gpu/drm/sti/sti_plane.c b/drivers/gpu/drm/sti/sti_plane.c
index 22cf30d..c58fe1b 100644
--- a/drivers/gpu/drm/sti/sti_plane.c
+++ b/drivers/gpu/drm/sti/sti_plane.c
@@ -132,6 +132,60 @@ void sti_plane_init_property(struct sti_plane *plane,
 			 plane->drm_plane.base.id, sti_plane_to_str(plane));
 }
 
+int sti_plane_set_property(struct drm_plane *plane,
+			   struct drm_property *property, uint64_t val)
+{
+	/*
+	 * Forked from drm_atomic_helper_plane_set_property().
+	 * Here we do not wait for vblank if the client is not atomic, so
+	 * DRM_IOCTL_MODE_OBJ_SETPROPERTY returns before vblank.
+	 */
+	struct drm_atomic_state *state;
+	struct drm_plane_state *plane_state;
+	struct sti_private *private = plane->dev->dev_private;
+	int ret = 0;
+
+	state = drm_atomic_state_alloc(plane->dev);
+	if (!state)
+		return -ENOMEM;
+
+	/* ->set_property is always called with all locks held. */
+	state->acquire_ctx = plane->dev->mode_config.acquire_ctx;
+retry:
+	plane_state = drm_atomic_get_plane_state(state, plane);
+	if (IS_ERR(plane_state)) {
+		ret = PTR_ERR(plane_state);
+		goto fail;
+	}
+
+	ret = drm_atomic_plane_set_property(plane, plane_state,
+					    property, val);
+	if (ret)
+		goto fail;
+
+	if (!private->filp->atomic)
+		state->legacy_cursor_update = true;
+
+	ret = drm_atomic_commit(state);
+	if (ret != 0)
+		goto fail;
+
+	/* Driver takes ownership of state on successful commit. */
+	return 0;
+fail:
+	if (ret == -EDEADLK)
+		goto backoff;
+
+	drm_atomic_state_free(state);
+
+	return ret;
+backoff:
+	drm_atomic_state_clear(state);
+	drm_atomic_legacy_backoff(state);
+
+	goto retry;
+}
+
 int sti_plane_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 			   struct drm_framebuffer *fb,
 			   int crtc_x, int crtc_y,
diff --git a/drivers/gpu/drm/sti/sti_plane.h b/drivers/gpu/drm/sti/sti_plane.h
index 1372b9c..aa1b6ce 100644
--- a/drivers/gpu/drm/sti/sti_plane.h
+++ b/drivers/gpu/drm/sti/sti_plane.h
@@ -82,6 +82,8 @@ void sti_plane_update_fps(struct sti_plane *plane,
 
 void sti_plane_init_property(struct sti_plane *plane,
 			     enum drm_plane_type type);
+int sti_plane_set_property(struct drm_plane *plane,
+			   struct drm_property *property, uint64_t val);
 void sti_plane_reset(struct drm_plane *plane);
 
 int sti_plane_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2017-01-03 16:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-03 16:56 [PATCH 0/5] drm/sti: do not sync legacy IOCTL on vblank if not ATOMIC Fabien Dessenne
2017-01-03 16:56 ` [PATCH 1/5] drm/sti: use atomic_helper for commit Fabien Dessenne
2017-01-03 16:56 ` [PATCH 2/5] drm/sti: add drm_file to sti_private Fabien Dessenne
2017-01-03 16:56 ` [PATCH 3/5] drm/sti: do not sync SETPLANE on vblank if not ATOMIC Fabien Dessenne
2017-01-03 16:56 ` Fabien Dessenne [this message]
2017-01-03 16:56 ` [PATCH 5/5] drm/sti: do not check hw scaling if mode is not set Fabien Dessenne
2017-01-04  9:18 ` [PATCH 0/5] drm/sti: do not sync legacy IOCTL on vblank if not ATOMIC Daniel Vetter
2017-01-05 15:23   ` Fabien DESSENNE
2017-01-09 10:03     ` 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=1483462612-29448-5-git-send-email-fabien.dessenne@st.com \
    --to=fabien.dessenne@st.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@stlinux.com \
    --cc=vincent.abriou@st.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox