Skip to contentSkip to conversation

drm/ast: Fix modeset failed on DisplayPort

PATCH Superseded Jammy Huang 2 participants 2 messages May 25, 2023 – May 31, 2023

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/ast: Fix modeset failed on DisplayPort

If we switch display and update cursor together, it could lead to modeset failed because of concurrent access to IO registers.

Add lock protection in DP's edid access to avoid this problem.

---
v2 changes:
- Fix build error since new struct ast_device is used.

---
 drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/ast/ast_mode.c +11 -0
index 36374828f6c8..9fcbf540d6fc 100644
@@ -1647,6 +1647,8 @@ static int ast_dp501_output_init(struct ast_device *ast)
 static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
 {
 	void *edid;
+	struct drm_device *dev = connector->dev;
+	struct ast_device *ast = to_ast_device(dev);
 
 	int succ;
 	int count;
@@ -1655,10 +1657,18 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
 	if (!edid)
 		goto err_drm_connector_update_edid_property;
 
+	/*
+	 * Protect access to I/O registers from concurrent modesetting
+	 * by acquiring the I/O-register lock.
+	 */
+	mutex_lock(&ast->ioregs_lock);
+
 	succ = ast_astdp_read_edid(connector->dev, edid);
 	if (succ < 0)
 		goto err_kfree;
 
+	mutex_unlock(&ast->ioregs_lock);
+
 	drm_connector_update_edid_property(connector, edid);
 	count = drm_add_edid_modes(connector, edid);
 	kfree(edid);
@@ -1666,6 +1676,7 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
 	return count;
 
 err_kfree:
+	mutex_unlock(&ast->ioregs_lock);
 	kfree(edid);
 err_drm_connector_update_edid_property:
 	drm_connector_update_edid_property(connector, NULL);

base-commit: 933174ae28ba72ab8de5b35cb7c98fc211235096

Signature · 1 line
2.25.1
maintainer Reviewed-by on v2 1/1
#1 lore raw

Hi Jammy

Am 25.05.23 um 03:29 schrieb Jammy Huang:

Quoted 46 lines

If we switch display and update cursor together, it could lead to modeset failed because of concurrent access to IO registers.

Add lock protection in DP's edid access to avoid this problem.

---
v2 changes:
- Fix build error since new struct ast_device is used.

---
  drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
drivers/gpu/drm/ast/ast_mode.c +10 -0
index 36374828f6c8..9fcbf540d6fc 100644
@@ -1647,6 +1647,8 @@ static int ast_dp501_output_init(struct ast_device *ast)
  static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
  {
  	void *edid;
+	struct drm_device *dev = connector->dev;
+	struct ast_device *ast = to_ast_device(dev);
 
  	int succ;
  	int count;
@@ -1655,10 +1657,18 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
  	if (!edid)
  		goto err_drm_connector_update_edid_property;
 
+	/*
+	 * Protect access to I/O registers from concurrent modesetting
+	 * by acquiring the I/O-register lock.
+	 */
+	mutex_lock(&ast->ioregs_lock);
+
  	succ = ast_astdp_read_edid(connector->dev, edid);
  	if (succ < 0)
  		goto err_kfree;
 
+	mutex_unlock(&ast->ioregs_lock);
+
  	drm_connector_update_edid_property(connector, edid);
  	count = drm_add_edid_modes(connector, edid);
  	kfree(edid);

drivers/gpu/drm/ast/ast_mode.c static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector) · line 1678

Quoted 3 lines
drivers/gpu/drm/ast/ast_mode.c +0 -0
@@ -1666,6 +1676,7 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
  	return count;
 
  err_kfree:

This label needs to be named 'err_mutex_unlock' please. With that fixed, you can add

Best regards
Thomas

Quoted 6 lines
drivers/gpu/drm/ast/ast_mode.c +1 -0
+	mutex_unlock(&ast->ioregs_lock);
  	kfree(edid);
  err_drm_connector_update_edid_property:
  	drm_connector_update_edid_property(connector, NULL);

base-commit: 933174ae28ba72ab8de5b35cb7c98fc211235096

Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)