Skip to contentSkip to conversation

drm/sched: fix the duplicated TMO message for one IB

PATCH In review Monk Liu 3 participants 17 messages May 9, 2019 – May 10, 2019 14 messages not in the archive

Subsystems (4)
lore
Share & tools
lore

Monk Liu

author
#0 lore raw

PATCH 1/1 drm/sched: fix the duplicated TMO message for one IB

we don't need duplicated IB's timeout error message reported endlessly, just one report per timedout IB is enough

---
 drivers/gpu/drm/scheduler/sched_main.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -5
index c1aaf85..d6c17f1 100644
@@ -308,7 +308,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
 {
 	struct drm_gpu_scheduler *sched;
 	struct drm_sched_job *job;
-	unsigned long flags;
 
 	sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
 	job = list_first_entry_or_null(&sched->ring_mirror_list,
@@ -316,10 +315,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
 
 	if (job)
 		job->sched->ops->timedout_job(job);
-
-	spin_lock_irqsave(&sched->job_list_lock, flags);
-	drm_sched_start_timeout(sched);
-	spin_unlock_irqrestore(&sched->job_list_lock, flags);
 }
 
  /**
Signature · 6 lines
2.7.4

_______________________________________________
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): 1557376305-24294-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 09.05.19 um 06:31 schrieb Monk Liu:

Quoted 2 lines

we don't need duplicated IB's timeout error message reported endlessly, just one report per timedout IB is enough

Well, NAK. We don't need multiple timeout reports, but we really need to restart the timeout counter after handling it.

Otherwise we will never run into a timeout again after handling one and it isn't unlikely that multiple IBs in a row doesn't work correctly.

Christian.

Quoted 19 lines
---
  drivers/gpu/drm/scheduler/sched_main.c | 5 -----
  1 file changed, 5 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -1
index c1aaf85..d6c17f1 100644
@@ -308,7 +308,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
  {
  	struct drm_gpu_scheduler *sched;
  	struct drm_sched_job *job;
-	unsigned long flags;
 
  	sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
  	job = list_first_entry_or_null(&sched->ring_mirror_list,

drivers/gpu/drm/scheduler/sched_main.c static void drm_sched_job_timedout(struct work_struct *work) · line 320

Quoted 10 lines
drivers/gpu/drm/scheduler/sched_main.c +0 -4
@@ -316,10 +315,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
 
  	if (job)
  		job->sched->ops->timedout_job(job);
-
-	spin_lock_irqsave(&sched->job_list_lock, flags);
-	drm_sched_start_timeout(sched);
-	spin_unlock_irqrestore(&sched->job_list_lock, flags);
  }
 
   /**

_______________________________________________
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): ca57f69d-eced-8e9d-5a07-42a642d96a0f-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author
#4 lore raw

Christian

Check "drm_sched_start" which is invoked from gpu_recover() , there is a "drm_sched_start_timeout()" in the tail

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 3:18 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Am 09.05.19 um 06:31 schrieb Monk Liu:

Quoted 2 lines

we don't need duplicated IB's timeout error message reported endlessly, just one report per timedout IB is enough

Well, NAK. We don't need multiple timeout reports, but we really need to restart the timeout counter after handling it.

Otherwise we will never run into a timeout again after handling one and it isn't unlikely that multiple IBs in a row doesn't work correctly.

Christian.

Quoted 30 lines
---
  drivers/gpu/drm/scheduler/sched_main.c | 5 -----
  1 file changed, 5 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -5
index c1aaf85..d6c17f1 100644
@@ -308,7 +308,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
  {
      struct drm_gpu_scheduler *sched;
      struct drm_sched_job *job;
-     unsigned long flags;
 
      sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
      job = list_first_entry_or_null(&sched->ring_mirror_list,
@@ -316,10 +315,6 @@ static void drm_sched_job_timedout(struct 
 work_struct *work)
 
      if (job)
              job->sched->ops->timedout_job(job);
-
-     spin_lock_irqsave(&sched->job_list_lock, flags);
-     drm_sched_start_timeout(sched);
-     spin_unlock_irqrestore(&sched->job_list_lock, flags);
  }
 
Quoted 1 line
   /**

_______________________________________________
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): BYAPR12MB3301677254798D131BC7E8FB84330-ZGDeBxoHBPmRc1D8ZEEGsgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#6 lore raw

drm_sched_start() is not necessary called from the timeout handler.

If a soft recovery is sufficient, we just continue without a complete reset.

Christian.

Am 09.05.19 um 12:25 schrieb Liu, Monk:

Quoted 52 lines

Christian

Check "drm_sched_start" which is invoked from gpu_recover() , there is a "drm_sched_start_timeout()" in the tail

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 3:18 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Am 09.05.19 um 06:31 schrieb Monk Liu:

Quoted 2 lines

we don't need duplicated IB's timeout error message reported endlessly, just one report per timedout IB is enough

Well, NAK. We don't need multiple timeout reports, but we really need to restart the timeout counter after handling it.

Otherwise we will never run into a timeout again after handling one and it isn't unlikely that multiple IBs in a row doesn't work correctly.

Christian.

Quoted 29 lines
---
   drivers/gpu/drm/scheduler/sched_main.c | 5 -----
   1 file changed, 5 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -5
index c1aaf85..d6c17f1 100644
@@ -308,7 +308,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
   {
       struct drm_gpu_scheduler *sched;
       struct drm_sched_job *job;
-     unsigned long flags;
 
       sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
       job = list_first_entry_or_null(&sched->ring_mirror_list,
@@ -316,10 +315,6 @@ static void drm_sched_job_timedout(struct
 work_struct *work)
 
       if (job)
               job->sched->ops->timedout_job(job);
-
-     spin_lock_irqsave(&sched->job_list_lock, flags);
-     drm_sched_start_timeout(sched);
-     spin_unlock_irqrestore(&sched->job_list_lock, flags);
   }
 
Quoted 5 lines
Quoted 1 line
    /**

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

_______________________________________________
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): 4b0c90d0-6535-9942-e140-666a4c0ff4b7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author
#8 lore raw

Hah ... I see, but my requirement cannot be satisfied with current design:

What I need to do is put a signal arming in job_timeout() to notify a USER SPACE daemon app , which finally leverage "UMR" to DUMP/retrieve sw/hw information related with the TMO/hang as much as possible . To make it straight forward I would signal USR1 to the registered app (the daemon) every time a TMO happens, and this would introduce lot of unnecessary DUMP if this "bug" cannot resolved.

I think keep reporting TMO message for one IB is a "bug" to me even it is not for my above feature...

To address your concern, what about this one:

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +4 -2
index 1397942..31d99e9 100644
@@ -28,7 +28,7 @@
 #include "amdgpu.h"
 #include "amdgpu_trace.h"
 
-static void amdgpu_job_timedout(struct drm_sched_job *s_job)
+static int amdgpu_job_timedout(struct drm_sched_job *s_job)
 {
        struct amdgpu_ring *ring = to_amdgpu_ring(s_job->sched);
        struct amdgpu_job *job = to_amdgpu_job(s_job);
@@ -39,7 +39,7 @@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)
        if (amdgpu_ring_soft_recovery(ring, job->vmid, s_job->s_fence->parent)) {
                DRM_ERROR("ring %s timeout, but soft recovered\n",
                          s_job->sched->name);
-               return;
+               return -ENODEV;
        }
 
        amdgpu_vm_get_task_info(ring->adev, job->pasid, &ti);
@@ -51,6 +51,8 @@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)
 
        if (amdgpu_device_should_recover_gpu(ring->adev))
                amdgpu_device_gpu_recover(ring->adev, job);
+
+       return 0;
 }
 
 int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,
drivers/gpu/drm/scheduler/sched_main.c +11 -6
index c1aaf85..b93deb1 100644
@@ -308,18 +308,23 @@ static void drm_sched_job_timedout(struct work_struct *work)
 {
        struct drm_gpu_scheduler *sched;
        struct drm_sched_job *job;
-       unsigned long flags;
+       int ret;
 
        sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
        job = list_first_entry_or_null(&sched->ring_mirror_list,
                                       struct drm_sched_job, node);
 
-       if (job)
-               job->sched->ops->timedout_job(job);
+       if (job) {
+               ret = job->sched->ops->timedout_job(job);
+               if (ret) {
+                       unsigned long flags;
 
-       spin_lock_irqsave(&sched->job_list_lock, flags);
-       drm_sched_start_timeout(sched);
-       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+                       /* means recovered, restart timer now */
+                       spin_lock_irqsave(&sched->job_list_lock, flags);
+                       drm_sched_start_timeout(sched);
+                       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+               }
+       }
 }
 
  /**
include/drm/gpu_scheduler.h +0 -0
index 9c2a957..c3884c3 100644

--- a/include/drm/gpu_scheduler.h
@@ -229,7 +229,7 @@ struct drm_sched_backend_ops {
* @timedout_job: Called when a job has taken too long to execute,
* to trigger GPU recovery.
*/
- void (*timedout_job)(struct drm_sched_job *sched_job);
+ int (*timedout_job)(struct drm_sched_job *sched_job);

/**
* @free_job: Called once the job's finished fence has been signaled
(END)

Thanks
/Monk
-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 6:30 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

drm_sched_start() is not necessary called from the timeout handler.

If a soft recovery is sufficient, we just continue without a complete reset.

Christian.

Am 09.05.19 um 12:25 schrieb Liu, Monk:

Quoted 54 lines

Christian

Check "drm_sched_start" which is invoked from gpu_recover() , there is a "drm_sched_start_timeout()" in the tail

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 3:18 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Am 09.05.19 um 06:31 schrieb Monk Liu:

Quoted 2 lines

we don't need duplicated IB's timeout error message reported endlessly, just one report per timedout IB is enough

Well, NAK. We don't need multiple timeout reports, but we really need to restart the timeout counter after handling it.

Otherwise we will never run into a timeout again after handling one and it isn't unlikely that multiple IBs in a row doesn't work correctly.

Christian.

Quoted 29 lines
---
   drivers/gpu/drm/scheduler/sched_main.c | 5 -----
   1 file changed, 5 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -5
index c1aaf85..d6c17f1 100644
@@ -308,7 +308,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
   {
       struct drm_gpu_scheduler *sched;
       struct drm_sched_job *job;
-     unsigned long flags;
 
       sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
       job = list_first_entry_or_null(&sched->ring_mirror_list,
@@ -316,10 +315,6 @@ static void drm_sched_job_timedout(struct 
 work_struct *work)
 
       if (job)
               job->sched->ops->timedout_job(job);
-
-     spin_lock_irqsave(&sched->job_list_lock, flags);
-     drm_sched_start_timeout(sched);
-     spin_unlock_irqrestore(&sched->job_list_lock, flags);
   }
 
Quoted 5 lines
Quoted 1 line
    /**

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

_______________________________________________
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): BYAPR12MB3301D3741595A6AEE81F184884330-ZGDeBxoHBPmRc1D8ZEEGsgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#10 lore raw

Hi Monk,

ok you don't seem to understand: It is intentional that the same job times out multiple times! So we can't really change anything here.

What we can do is instead of sending a signal (which is not a good idea from the timeout handler anyway) we can start a background script to do the dumping.

Now when the next timeout happens we double check if the background script is still running and if yes, simply ignore the timeout and wait for the next one.

Christian.

Am 09.05.19 um 12:49 schrieb Liu, Monk:

Quoted 98 lines

Hah ... I see, but my requirement cannot be satisfied with current design:

What I need to do is put a signal arming in job_timeout() to notify a USER SPACE daemon app , which finally leverage "UMR" to DUMP/retrieve sw/hw information related with the TMO/hang as much as possible . To make it straight forward I would signal USR1 to the registered app (the daemon) every time a TMO happens, and this would introduce lot of unnecessary DUMP if this "bug" cannot resolved.

I think keep reporting TMO message for one IB is a "bug" to me even it is not for my above feature...

To address your concern, what about this one:

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +4 -2
index 1397942..31d99e9 100644
@@ -28,7 +28,7 @@
  #include "amdgpu.h"
  #include "amdgpu_trace.h"
 
-static void amdgpu_job_timedout(struct drm_sched_job *s_job)
+static int amdgpu_job_timedout(struct drm_sched_job *s_job)
  {
         struct amdgpu_ring *ring = to_amdgpu_ring(s_job->sched);
         struct amdgpu_job *job = to_amdgpu_job(s_job);
@@ -39,7 +39,7 @@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)
         if (amdgpu_ring_soft_recovery(ring, job->vmid, s_job->s_fence->parent)) {
                 DRM_ERROR("ring %s timeout, but soft recovered\n",
                           s_job->sched->name);
-               return;
+               return -ENODEV;
         }
 
         amdgpu_vm_get_task_info(ring->adev, job->pasid, &ti);
@@ -51,6 +51,8 @@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)
 
         if (amdgpu_device_should_recover_gpu(ring->adev))
                 amdgpu_device_gpu_recover(ring->adev, job);
+
+       return 0;
  }
 
  int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,
drivers/gpu/drm/scheduler/sched_main.c +11 -6
index c1aaf85..b93deb1 100644
@@ -308,18 +308,23 @@ static void drm_sched_job_timedout(struct work_struct *work)
  {
         struct drm_gpu_scheduler *sched;
         struct drm_sched_job *job;
-       unsigned long flags;
+       int ret;
 
         sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
         job = list_first_entry_or_null(&sched->ring_mirror_list,
                                        struct drm_sched_job, node);
 
-       if (job)
-               job->sched->ops->timedout_job(job);
+       if (job) {
+               ret = job->sched->ops->timedout_job(job);
+               if (ret) {
+                       unsigned long flags;
 
-       spin_lock_irqsave(&sched->job_list_lock, flags);
-       drm_sched_start_timeout(sched);
-       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+                       /* means recovered, restart timer now */
+                       spin_lock_irqsave(&sched->job_list_lock, flags);
+                       drm_sched_start_timeout(sched);
+                       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+               }
+       }
  }
 
   /**
include/drm/gpu_scheduler.h +1 -2
index 9c2a957..c3884c3 100644
--- a/include/drm/gpu_scheduler.h
@@ -229,7 +229,7 @@ struct drm_sched_backend_ops {
           * @timedout_job: Called when a job has taken too long to execute,
           * to trigger GPU recovery.
          */
-       void (*timedout_job)(struct drm_sched_job *sched_job);
+       int (*timedout_job)(struct drm_sched_job *sched_job);
 
         /**
           * @free_job: Called once the job's finished fence has been signaled

(END)

Thanks
/Monk
-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 6:30 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Quoted 66 lines

drm_sched_start() is not necessary called from the timeout handler.

If a soft recovery is sufficient, we just continue without a complete reset.

Christian.

Am 09.05.19 um 12:25 schrieb Liu, Monk:

Quoted 59 lines

Christian

Check "drm_sched_start" which is invoked from gpu_recover() , there is a "drm_sched_start_timeout()" in the tail

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 3:18 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Am 09.05.19 um 06:31 schrieb Monk Liu:

Quoted 2 lines

we don't need duplicated IB's timeout error message reported endlessly, just one report per timedout IB is enough

Well, NAK. We don't need multiple timeout reports, but we really need to restart the timeout counter after handling it.

Otherwise we will never run into a timeout again after handling one and it isn't unlikely that multiple IBs in a row doesn't work correctly.

Christian.

Quoted 29 lines
---
    drivers/gpu/drm/scheduler/sched_main.c | 5 -----
    1 file changed, 5 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -5
index c1aaf85..d6c17f1 100644
@@ -308,7 +308,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
    {
        struct drm_gpu_scheduler *sched;
        struct drm_sched_job *job;
-     unsigned long flags;
 
        sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
        job = list_first_entry_or_null(&sched->ring_mirror_list,
@@ -316,10 +315,6 @@ static void drm_sched_job_timedout(struct
 work_struct *work)
 
        if (job)
                job->sched->ops->timedout_job(job);
-
-     spin_lock_irqsave(&sched->job_list_lock, flags);
-     drm_sched_start_timeout(sched);
-     spin_unlock_irqrestore(&sched->job_list_lock, flags);
    }
 
Quoted 1 line
     /**

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

_______________________________________________
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): 2a65cd8c-78ef-8f99-8c6c-67fe02afc062-5C7GfCeVMHo@public.gmane.org

author
#12 lore raw

Christian,
Why this is intentional that the same job keep reporting timeout ? And why we cannot change that ?

That's looks just a bug

/Monk

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Koenig, Christian
Sent: Thursday, May 9, 2019 6:54 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Hi Monk,

ok you don't seem to understand: It is intentional that the same job times out multiple times! So we can't really change anything here.

What we can do is instead of sending a signal (which is not a good idea from the timeout handler anyway) we can start a background script to do the dumping.

Now when the next timeout happens we double check if the background script is still running and if yes, simply ignore the timeout and wait for the next one.

Christian.

Am 09.05.19 um 12:49 schrieb Liu, Monk:

Quoted 104 lines

Hah ... I see, but my requirement cannot be satisfied with current design:

What I need to do is put a signal arming in job_timeout() to notify a USER SPACE daemon app , which finally leverage "UMR" to DUMP/retrieve sw/hw information related with the TMO/hang as much as possible . To make it straight forward I would signal USR1 to the registered app (the daemon) every time a TMO happens, and this would introduce lot of unnecessary DUMP if this "bug" cannot resolved.

I think keep reporting TMO message for one IB is a "bug" to me even it is not for my above feature...

To address your concern, what about this one:

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
index 1397942..31d99e9 100644
@@ -28,7 +28,7 @@
  #include "amdgpu.h"
  #include "amdgpu_trace.h"
 
-static void amdgpu_job_timedout(struct drm_sched_job *s_job)
+static int amdgpu_job_timedout(struct drm_sched_job *s_job)
  {
         struct amdgpu_ring *ring = to_amdgpu_ring(s_job->sched);
         struct amdgpu_job *job = to_amdgpu_job(s_job); @@ -39,7 +39,7 

@@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)

         if (amdgpu_ring_soft_recovery(ring, job->vmid, s_job->s_fence->parent)) {
                 DRM_ERROR("ring %s timeout, but soft recovered\n",
                           s_job->sched->name);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -2
-               return;
+               return -ENODEV;
         }
 
         amdgpu_vm_get_task_info(ring->adev, job->pasid, &ti); @@ 
-51,6 +51,8 @@ static void amdgpu_job_timedout(struct drm_sched_job 

*s_job)

         if (amdgpu_device_should_recover_gpu(ring->adev))
                 amdgpu_device_gpu_recover(ring->adev, job);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
+
+       return 0;
  }
 
  int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs, 
drivers/gpu/drm/scheduler/sched_main.c +11 -6
index c1aaf85..b93deb1 100644
@@ -308,18 +308,23 @@ static void drm_sched_job_timedout(struct work_struct *work)
  {
         struct drm_gpu_scheduler *sched;
         struct drm_sched_job *job;
-       unsigned long flags;
+       int ret;
 
         sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
         job = list_first_entry_or_null(&sched->ring_mirror_list,
                                        struct drm_sched_job, node);
 
-       if (job)
-               job->sched->ops->timedout_job(job);
+       if (job) {
+               ret = job->sched->ops->timedout_job(job);
+               if (ret) {
+                       unsigned long flags;
 
-       spin_lock_irqsave(&sched->job_list_lock, flags);
-       drm_sched_start_timeout(sched);
-       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+                       /* means recovered, restart timer now */
+                       spin_lock_irqsave(&sched->job_list_lock, flags);
+                       drm_sched_start_timeout(sched);
+                       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+               }
+       }
  }
 
   /**
include/drm/gpu_scheduler.h +1 -2
index 9c2a957..c3884c3 100644
--- a/include/drm/gpu_scheduler.h
@@ -229,7 +229,7 @@ struct drm_sched_backend_ops {
           * @timedout_job: Called when a job has taken too long to execute,
           * to trigger GPU recovery.
          */
-       void (*timedout_job)(struct drm_sched_job *sched_job);
+       int (*timedout_job)(struct drm_sched_job *sched_job);
 
         /**
           * @free_job: Called once the job's finished fence has been 

signaled
(END)

Thanks
/Monk
-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 6:30 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Quoted 66 lines

drm_sched_start() is not necessary called from the timeout handler.

If a soft recovery is sufficient, we just continue without a complete reset.

Christian.

Am 09.05.19 um 12:25 schrieb Liu, Monk:

Quoted 59 lines

Christian

Check "drm_sched_start" which is invoked from gpu_recover() , there is a "drm_sched_start_timeout()" in the tail

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 3:18 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Am 09.05.19 um 06:31 schrieb Monk Liu:

Quoted 2 lines

we don't need duplicated IB's timeout error message reported endlessly, just one report per timedout IB is enough

Well, NAK. We don't need multiple timeout reports, but we really need to restart the timeout counter after handling it.

Otherwise we will never run into a timeout again after handling one and it isn't unlikely that multiple IBs in a row doesn't work correctly.

Christian.

Quoted 29 lines
---
    drivers/gpu/drm/scheduler/sched_main.c | 5 -----
    1 file changed, 5 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -5
index c1aaf85..d6c17f1 100644
@@ -308,7 +308,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
    {
        struct drm_gpu_scheduler *sched;
        struct drm_sched_job *job;
-     unsigned long flags;
 
        sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
        job = list_first_entry_or_null(&sched->ring_mirror_list,
@@ -316,10 +315,6 @@ static void drm_sched_job_timedout(struct 
 work_struct *work)
 
        if (job)
                job->sched->ops->timedout_job(job);
-
-     spin_lock_irqsave(&sched->job_list_lock, flags);
-     drm_sched_start_timeout(sched);
-     spin_unlock_irqrestore(&sched->job_list_lock, flags);
    }
 
Quoted 1 line
     /**

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

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
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): BYAPR12MB33012AC49AC6DB8F728BA43084330-ZGDeBxoHBPmRc1D8ZEEGsgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#14 lore raw

Hi Monk,

the timeout handler might only kill waves until we see some progress again and then continue.

E.g. we don't necessary kill the whole job, but maybe just one drawing/computing operations. Or the same job is submitted another time.

As long as there is a job running on the hardware there should also be a timer running.

Not only our driver is relying on that but also the ARM drivers. See the history of that change.

When we don't want the timeout to fire again for this job we should probably remove the job from the ring mirror list and destroy it.

Christian.

Am 09.05.19 um 12:56 schrieb Liu, Monk:

Quoted 197 lines

Christian,
Why this is intentional that the same job keep reporting timeout ? And why we cannot change that ?

That's looks just a bug

/Monk

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Koenig, Christian
Sent: Thursday, May 9, 2019 6:54 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Hi Monk,

ok you don't seem to understand: It is intentional that the same job times out multiple times! So we can't really change anything here.

What we can do is instead of sending a signal (which is not a good idea from the timeout handler anyway) we can start a background script to do the dumping.

Now when the next timeout happens we double check if the background script is still running and if yes, simply ignore the timeout and wait for the next one.

Christian.

Am 09.05.19 um 12:49 schrieb Liu, Monk:

Quoted 104 lines

Hah ... I see, but my requirement cannot be satisfied with current design:

What I need to do is put a signal arming in job_timeout() to notify a USER SPACE daemon app , which finally leverage "UMR" to DUMP/retrieve sw/hw information related with the TMO/hang as much as possible . To make it straight forward I would signal USR1 to the registered app (the daemon) every time a TMO happens, and this would introduce lot of unnecessary DUMP if this "bug" cannot resolved.

I think keep reporting TMO message for one IB is a "bug" to me even it is not for my above feature...

To address your concern, what about this one:

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
index 1397942..31d99e9 100644
@@ -28,7 +28,7 @@
   #include "amdgpu.h"
   #include "amdgpu_trace.h"
 
-static void amdgpu_job_timedout(struct drm_sched_job *s_job)
+static int amdgpu_job_timedout(struct drm_sched_job *s_job)
   {
          struct amdgpu_ring *ring = to_amdgpu_ring(s_job->sched);
          struct amdgpu_job *job = to_amdgpu_job(s_job); @@ -39,7 +39,7

@@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)

          if (amdgpu_ring_soft_recovery(ring, job->vmid, s_job->s_fence->parent)) {
                  DRM_ERROR("ring %s timeout, but soft recovered\n",
                            s_job->sched->name);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -2
-               return;
+               return -ENODEV;
          }
 
          amdgpu_vm_get_task_info(ring->adev, job->pasid, &ti); @@
-51,6 +51,8 @@ static void amdgpu_job_timedout(struct drm_sched_job

*s_job)

          if (amdgpu_device_should_recover_gpu(ring->adev))
                  amdgpu_device_gpu_recover(ring->adev, job);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
+
+       return 0;
   }
 
   int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,
drivers/gpu/drm/scheduler/sched_main.c +11 -6
index c1aaf85..b93deb1 100644
@@ -308,18 +308,23 @@ static void drm_sched_job_timedout(struct work_struct *work)
   {
          struct drm_gpu_scheduler *sched;
          struct drm_sched_job *job;
-       unsigned long flags;
+       int ret;
 
          sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
          job = list_first_entry_or_null(&sched->ring_mirror_list,
                                         struct drm_sched_job, node);
 
-       if (job)
-               job->sched->ops->timedout_job(job);
+       if (job) {
+               ret = job->sched->ops->timedout_job(job);
+               if (ret) {
+                       unsigned long flags;
 
-       spin_lock_irqsave(&sched->job_list_lock, flags);
-       drm_sched_start_timeout(sched);
-       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+                       /* means recovered, restart timer now */
+                       spin_lock_irqsave(&sched->job_list_lock, flags);
+                       drm_sched_start_timeout(sched);
+                       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+               }
+       }
   }
 
    /**
include/drm/gpu_scheduler.h +1 -2
index 9c2a957..c3884c3 100644
--- a/include/drm/gpu_scheduler.h
@@ -229,7 +229,7 @@ struct drm_sched_backend_ops {
            * @timedout_job: Called when a job has taken too long to execute,
            * to trigger GPU recovery.
           */
-       void (*timedout_job)(struct drm_sched_job *sched_job);
+       int (*timedout_job)(struct drm_sched_job *sched_job);
 
          /**
            * @free_job: Called once the job's finished fence has been

signaled
(END)

Thanks
/Monk
-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 6:30 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Quoted 66 lines

drm_sched_start() is not necessary called from the timeout handler.

If a soft recovery is sufficient, we just continue without a complete reset.

Christian.

Am 09.05.19 um 12:25 schrieb Liu, Monk:

Quoted 59 lines

Christian

Check "drm_sched_start" which is invoked from gpu_recover() , there is a "drm_sched_start_timeout()" in the tail

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 3:18 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Am 09.05.19 um 06:31 schrieb Monk Liu:

Quoted 2 lines

we don't need duplicated IB's timeout error message reported endlessly, just one report per timedout IB is enough

Well, NAK. We don't need multiple timeout reports, but we really need to restart the timeout counter after handling it.

Otherwise we will never run into a timeout again after handling one and it isn't unlikely that multiple IBs in a row doesn't work correctly.

Christian.

Quoted 29 lines
---
     drivers/gpu/drm/scheduler/sched_main.c | 5 -----
     1 file changed, 5 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -5
index c1aaf85..d6c17f1 100644
@@ -308,7 +308,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
     {
         struct drm_gpu_scheduler *sched;
         struct drm_sched_job *job;
-     unsigned long flags;
 
         sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
         job = list_first_entry_or_null(&sched->ring_mirror_list,
@@ -316,10 +315,6 @@ static void drm_sched_job_timedout(struct
 work_struct *work)
 
         if (job)
                 job->sched->ops->timedout_job(job);
-
-     spin_lock_irqsave(&sched->job_list_lock, flags);
-     drm_sched_start_timeout(sched);
-     spin_unlock_irqrestore(&sched->job_list_lock, flags);
     }
 
Quoted 1 line
      /**

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

Quoted 8 lines

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

_______________________________________________
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): 7d878a74-6c72-b36c-ddd5-57c7e24fb46f-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author
#16 lore raw

Hi Christian

I saw your patch commit ""19067e"", it actually explained nothing about why need this timer to restarted since handler already restarted this timer inside ...

and sorry that I don't have the history background to understand your previous reply, please check in lines:

Quoted 1 line
Quoted 1 line

the timeout handler might only kill waves until we see some progress again and then continue E.g. we don't necessary kill the whole job, but maybe just one drawing/computing operations. Or the same job is submitted another time.

[ML] what do you mean don't kill the whole job ?? the job is the minimal granularity to either signal or force completion ... I don't get your point here ... and how to explain "kill" ? (do you mean terminate the application during the "wave" being excuted ?) Can you use plain words to avoid term misunderstanding ? thanks

Quoted 1 line
Quoted 1 line

As long as there is a job running on the hardware there should also be a timer running.

[ML] this part I think there is no problem, after handler recovered scheduler the TIMER do get restarted in "post_asic_reset"

/Monk
-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 7:08 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Hi Monk,

the timeout handler might only kill waves until we see some progress again and then continue.

E.g. we don't necessary kill the whole job, but maybe just one drawing/computing operations. Or the same job is submitted another time.

As long as there is a job running on the hardware there should also be a timer running.

Not only our driver is relying on that but also the ARM drivers. See the history of that change.

When we don't want the timeout to fire again for this job we should probably remove the job from the ring mirror list and destroy it.

Christian.

Am 09.05.19 um 12:56 schrieb Liu, Monk:

Quoted 199 lines

Christian,
Why this is intentional that the same job keep reporting timeout ? And why we cannot change that ?

That's looks just a bug

/Monk

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Koenig, Christian
Sent: Thursday, May 9, 2019 6:54 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Hi Monk,

ok you don't seem to understand: It is intentional that the same job times out multiple times! So we can't really change anything here.

What we can do is instead of sending a signal (which is not a good idea from the timeout handler anyway) we can start a background script to do the dumping.

Now when the next timeout happens we double check if the background script is still running and if yes, simply ignore the timeout and wait for the next one.

Christian.

Am 09.05.19 um 12:49 schrieb Liu, Monk:

Quoted 104 lines

Hah ... I see, but my requirement cannot be satisfied with current design:

What I need to do is put a signal arming in job_timeout() to notify a USER SPACE daemon app , which finally leverage "UMR" to DUMP/retrieve sw/hw information related with the TMO/hang as much as possible . To make it straight forward I would signal USR1 to the registered app (the daemon) every time a TMO happens, and this would introduce lot of unnecessary DUMP if this "bug" cannot resolved.

I think keep reporting TMO message for one IB is a "bug" to me even it is not for my above feature...

To address your concern, what about this one:

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +3 -3
index 1397942..31d99e9 100644
@@ -28,7 +28,7 @@
   #include "amdgpu.h"
   #include "amdgpu_trace.h"
 
-static void amdgpu_job_timedout(struct drm_sched_job *s_job)
+static int amdgpu_job_timedout(struct drm_sched_job *s_job)
   {
          struct amdgpu_ring *ring = to_amdgpu_ring(s_job->sched);
          struct amdgpu_job *job = to_amdgpu_job(s_job); @@ -39,7 
+39,7 @@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)
          if (amdgpu_ring_soft_recovery(ring, job->vmid, s_job->s_fence->parent)) {
                  DRM_ERROR("ring %s timeout, but soft recovered\n",
                            s_job->sched->name);
-               return;
+               return -ENODEV;
          }
 
          amdgpu_vm_get_task_info(ring->adev, job->pasid, &ti); @@
-51,6 +51,8 @@ static void amdgpu_job_timedout(struct drm_sched_job

*s_job)

          if (amdgpu_device_should_recover_gpu(ring->adev))
                  amdgpu_device_gpu_recover(ring->adev, job);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
+
+       return 0;
   }
 
   int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs, 
drivers/gpu/drm/scheduler/sched_main.c +11 -6
index c1aaf85..b93deb1 100644
@@ -308,18 +308,23 @@ static void drm_sched_job_timedout(struct work_struct *work)
   {
          struct drm_gpu_scheduler *sched;
          struct drm_sched_job *job;
-       unsigned long flags;
+       int ret;
 
          sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
          job = list_first_entry_or_null(&sched->ring_mirror_list,
                                         struct drm_sched_job, node);
 
-       if (job)
-               job->sched->ops->timedout_job(job);
+       if (job) {
+               ret = job->sched->ops->timedout_job(job);
+               if (ret) {
+                       unsigned long flags;
 
-       spin_lock_irqsave(&sched->job_list_lock, flags);
-       drm_sched_start_timeout(sched);
-       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+                       /* means recovered, restart timer now */
+                       spin_lock_irqsave(&sched->job_list_lock, flags);
+                       drm_sched_start_timeout(sched);
+                       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+               }
+       }
   }
 
    /**
(quoted diff) +0 -0

b/include/drm/gpu_scheduler.h index 9c2a957..c3884c3 100644 --- a/include/drm/gpu_scheduler.h

(quoted diff) +1 -1
@@ -229,7 +229,7 @@ struct drm_sched_backend_ops {
            * @timedout_job: Called when a job has taken too long to execute,
            * to trigger GPU recovery.
           */
-       void (*timedout_job)(struct drm_sched_job *sched_job);
+       int (*timedout_job)(struct drm_sched_job *sched_job);
 
          /**
            * @free_job: Called once the job's finished fence has 

been signaled
(END)

Thanks
/Monk
-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 6:30 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Quoted 66 lines

drm_sched_start() is not necessary called from the timeout handler.

If a soft recovery is sufficient, we just continue without a complete reset.

Christian.

Am 09.05.19 um 12:25 schrieb Liu, Monk:

Quoted 59 lines

Christian

Check "drm_sched_start" which is invoked from gpu_recover() , there is a "drm_sched_start_timeout()" in the tail

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 3:18 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Am 09.05.19 um 06:31 schrieb Monk Liu:

Quoted 2 lines

we don't need duplicated IB's timeout error message reported endlessly, just one report per timedout IB is enough

Well, NAK. We don't need multiple timeout reports, but we really need to restart the timeout counter after handling it.

Otherwise we will never run into a timeout again after handling one and it isn't unlikely that multiple IBs in a row doesn't work correctly.

Christian.

Quoted 29 lines
---
     drivers/gpu/drm/scheduler/sched_main.c | 5 -----
     1 file changed, 5 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -5
index c1aaf85..d6c17f1 100644
@@ -308,7 +308,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
     {
         struct drm_gpu_scheduler *sched;
         struct drm_sched_job *job;
-     unsigned long flags;
 
         sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
         job = list_first_entry_or_null(&sched->ring_mirror_list,
@@ -316,10 +315,6 @@ static void drm_sched_job_timedout(struct 
 work_struct *work)
 
         if (job)
                 job->sched->ops->timedout_job(job);
-
-     spin_lock_irqsave(&sched->job_list_lock, flags);
-     drm_sched_start_timeout(sched);
-     spin_unlock_irqrestore(&sched->job_list_lock, flags);
     }
 
Quoted 1 line
      /**

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

Quoted 8 lines

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

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

#17 lore raw
In reply to a message not in the archive

Hi Monk,

the timeout handler might only kill waves until we see some progress again and then continue.

E.g. we don't necessary kill the whole job, but maybe just one drawing/computing operations. Or the same job is submitted another time. etc...

As long as there is a job running on the hardware there should also be a timer running.

And not only our driver is relying on that but also the ARM drivers. See the history of that change.

When we don't want the timeout to fire again for this job we should probably remove the job from the ring mirror list and destroy it.

Christian.

Am 09.05.19 um 12:56 schrieb Liu, Monk:

Quoted 197 lines

Christian,
Why this is intentional that the same job keep reporting timeout ? And why we cannot change that ?

That's looks just a bug

/Monk

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Koenig, Christian
Sent: Thursday, May 9, 2019 6:54 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Hi Monk,

ok you don't seem to understand: It is intentional that the same job times out multiple times! So we can't really change anything here.

What we can do is instead of sending a signal (which is not a good idea from the timeout handler anyway) we can start a background script to do the dumping.

Now when the next timeout happens we double check if the background script is still running and if yes, simply ignore the timeout and wait for the next one.

Christian.

Am 09.05.19 um 12:49 schrieb Liu, Monk:

Quoted 104 lines

Hah ... I see, but my requirement cannot be satisfied with current design:

What I need to do is put a signal arming in job_timeout() to notify a USER SPACE daemon app , which finally leverage "UMR" to DUMP/retrieve sw/hw information related with the TMO/hang as much as possible . To make it straight forward I would signal USR1 to the registered app (the daemon) every time a TMO happens, and this would introduce lot of unnecessary DUMP if this "bug" cannot resolved.

I think keep reporting TMO message for one IB is a "bug" to me even it is not for my above feature...

To address your concern, what about this one:

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
index 1397942..31d99e9 100644
@@ -28,7 +28,7 @@
   #include "amdgpu.h"
   #include "amdgpu_trace.h"
 
-static void amdgpu_job_timedout(struct drm_sched_job *s_job)
+static int amdgpu_job_timedout(struct drm_sched_job *s_job)
   {
          struct amdgpu_ring *ring = to_amdgpu_ring(s_job->sched);
          struct amdgpu_job *job = to_amdgpu_job(s_job); @@ -39,7 +39,7

@@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)

          if (amdgpu_ring_soft_recovery(ring, job->vmid, s_job->s_fence->parent)) {
                  DRM_ERROR("ring %s timeout, but soft recovered\n",
                            s_job->sched->name);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -2
-               return;
+               return -ENODEV;
          }
 
          amdgpu_vm_get_task_info(ring->adev, job->pasid, &ti); @@
-51,6 +51,8 @@ static void amdgpu_job_timedout(struct drm_sched_job

*s_job)

          if (amdgpu_device_should_recover_gpu(ring->adev))
                  amdgpu_device_gpu_recover(ring->adev, job);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
+
+       return 0;
   }
 
   int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,
drivers/gpu/drm/scheduler/sched_main.c +11 -6
index c1aaf85..b93deb1 100644
@@ -308,18 +308,23 @@ static void drm_sched_job_timedout(struct work_struct *work)
   {
          struct drm_gpu_scheduler *sched;
          struct drm_sched_job *job;
-       unsigned long flags;
+       int ret;
 
          sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
          job = list_first_entry_or_null(&sched->ring_mirror_list,
                                         struct drm_sched_job, node);
 
-       if (job)
-               job->sched->ops->timedout_job(job);
+       if (job) {
+               ret = job->sched->ops->timedout_job(job);
+               if (ret) {
+                       unsigned long flags;
 
-       spin_lock_irqsave(&sched->job_list_lock, flags);
-       drm_sched_start_timeout(sched);
-       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+                       /* means recovered, restart timer now */
+                       spin_lock_irqsave(&sched->job_list_lock, flags);
+                       drm_sched_start_timeout(sched);
+                       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+               }
+       }
   }
 
    /**
include/drm/gpu_scheduler.h +1 -2
index 9c2a957..c3884c3 100644
--- a/include/drm/gpu_scheduler.h
@@ -229,7 +229,7 @@ struct drm_sched_backend_ops {
            * @timedout_job: Called when a job has taken too long to execute,
            * to trigger GPU recovery.
           */
-       void (*timedout_job)(struct drm_sched_job *sched_job);
+       int (*timedout_job)(struct drm_sched_job *sched_job);
 
          /**
            * @free_job: Called once the job's finished fence has been

signaled
(END)

Thanks
/Monk
-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 6:30 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Quoted 66 lines

drm_sched_start() is not necessary called from the timeout handler.

If a soft recovery is sufficient, we just continue without a complete reset.

Christian.

Am 09.05.19 um 12:25 schrieb Liu, Monk:

Quoted 59 lines

Christian

Check "drm_sched_start" which is invoked from gpu_recover() , there is a "drm_sched_start_timeout()" in the tail

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 3:18 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Am 09.05.19 um 06:31 schrieb Monk Liu:

Quoted 2 lines

we don't need duplicated IB's timeout error message reported endlessly, just one report per timedout IB is enough

Well, NAK. We don't need multiple timeout reports, but we really need to restart the timeout counter after handling it.

Otherwise we will never run into a timeout again after handling one and it isn't unlikely that multiple IBs in a row doesn't work correctly.

Christian.

Quoted 29 lines
---
     drivers/gpu/drm/scheduler/sched_main.c | 5 -----
     1 file changed, 5 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -5
index c1aaf85..d6c17f1 100644
@@ -308,7 +308,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
     {
         struct drm_gpu_scheduler *sched;
         struct drm_sched_job *job;
-     unsigned long flags;
 
         sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
         job = list_first_entry_or_null(&sched->ring_mirror_list,
@@ -316,10 +315,6 @@ static void drm_sched_job_timedout(struct
 work_struct *work)
 
         if (job)
                 job->sched->ops->timedout_job(job);
-
-     spin_lock_irqsave(&sched->job_list_lock, flags);
-     drm_sched_start_timeout(sched);
-     spin_unlock_irqrestore(&sched->job_list_lock, flags);
     }
 
Quoted 1 line
      /**

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

Quoted 8 lines

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

_______________________________________________
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): afac6e4d-5002-2a47-85d8-52e5359b2b22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author
#19 lore raw
Quoted 1 line
Quoted 1 line

And not only our driver is relying on that but also the ARM drivers. See the history of that change.

That 's the issue I didn't see earlier, if ARM drivers doesn't restart timer in their job_timeout() it is a problem

But I don't want to change my plan on that feature, so can you give more explain on the aspect except this "ARM" driver ? Because I cannot even implement it my way in the customer branch if except ARM reason there are other bad side effects

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 7:09 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Hi Monk,

the timeout handler might only kill waves until we see some progress again and then continue.

E.g. we don't necessary kill the whole job, but maybe just one drawing/computing operations. Or the same job is submitted another time. etc...

As long as there is a job running on the hardware there should also be a timer running.

And not only our driver is relying on that but also the ARM drivers. See the history of that change.

When we don't want the timeout to fire again for this job we should probably remove the job from the ring mirror list and destroy it.

Christian.

Am 09.05.19 um 12:56 schrieb Liu, Monk:

Quoted 199 lines

Christian,
Why this is intentional that the same job keep reporting timeout ? And why we cannot change that ?

That's looks just a bug

/Monk

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Koenig, Christian
Sent: Thursday, May 9, 2019 6:54 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Hi Monk,

ok you don't seem to understand: It is intentional that the same job times out multiple times! So we can't really change anything here.

What we can do is instead of sending a signal (which is not a good idea from the timeout handler anyway) we can start a background script to do the dumping.

Now when the next timeout happens we double check if the background script is still running and if yes, simply ignore the timeout and wait for the next one.

Christian.

Am 09.05.19 um 12:49 schrieb Liu, Monk:

Quoted 104 lines

Hah ... I see, but my requirement cannot be satisfied with current design:

What I need to do is put a signal arming in job_timeout() to notify a USER SPACE daemon app , which finally leverage "UMR" to DUMP/retrieve sw/hw information related with the TMO/hang as much as possible . To make it straight forward I would signal USR1 to the registered app (the daemon) every time a TMO happens, and this would introduce lot of unnecessary DUMP if this "bug" cannot resolved.

I think keep reporting TMO message for one IB is a "bug" to me even it is not for my above feature...

To address your concern, what about this one:

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +3 -3
index 1397942..31d99e9 100644
@@ -28,7 +28,7 @@
   #include "amdgpu.h"
   #include "amdgpu_trace.h"
 
-static void amdgpu_job_timedout(struct drm_sched_job *s_job)
+static int amdgpu_job_timedout(struct drm_sched_job *s_job)
   {
          struct amdgpu_ring *ring = to_amdgpu_ring(s_job->sched);
          struct amdgpu_job *job = to_amdgpu_job(s_job); @@ -39,7 
+39,7 @@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)
          if (amdgpu_ring_soft_recovery(ring, job->vmid, s_job->s_fence->parent)) {
                  DRM_ERROR("ring %s timeout, but soft recovered\n",
                            s_job->sched->name);
-               return;
+               return -ENODEV;
          }
 
          amdgpu_vm_get_task_info(ring->adev, job->pasid, &ti); @@
-51,6 +51,8 @@ static void amdgpu_job_timedout(struct drm_sched_job

*s_job)

          if (amdgpu_device_should_recover_gpu(ring->adev))
                  amdgpu_device_gpu_recover(ring->adev, job);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
+
+       return 0;
   }
 
   int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs, 
drivers/gpu/drm/scheduler/sched_main.c +11 -6
index c1aaf85..b93deb1 100644
@@ -308,18 +308,23 @@ static void drm_sched_job_timedout(struct work_struct *work)
   {
          struct drm_gpu_scheduler *sched;
          struct drm_sched_job *job;
-       unsigned long flags;
+       int ret;
 
          sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
          job = list_first_entry_or_null(&sched->ring_mirror_list,
                                         struct drm_sched_job, node);
 
-       if (job)
-               job->sched->ops->timedout_job(job);
+       if (job) {
+               ret = job->sched->ops->timedout_job(job);
+               if (ret) {
+                       unsigned long flags;
 
-       spin_lock_irqsave(&sched->job_list_lock, flags);
-       drm_sched_start_timeout(sched);
-       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+                       /* means recovered, restart timer now */
+                       spin_lock_irqsave(&sched->job_list_lock, flags);
+                       drm_sched_start_timeout(sched);
+                       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+               }
+       }
   }
 
    /**
(quoted diff) +0 -0

b/include/drm/gpu_scheduler.h index 9c2a957..c3884c3 100644 --- a/include/drm/gpu_scheduler.h

(quoted diff) +1 -1
@@ -229,7 +229,7 @@ struct drm_sched_backend_ops {
            * @timedout_job: Called when a job has taken too long to execute,
            * to trigger GPU recovery.
           */
-       void (*timedout_job)(struct drm_sched_job *sched_job);
+       int (*timedout_job)(struct drm_sched_job *sched_job);
 
          /**
            * @free_job: Called once the job's finished fence has 

been signaled
(END)

Thanks
/Monk
-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 6:30 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Quoted 66 lines

drm_sched_start() is not necessary called from the timeout handler.

If a soft recovery is sufficient, we just continue without a complete reset.

Christian.

Am 09.05.19 um 12:25 schrieb Liu, Monk:

Quoted 59 lines

Christian

Check "drm_sched_start" which is invoked from gpu_recover() , there is a "drm_sched_start_timeout()" in the tail

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 3:18 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Am 09.05.19 um 06:31 schrieb Monk Liu:

Quoted 2 lines

we don't need duplicated IB's timeout error message reported endlessly, just one report per timedout IB is enough

Well, NAK. We don't need multiple timeout reports, but we really need to restart the timeout counter after handling it.

Otherwise we will never run into a timeout again after handling one and it isn't unlikely that multiple IBs in a row doesn't work correctly.

Christian.

Quoted 29 lines
---
     drivers/gpu/drm/scheduler/sched_main.c | 5 -----
     1 file changed, 5 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -5
index c1aaf85..d6c17f1 100644
@@ -308,7 +308,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
     {
         struct drm_gpu_scheduler *sched;
         struct drm_sched_job *job;
-     unsigned long flags;
 
         sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
         job = list_first_entry_or_null(&sched->ring_mirror_list,
@@ -316,10 +315,6 @@ static void drm_sched_job_timedout(struct 
 work_struct *work)
 
         if (job)
                 job->sched->ops->timedout_job(job);
-
-     spin_lock_irqsave(&sched->job_list_lock, flags);
-     drm_sched_start_timeout(sched);
-     spin_unlock_irqrestore(&sched->job_list_lock, flags);
     }
 
Quoted 1 line
      /**

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

Quoted 8 lines

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

_______________________________________________
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): BYAPR12MB33019D428603A443D11A398384330-ZGDeBxoHBPmRc1D8ZEEGsgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#21 lore raw

Well putting the other drivers aside for moment, I would also say that it is bad design to not restart the timeout. So even then I would not review that patch.

Question is rather what are you actually trying to do and why don't you want to change your design?

Designs should be discussed on the public mailing list and not done internally.

Regards,
Christian.

Am 09.05.19 um 13:40 schrieb Liu, Monk:

Quoted 25 lines
Quoted 1 line
Quoted 1 line

And not only our driver is relying on that but also the ARM drivers. See the history of that change.

That 's the issue I didn't see earlier, if ARM drivers doesn't restart timer in their job_timeout() it is a problem

But I don't want to change my plan on that feature, so can you give more explain on the aspect except this "ARM" driver ? Because I cannot even implement it my way in the customer branch if except ARM reason there are other bad side effects

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 7:09 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Hi Monk,

the timeout handler might only kill waves until we see some progress again and then continue.

E.g. we don't necessary kill the whole job, but maybe just one drawing/computing operations. Or the same job is submitted another time. etc...

As long as there is a job running on the hardware there should also be a timer running.

Quoted 214 lines

And not only our driver is relying on that but also the ARM drivers. See the history of that change.

When we don't want the timeout to fire again for this job we should probably remove the job from the ring mirror list and destroy it.

Christian.

Am 09.05.19 um 12:56 schrieb Liu, Monk:

Quoted 207 lines

Christian,
Why this is intentional that the same job keep reporting timeout ? And why we cannot change that ?

That's looks just a bug

/Monk

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Koenig, Christian
Sent: Thursday, May 9, 2019 6:54 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Hi Monk,

ok you don't seem to understand: It is intentional that the same job times out multiple times! So we can't really change anything here.

What we can do is instead of sending a signal (which is not a good idea from the timeout handler anyway) we can start a background script to do the dumping.

Now when the next timeout happens we double check if the background script is still running and if yes, simply ignore the timeout and wait for the next one.

Christian.

Am 09.05.19 um 12:49 schrieb Liu, Monk:

Quoted 104 lines

Hah ... I see, but my requirement cannot be satisfied with current design:

What I need to do is put a signal arming in job_timeout() to notify a USER SPACE daemon app , which finally leverage "UMR" to DUMP/retrieve sw/hw information related with the TMO/hang as much as possible . To make it straight forward I would signal USR1 to the registered app (the daemon) every time a TMO happens, and this would introduce lot of unnecessary DUMP if this "bug" cannot resolved.

I think keep reporting TMO message for one IB is a "bug" to me even it is not for my above feature...

To address your concern, what about this one:

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +3 -3
index 1397942..31d99e9 100644
@@ -28,7 +28,7 @@
    #include "amdgpu.h"
    #include "amdgpu_trace.h"
 
-static void amdgpu_job_timedout(struct drm_sched_job *s_job)
+static int amdgpu_job_timedout(struct drm_sched_job *s_job)
    {
           struct amdgpu_ring *ring = to_amdgpu_ring(s_job->sched);
           struct amdgpu_job *job = to_amdgpu_job(s_job); @@ -39,7
+39,7 @@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)
           if (amdgpu_ring_soft_recovery(ring, job->vmid, s_job->s_fence->parent)) {
                   DRM_ERROR("ring %s timeout, but soft recovered\n",
                             s_job->sched->name);
-               return;
+               return -ENODEV;
           }
 
           amdgpu_vm_get_task_info(ring->adev, job->pasid, &ti); @@
-51,6 +51,8 @@ static void amdgpu_job_timedout(struct drm_sched_job

*s_job)

           if (amdgpu_device_should_recover_gpu(ring->adev))
                   amdgpu_device_gpu_recover(ring->adev, job);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
+
+       return 0;
    }
 
    int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,
drivers/gpu/drm/scheduler/sched_main.c +11 -6
index c1aaf85..b93deb1 100644
@@ -308,18 +308,23 @@ static void drm_sched_job_timedout(struct work_struct *work)
    {
           struct drm_gpu_scheduler *sched;
           struct drm_sched_job *job;
-       unsigned long flags;
+       int ret;
 
           sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
           job = list_first_entry_or_null(&sched->ring_mirror_list,
                                          struct drm_sched_job, node);
 
-       if (job)
-               job->sched->ops->timedout_job(job);
+       if (job) {
+               ret = job->sched->ops->timedout_job(job);
+               if (ret) {
+                       unsigned long flags;
 
-       spin_lock_irqsave(&sched->job_list_lock, flags);
-       drm_sched_start_timeout(sched);
-       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+                       /* means recovered, restart timer now */
+                       spin_lock_irqsave(&sched->job_list_lock, flags);
+                       drm_sched_start_timeout(sched);
+                       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+               }
+       }
    }
 
     /**
(quoted diff) +0 -0

b/include/drm/gpu_scheduler.h index 9c2a957..c3884c3 100644 --- a/include/drm/gpu_scheduler.h

(quoted diff) +1 -1
@@ -229,7 +229,7 @@ struct drm_sched_backend_ops {
             * @timedout_job: Called when a job has taken too long to execute,
             * to trigger GPU recovery.
            */
-       void (*timedout_job)(struct drm_sched_job *sched_job);
+       int (*timedout_job)(struct drm_sched_job *sched_job);
 
           /**
             * @free_job: Called once the job's finished fence has

been signaled
(END)

Thanks
/Monk
-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 6:30 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Quoted 66 lines

drm_sched_start() is not necessary called from the timeout handler.

If a soft recovery is sufficient, we just continue without a complete reset.

Christian.

Am 09.05.19 um 12:25 schrieb Liu, Monk:

Quoted 59 lines

Christian

Check "drm_sched_start" which is invoked from gpu_recover() , there is a "drm_sched_start_timeout()" in the tail

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 3:18 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Am 09.05.19 um 06:31 schrieb Monk Liu:

Quoted 2 lines

we don't need duplicated IB's timeout error message reported endlessly, just one report per timedout IB is enough

Well, NAK. We don't need multiple timeout reports, but we really need to restart the timeout counter after handling it.

Otherwise we will never run into a timeout again after handling one and it isn't unlikely that multiple IBs in a row doesn't work correctly.

Christian.

Quoted 29 lines
---
      drivers/gpu/drm/scheduler/sched_main.c | 5 -----
      1 file changed, 5 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -5
index c1aaf85..d6c17f1 100644
@@ -308,7 +308,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
      {
          struct drm_gpu_scheduler *sched;
          struct drm_sched_job *job;
-     unsigned long flags;
 
          sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
          job = list_first_entry_or_null(&sched->ring_mirror_list,
@@ -316,10 +315,6 @@ static void drm_sched_job_timedout(struct
 work_struct *work)
 
          if (job)
                  job->sched->ops->timedout_job(job);
-
-     spin_lock_irqsave(&sched->job_list_lock, flags);
-     drm_sched_start_timeout(sched);
-     spin_unlock_irqrestore(&sched->job_list_lock, flags);
      }
 
Quoted 1 line
       /**

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

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

_______________________________________________
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): f7e39c67-b5ec-0e18-97b0-c34fef640806-5C7GfCeVMHo@public.gmane.org

author
#23 lore raw

Christian

I believe even yourself would agree that keep reporting TMO for the same IB is ugly (need put a "gpu_recovery=0" as option ), I can also argue with you that this is a bad design ... Besides you didn't on technique persuade me to believe there will be bad things upcoming with my patch, you even didn't give me a sequence to prove my patch is wrong.

Since you are the maintainer I would have no choice but keep my patch the customer branch given the case you won't review it, it's only used for AMDGPU virtualization customer anyway

For the design of that feature, your feedback is welcomed:

Backgrounds:
Customer want sw and hw related information (pretty much infos we can collect by UMR) automatically dumped upon Any IB hang.

Design:
- there would be an APP running in background as a daemon utility
- in the beginning of this daemon it would write "register" to a debugfs file like : /sys/kernel/debug/dri/0/amdgpu_dump_register
- kernel driver would remember the PID/task of this daemon upon it write "register" to that debugfs file
- since GIM driver would also detect GPU hang (which lead to a VF FLR), kernel driver should interacted with GIM to block GIM's FLR until the DUMP finished by that daemon.
- upon an IB hang, job_timeout() would kick off and inside it KMD would send an signal "USR1" to the registered task,
- upon "USR1" signal received by the daemon app, it would call "UMR" to dump whatever interested for the offline debugging

With current design if I pass "gpu_recover=0" to KMD there will be infinite job_timeout() triggered for one IB, thus the auto DUMP would also be crazy about its duplication

/Monk

-----Original Message-----
From: Koenig, Christian
Sent: Thursday, May 9, 2019 7:45 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

Well putting the other drivers aside for moment, I would also say that it is bad design to not restart the timeout. So even then I would not review that patch.

Question is rather what are you actually trying to do and why don't you want to change your design?

Designs should be discussed on the public mailing list and not done internally.

Regards,
Christian.

Am 09.05.19 um 13:40 schrieb Liu, Monk:

Quoted 29 lines
Quoted 1 line
Quoted 1 line

And not only our driver is relying on that but also the ARM drivers. See the history of that change.

That 's the issue I didn't see earlier, if ARM drivers doesn't restart timer in their job_timeout() it is a problem

But I don't want to change my plan on that feature, so can you give more explain on the aspect except this "ARM" driver ? Because I cannot even implement it my way in the customer branch if
except ARM reason there are other bad side effects

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 7:09 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Hi Monk,

the timeout handler might only kill waves until we see some progress again and then continue.

E.g. we don't necessary kill the whole job, but maybe just one drawing/computing operations. Or the same job is submitted another time. etc...

As long as there is a job running on the hardware there should also be a timer running.

Quoted 216 lines

And not only our driver is relying on that but also the ARM drivers. See the history of that change.

When we don't want the timeout to fire again for this job we should probably remove the job from the ring mirror list and destroy it.

Christian.

Am 09.05.19 um 12:56 schrieb Liu, Monk:

Quoted 209 lines

Christian,
Why this is intentional that the same job keep reporting timeout ? And why we cannot change that ?

That's looks just a bug

/Monk

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Koenig, Christian
Sent: Thursday, May 9, 2019 6:54 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Hi Monk,

ok you don't seem to understand: It is intentional that the same job times out multiple times! So we can't really change anything here.

What we can do is instead of sending a signal (which is not a good idea from the timeout handler anyway) we can start a background script to do the dumping.

Now when the next timeout happens we double check if the background script is still running and if yes, simply ignore the timeout and wait for the next one.

Christian.

Am 09.05.19 um 12:49 schrieb Liu, Monk:

Quoted 106 lines

Hah ... I see, but my requirement cannot be satisfied with current design:

What I need to do is put a signal arming in job_timeout() to notify a USER SPACE daemon app , which finally leverage "UMR" to DUMP/retrieve sw/hw information related with the TMO/hang as much as possible . To make it straight forward I would signal USR1 to the registered app (the daemon) every time a TMO happens, and this would introduce lot of unnecessary DUMP if this "bug" cannot resolved.

I think keep reporting TMO message for one IB is a "bug" to me even it is not for my above feature...

To address your concern, what about this one:

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +4 -3
index 1397942..31d99e9 100644
@@ -28,7 +28,7 @@
    #include "amdgpu.h"
    #include "amdgpu_trace.h"
 
-static void amdgpu_job_timedout(struct drm_sched_job *s_job)
+static int amdgpu_job_timedout(struct drm_sched_job *s_job)
    {
           struct amdgpu_ring *ring = to_amdgpu_ring(s_job->sched);
           struct amdgpu_job *job = to_amdgpu_job(s_job); @@ -39,7
+39,7 @@ static void amdgpu_job_timedout(struct drm_sched_job 
+*s_job)
           if (amdgpu_ring_soft_recovery(ring, job->vmid, s_job->s_fence->parent)) {
                   DRM_ERROR("ring %s timeout, but soft recovered\n",
                             s_job->sched->name);
-               return;
+               return -ENODEV;
           }
 
           amdgpu_vm_get_task_info(ring->adev, job->pasid, &ti); @@
-51,6 +51,8 @@ static void amdgpu_job_timedout(struct drm_sched_job

*s_job)

           if (amdgpu_device_should_recover_gpu(ring->adev))
                   amdgpu_device_gpu_recover(ring->adev, job);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
+
+       return 0;
    }
 
    int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned 

num_ibs, diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index c1aaf85..b93deb1 100644

drivers/gpu/drm/scheduler/sched_main.c +11 -6
@@ -308,18 +308,23 @@ static void drm_sched_job_timedout(struct work_struct *work)
    {
           struct drm_gpu_scheduler *sched;
           struct drm_sched_job *job;
-       unsigned long flags;
+       int ret;
 
           sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
           job = list_first_entry_or_null(&sched->ring_mirror_list,
                                          struct drm_sched_job, 
 node);
 
-       if (job)
-               job->sched->ops->timedout_job(job);
+       if (job) {
+               ret = job->sched->ops->timedout_job(job);
+               if (ret) {
+                       unsigned long flags;
 
-       spin_lock_irqsave(&sched->job_list_lock, flags);
-       drm_sched_start_timeout(sched);
-       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+                       /* means recovered, restart timer now */
+                       spin_lock_irqsave(&sched->job_list_lock, flags);
+                       drm_sched_start_timeout(sched);
+                       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+               }
+       }
    }
 
     /**
(quoted diff) +0 -0

b/include/drm/gpu_scheduler.h index 9c2a957..c3884c3 100644 --- a/include/drm/gpu_scheduler.h

drivers/gpu/drm/scheduler/sched_main.c +1 -1
@@ -229,7 +229,7 @@ struct drm_sched_backend_ops {
             * @timedout_job: Called when a job has taken too long to execute,
             * to trigger GPU recovery.
            */
-       void (*timedout_job)(struct drm_sched_job *sched_job);
+       int (*timedout_job)(struct drm_sched_job *sched_job);
 
           /**
             * @free_job: Called once the job's finished fence has 

been signaled
(END)

Thanks
/Monk
-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 6:30 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Quoted 66 lines

drm_sched_start() is not necessary called from the timeout handler.

If a soft recovery is sufficient, we just continue without a complete reset.

Christian.

Am 09.05.19 um 12:25 schrieb Liu, Monk:

Quoted 59 lines

Christian

Check "drm_sched_start" which is invoked from gpu_recover() , there is a "drm_sched_start_timeout()" in the tail

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 3:18 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Am 09.05.19 um 06:31 schrieb Monk Liu:

Quoted 2 lines

we don't need duplicated IB's timeout error message reported endlessly, just one report per timedout IB is enough

Well, NAK. We don't need multiple timeout reports, but we really need to restart the timeout counter after handling it.

Otherwise we will never run into a timeout again after handling one and it isn't unlikely that multiple IBs in a row doesn't work correctly.

Christian.

Quoted 29 lines
---
      drivers/gpu/drm/scheduler/sched_main.c | 5 -----
      1 file changed, 5 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -5
index c1aaf85..d6c17f1 100644
@@ -308,7 +308,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
      {
          struct drm_gpu_scheduler *sched;
          struct drm_sched_job *job;
-     unsigned long flags;
 
          sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
          job = list_first_entry_or_null(&sched->ring_mirror_list,
@@ -316,10 +315,6 @@ static void drm_sched_job_timedout(struct 
 work_struct *work)
 
          if (job)
                  job->sched->ops->timedout_job(job);
-
-     spin_lock_irqsave(&sched->job_list_lock, flags);
-     drm_sched_start_timeout(sched);
-     spin_unlock_irqrestore(&sched->job_list_lock, flags);
      }
 
Quoted 1 line
       /**

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

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

_______________________________________________
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): BYAPR12MB33019439A4944127ACC32E1B84330-ZGDeBxoHBPmRc1D8ZEEGsgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#25 lore raw

Am 09.05.19 um 14:49 schrieb Liu, Monk:

Quoted 3 lines

Christian

I believe even yourself would agree that keep reporting TMO for the same IB is ugly (need put a "gpu_recovery=0" as option ), I can also argue with you that this is a bad design ...

Well exactly that's what I disagree on. A second timeout on the same job is perfectly possible and desired, we just don't need to necessarily report it once more.

Quoted 3 lines

Besides you didn't on technique persuade me to believe there will be bad things upcoming with my patch, you even didn't give me a sequence to prove my patch is wrong.

Since you are the maintainer I would have no choice but keep my patch the customer branch given the case you won't review it, it's only used for AMDGPU virtualization customer anyway

Well, I didn't say your patch is wrong. A NAK doesn't mean general rejection, but that you should start from the beginning and reiterate what you are trying to archive here. I mean what does a computer do when it receives the NAK? It retries the transmission.

But the general problem here is that you are quite often coming up with individual patches ripped out of the context without explaining the general intention.

Quoted 4 lines

For the design of that feature, your feedback is welcomed:

Backgrounds:
Customer want sw and hw related information (pretty much infos we can collect by UMR) automatically dumped upon Any IB hang.

Yeah, in general that is a really good idea and discussed multiple times now.

Quoted 4 lines

Design:
- there would be an APP running in background as a daemon utility
- in the beginning of this daemon it would write "register" to a debugfs file like : /sys/kernel/debug/dri/0/amdgpu_dump_register
- kernel driver would remember the PID/task of this daemon upon it write "register" to that debugfs file

That is a rather bad idea because it doesn't handle killed daemon processes correctly. A better approach is let the daemon open up the virtual file and keep the connection open until the process exits.

Quoted 3 lines

- since GIM driver would also detect GPU hang (which lead to a VF FLR), kernel driver should interacted with GIM to block GIM's FLR until the DUMP finished by that daemon.
- upon an IB hang, job_timeout() would kick off and inside it KMD would send an signal "USR1" to the registered task,
- upon "USR1" signal received by the daemon app, it would call "UMR" to dump whatever interested for the offline debugging

Signals are a bad idea for kernel->userspace communication, better use a pipe where data becomes available on a GPU reset.

Quoted 1 line

With current design if I pass "gpu_recover=0" to KMD there will be infinite job_timeout() triggered for one IB, thus the auto DUMP would also be crazy about its duplication

But that's not because of the scheduler but rather because your design is missing another important piece: How does the daemon process signals the kernel driver that it is done with dumping the state? E.g. How do you signal the GIM that it can do a FLR again somehow?

What you can do is to either block the timeout handler until the userspace process signals that it is done with dumping, or if that's not possible because of locks (etc) you could use the drm_sched_suspend_timeout() and drm_sched_resume_timeout() helpers which allow us to disable the scheduler timeout for a moment.

Regards,
Christian.

Quoted 9 lines

/Monk

-----Original Message-----
From: Koenig, Christian
Sent: Thursday, May 9, 2019 7:45 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

Quoted 9 lines

Well putting the other drivers aside for moment, I would also say that it is bad design to not restart the timeout. So even then I would not review that patch.

Question is rather what are you actually trying to do and why don't you want to change your design?

Designs should be discussed on the public mailing list and not done internally.

Regards,
Christian.

_______________________________________________
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): 4014f9b8-bfd8-36be-b26e-07fb80682501-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author
#27 lore raw

Hi Christian

Quoted 1 line
Quoted 1 line

Well exactly that's what I disagree on. A second timeout on the same job is perfectly possible and desired, we just don't need to necessarily report it once more

It is not a second timeout on the same job...if you disable gpu_recovery it is endless report on the same job ... you sure you need that ?

Quoted 1 line
Quoted 1 line

But the general problem here is that you are quite often coming up with individual patches ripped out of the context without explaining the general intention.

I don't like explain the work style here but looks it is needed as you complained that:
1) if I open the discussion in public and explain the general intention I'm afraid the schedule will not be satisfied, a customer feature/requirement is not like our daily maintain that you can discuss before you action, usually customer only want a prototype (although it may not perfect) first, and there are more time left for us to improve it later.

2) this endless reporting on the same job looks a general flaw to me (well I won't call it bug since from gpu-scheduler perspective it is not required that all vendor's callback of job_timout() will rearm the TIMER, so I agree that restart the TIMER in scheduler is the only option *if* don't change other vendor's code), the better design should something like optionally do the rearm in scheduler part according to the return value from job_timeout, ( 0 means need scheduler do rearm, other means not need)

Quoted 1 line
Quoted 1 line
Quoted 1 line

That is a rather bad idea because it doesn't handle killed daemon processes correctly. A better approach is let the daemon open up the virtual file and keep the connection open until the process exits.

UMD team has an existence daemon, their prototype is already made on signal mechanism, I prefer compatible with their way first and if I cannot fix the issue you mentioned then I can switch to another way later. But I don't see it’s a problem for a prototype rightnow.

Quoted 1 line
Quoted 1 line
Quoted 1 line

But that's not because of the scheduler but rather because your design is missing another important piece: How does the daemon process signals the kernel driver that it is done with dumping the state? E.g. How do you signal the GIM that it can do a FLR again somehow?

When the daemon finishes its dumping it can simply write something to a debugfs and before that kernel driver will keep blocking the recover routine, as well as the FLR on GIM side... Once receive the debugfs from that daemon, kernel driver can release GIM to do FLR, and continue its gpu recovery routine

With a second thought, I think I don't need to fix that endless report actually, I can insert above logic in the gpu_recover() routine, before pre_asic_reset(), thus it only dump once per hang. And if "gpu_recover=0" no dump will do so that endless reporting won't bother me ...

BTW:
We can check "sched_job.id" to judge if the upcoming timeout reporting is a repeated one and skip the waring string if it is repeated, I hat my DMESG all flushed by those identical warning all my screen ....

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 9:26 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Am 09.05.19 um 14:49 schrieb Liu, Monk:

Quoted 3 lines

Christian

I believe even yourself would agree that keep reporting TMO for the same IB is ugly (need put a "gpu_recovery=0" as option ), I can also argue with you that this is a bad design ...

Well exactly that's what I disagree on. A second timeout on the same job is perfectly possible and desired, we just don't need to necessarily report it once more.

Quoted 5 lines

Besides you didn't on technique persuade me to believe there will be bad things upcoming with my patch, you even didn't give me a sequence to prove my patch is wrong.

Since you are the maintainer I would have no choice but keep my patch the customer branch given the case you won't review it, it's only used for AMDGPU virtualization customer anyway

Well, I didn't say your patch is wrong. A NAK doesn't mean general rejection, but that you should start from the beginning and reiterate what you are trying to archive here. I mean what does a computer do when it receives the NAK? It retries the transmission.

But the general problem here is that you are quite often coming up with individual patches ripped out of the context without explaining the general intention.

Quoted 4 lines

For the design of that feature, your feedback is welcomed:

Backgrounds:
Customer want sw and hw related information (pretty much infos we can collect by UMR) automatically dumped upon Any IB hang.

Yeah, in general that is a really good idea and discussed multiple times now.

Quoted 6 lines

Design:
- there would be an APP running in background as a daemon utility
- in the beginning of this daemon it would write "register" to a debugfs file like : /sys/kernel/debug/dri/0/amdgpu_dump_register
- kernel driver would remember the PID/task of this daemon upon it write "register" to that debugfs file

That is a rather bad idea because it doesn't handle killed daemon processes correctly. A better approach is let the daemon open up the virtual file and keep the connection open until the process exits.

Quoted 5 lines

- since GIM driver would also detect GPU hang (which lead to a VF FLR), kernel driver should interacted with GIM to block GIM's FLR until the DUMP finished by that daemon.
- upon an IB hang, job_timeout() would kick off and inside it KMD
would send an signal "USR1" to the registered task,
- upon "USR1" signal received by the daemon app, it would call "UMR"
to dump whatever interested for the offline debugging

Signals are a bad idea for kernel->userspace communication, better use a pipe where data becomes available on a GPU reset.

Quoted 3 lines

With current design if I pass "gpu_recover=0" to KMD there will be infinite job_timeout() triggered for one IB, thus the auto DUMP would also be crazy about its duplication

But that's not because of the scheduler but rather because your design is missing another important piece: How does the daemon process signals the kernel driver that it is done with dumping the state? E.g. How do you signal the GIM that it can do a FLR again somehow?

What you can do is to either block the timeout handler until the userspace process signals that it is done with dumping, or if that's not possible because of locks (etc) you could use the drm_sched_suspend_timeout() and drm_sched_resume_timeout() helpers which allow us to disable the scheduler timeout for a moment.

Regards,
Christian.

Quoted 10 lines

/Monk

-----Original Message-----
From: Koenig, Christian
Sent: Thursday, May 9, 2019 7:45 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

Quoted 9 lines

Well putting the other drivers aside for moment, I would also say that it is bad design to not restart the timeout. So even then I would not review that patch.

Question is rather what are you actually trying to do and why don't you want to change your design?

Designs should be discussed on the public mailing list and not done internally.

Regards,
Christian.

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

author
#28 lore raw
In reply to a message not in the archive

Christian

I think your previous reply > " Well, NAK. We don't need multiple timeout reports, but we really need to restart the timeout counter after handling it." Just looks paradox with what you say now > " ok you don't seem to understand: It is intentional that the same job times out multiple times! So we can't really change anything here."

Can you be specific and let me know what will broken with my patch.

/Monk

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Koenig, Christian
Sent: Thursday, May 9, 2019 6:54 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Hi Monk,

ok you don't seem to understand: It is intentional that the same job times out multiple times! So we can't really change anything here.

What we can do is instead of sending a signal (which is not a good idea from the timeout handler anyway) we can start a background script to do the dumping.

Now when the next timeout happens we double check if the background script is still running and if yes, simply ignore the timeout and wait for the next one.

Christian.

Am 09.05.19 um 12:49 schrieb Liu, Monk:

Quoted 104 lines

Hah ... I see, but my requirement cannot be satisfied with current design:

What I need to do is put a signal arming in job_timeout() to notify a USER SPACE daemon app , which finally leverage "UMR" to DUMP/retrieve sw/hw information related with the TMO/hang as much as possible . To make it straight forward I would signal USR1 to the registered app (the daemon) every time a TMO happens, and this would introduce lot of unnecessary DUMP if this "bug" cannot resolved.

I think keep reporting TMO message for one IB is a "bug" to me even it is not for my above feature...

To address your concern, what about this one:

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
index 1397942..31d99e9 100644
@@ -28,7 +28,7 @@
  #include "amdgpu.h"
  #include "amdgpu_trace.h"
 
-static void amdgpu_job_timedout(struct drm_sched_job *s_job)
+static int amdgpu_job_timedout(struct drm_sched_job *s_job)
  {
         struct amdgpu_ring *ring = to_amdgpu_ring(s_job->sched);
         struct amdgpu_job *job = to_amdgpu_job(s_job); @@ -39,7 +39,7 

@@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)

         if (amdgpu_ring_soft_recovery(ring, job->vmid, s_job->s_fence->parent)) {
                 DRM_ERROR("ring %s timeout, but soft recovered\n",
                           s_job->sched->name);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -2
-               return;
+               return -ENODEV;
         }
 
         amdgpu_vm_get_task_info(ring->adev, job->pasid, &ti); @@ 
-51,6 +51,8 @@ static void amdgpu_job_timedout(struct drm_sched_job 

*s_job)

         if (amdgpu_device_should_recover_gpu(ring->adev))
                 amdgpu_device_gpu_recover(ring->adev, job);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
+
+       return 0;
  }
 
  int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs, 
drivers/gpu/drm/scheduler/sched_main.c +11 -6
index c1aaf85..b93deb1 100644
@@ -308,18 +308,23 @@ static void drm_sched_job_timedout(struct work_struct *work)
  {
         struct drm_gpu_scheduler *sched;
         struct drm_sched_job *job;
-       unsigned long flags;
+       int ret;
 
         sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
         job = list_first_entry_or_null(&sched->ring_mirror_list,
                                        struct drm_sched_job, node);
 
-       if (job)
-               job->sched->ops->timedout_job(job);
+       if (job) {
+               ret = job->sched->ops->timedout_job(job);
+               if (ret) {
+                       unsigned long flags;
 
-       spin_lock_irqsave(&sched->job_list_lock, flags);
-       drm_sched_start_timeout(sched);
-       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+                       /* means recovered, restart timer now */
+                       spin_lock_irqsave(&sched->job_list_lock, flags);
+                       drm_sched_start_timeout(sched);
+                       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+               }
+       }
  }
 
   /**
include/drm/gpu_scheduler.h +1 -2
index 9c2a957..c3884c3 100644
--- a/include/drm/gpu_scheduler.h
@@ -229,7 +229,7 @@ struct drm_sched_backend_ops {
           * @timedout_job: Called when a job has taken too long to execute,
           * to trigger GPU recovery.
          */
-       void (*timedout_job)(struct drm_sched_job *sched_job);
+       int (*timedout_job)(struct drm_sched_job *sched_job);
 
         /**
           * @free_job: Called once the job's finished fence has been 

signaled
(END)

Thanks
/Monk
-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 6:30 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Quoted 66 lines

drm_sched_start() is not necessary called from the timeout handler.

If a soft recovery is sufficient, we just continue without a complete reset.

Christian.

Am 09.05.19 um 12:25 schrieb Liu, Monk:

Quoted 59 lines

Christian

Check "drm_sched_start" which is invoked from gpu_recover() , there is a "drm_sched_start_timeout()" in the tail

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 3:18 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Am 09.05.19 um 06:31 schrieb Monk Liu:

Quoted 2 lines

we don't need duplicated IB's timeout error message reported endlessly, just one report per timedout IB is enough

Well, NAK. We don't need multiple timeout reports, but we really need to restart the timeout counter after handling it.

Otherwise we will never run into a timeout again after handling one and it isn't unlikely that multiple IBs in a row doesn't work correctly.

Christian.

Quoted 29 lines
---
    drivers/gpu/drm/scheduler/sched_main.c | 5 -----
    1 file changed, 5 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -5
index c1aaf85..d6c17f1 100644
@@ -308,7 +308,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
    {
        struct drm_gpu_scheduler *sched;
        struct drm_sched_job *job;
-     unsigned long flags;
 
        sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
        job = list_first_entry_or_null(&sched->ring_mirror_list,
@@ -316,10 +315,6 @@ static void drm_sched_job_timedout(struct 
 work_struct *work)
 
        if (job)
                job->sched->ops->timedout_job(job);
-
-     spin_lock_irqsave(&sched->job_list_lock, flags);
-     drm_sched_start_timeout(sched);
-     spin_unlock_irqrestore(&sched->job_list_lock, flags);
    }
 
Quoted 1 line
     /**

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

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
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): BYAPR12MB3301A80100FE302B3C263B6684330-ZGDeBxoHBPmRc1D8ZEEGsgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#30 lore raw

Sorry for the confusion.

What I wanted to say is that we don't necessary need to report the same job twice in the logs.

But as long as the job is still running on the hardware we should also keep the timeout running as well.

Christian.

Am 09.05.19 um 13:06 schrieb Liu, Monk:

Quoted 198 lines

Christian

I think your previous reply > " Well, NAK. We don't need multiple timeout reports, but we really need to restart the timeout counter after handling it." Just looks paradox with what you say now > " ok you don't seem to understand: It is intentional that the same job times out multiple times! So we can't really change anything here."

Can you be specific and let me know what will broken with my patch.

/Monk

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Koenig, Christian
Sent: Thursday, May 9, 2019 6:54 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Hi Monk,

ok you don't seem to understand: It is intentional that the same job times out multiple times! So we can't really change anything here.

What we can do is instead of sending a signal (which is not a good idea from the timeout handler anyway) we can start a background script to do the dumping.

Now when the next timeout happens we double check if the background script is still running and if yes, simply ignore the timeout and wait for the next one.

Christian.

Am 09.05.19 um 12:49 schrieb Liu, Monk:

Quoted 104 lines

Hah ... I see, but my requirement cannot be satisfied with current design:

What I need to do is put a signal arming in job_timeout() to notify a USER SPACE daemon app , which finally leverage "UMR" to DUMP/retrieve sw/hw information related with the TMO/hang as much as possible . To make it straight forward I would signal USR1 to the registered app (the daemon) every time a TMO happens, and this would introduce lot of unnecessary DUMP if this "bug" cannot resolved.

I think keep reporting TMO message for one IB is a "bug" to me even it is not for my above feature...

To address your concern, what about this one:

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
index 1397942..31d99e9 100644
@@ -28,7 +28,7 @@
   #include "amdgpu.h"
   #include "amdgpu_trace.h"
 
-static void amdgpu_job_timedout(struct drm_sched_job *s_job)
+static int amdgpu_job_timedout(struct drm_sched_job *s_job)
   {
          struct amdgpu_ring *ring = to_amdgpu_ring(s_job->sched);
          struct amdgpu_job *job = to_amdgpu_job(s_job); @@ -39,7 +39,7

@@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)

          if (amdgpu_ring_soft_recovery(ring, job->vmid, s_job->s_fence->parent)) {
                  DRM_ERROR("ring %s timeout, but soft recovered\n",
                            s_job->sched->name);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -2
-               return;
+               return -ENODEV;
          }
 
          amdgpu_vm_get_task_info(ring->adev, job->pasid, &ti); @@
-51,6 +51,8 @@ static void amdgpu_job_timedout(struct drm_sched_job

*s_job)

          if (amdgpu_device_should_recover_gpu(ring->adev))
                  amdgpu_device_gpu_recover(ring->adev, job);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
+
+       return 0;
   }
 
   int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,
drivers/gpu/drm/scheduler/sched_main.c +11 -6
index c1aaf85..b93deb1 100644
@@ -308,18 +308,23 @@ static void drm_sched_job_timedout(struct work_struct *work)
   {
          struct drm_gpu_scheduler *sched;
          struct drm_sched_job *job;
-       unsigned long flags;
+       int ret;
 
          sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
          job = list_first_entry_or_null(&sched->ring_mirror_list,
                                         struct drm_sched_job, node);
 
-       if (job)
-               job->sched->ops->timedout_job(job);
+       if (job) {
+               ret = job->sched->ops->timedout_job(job);
+               if (ret) {
+                       unsigned long flags;
 
-       spin_lock_irqsave(&sched->job_list_lock, flags);
-       drm_sched_start_timeout(sched);
-       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+                       /* means recovered, restart timer now */
+                       spin_lock_irqsave(&sched->job_list_lock, flags);
+                       drm_sched_start_timeout(sched);
+                       spin_unlock_irqrestore(&sched->job_list_lock, flags);
+               }
+       }
   }
 
    /**
include/drm/gpu_scheduler.h +1 -2
index 9c2a957..c3884c3 100644
--- a/include/drm/gpu_scheduler.h
@@ -229,7 +229,7 @@ struct drm_sched_backend_ops {
            * @timedout_job: Called when a job has taken too long to execute,
            * to trigger GPU recovery.
           */
-       void (*timedout_job)(struct drm_sched_job *sched_job);
+       int (*timedout_job)(struct drm_sched_job *sched_job);
 
          /**
            * @free_job: Called once the job's finished fence has been

signaled
(END)

Thanks
/Monk
-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 6:30 PM
To: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Quoted 66 lines

drm_sched_start() is not necessary called from the timeout handler.

If a soft recovery is sufficient, we just continue without a complete reset.

Christian.

Am 09.05.19 um 12:25 schrieb Liu, Monk:

Quoted 59 lines

Christian

Check "drm_sched_start" which is invoked from gpu_recover() , there is a "drm_sched_start_timeout()" in the tail

/Monk

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, May 9, 2019 3:18 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/sched: fix the duplicated TMO message for one IB

[CAUTION: External Email]

Am 09.05.19 um 06:31 schrieb Monk Liu:

Quoted 2 lines

we don't need duplicated IB's timeout error message reported endlessly, just one report per timedout IB is enough

Well, NAK. We don't need multiple timeout reports, but we really need to restart the timeout counter after handling it.

Otherwise we will never run into a timeout again after handling one and it isn't unlikely that multiple IBs in a row doesn't work correctly.

Christian.

Quoted 29 lines
---
     drivers/gpu/drm/scheduler/sched_main.c | 5 -----
     1 file changed, 5 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +0 -5
index c1aaf85..d6c17f1 100644
@@ -308,7 +308,6 @@ static void drm_sched_job_timedout(struct work_struct *work)
     {
         struct drm_gpu_scheduler *sched;
         struct drm_sched_job *job;
-     unsigned long flags;
 
         sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
         job = list_first_entry_or_null(&sched->ring_mirror_list,
@@ -316,10 +315,6 @@ static void drm_sched_job_timedout(struct
 work_struct *work)
 
         if (job)
                 job->sched->ops->timedout_job(job);
-
-     spin_lock_irqsave(&sched->job_list_lock, flags);
-     drm_sched_start_timeout(sched);
-     spin_unlock_irqrestore(&sched->job_list_lock, flags);
     }
 
Quoted 1 line
      /**

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

Quoted 4 lines

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

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