drm: add a flag to indicate job is resubmitted
Subsystems (4)
PATCH 1/2 drm: add a flag to indicate job is resubmitted
Add a flag in drm_sched_job to indicate the job resubmit.
--- drivers/gpu/drm/scheduler/sched_main.c | 2 ++ include/drm/gpu_scheduler.h | 2 ++ 2 files changed, 4 insertions(+)
drivers/gpu/drm/scheduler/sched_main.c +2 -0
@@ -517,6 +517,7 @@ void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched)if (found_guilty && s_job->s_fence->scheduled.context == guilty_context)dma_fence_set_error (&s_fence->finished, -ECANCELED ); + s_job->flags |=DRM_FLAG_RESUBMIT_JOB ;dma_fence_put (s_job->s_fence->parent); fence = sched->ops->run_job (s_job);
@@ -565,6 +566,7 @@ int drm_sched_job_init(struct drm_sched_job *job,if (!job->s_fence)return -ENOMEM ; job->id =atomic64_inc_return (&sched->job_id_count); + job->flags =0 ;INIT_LIST_HEAD (&job->node);
include/drm/gpu_scheduler.h +2 -0
@@ -29,6 +29,7 @@#include <linux/completion.h> #define MAX_WAIT_SCHED_ENTITY_Q_EMPTY msecs_to_jiffies(1000) +#define DRM_FLAG_RESUBMIT_JOB (1 << 0)struct drm_gpu_scheduler ;struct drm_sched_rq ;
@@ -198,6 +199,7 @@ struct drm_sched_job {enum drm_sched_priority s_priority;struct drm_sched_entity *entity;struct dma_fence_cb cb; +uint32_t flags; }; static inline bool drm_sched_invalidate_job(struct drm_sched_job *s_job,
Signature · 6 lines
2.25.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/2 drm/amd/amdgpu: force flush resubmit job
[Why]
when a job is scheduled during TDR(after device reset count increase and before drm_sched_stop), this job won't do vm_flush when resubmit itself after GPU reset done. This can lead to a page fault.
[How]
Always do vm_flush for resubmit job.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -1
@@ -1088,7 +1088,8 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,if (update_spm_vmid_needed && adev->gfx.rlc.funcs->update_spm_vmid) adev->gfx.rlc.funcs->update_spm_vmid (adev, job->vmid); -if (amdgpu_vmid_had_gpu_reset (adev, id)) { +if (amdgpu_vmid_had_gpu_reset (adev, id) || + (job->base.flags &DRM_FLAG_RESUBMIT_JOB )) { gds_switch_needed = true; vm_flush_needed = true; pasid_mapping_needed = true;
Signature · 6 lines
2.25.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/2] drm/amd/amdgpu: force flush resubmit job
Am 25.02.21 um 06:27 schrieb Jingwen Chen:
Quoted 8 lines
[Why]
when a job is scheduled duringTDR(after device reset count increase and before drm_sched_stop), this job won't dovm_flushwhen resubmit itself after GPU reset done. This can lead to a page fault.[How]
Always dovm_flushfor resubmit job.
NAK, what do you think amdgpu_vmid_had_gpu_reset already does?
Christian.
Quoted 11 lines
Signed-off-by Jingwen Chen <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, · line 1095
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1@@ -1088,7 +1088,8 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,if (update_spm_vmid_needed && adev->gfx.rlc.funcs->update_spm_vmid) adev->gfx.rlc.funcs->update_spm_vmid (adev, job->vmid); -if (amdgpu_vmid_had_gpu_reset (adev, id)) { +if (amdgpu_vmid_had_gpu_reset (adev, id) || + (job->base.flags &DRM_FLAG_RESUBMIT_JOB )) { gds_switch_needed = true; vm_flush_needed = true; pasid_mapping_needed = true;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Chen, JingWen
NAKRE: [PATCH 2/2] drm/amd/amdgpu: force flush resubmit job
[AMD Official Use Only - Internal Distribution Only]
Consider this sequence:
1. GPU reset begin
2. device reset count + 1
3. job id 1 scheduled with vm_need_flush=false
4. When handling this job in vm_flush, amdgpu_vmid_had_gpu_reset will return true, thus this job will be flush and the vmid_reset_count will be set equals to device_reset_count
5. stop drm scheduler
6. GPU do real reset
7. resubmit job id 1 with vm_need_flush=false
8. Job id 1 is the first job to resubmit after reset. This time amdgpu_vmid_had_gpu_reset returns false and the vm_need_flush==false
Then no one will flush pd_addr and vmid for jobs after resubmit. In this sequence amdgpu_vmid_had_gpu_reset doesn't work.
Best Regards,
JingWen Chen
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Thursday, February 25, 2021 3:46 PM
To: Chen, JingWen <[email protected]>; [email protected]
Cc: Liu, Monk <[email protected]>
Subject: Re: [PATCH 2/2] drm/amd/amdgpu: force flush resubmit job
Am 25.02.21 um 06:27 schrieb Jingwen Chen:
Quoted 7 lines
[Why]
when a job is scheduled duringTDR(after device reset count increase and before drm_sched_stop), this job won't dovm_flushwhen resubmit itself after GPU reset done. This can lead to a page fault.[How]
Always dovm_flushfor resubmit job.
NAK, what do you think amdgpu_vmid_had_gpu_reset already does?
Christian.
Quoted 12 lines
Signed-off-by Jingwen Chen <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, · line 1095
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1@@ -1088,7 +1088,8 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,if (update_spm_vmid_needed && adev->gfx.rlc.funcs->update_spm_vmid) adev->gfx.rlc.funcs->update_spm_vmid (adev, job->vmid); -if (amdgpu_vmid_had_gpu_reset (adev, id)) { +if (amdgpu_vmid_had_gpu_reset (adev, id)|| +(job->base.flags &DRM_FLAG_RESUBMIT_JOB )) { gds_switch_needed = true; vm_flush_needed = true; pasid_mapping_needed = true;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerRe: [PATCH 2/2] drm/amd/amdgpu: force flush resubmit job
Good catch, but the approach for the fix is incorrect.
The device reset count can only be incremented after taking the reset lock and stopping the scheduler, otherwise a whole bunch of different race conditions can happen.
Christian.
Am 25.02.21 um 08:56 schrieb Chen, JingWen:
Quoted 53 lines
[AMD Official Use Only - Internal Distribution Only]
Consider this sequence:
1. GPU reset begin
2. device reset count + 1
3. job id 1 scheduled with vm_need_flush=false
4. When handling this job invm_flush,amdgpu_vmid_had_gpu_resetwill return true, thus this job will be flush and thevmid_reset_countwill be set equals todevice_reset_count
5. stop drm scheduler
6. GPU do real reset
7. resubmit job id 1 with vm_need_flush=false
8. Job id 1 is the first job to resubmit after reset. This timeamdgpu_vmid_had_gpu_resetreturns false and the vm_need_flush==falseThen no one will flush
pd_addrand vmid for jobs after resubmit. In this sequenceamdgpu_vmid_had_gpu_resetdoesn't work.Best Regards,
JingWen Chen-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Thursday, February 25, 2021 3:46 PM
To: Chen, JingWen <[email protected]>; [email protected]
Cc: Liu, Monk <[email protected]>
Subject: Re: [PATCH 2/2] drm/amd/amdgpu: force flush resubmit jobAm 25.02.21 um 06:27 schrieb Jingwen Chen:
Quoted 7 lines
[Why]
when a job is scheduled duringTDR(after device reset count increase and before drm_sched_stop), this job won't dovm_flushwhen resubmit itself after GPU reset done. This can lead to a page fault.[How]
Always dovm_flushfor resubmit job.NAK, what do you think
amdgpu_vmid_had_gpu_resetalready does?Christian.
Quoted 14 lines
Signed-off-by Jingwen Chen <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -1088,7 +1088,8 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,if (update_spm_vmid_needed && adev->gfx.rlc.funcs->update_spm_vmid) adev->gfx.rlc.funcs->update_spm_vmid (adev, job->vmid);
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, · line 1095
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1-if (amdgpu_vmid_had_gpu_reset (adev, id)) { +if (amdgpu_vmid_had_gpu_reset (adev, id)|| +(job->base.flags &DRM_FLAG_RESUBMIT_JOB )) { gds_switch_needed = true; vm_flush_needed = true; pasid_mapping_needed = true;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 2/2] drm/amd/amdgpu: force flush resubmit job
[AMD Official Use Only - Internal Distribution Only]
Yeah, that sounds better than original fix
Thanks Christian
------------------------------------------
Monk Liu | Cloud-GPU Core team
------------------------------------------
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Thursday, February 25, 2021 4:08 PM
To: Chen, JingWen <[email protected]>; [email protected]
Cc: Liu, Monk <[email protected]>
Subject: Re: [PATCH 2/2] drm/amd/amdgpu: force flush resubmit job
Good catch, but the approach for the fix is incorrect.
The device reset count can only be incremented after taking the reset lock and stopping the scheduler, otherwise a whole bunch of different race conditions can happen.
Christian.
Am 25.02.21 um 08:56 schrieb Chen, JingWen:
Quoted 55 lines
[AMD Official Use Only - Internal Distribution Only]
Consider this sequence:
1. GPU reset begin
2. device reset count + 1
3. job id 1 scheduled with vm_need_flush=false 4. When handling this job invm_flush,amdgpu_vmid_had_gpu_resetwill return true, thus this job will be flush and thevmid_reset_countwill be set equals todevice_reset_count5. stop drm scheduler 6. GPU do real reset 7. resubmit job id 1 with vm_need_flush=false 8. Job id 1 is the first job to resubmit after reset. This timeamdgpu_vmid_had_gpu_resetreturns false and the vm_need_flush==falseThen no one will flush
pd_addrand vmid for jobs after resubmit. In this sequenceamdgpu_vmid_had_gpu_resetdoesn't work.Best Regards,
JingWen Chen-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Thursday, February 25, 2021 3:46 PM
To: Chen, JingWen <[email protected]>; [email protected]
Cc: Liu, Monk <[email protected]>
Subject: Re: [PATCH 2/2] drm/amd/amdgpu: force flush resubmit jobAm 25.02.21 um 06:27 schrieb Jingwen Chen:
Quoted 7 lines
[Why]
when a job is scheduled duringTDR(after device reset count increase and before drm_sched_stop), this job won't dovm_flushwhen resubmit itself after GPU reset done. This can lead to a page fault.[How]
Always dovm_flushfor resubmit job.NAK, what do you think
amdgpu_vmid_had_gpu_resetalready does?Christian.
Quoted 14 lines
Signed-off-by Jingwen Chen <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -1088,7 +1088,8 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,if (update_spm_vmid_needed && adev->gfx.rlc.funcs->update_spm_vmid) adev->gfx.rlc.funcs->update_spm_vmid (adev, job->vmid);
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, · line 1095
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1-if (amdgpu_vmid_had_gpu_reset (adev, id)) { +if (amdgpu_vmid_had_gpu_reset (adev, id)|| (job->base.flags & +DRM_FLAG_RESUBMIT_JOB )) { gds_switch_needed = true; vm_flush_needed = true; pasid_mapping_needed = true;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
[AMD Official Use Only - Internal Distribution Only]
Patches are fine by me, reviewed by: Monk Liu <[email protected]>
Still need Christian to take a look
Thanks
------------------------------------------
Monk Liu | Cloud-GPU Core team
------------------------------------------
-----Original Message-----
From: Jingwen Chen <[email protected]>
Sent: Thursday, February 25, 2021 1:27 PM
To: [email protected]
Cc: Liu, Monk <[email protected]>; Koenig, Christian <[email protected]>; Chen, JingWen <[email protected]>
Subject: [PATCH 1/2] drm: add a flag to indicate job is resubmitted
Add a flag in drm_sched_job to indicate the job resubmit.
--- drivers/gpu/drm/scheduler/sched_main.c | 2 ++ include/drm/gpu_scheduler.h | 2 ++ 2 files changed, 4 insertions(+)
drivers/gpu/drm/scheduler/sched_main.c +2 -0
@@ -517,6 +517,7 @@ void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched)if (found_guilty && s_job->s_fence->scheduled.context == guilty_context)dma_fence_set_error (&s_fence->finished, -ECANCELED ); + s_job->flags |=DRM_FLAG_RESUBMIT_JOB ;dma_fence_put (s_job->s_fence->parent); fence = sched->ops->run_job (s_job);
@@ -565,6 +566,7 @@ int drm_sched_job_init(struct drm_sched_job *job,if (!job->s_fence)return -ENOMEM ; job->id =atomic64_inc_return (&sched->job_id_count); + job->flags =0 ;INIT_LIST_HEAD (&job->node);
include/drm/gpu_scheduler.h +2 -0
@@ -29,6 +29,7 @@#include <linux/completion.h> #define MAX_WAIT_SCHED_ENTITY_Q_EMPTY msecs_to_jiffies(1000) +#define DRM_FLAG_RESUBMIT_JOB (1 << 0)struct drm_gpu_scheduler ;struct drm_sched_rq ;
@@ -198,6 +199,7 @@ struct drm_sched_job {enum drm_sched_priority s_priority;struct drm_sched_entity *entity;struct dma_fence_cb cb; +uint32_t flags; }; static inline bool drm_sched_invalidate_job(struct drm_sched_job *s_job,
--
2.25.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx