Skip to contentSkip to conversation

drm/amdgpu: treat negative lockup timeout as 'infinite timeout' V2

PATCH In review Evan Quan 2 participants 2 messages May 7, 2019 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Evan Quan

author
#0 lore raw

PATCH 1/1 drm/amdgpu: treat negative lockup timeout as 'infinite timeout' V2

Negative lockup timeout is valid and will be treated as 'infinite timeout'.

- V2: use msecs_to_jiffies for negative values

Change-Id I0d8387956a9c744073c0281ef2e1a547d4f16dec
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +12 -8
index c5fba79c3660..bcd59ba07bb0 100644
@@ -237,13 +237,14 @@ module_param_named(msi, amdgpu_msi, int, 0444);
  * Set GPU scheduler timeout value in ms.
  *
  * The format can be [Non-Compute] or [GFX,Compute,SDMA,Video]. That is there can be one or
- * multiple values specified. 0 and negative values are invalidated. They will be adjusted
- * to default timeout.
+ * multiple values specified.
  *  - With one value specified, the setting will apply to all non-compute jobs.
  *  - With multiple values specified, the first one will be for GFX. The second one is for Compute.
  *    And the third and fourth ones are for SDMA and Video.
  * By default(with no lockup_timeout settings), the timeout for all non-compute(GFX, SDMA and Video)
  * jobs is 10000. And there is no timeout enforced on compute jobs.
+ * Value 0 is invalidated, will be adjusted to default timeout settings.
+ * Negative values mean 'infinite timeout' (MAX_JIFFY_OFFSET).
  */
 MODULE_PARM_DESC(lockup_timeout, "GPU lockup timeout in ms (default: 10000 for non-compute jobs and no timeout for compute jobs), "
 		"format is [Non-Compute] or [GFX,Compute,SDMA,Video]");
@@ -1339,24 +1340,27 @@ int amdgpu_device_get_job_timeout_settings(struct amdgpu_device *adev)
 			if (ret)
 				return ret;
 
-			/* Invalidate 0 and negative values */
-			if (timeout <= 0) {
+			/*
+			 * Value 0 will be adjusted to default timeout settings.
+			 * Negative values mean 'infinite timeout' (MAX_JIFFY_OFFSET).
+			 */
+			if (!timeout) {
 				index++;
 				continue;
 			}
 
 			switch (index++) {
 			case 0:
-				adev->gfx_timeout = timeout;
+				adev->gfx_timeout = msecs_to_jiffies(timeout);
 				break;
 			case 1:
-				adev->compute_timeout = timeout;
+				adev->compute_timeout = msecs_to_jiffies(timeout);
 				break;
 			case 2:
-				adev->sdma_timeout = timeout;
+				adev->sdma_timeout = msecs_to_jiffies(timeout);
 				break;
 			case 3:
-				adev->video_timeout = timeout;
+				adev->video_timeout = msecs_to_jiffies(timeout);
 				break;
 			default:
 				break;
Signature · 6 lines
2.21.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Am 07.05.19 um 03:47 schrieb Evan Quan:

Quoted 53 lines

Negative lockup timeout is valid and will be treated as 'infinite timeout'.

- V2: use msecs_to_jiffies for negative values

Change-Id I0d8387956a9c744073c0281ef2e1a547d4f16dec
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 20 ++++++++++++--------
  1 file changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +9 -5
index c5fba79c3660..bcd59ba07bb0 100644
@@ -237,13 +237,14 @@ module_param_named(msi, amdgpu_msi, int, 0444);
   * Set GPU scheduler timeout value in ms.
   *
   * The format can be [Non-Compute] or [GFX,Compute,SDMA,Video]. That is there can be one or
- * multiple values specified. 0 and negative values are invalidated. They will be adjusted
- * to default timeout.
+ * multiple values specified.
   *  - With one value specified, the setting will apply to all non-compute jobs.
   *  - With multiple values specified, the first one will be for GFX. The second one is for Compute.
   *    And the third and fourth ones are for SDMA and Video.
   * By default(with no lockup_timeout settings), the timeout for all non-compute(GFX, SDMA and Video)
   * jobs is 10000. And there is no timeout enforced on compute jobs.
+ * Value 0 is invalidated, will be adjusted to default timeout settings.
+ * Negative values mean 'infinite timeout' (MAX_JIFFY_OFFSET).
   */
  MODULE_PARM_DESC(lockup_timeout, "GPU lockup timeout in ms (default: 10000 for non-compute jobs and no timeout for compute jobs), "
  		"format is [Non-Compute] or [GFX,Compute,SDMA,Video]");
@@ -1339,24 +1340,27 @@ int amdgpu_device_get_job_timeout_settings(struct amdgpu_device *adev)
  			if (ret)
  				return ret;
 
-			/* Invalidate 0 and negative values */
-			if (timeout <= 0) {
+			/*
+			 * Value 0 will be adjusted to default timeout settings.
+			 * Negative values mean 'infinite timeout' (MAX_JIFFY_OFFSET).
+			 */
+			if (!timeout) {
  				index++;
  				continue;
  			}
 
  			switch (index++) {
  			case 0:
-				adev->gfx_timeout = timeout;
+				adev->gfx_timeout = msecs_to_jiffies(timeout);
  				break;
  			case 1:

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c int amdgpu_device_get_job_timeout_settings(struct amdgpu_device *adev) · line 1363

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3 -3
-				adev->compute_timeout = timeout;
+				adev->compute_timeout = msecs_to_jiffies(timeout);
  				break;
  			case 2:
-				adev->sdma_timeout = timeout;
+				adev->sdma_timeout = msecs_to_jiffies(timeout);
  				break;
  			case 3:
-				adev->video_timeout = timeout;
+				adev->video_timeout = msecs_to_jiffies(timeout);

Maybe move the msecs_to_jiffies() call before the switch to add it only once.

Apart from that looks good to me,
Christian.

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c int amdgpu_device_get_job_timeout_settings(struct amdgpu_device *adev) · line 1366

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
  				break;
  			default:
  				break;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx