Skip to contentSkip to conversation

drm/ast: Use msleep instead of mdelay for edid read

RFC PATCH In review Nirmoy Das 3 participants 6 messages Sep 17, 2025 – Sep 18, 2025

Subsystems (3)
lore
Share & tools
lore

Nirmoy Das

author
#0 lore raw

RFC PATCH 1/1 drm/ast: Use msleep instead of mdelay for edid read

The busy-waiting in mdelay() can cause CPU stalls and kernel timeouts during boot.

Sending this as RFC as I am familiar with the code and not sure if this transition is safe.

---
 drivers/gpu/drm/ast/ast_dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_dp.c +1 -1
index 19c04687b0fe1..8e650a02c5287 100644
@@ -134,7 +134,7 @@ static int ast_astdp_read_edid_block(void *data, u8 *buf, unsigned int block, si
 			 * 3. The Delays are often longer a lot when system resume from S3/S4.
 			 */
 			if (j)
-				mdelay(j + 1);
+				msleep(j + 1);
 
 			/* Wait for EDID offset to show up in mirror register */
 			vgacrd7 = ast_get_index_reg(ast, AST_IO_VGACRI, 0xd7);

--
2.43.0

author
#1 lore raw
Quoted 6 lines · Nirmoy Das

The busy-waiting in mdelay() can cause CPU stalls and kernel timeouts during boot.

Sending this as RFC as I am familiar with the code and not sure

I meant: I am not familiar with the code.

Adding more details:
Seeing below trace at boot time:

[   49.908436] Workqueue: events work_for_cpu_fn
[   49.908440] pstate: 83400009 (Nzcv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--) [   49.908443] pc : __delay+0x6c/0x118
[   49.908449] lr : __delay+0x74/0x118
[   49.908455] sp : ffff8000848af830
[   49.908460] x29: ffff8000848af830 x28: ffffc42fa1fb2d70 x27: ffff8001288c03d5 [   49.908468] x26: 00000000000000ff x25: ffff000080a2e980 x24: 000000000000009d [   49.908472] x23: 0000000000418958 x22: ffffffd0004105a0 x21: 0000002fffc08100 [   49.908475] x20: ffffc42fe7b1b348 x19: 00000000000f4247 x18: ffff8000848c0088 [   49.908478] x17: 0000000000000000 x16: ffffc42fe72655c8 x15: 0000000000000000 [   49.908482] x14: 0000000000000000 x13: 20706f6f6c20726f x12: 6620676e69747261 [   49.908485] x11: 747320646964655f x10: 0000000000000000 x9 : ffffc42fe72654ec [   49.908489] x8 : 0000000000000000 x7 : 0000000000000000 x6 : 0000000000000000 [   49.908492] x5 : 00000000000000ff x4 : 0000000000000000 x3 : 0000000000000000 [   49.908496] x2 : 0000000000000000 x1 : 0000000000000000 x0 : 00000000000485c0 [   49.908500] Call trace:
[   49.908501]  __delay+0x6c/0x118
[   49.908504]  __const_udelay+0x30/0x58
[   49.908506]  ast_astdp_read_edid+0x690/0xc68 [ast]
[   49.908510]  ast_astdp_connector_helper_get_modes+0x90/0x158 [ast] [   49.908515] drm_helper_probe_single_connector_modes+0x1ac/0x628 [   49.908522]  drm_client_modeset_probe+0x22c/0x1558
[   49.908528] __drm_fb_helper_initial_config_and_unlock+0x60/0x550 [   49.908530]  drm_fb_helper_initial_config+0x4c/0x88
[   49.908532]  drm_fbdev_generic_client_hotplug+0xa4/0x110
[   49.908535]  drm_client_register+0x64/0xd0
[   49.908540]  drm_fbdev_generic_setup+0x134/0x1e0
[   49.908545]  ast_pci_probe+0x310/0x898 [ast]
[   49.908548]  local_pci_probe+0x4c/0xe0
[   49.908552]  work_for_cpu_fn+0x28/0x58
[   49.908554]  process_one_work+0x17c/0x448
[   49.908556]  worker_thread+0x360/0x480
[   49.908557]  kthread+0x11c/0x128
[   49.908562]  ret_from_fork+0x10/0x20

This also cause timeouts in other drivers  because of this long udelay.

Regards,

Nirmoy

Quoted 21 lines

if this transition is safe.

---
  drivers/gpu/drm/ast/ast_dp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_dp.c +1 -2
index 19c04687b0fe1..8e650a02c5287 100644
@@ -134,7 +134,7 @@ static int ast_astdp_read_edid_block(void *data, u8 *buf, unsigned int block, si
  			 * 3. The Delays are often longer a lot when system resume from S3/S4.
  			 */
  			if (j)
-				mdelay(j + 1);
+				msleep(j + 1);
 
  			/* Wait for EDID offset to show up in mirror register */
  			vgacrd7 = ast_get_index_reg(ast, AST_IO_VGACRI, 0xd7);
--

2.43.0

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Nirmoy Das

Hi

Am 17.09.25 um 21:43 schrieb Nirmoy Das:

Quoted 4 lines

The busy-waiting in mdelay() can cause CPU stalls and kernel timeouts during boot.

Quoted 3 lines

Sending this as RFC as I am familiar with the code and not sure if this transition is safe.

It's only waiting for hardware, so most likely safe. I'll give it a try before merging the patch. Thanks for this fix.

There are other calls to mdelay in the driver. Should they be replaced as well?

Best regards
Thomas

Quoted 20 lines
---
  drivers/gpu/drm/ast/ast_dp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_dp.c +1 -2
index 19c04687b0fe1..8e650a02c5287 100644
@@ -134,7 +134,7 @@ static int ast_astdp_read_edid_block(void *data, u8 *buf, unsigned int block, si
  			 * 3. The Delays are often longer a lot when system resume from S3/S4.
  			 */
  			if (j)
-				mdelay(j + 1);
+				msleep(j + 1);
 
  			/* Wait for EDID offset to show up in mirror register */
  			vgacrd7 = ast_get_index_reg(ast, AST_IO_VGACRI, 0xd7);
--

2.43.0

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

Hi Thomas,

Quoted 8 lines · Thomas Zimmermann

Hi

Am 17.09.25 um 21:43 schrieb Nirmoy Das:

Quoted 4 lines

The busy-waiting in mdelay() can cause CPU stalls and kernel timeouts during boot.

Quoted 8 lines
Quoted 3 lines

Sending this as RFC as I am familiar with the code and not sure if this transition is safe.

It's only waiting for hardware, so most likely safe. I'll give it a try before merging the patch. Thanks for this fix.

Perfect. Thanks for also trying it out. We tried it on older kernel and it helped.

Quoted 1 line

There are other calls to mdelay in the driver. Should they be replaced as well?

Haven't observed any issue with those calls which occurs at shorter intervals and may be that is why they didn't cause a blockage.

Regards,

Nirmoy

Quoted 26 lines

Best regards
Thomas

Quoted 21 lines

---
  drivers/gpu/drm/ast/ast_dp.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_dp.c +0 -0
index 19c04687b0fe1..8e650a02c5287 100644
@@ -134,7 +134,7 @@ static int ast_astdp_read_edid_block(void *data, 

u8 *buf, unsigned int block, si
               * 3. The Delays are often longer a lot when system resume from S3/S4. */
              if (j)
-                mdelay(j + 1);
+                msleep(j + 1);

              /* Wait for EDID offset to show up in mirror register */ vgacrd7 = ast_get_index_reg(ast, AST_IO_VGACRI, 0xd7);

Signature · 1 line
2.43.0
Tested-by Carol L Soto [email protected]
#4 lore raw

From: Nirmoy Das <[email protected]>
Date: Thursday, September 18, 2025 at 7:17 AM
To: Thomas Zimmermann <[email protected]>, [email protected] <[email protected]>
Cc: [email protected] <[email protected]>, [email protected] <[email protected]>, Carol Soto <[email protected]>
Subject: Re: [RFC PATCH] drm/ast: Use msleep instead of mdelay for edid read
Hi Thomas,

Quoted 8 lines · Thomas Zimmermann

Hi

Am 17.09.25 um 21:43 schrieb Nirmoy Das:

Quoted 4 lines

The busy-waiting in mdelay() can cause CPU stalls and kernel timeouts during boot.

Quoted 9 lines
Quoted 3 lines

Sending this as RFC as I am familiar with the code and not sure if this transition is safe.

It's only waiting for hardware, so most likely safe. I'll give it a try before merging the patch. Thanks for this fix.

Perfect. Thanks for also trying it out. We tried it on older kernel and it helped.

Quoted 2 lines

There are other calls to mdelay in the driver. Should they be replaced as well?

Haven't observed any issue with those calls which occurs at shorter intervals and may be that is why they didn't cause a blockage.

Regards,

Nirmoy

Quoted 27 lines

Best regards
Thomas

Quoted 22 lines
---
  drivers/gpu/drm/ast/ast_dp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_dp.c +0 -0
index 19c04687b0fe1..8e650a02c5287 100644
@@ -134,7 +134,7 @@ static int ast_astdp_read_edid_block(void *data,

u8 *buf, unsigned int block, si
* 3. The Delays are often longer a lot when system
resume from S3/S4.

               */
              if (j)
drivers/gpu/drm/ast/ast_dp.c +1 -2
-                mdelay(j + 1);
+                msleep(j + 1);
 
              /* Wait for EDID offset to show up in mirror register */
              vgacrd7 = ast_get_index_reg(ast, AST_IO_VGACRI, 0xd7);
--

2.43.0

#5 lore raw
In reply to Nirmoy Das

Am 17.09.25 um 21:43 schrieb Nirmoy Das:

Quoted 4 lines

The busy-waiting in mdelay() can cause CPU stalls and kernel timeouts during boot.

Fixes 594e9c04b586 ("drm/ast: Create the driver for ASPEED proprietory Display-Port")
Cc KuoHsiang Chou <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Jocelyn Falempe <[email protected]>
Cc <[email protected]> # v5.19+
Quoted 23 lines

Sending this as RFC as I am familiar with the code and not sure if this transition is safe.

---
  drivers/gpu/drm/ast/ast_dp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_dp.c +1 -2
index 19c04687b0fe1..8e650a02c5287 100644
@@ -134,7 +134,7 @@ static int ast_astdp_read_edid_block(void *data, u8 *buf, unsigned int block, si
  			 * 3. The Delays are often longer a lot when system resume from S3/S4.
  			 */
  			if (j)
-				mdelay(j + 1);
+				msleep(j + 1);
 
  			/* Wait for EDID offset to show up in mirror register */
  			vgacrd7 = ast_get_index_reg(ast, AST_IO_VGACRI, 0xd7);
--

2.43.0

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)