All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: airlied@redhat.com, jfalempe@redhat.com, daniel@ffwll.ch,
	kuohsiang_chou@aspeedtech.com, jammy_huang@aspeedtech.com,
	ilpo.jarvinen@cs.helsinki.fi
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH 1/8] drm/ast: Acquire I/O-register lock in atomic_commit_tail function
Date: Mon, 10 Oct 2022 12:36:18 +0200	[thread overview]
Message-ID: <20221010103625.19958-2-tzimmermann@suse.de> (raw)
In-Reply-To: <20221010103625.19958-1-tzimmermann@suse.de>

Hold I/O-register lock in atomic_commit_tail to protect all pipeline
updates at once. Protects modesetting against concurrent EDID reads.

Complex modesetting operations involve mode changes and plane updates.
These steps used to be protected individually against concurrent I/O.
Make all this atomic wrt to reading display modes via EDID. The EDID
code in the conenctor's get_modes helper already acquires the necessary
lock.

A similar issue was fixed in commit 2d70b9a1482e ("drm/mgag200: Acquire
I/O-register lock in atomic_commit_tail function") for mgag200.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/ast/ast_mode.c | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index d5ee3ad538a8..e1e07928906e 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -1200,20 +1200,6 @@ static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,
 	return drm_atomic_add_affected_planes(state, crtc);
 }
 
-static void ast_crtc_helper_atomic_begin(struct drm_crtc *crtc, struct drm_atomic_state *state)
-{
-	struct drm_device *dev = crtc->dev;
-	struct ast_private *ast = to_ast_private(dev);
-
-	/*
-	 * Concurrent operations could possibly trigger a call to
-	 * drm_connector_helper_funcs.get_modes by trying to read the
-	 * display modes. Protect access to I/O registers by acquiring
-	 * the I/O-register lock. Released in atomic_flush().
-	 */
-	mutex_lock(&ast->ioregs_lock);
-}
-
 static void
 ast_crtc_helper_atomic_flush(struct drm_crtc *crtc,
 			     struct drm_atomic_state *state)
@@ -1241,8 +1227,6 @@ ast_crtc_helper_atomic_flush(struct drm_crtc *crtc,
 	//Set Aspeed Display-Port
 	if (ast->tx_chip_types & AST_TX_ASTDP_BIT)
 		ast_dp_set_mode(crtc, vbios_mode_info);
-
-	mutex_unlock(&ast->ioregs_lock);
 }
 
 static void
@@ -1301,7 +1285,6 @@ ast_crtc_helper_atomic_disable(struct drm_crtc *crtc,
 static const struct drm_crtc_helper_funcs ast_crtc_helper_funcs = {
 	.mode_valid = ast_crtc_helper_mode_valid,
 	.atomic_check = ast_crtc_helper_atomic_check,
-	.atomic_begin = ast_crtc_helper_atomic_begin,
 	.atomic_flush = ast_crtc_helper_atomic_flush,
 	.atomic_enable = ast_crtc_helper_atomic_enable,
 	.atomic_disable = ast_crtc_helper_atomic_disable,
@@ -1771,8 +1754,23 @@ static int ast_astdp_output_init(struct ast_private *ast)
  * Mode config
  */
 
+static void ast_mode_config_helper_atomic_commit_tail(struct drm_atomic_state *state)
+{
+	struct ast_private *ast = to_ast_private(state->dev);
+
+	/*
+	 * Concurrent operations could possibly trigger a call to
+	 * drm_connector_helper_funcs.get_modes by trying to read the
+	 * display modes. Protect access to I/O registers by acquiring
+	 * the I/O-register lock. Released in atomic_flush().
+	 */
+	mutex_lock(&ast->ioregs_lock);
+	drm_atomic_helper_commit_tail_rpm(state);
+	mutex_unlock(&ast->ioregs_lock);
+}
+
 static const struct drm_mode_config_helper_funcs ast_mode_config_helper_funcs = {
-	.atomic_commit_tail = drm_atomic_helper_commit_tail_rpm,
+	.atomic_commit_tail = ast_mode_config_helper_atomic_commit_tail,
 };
 
 static const struct drm_mode_config_funcs ast_mode_config_funcs = {
-- 
2.37.3


  reply	other threads:[~2022-10-10 10:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-10 10:36 [PATCH 0/8] drm/ast: Convert ast driver to SHMEM Thomas Zimmermann
2022-10-10 10:36 ` Thomas Zimmermann [this message]
2022-10-11 17:13   ` [PATCH 1/8] drm/ast: Acquire I/O-register lock in atomic_commit_tail function Jocelyn Falempe
2022-10-10 10:36 ` [PATCH 2/8] drm/ast: Call drm_atomic_helper_check_plane_state() unconditionally Thomas Zimmermann
2022-10-10 10:36 ` [PATCH 3/8] drm/ast: Do not call drm_atomic_add_affected_planes() Thomas Zimmermann
2022-10-10 17:06   ` Javier Martinez Canillas
2022-10-10 10:36 ` [PATCH 4/8] drm/ast: Remove cursor double buffering Thomas Zimmermann
2022-10-10 10:36 ` [PATCH 5/8] drm/ast: Rename struct ast_cursor_plane to struct ast_plane Thomas Zimmermann
2022-10-10 10:36 ` [PATCH 6/8] drm/ast: Style cleanups in plane code Thomas Zimmermann
2022-10-10 10:36 ` [PATCH 7/8] drm/ast: Convert ast to SHMEM Thomas Zimmermann
2022-10-11 17:17   ` Jocelyn Falempe
2022-10-10 10:36 ` [PATCH 8/8] drm/ast: Avoid reprogramming primary-plane scanout address Thomas Zimmermann
2022-10-11 14:21   ` Jocelyn Falempe
2022-10-11 14:59     ` Thomas Zimmermann
2022-10-11 17:09       ` Jocelyn Falempe
2022-10-11 17:26 ` [PATCH 0/8] drm/ast: Convert ast driver to SHMEM Jocelyn Falempe

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=20221010103625.19958-2-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ilpo.jarvinen@cs.helsinki.fi \
    --cc=jammy_huang@aspeedtech.com \
    --cc=jfalempe@redhat.com \
    --cc=kuohsiang_chou@aspeedtech.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.