Skip to contentSkip to conversation

drm/ast: Fix soft lockup

PATCH In review Jammy Huang 2 participants 4 messages Apr 3, 2024 – Apr 8, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/ast: Fix soft lockup

There is a while-loop in ast_dp_set_on_off() that could lead to infinite-loop. This is because the register, VGACRI-Dx, checked in this API is a scratch register actually controlled by a MCU, named DPMCU, in BMC.

These scratch registers are protected by scu-lock. If suc-lock is not off, DPMCU can not update these registers and then host will have soft lockup due to never updated status.

DPMCU is used to control DP and relative registers to handshake with host's VGA driver. Even the most time-consuming task, DP's link training, is less than 100ms. 200ms should be enough.

---
 drivers/gpu/drm/ast/ast_dp.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/ast/ast_dp.c +3 -0
index ebb6d8ebd44e..1e9259416980 100644
@@ -180,6 +180,7 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on)
 {
 	struct ast_device *ast = to_ast_device(dev);
 	u8 video_on_off = on;
+	u32 i = 0;
 
 	// Video On/Off
 	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, (u8) ~AST_DP_VIDEO_ENABLE, on);
@@ -192,6 +193,8 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on)
 						ASTDP_MIRROR_VIDEO_ENABLE) != video_on_off) {
 			// wait 1 ms
 			mdelay(1);
+			if (++i > 200)
+				break;
 		}
 	}
 }

base-commit: b0546776ad3f332e215cebc0b063ba4351971cca

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

Am 03.04.24 um 11:02 schrieb Jammy Huang:

Quoted 9 lines

There is a while-loop in ast_dp_set_on_off() that could lead to infinite-loop. This is because the register, VGACRI-Dx, checked in this API is a scratch register actually controlled by a MCU, named DPMCU, in BMC.

These scratch registers are protected by scu-lock. If suc-lock is not off, DPMCU can not update these registers and then host will have soft lockup due to never updated status.

Quoted 6 lines

DPMCU is used to control DP and relative registers to handshake with host's VGA driver. Even the most time-consuming task, DP's link training, is less than 100ms. 200ms should be enough.

Quoted 27 lines
---
  drivers/gpu/drm/ast/ast_dp.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/ast/ast_dp.c +3 -0
index ebb6d8ebd44e..1e9259416980 100644
@@ -180,6 +180,7 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on)
  {
  	struct ast_device *ast = to_ast_device(dev);
  	u8 video_on_off = on;
+	u32 i = 0;
 
  	// Video On/Off
  	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, (u8) ~AST_DP_VIDEO_ENABLE, on);
@@ -192,6 +193,8 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on)
  						ASTDP_MIRROR_VIDEO_ENABLE) != video_on_off) {
  			// wait 1 ms
  			mdelay(1);
+			if (++i > 200)
+				break;
  		}
  	}
  }

base-commit: b0546776ad3f332e215cebc0b063ba4351971cca

Signature · 7 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
In reply to Jammy Huang

Hi,

I've added a Fixes tag and pushed to patch into drm-misc-fixes.

Best regards
Thomas

Am 03.04.24 um 11:02 schrieb Jammy Huang:

Quoted 42 lines

There is a while-loop in ast_dp_set_on_off() that could lead to infinite-loop. This is because the register, VGACRI-Dx, checked in this API is a scratch register actually controlled by a MCU, named DPMCU, in BMC.

These scratch registers are protected by scu-lock. If suc-lock is not off, DPMCU can not update these registers and then host will have soft lockup due to never updated status.

DPMCU is used to control DP and relative registers to handshake with host's VGA driver. Even the most time-consuming task, DP's link training, is less than 100ms. 200ms should be enough.

---
  drivers/gpu/drm/ast/ast_dp.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/ast/ast_dp.c +3 -0
index ebb6d8ebd44e..1e9259416980 100644
@@ -180,6 +180,7 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on)
  {
  	struct ast_device *ast = to_ast_device(dev);
  	u8 video_on_off = on;
+	u32 i = 0;
 
  	// Video On/Off
  	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, (u8) ~AST_DP_VIDEO_ENABLE, on);
@@ -192,6 +193,8 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on)
  						ASTDP_MIRROR_VIDEO_ENABLE) != video_on_off) {
  			// wait 1 ms
  			mdelay(1);
+			if (++i > 200)
+				break;
  		}
  	}
  }

base-commit: b0546776ad3f332e215cebc0b063ba4351971cca

Signature · 7 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)
#3 lore raw

Hi Thomas,

Thank you.

Regards,
Jammy Huang

Quoted 63 lines

Hi,

I've added a Fixes tag and pushed to patch into drm-misc-fixes.

Best regards
Thomas

Am 03.04.24 um 11:02 schrieb Jammy Huang:

drivers/gpu/drm/ast/ast_dp.c void ast_dp_set_on_off(struct drm_device *dev, bool

Quoted 24 lines

There is a while-loop in ast_dp_set_on_off() that could lead to infinite-loop. This is because the register, VGACRI-Dx, checked in this API is a scratch register actually controlled by a MCU, named DPMCU, in BMC.

These scratch registers are protected by scu-lock. If suc-lock is not off, DPMCU can not update these registers and then host will have soft lockup due to never updated status.

DPMCU is used to control DP and relative registers to handshake with host's VGA driver. Even the most time-consuming task, DP's link training, is less than 100ms. 200ms should be enough.

---
  drivers/gpu/drm/ast/ast_dp.c | 3 +++
  1 file changed, 3 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/ast/ast_dp.c index ebb6d8ebd44e..1e9259416980 100644

drivers/gpu/drm/ast/ast_dp.c +0 -0
@@ -180,6 +180,7 @@ void ast_dp_set_on_off(struct drm_device *dev, bool

on)

Quoted 8 lines
drivers/gpu/drm/ast/ast_dp.c +1 -0
  {
  	struct ast_device *ast = to_ast_device(dev);
  	u8 video_on_off = on;
+	u32 i = 0;
 
  	// Video On/Off
  	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, (u8)

~AST_DP_VIDEO_ENABLE, on); @@ -192,6 +193,8 @@ void

ast_dp_set_on_off(struct drm_device *dev, bool on)

Quoted 1 line

ASTDP_MIRROR_VIDEO_ENABLE) !=

video_on_off) {

Quoted 9 lines
  			// wait 1 ms
  			mdelay(1);
drivers/gpu/drm/ast/ast_dp.c +2 -0
+			if (++i > 200)
+				break;
  		}
  	}
  }

base-commit: b0546776ad3f332e215cebc0b063ba4351971cca

--
--
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)