Skip to contentSkip to conversation

drm/amdgpu: dont schedule jobs while in reset

PATCH In review S, Shirish 4 participants 5 messages Oct 30, 2019 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

S, Shirish

author
#0 lore raw

PATCH 1/1 drm/amdgpu: dont schedule jobs while in reset

[Why]

doing kthread_park()/unpark() from drm_sched_entity_fini while GPU reset is in progress defeats all the purpose of drm_sched_stop->kthread_park.
If drm_sched_entity_fini->kthread_unpark() happens AFTER drm_sched_stop->kthread_park nothing prevents from another (third) thread to keep submitting job to HW which will be picked up by the unparked scheduler thread and try to submit to HW but fail because the HW ring is deactivated.

[How]
grab the reset lock before calling drm_sched_entity_fini()

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +4 -1
index 6614d8a..2cdaf3b 100644
@@ -604,8 +604,11 @@ void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr)
 			continue;
 		}
 
-		for (i = 0; i < num_entities; i++)
+		for (i = 0; i < num_entities; i++) {
+			mutex_lock(&ctx->adev->lock_reset);
 			drm_sched_entity_fini(&ctx->entities[0][i].entity);
+			mutex_unlock(&ctx->adev->lock_reset);
+		}
 	}
 }
 
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): 1572426811-30618-1-git-send-email-shirish.s-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 30.10.19 um 10:13 schrieb S, Shirish:

Quoted 11 lines

[Why]

doing kthread_park()/unpark() from drm_sched_entity_fini while GPU reset is in progress defeats all the purpose of drm_sched_stop->kthread_park.
If drm_sched_entity_fini->kthread_unpark() happens AFTER drm_sched_stop->kthread_park nothing prevents from another (third) thread to keep submitting job to HW which will be picked up by the unparked scheduler thread and try to submit to HW but fail because the HW ring is deactivated.

Quoted 5 lines

[How]
grab the reset lock before calling drm_sched_entity_fini()

Patch itself is Reviewed-by: Christian König <[email protected]>

Does that also fix the problems you have been seeing?

Thanks,
Christian.

Quoted 11 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +0 -0
index 6614d8a..2cdaf3b 100644
@@ -604,8 +604,11 @@ void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr)
  			continue;
  		}

drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr) · line 614

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +4 -1
 
-		for (i = 0; i < num_entities; i++)
+		for (i = 0; i < num_entities; i++) {
+			mutex_lock(&ctx->adev->lock_reset);
  			drm_sched_entity_fini(&ctx->entities[0][i].entity);
+			mutex_unlock(&ctx->adev->lock_reset);
+		}
  	}
  }
 

_______________________________________________
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): bfefc5cb-c560-868a-7b03-90f4e5118451-5C7GfCeVMHo@public.gmane.org

#4 lore raw
Quoted 12 lines · Christian

Am 30.10.19 um 10:13 schrieb S, Shirish:

Quoted 11 lines

[Why]

doing kthread_park()/unpark() from drm_sched_entity_fini while GPU reset is in progress defeats all the purpose of drm_sched_stop->kthread_park.
If drm_sched_entity_fini->kthread_unpark() happens AFTER drm_sched_stop->kthread_park nothing prevents from another (third) thread to keep submitting job to HW which will be picked up by the unparked scheduler thread and try to submit to HW but fail because the HW ring is deactivated.

Quoted 8 lines
Quoted 5 lines

[How]
grab the reset lock before calling drm_sched_entity_fini()

Patch itself is Reviewed-by: Christian König <[email protected]>

Does that also fix the problems you have been seeing?

Yes Christian.

Regards,

Shirish S

Quoted 25 lines

Thanks,
Christian.

Quoted 21 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 ++++-
   1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +4 -1
index 6614d8a..2cdaf3b 100644
@@ -604,8 +604,11 @@ void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr)
   			continue;
   		}
 
-		for (i = 0; i < num_entities; i++)
+		for (i = 0; i < num_entities; i++) {
+			mutex_lock(&ctx->adev->lock_reset);
   			drm_sched_entity_fini(&ctx->entities[0][i].entity);
+			mutex_unlock(&ctx->adev->lock_reset);
+		}
   	}
   }
 
Signature · 7 lines
Regards,
Shirish S

_______________________________________________
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): 58085e1d-39f4-1907-4495-71a13c52b825-5C7GfCeVMHo@public.gmane.org

#6 lore raw
Quoted 18 lines · Shirish
Quoted 17 lines · Christian

Am 30.10.19 um 10:13 schrieb S, Shirish:

Quoted 16 lines

[Why]

doing kthread_park()/unpark() from drm_sched_entity_fini while GPU reset is in progress defeats all the purpose of drm_sched_stop->kthread_park.
If drm_sched_entity_fini->kthread_unpark() happens AFTER drm_sched_stop->kthread_park nothing prevents from another (third) thread to keep submitting job to HW which will be picked up by the unparked scheduler thread and try to submit to HW but fail because the HW ring is deactivated.

[How]
grab the reset lock before calling drm_sched_entity_fini()

Quoted 8 lines
Quoted 3 lines

Patch itself is Reviewed-by: Christian König <[email protected]>

Does that also fix the problems you have been seeing?

Yes Christian.

Regards,

Shirish S

Missed that one, why don't we fix it within scheduler code - the race is within scheduler ?

Andrey

Quoted 16 lines
Quoted 16 lines

Thanks,
Christian.

Quoted 12 lines
---
    drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 ++++-
    1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +0 -0
index 6614d8a..2cdaf3b 100644
@@ -604,8 +604,11 @@ void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr)
    			continue;
    		}
 
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr) · line 614

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +4 -1
-		for (i = 0; i < num_entities; i++)
+		for (i = 0; i < num_entities; i++) {
+			mutex_lock(&ctx->adev->lock_reset);
    			drm_sched_entity_fini(&ctx->entities[0][i].entity);
+			mutex_unlock(&ctx->adev->lock_reset);
+		}
    	}
    }
 

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

Reviewed-by Andrey Grodzovsky
#7 lore raw
In reply to a message not in the archive

Andrey

Quoted 36 lines · Christian

Am 30.10.19 um 10:13 schrieb S, Shirish:

Quoted 11 lines

[Why]

doing kthread_park()/unpark() from drm_sched_entity_fini while GPU reset is in progress defeats all the purpose of drm_sched_stop->kthread_park.
If drm_sched_entity_fini->kthread_unpark() happens AFTER drm_sched_stop->kthread_park nothing prevents from another (third) thread to keep submitting job to HW which will be picked up by the unparked scheduler thread and try to submit to HW but fail because the HW ring is deactivated.

Quoted 5 lines

[How]
grab the reset lock before calling drm_sched_entity_fini()

Patch itself is Reviewed-by: Christian König <[email protected]>

Does that also fix the problems you have been seeing?

Thanks,
Christian.

Quoted 12 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 5 ++++-
   1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +0 -0
index 6614d8a..2cdaf3b 100644
@@ -604,8 +604,11 @@ void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr)
   			continue;
   		}
 
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr) · line 614

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +4 -1
-		for (i = 0; i < num_entities; i++)
+		for (i = 0; i < num_entities; i++) {
+			mutex_lock(&ctx->adev->lock_reset);
   			drm_sched_entity_fini(&ctx->entities[0][i].entity);
+			mutex_unlock(&ctx->adev->lock_reset);
+		}
   	}
   }
 

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