Skip to contentSkip to conversation

drm/amdgpu/display: adjust msleep limit in dp_wait_for_training_aux_rd_interval

PATCH In review Alex Deucher 5 participants 9 messages Jan 20, 2022 – Jan 25, 2022

Subsystems (3)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/2 drm/amdgpu/display: adjust msleep limit in dp_wait_for_training_aux_rd_interval

Some architectures (e.g., ARM) have relatively low udelay limits. On most architectures, anything longer than 2000us is not recommended. Change the check to align with other similar checks in DC.

---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +1 -1
index 1f8831156bc4..aa1c67c3c386 100644
@@ -202,7 +202,7 @@ void dp_wait_for_training_aux_rd_interval(
 	uint32_t wait_in_micro_secs)
 {
 #if defined(CONFIG_DRM_AMD_DC_DCN)
-	if (wait_in_micro_secs > 16000)
+	if (wait_in_micro_secs > 1000)
 		msleep(wait_in_micro_secs/1000);
 	else
 		udelay(wait_in_micro_secs);
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH 2/2 drm/amdgpu/display: use msleep rather than udelay for long delays

Some architectures (e.g., ARM) throw an compilation error if the udelay is too long. In general udelays of longer than 2000us are not recommended on any architecture. Switch to msleep in these cases.

---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +2 -2
index aa1c67c3c386..eb4432dca761 100644
@@ -6941,7 +6941,7 @@ bool dpcd_write_128b_132b_sst_payload_allocation_table(
 			}
 		}
 		retries++;
-		udelay(5000);
+		msleep(5);
 	}
 
 	if (!result && retries == max_retries) {
@@ -6993,7 +6993,7 @@ bool dpcd_poll_for_allocation_change_trigger(struct dc_link *link)
 			break;
 		}
 
-		udelay(5000);
+		msleep(5);
 	}
 
 	if (result == ACT_FAILED) {
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/amdgpu/display: use msleep rather than udelay for long delays

Quoted 6 lines · Alex Deucher

Some architectures (e.g., ARM) throw an compilation error if the udelay is too long. In general udelays of longer than 2000us are not recommended on any architecture. Switch to msleep in these cases.

Series is

Harry

Quoted 26 lines
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +2 -2
index aa1c67c3c386..eb4432dca761 100644
@@ -6941,7 +6941,7 @@ bool dpcd_write_128b_132b_sst_payload_allocation_table(
 			}
 		}
 		retries++;
-		udelay(5000);
+		msleep(5);
 	}
 
 	if (!result && retries == max_retries) {
@@ -6993,7 +6993,7 @@ bool dpcd_poll_for_allocation_change_trigger(struct dc_link *link)
 			break;
 		}
 
-		udelay(5000);
+		msleep(5);
 	}
 
 	if (result == ACT_FAILED) {
#3 lore raw

Re: [PATCH 2/2] drm/amdgpu/display: use msleep rather than udelay for long delays

In reply to Alex Deucher
Quoted 15 lines · Alex Deucher

Some architectures (e.g., ARM) throw an compilation error if the udelay is too long. In general udelays of longer than 2000us are not recommended on any architecture. Switch to msleep in these cases.

---
  drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +0 -0
index aa1c67c3c386..eb4432dca761 100644

drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c bool dpcd_write_128b_132b_sst_payload_allocation_table( · line 6944

Quoted 5 lines
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +1 -1
@@ -6941,7 +6941,7 @@ bool dpcd_write_128b_132b_sst_payload_allocation_table(
  			}
  		}
  		retries++;
-		udelay(5000);
+		msleep(5);

msleep is not recommended for sleeps < 20ms. The original code (modified in patch 1) seems to do such a check. As per kernel doc, if precision matters recommendation is to use usleep_range().

Thanks,
Lijo

Quoted 13 lines
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +1 -1
  	}
 
  	if (!result && retries == max_retries) {
@@ -6993,7 +6993,7 @@ bool dpcd_poll_for_allocation_change_trigger(struct dc_link *link)
  			break;
  		}
 
-		udelay(5000);
+		msleep(5);
  	}
 
  	if (result == ACT_FAILED) {
maintainer
#4 lore raw

Re: [PATCH 2/2] drm/amdgpu/display: use msleep rather than udelay for long delays

Quoted 13 lines · Lijo
Quoted 10 lines · Alex Deucher

Some architectures (e.g., ARM) throw an compilation error if the udelay is too long.  In general udelays of longer than 2000us are not recommended on any architecture.  Switch to msleep in these cases.

---
  drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 13 lines

drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c bool dpcd_write_128b_132b_sst_payload_allocation_table( · line 6944

Quoted 10 lines
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +1 -1
index aa1c67c3c386..eb4432dca761 100644
@@ -6941,7 +6941,7 @@ bool dpcd_write_128b_132b_sst_payload_allocation_table(
               }
           }
           retries++;
-        udelay(5000);
+        msleep(5);

msleep is not recommended for sleeps < 20ms. The original code (modified in patch 1) seems to do such a check. As per kernel doc, if precision matters recommendation is to use usleep_range().

If I remember right the sleep (non-polling) function can take (significantly) longer than the requested time, but never shorter. This should be fine in this case.

Harry

Quoted 13 lines

Thanks,
Lijo

Quoted 10 lines
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +1 -0
       }
         if (!result && retries == max_retries) {
@@ -6993,7 +6993,7 @@ bool dpcd_poll_for_allocation_change_trigger(struct dc_link *link)
               break;
           }
   -        udelay(5000);
+        msleep(5);
       }
         if (result == ACT_FAILED) {
 
#5 lore raw

Re: [PATCH 2/2] drm/amdgpu/display: use msleep rather than udelay for long delays

In reply to Lazar, Lijo
Quoted 14 lines · Lijo
Quoted 10 lines · Alex Deucher

Some architectures (e.g., ARM) throw an compilation error if the udelay is too long. In general udelays of longer than 2000us are not recommended on any architecture. Switch to msleep in these cases.

---
  drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 14 lines

drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c bool dpcd_write_128b_132b_sst_payload_allocation_table( · line 6944

Quoted 10 lines
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +1 -1
index aa1c67c3c386..eb4432dca761 100644
@@ -6941,7 +6941,7 @@ bool dpcd_write_128b_132b_sst_payload_allocation_table(
                      }
              }
              retries++;
-             udelay(5000);
+             msleep(5);

msleep is not recommended for sleeps < 20ms. The original code (modified in patch 1) seems to do such a check. As per kernel doc, if precision matters recommendation is to use usleep_range().

I'm not sure what to use here. ARM32 doesn't allow udelay longer than 2000us.

Alex

Quoted 17 lines

Thanks,
Lijo

Quoted 13 lines
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +1 -1
      }
 
      if (!result && retries == max_retries) {
@@ -6993,7 +6993,7 @@ bool dpcd_poll_for_allocation_change_trigger(struct dc_link *link)
                      break;
              }
 
-             udelay(5000);
+             msleep(5);
      }
 
      if (result == ACT_FAILED) {
#6 lore raw
In reply to Alex Deucher

[Public]

If we change if condition, how about the division by "wait_in_micro_secs/1000", as the sleep time is less now. Shall we adjust it as well?

Regards,
Guchun

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, January 21, 2022 2:04 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu/display: adjust msleep limit in dp_wait_for_training_aux_rd_interval

Some architectures (e.g., ARM) have relatively low udelay limits. On most architectures, anything longer than 2000us is not recommended. Change the check to align with other similar checks in DC.

---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +1 -1
index 1f8831156bc4..aa1c67c3c386 100644
@@ -202,7 +202,7 @@ void dp_wait_for_training_aux_rd_interval(
 	uint32_t wait_in_micro_secs)
 {
 #if defined(CONFIG_DRM_AMD_DC_DCN)
-	if (wait_in_micro_secs > 16000)
+	if (wait_in_micro_secs > 1000)
 		msleep(wait_in_micro_secs/1000);
 	else
 		udelay(wait_in_micro_secs);
Signature · 1 line
2.34.1
author maintainer
#7 lore raw

[Public]

It just changes the limit for when we use msleep vs udelay, not the units.

Alex
________________________________
From: Chen, Guchun <[email protected]>
Sent: Thursday, January 20, 2022 8:49 PM
To: Deucher, Alexander <[email protected]>; [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>
Subject: RE: [PATCH 1/2] drm/amdgpu/display: adjust msleep limit in dp_wait_for_training_aux_rd_interval

[Public]

If we change if condition, how about the division by "wait_in_micro_secs/1000", as the sleep time is less now. Shall we adjust it as well?

Regards,
Guchun

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, January 21, 2022 2:04 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu/display: adjust msleep limit in dp_wait_for_training_aux_rd_interval

Some architectures (e.g., ARM) have relatively low udelay limits. On most architectures, anything longer than 2000us is not recommended. Change the check to align with other similar checks in DC.

---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +1 -1
index 1f8831156bc4..aa1c67c3c386 100644
@@ -202,7 +202,7 @@ void dp_wait_for_training_aux_rd_interval(
         uint32_t wait_in_micro_secs)
 {
 #if defined(CONFIG_DRM_AMD_DC_DCN)
-       if (wait_in_micro_secs > 16000)
+       if (wait_in_micro_secs > 1000)
                 msleep(wait_in_micro_secs/1000);
         else
                 udelay(wait_in_micro_secs);

--
2.34.1

#8 lore raw

[Public]

Series is: Reviewed-by: Guchun Chen [email protected]<mailto:[email protected]>

Regards,
Guchun

From: Deucher, Alexander <[email protected]>
Sent: Saturday, January 22, 2022 1:00 AM
To: Chen, Guchun <[email protected]>; [email protected]
Subject: Re: [PATCH 1/2] drm/amdgpu/display: adjust msleep limit in dp_wait_for_training_aux_rd_interval

[Public]

It just changes the limit for when we use msleep vs udelay, not the units.

Alex
________________________________
From: Chen, Guchun <[email protected]<mailto:[email protected]>>
Sent: Thursday, January 20, 2022 8:49 PM
To: Deucher, Alexander <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Cc: Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: RE: [PATCH 1/2] drm/amdgpu/display: adjust msleep limit in dp_wait_for_training_aux_rd_interval

[Public]

If we change if condition, how about the division by "wait_in_micro_secs/1000", as the sleep time is less now. Shall we adjust it as well?

Regards,
Guchun

-----Original Message-----
From: amd-gfx <[email protected]<mailto:[email protected]>> On Behalf Of Alex Deucher
Sent: Friday, January 21, 2022 2:04 AM
To: [email protected]<mailto:[email protected]>
Cc: Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: [PATCH 1/2] drm/amdgpu/display: adjust msleep limit in dp_wait_for_training_aux_rd_interval

Some architectures (e.g., ARM) have relatively low udelay limits. On most architectures, anything longer than 2000us is not recommended. Change the check to align with other similar checks in DC.

---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +1 -1
index 1f8831156bc4..aa1c67c3c386 100644
@@ -202,7 +202,7 @@ void dp_wait_for_training_aux_rd_interval(
         uint32_t wait_in_micro_secs)
 {
 #if defined(CONFIG_DRM_AMD_DC_DCN)
-       if (wait_in_micro_secs > 16000)
+       if (wait_in_micro_secs > 1000)
                 msleep(wait_in_micro_secs/1000);
         else
                 udelay(wait_in_micro_secs);

--
2.34.1