All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard@free-electrons.com>
To: Chen-Yu Tsai <wens@csie.org>,
	Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, narmstrong@baylibre.com,
	thomas@vitsch.nl
Subject: [PATCH v4 12/13] drm/sun4i: backend: Make sure we don't have a commit pending
Date: Mon, 22 Jan 2018 10:25:26 +0100	[thread overview]
Message-ID: <35604307e5bde2b85c674de79fa7c4d55700f085.1516613040.git-series.maxime.ripard@free-electrons.com> (raw)
In-Reply-To: <cover.671c2fcad4ca649d65bd2b9982a8361befa8bfd1.1516613040.git-series.maxime.ripard@free-electrons.com>
In-Reply-To: <cover.671c2fcad4ca649d65bd2b9982a8361befa8bfd1.1516613040.git-series.maxime.ripard@free-electrons.com>

If we try to read the backend registers while it fetches the new values, we
end up with the value of some random register instead of the one we asked
for.

In order to prevent that, let's make sure that the very first thing we do
during our atomic modesetting is to let the commit bit come to a rest.

We don't have to worry about anything else since the only time we will
trigger a new transaction is during the atomic_commit which comes much
later.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 drivers/gpu/drm/sun4i/sun4i_backend.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 1b8e3dcbe47a..5d4a49e9ccc3 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -297,6 +297,17 @@ static bool sun4i_backend_plane_uses_frontend(struct drm_plane_state *state)
 	return sun4i_backend_plane_uses_scaler(state);
 }
 
+static void sun4i_backend_atomic_begin(struct sunxi_engine *engine,
+				       struct drm_crtc_state *old_state)
+{
+	u32 val;
+
+	WARN_ON(regmap_read_poll_timeout(engine->regs,
+					 SUN4I_BACKEND_REGBUFFCTL_REG,
+					 val, !(val & SUN4I_BACKEND_REGBUFFCTL_LOADCTL),
+					 100, 50000));
+}
+
 static int sun4i_backend_atomic_check(struct sunxi_engine *engine,
 				      struct drm_crtc_state *crtc_state)
 {
@@ -479,6 +490,7 @@ static struct sun4i_frontend *sun4i_backend_find_frontend(struct sun4i_drv *drv,
 }
 
 static const struct sunxi_engine_ops sun4i_backend_engine_ops = {
+	.atomic_begin			= sun4i_backend_atomic_begin,
 	.atomic_check			= sun4i_backend_atomic_check,
 	.commit				= sun4i_backend_commit,
 	.layers_init			= sun4i_layers_init,
-- 
git-series 0.9.1

WARNING: multiple messages have this Message-ID (diff)
From: maxime.ripard@free-electrons.com (Maxime Ripard)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 12/13] drm/sun4i: backend: Make sure we don't have a commit pending
Date: Mon, 22 Jan 2018 10:25:26 +0100	[thread overview]
Message-ID: <35604307e5bde2b85c674de79fa7c4d55700f085.1516613040.git-series.maxime.ripard@free-electrons.com> (raw)
In-Reply-To: <cover.671c2fcad4ca649d65bd2b9982a8361befa8bfd1.1516613040.git-series.maxime.ripard@free-electrons.com>

If we try to read the backend registers while it fetches the new values, we
end up with the value of some random register instead of the one we asked
for.

In order to prevent that, let's make sure that the very first thing we do
during our atomic modesetting is to let the commit bit come to a rest.

We don't have to worry about anything else since the only time we will
trigger a new transaction is during the atomic_commit which comes much
later.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 drivers/gpu/drm/sun4i/sun4i_backend.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 1b8e3dcbe47a..5d4a49e9ccc3 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -297,6 +297,17 @@ static bool sun4i_backend_plane_uses_frontend(struct drm_plane_state *state)
 	return sun4i_backend_plane_uses_scaler(state);
 }
 
+static void sun4i_backend_atomic_begin(struct sunxi_engine *engine,
+				       struct drm_crtc_state *old_state)
+{
+	u32 val;
+
+	WARN_ON(regmap_read_poll_timeout(engine->regs,
+					 SUN4I_BACKEND_REGBUFFCTL_REG,
+					 val, !(val & SUN4I_BACKEND_REGBUFFCTL_LOADCTL),
+					 100, 50000));
+}
+
 static int sun4i_backend_atomic_check(struct sunxi_engine *engine,
 				      struct drm_crtc_state *crtc_state)
 {
@@ -479,6 +490,7 @@ static struct sun4i_frontend *sun4i_backend_find_frontend(struct sun4i_drv *drv,
 }
 
 static const struct sunxi_engine_ops sun4i_backend_engine_ops = {
+	.atomic_begin			= sun4i_backend_atomic_begin,
 	.atomic_check			= sun4i_backend_atomic_check,
 	.commit				= sun4i_backend_commit,
 	.layers_init			= sun4i_layers_init,
-- 
git-series 0.9.1

WARNING: multiple messages have this Message-ID (diff)
From: Maxime Ripard <maxime.ripard@free-electrons.com>
To: Chen-Yu Tsai <wens@csie.org>,
	Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: linux-arm-kernel@lists.infradead.org, thomas@vitsch.nl,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	narmstrong@baylibre.com
Subject: [PATCH v4 12/13] drm/sun4i: backend: Make sure we don't have a commit pending
Date: Mon, 22 Jan 2018 10:25:26 +0100	[thread overview]
Message-ID: <35604307e5bde2b85c674de79fa7c4d55700f085.1516613040.git-series.maxime.ripard@free-electrons.com> (raw)
In-Reply-To: <cover.671c2fcad4ca649d65bd2b9982a8361befa8bfd1.1516613040.git-series.maxime.ripard@free-electrons.com>
In-Reply-To: <cover.671c2fcad4ca649d65bd2b9982a8361befa8bfd1.1516613040.git-series.maxime.ripard@free-electrons.com>

If we try to read the backend registers while it fetches the new values, we
end up with the value of some random register instead of the one we asked
for.

In order to prevent that, let's make sure that the very first thing we do
during our atomic modesetting is to let the commit bit come to a rest.

We don't have to worry about anything else since the only time we will
trigger a new transaction is during the atomic_commit which comes much
later.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 drivers/gpu/drm/sun4i/sun4i_backend.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 1b8e3dcbe47a..5d4a49e9ccc3 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -297,6 +297,17 @@ static bool sun4i_backend_plane_uses_frontend(struct drm_plane_state *state)
 	return sun4i_backend_plane_uses_scaler(state);
 }
 
+static void sun4i_backend_atomic_begin(struct sunxi_engine *engine,
+				       struct drm_crtc_state *old_state)
+{
+	u32 val;
+
+	WARN_ON(regmap_read_poll_timeout(engine->regs,
+					 SUN4I_BACKEND_REGBUFFCTL_REG,
+					 val, !(val & SUN4I_BACKEND_REGBUFFCTL_LOADCTL),
+					 100, 50000));
+}
+
 static int sun4i_backend_atomic_check(struct sunxi_engine *engine,
 				      struct drm_crtc_state *crtc_state)
 {
@@ -479,6 +490,7 @@ static struct sun4i_frontend *sun4i_backend_find_frontend(struct sun4i_drv *drv,
 }
 
 static const struct sunxi_engine_ops sun4i_backend_engine_ops = {
+	.atomic_begin			= sun4i_backend_atomic_begin,
 	.atomic_check			= sun4i_backend_atomic_check,
 	.commit				= sun4i_backend_commit,
 	.layers_init			= sun4i_layers_init,
-- 
git-series 0.9.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2018-01-22  9:25 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22  9:25 [PATCH v4 00/13] drm/sun4i: Support the Display Engine frontend Maxime Ripard
2018-01-22  9:25 ` Maxime Ripard
2018-01-22  9:25 ` [PATCH v4 01/13] drm/sun4i: backend: Move line stride setup to buffer setup function Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25 ` [PATCH v4 02/13] drm/sun4i: backend: Document the engine operations Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25 ` [PATCH v4 03/13] drm/sun4i: backend: Allow a NULL plane pointer to retrieve the format Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25 ` [PATCH v4 04/13] drm/sun4i: backend: Add a custom plane state Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25 ` [PATCH v4 05/13] drm/sun4i: engine: Add a custom crtc atomic_check Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25 ` [PATCH v4 06/13] drm/sun4i: engine: Add a VBLANK quirk callback Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25 ` [PATCH v4 07/13] drm/sun4i: engine: Create an atomic_begin callback Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25 ` [PATCH v4 08/13] drm/sun4i: Add a driver for the display frontend Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22 13:28   ` Chen-Yu Tsai
2018-01-22 13:28     ` Chen-Yu Tsai
2018-01-22 13:28     ` Chen-Yu Tsai
2018-01-22  9:25 ` [PATCH v4 09/13] drm/sun4i: backend: Wire in the frontend Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25 ` [PATCH v4 10/13] drm/sun4i: backend: Add a custom atomic_check for " Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25 ` [PATCH v4 11/13] drm/sun4i: backend: Use runtime_pm variant of atomic_commit_tail Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25 ` Maxime Ripard [this message]
2018-01-22  9:25   ` [PATCH v4 12/13] drm/sun4i: backend: Make sure we don't have a commit pending Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25 ` [PATCH v4 13/13] ARM: dts: sun8i: a33 Enable our display frontend Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22  9:25   ` Maxime Ripard
2018-01-22 14:27 ` [PATCH v4 00/13] drm/sun4i: Support the Display Engine frontend Maxime Ripard
2018-01-22 14:27   ` Maxime Ripard

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=35604307e5bde2b85c674de79fa7c4d55700f085.1516613040.git-series.maxime.ripard@free-electrons.com \
    --to=maxime.ripard@free-electrons.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=narmstrong@baylibre.com \
    --cc=thomas@vitsch.nl \
    --cc=wens@csie.org \
    /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.