Skip to contentSkip to conversation

drm/ast: Fix modeset failed on DisplayPort

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

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/ast/ast_mode.c +11 -0
index 984ec590a7e7..fe5f1fd61361 100644
@@ -1635,6 +1635,8 @@ static int ast_dp501_output_init(struct ast_private *ast)
 static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
 {
 	void *edid;
+	struct drm_device *dev = connector->dev;
+	struct ast_private *ast = to_ast_private(dev);
 
 	int succ;
 	int count;
@@ -1643,10 +1645,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);
@@ -1654,6 +1664,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: 61d325dcbc05d8fef88110d35ef7776f3ac3f68b

Signature · 1 line
2.25.1
#1 lore raw

Hi

Am 25.04.23 um 09:03 schrieb Jammy Huang:

Quoted 4 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.

Thanks for the patch. I thought I fixed this issue already, but that apparently only happened for SIL164 and VGA.

What about ast_dp501_connector_helper_get_modes()? Does it require the locking as well?

Quoted 11 lines
---
  drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
drivers/gpu/drm/ast/ast_mode.c +0 -0
index 984ec590a7e7..fe5f1fd61361 100644

drivers/gpu/drm/ast/ast_mode.c static int ast_dp501_output_init(struct ast_private *ast) · line 1639

Quoted 5 lines
drivers/gpu/drm/ast/ast_mode.c +2 -0
@@ -1635,6 +1635,8 @@ static int ast_dp501_output_init(struct ast_private *ast)
  static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
  {
  	void *edid;
+	struct drm_device *dev = connector->dev;
+	struct ast_private *ast = to_ast_private(dev);

We've meanwhile renamed ast_private to ast_device. Could you please provide an updated patch for the drm-misc-next tree?

Best regards
Thomas

Quoted 32 lines
drivers/gpu/drm/ast/ast_mode.c +9 -0
  	int succ;
  	int count;
@@ -1643,10 +1645,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);
@@ -1654,6 +1664,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: 61d325dcbc05d8fef88110d35ef7776f3ac3f68b

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)
#2 lore raw

Hi Thomas,

I think DP501 is OK. It doesn't use ioregs in ast_dp501_read_edid().

Quoted 66 lines · Thomas Zimmermann

Hi

Am 25.04.23 um 09:03 schrieb Jammy Huang:

Quoted 4 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.

Thanks for the patch. I thought I fixed this issue already, but that apparently only happened for SIL164 and VGA.

What about ast_dp501_connector_helper_get_modes()? Does it require the locking as well?

Quoted 11 lines

---
  drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++++

  1 file changed, 11 insertions(+)
drivers/gpu/drm/ast/ast_mode.c +0 -0
index 984ec590a7e7..fe5f1fd61361 100644

drivers/gpu/drm/ast/ast_mode.c static int ast_dp501_output_init(struct · line 1640

Quoted 6 lines
drivers/gpu/drm/ast/ast_mode.c +2 -0
@@ -1635,6 +1635,8 @@ static int ast_dp501_output_init(struct 
 ast_private *ast)
   static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
   {
       void *edid;
+    struct drm_device *dev = connector->dev;
+    struct ast_private *ast = to_ast_private(dev);

We've meanwhile renamed ast_private to ast_device. Could you please provide an updated patch for the drm-misc-next tree?

Best regards
Thomas

Quoted 30 lines
drivers/gpu/drm/ast/ast_mode.c +0 -0
         int succ;
       int count;
@@ -1643,10 +1645,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 +0 -0
@@ -1654,6 +1664,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: 61d325dcbc05d8fef88110d35ef7776f3ac3f68b

Signature · 2 lines
Best Regards
Jammy
#3 lore raw

Hi Thomas,

Do you have other suggestion for this patch??

Please kindly advise.

Quoted 71 lines · Jammy Huang

Hi Thomas,

I think DP501 is OK. It doesn't use ioregs in ast_dp501_read_edid().

Quoted 66 lines · Thomas Zimmermann

Hi

Am 25.04.23 um 09:03 schrieb Jammy Huang:

Quoted 4 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.

Thanks for the patch. I thought I fixed this issue already, but that apparently only happened for SIL164 and VGA.

What about ast_dp501_connector_helper_get_modes()? Does it require the locking as well?

Quoted 11 lines

---
  drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++++

  1 file changed, 11 insertions(+)
drivers/gpu/drm/ast/ast_mode.c +0 -0
index 984ec590a7e7..fe5f1fd61361 100644

drivers/gpu/drm/ast/ast_mode.c static int ast_dp501_output_init(struct · line 1640

Quoted 6 lines
drivers/gpu/drm/ast/ast_mode.c +2 -0
@@ -1635,6 +1635,8 @@ static int ast_dp501_output_init(struct 
 ast_private *ast)
   static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
   {
       void *edid;
+    struct drm_device *dev = connector->dev;
+    struct ast_private *ast = to_ast_private(dev);

We've meanwhile renamed ast_private to ast_device. Could you please provide an updated patch for the drm-misc-next tree?

Best regards
Thomas

Quoted 30 lines
drivers/gpu/drm/ast/ast_mode.c +0 -0
         int succ;
       int count;
@@ -1643,10 +1645,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 +0 -0
@@ -1654,6 +1664,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: 61d325dcbc05d8fef88110d35ef7776f3ac3f68b

Signature · 2 lines
Best Regards
Jammy
#4 lore raw

Hi,

this patch also fell through the cracks. Apologies.

Am 24.05.23 um 04:29 schrieb Jammy Huang:

Quoted 3 lines

Hi Thomas,

Do you have other suggestion for this patch??

The main issue was that struct ast_private is now called struct ast_device. So the current patch cannot be applied.

Quoted 60 lines

Please kindly advise.

Quoted 56 lines · Jammy Huang

Hi Thomas,

I think DP501 is OK. It doesn't use ioregs in ast_dp501_read_edid().

Quoted 51 lines · Thomas Zimmermann

Hi

Am 25.04.23 um 09:03 schrieb Jammy Huang:

Quoted 4 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.

Thanks for the patch. I thought I fixed this issue already, but that apparently only happened for SIL164 and VGA.

What about ast_dp501_connector_helper_get_modes()? Does it require the locking as well?

Quoted 11 lines

---
  drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++++

  1 file changed, 11 insertions(+)
drivers/gpu/drm/ast/ast_mode.c +0 -0
index 984ec590a7e7..fe5f1fd61361 100644

drivers/gpu/drm/ast/ast_mode.c static int ast_dp501_output_init(struct · line 1640

Quoted 6 lines
drivers/gpu/drm/ast/ast_mode.c +2 -0
@@ -1635,6 +1635,8 @@ static int ast_dp501_output_init(struct 
 ast_private *ast)
   static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
   {
       void *edid;
+    struct drm_device *dev = connector->dev;
+    struct ast_private *ast = to_ast_private(dev);

We've meanwhile renamed ast_private to ast_device. Could you please provide an updated patch for the drm-misc-next tree?

Best regards
Thomas

Quoted 16 lines
drivers/gpu/drm/ast/ast_mode.c +0 -0
         int succ;
       int count;
@@ -1643,10 +1645,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);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

+
      drm_connector_update_edid_property(connector, edid); count = drm_add_edid_modes(connector, edid); kfree(edid);

drivers/gpu/drm/ast/ast_mode.c +0 -0
@@ -1654,6 +1664,7 @@ static int 
 ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
       return count;

    err_kfree:

Here's a minor issue that the goto label should now be called err_mutex_unlock.

Best regards
Thomas

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

+    mutex_unlock(&ast->ioregs_lock); kfree(edid); err_drm_connector_update_edid_property:
      drm_connector_update_edid_property(connector, NULL);

base-commit: 61d325dcbc05d8fef88110d35ef7776f3ac3f68b

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)
#5 lore raw

Hi Thomas,

Thanks, I will modify the patch accordingly.

Quoted 93 lines · Thomas Zimmermann

Hi,

this patch also fell through the cracks. Apologies.

Am 24.05.23 um 04:29 schrieb Jammy Huang:

Quoted 3 lines

Hi Thomas,

Do you have other suggestion for this patch??

The main issue was that struct ast_private is now called struct ast_device.  So the current patch cannot be applied.

Quoted 60 lines

Please kindly advise.

Quoted 56 lines · Jammy Huang

Hi Thomas,

I think DP501 is OK. It doesn't use ioregs in ast_dp501_read_edid().

Quoted 51 lines · Thomas Zimmermann

Hi

Am 25.04.23 um 09:03 schrieb Jammy Huang:

Quoted 4 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.

Thanks for the patch. I thought I fixed this issue already, but that apparently only happened for SIL164 and VGA.

What about ast_dp501_connector_helper_get_modes()? Does it require the locking as well?

Quoted 11 lines

---
  drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++++

  1 file changed, 11 insertions(+)
drivers/gpu/drm/ast/ast_mode.c +0 -0
index 984ec590a7e7..fe5f1fd61361 100644

drivers/gpu/drm/ast/ast_mode.c static int ast_dp501_output_init(struct · line 1640

Quoted 6 lines
drivers/gpu/drm/ast/ast_mode.c +2 -0
@@ -1635,6 +1635,8 @@ static int ast_dp501_output_init(struct 
 ast_private *ast)
   static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
   {
       void *edid;
+    struct drm_device *dev = connector->dev;
+    struct ast_private *ast = to_ast_private(dev);

We've meanwhile renamed ast_private to ast_device. Could you please provide an updated patch for the drm-misc-next tree?

Best regards
Thomas

Quoted 16 lines
drivers/gpu/drm/ast/ast_mode.c +0 -0
         int succ;
       int count;
@@ -1643,10 +1645,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);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

+
      drm_connector_update_edid_property(connector, edid); count = drm_add_edid_modes(connector, edid); kfree(edid);

drivers/gpu/drm/ast/ast_mode.c +0 -0
@@ -1654,6 +1664,7 @@ static int 
 ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
       return count;

    err_kfree:

Here's a minor issue that the goto label should now be called err_mutex_unlock.

Best regards
Thomas

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

+ mutex_unlock(&ast->ioregs_lock);
      kfree(edid); err_drm_connector_update_edid_property:
      drm_connector_update_edid_property(connector, NULL);

base-commit: 61d325dcbc05d8fef88110d35ef7776f3ac3f68b

Signature · 2 lines
Best Regards
Jammy