drm/amdgpu: use a dummy owner for sysfs triggered cleaner shaders
Subsystems (2)
PATCH 1/2 drm/amdgpu: use a dummy owner for sysfs triggered cleaner shaders
Otherwise triggering sysfs multiple times without other submissions in between only runs the shader once.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +4 -3
@@ -1439,6 +1439,7 @@ static int amdgpu_gfx_run_cleaner_shader_job(struct amdgpu_ring *ring)struct amdgpu_device *adev = ring->adev;struct drm_gpu_scheduler *sched = &ring->sched;struct drm_sched_entity entity; +static atomic_t counter;struct dma_fence *f;struct amdgpu_job *job;struct amdgpu_ib *ib;
@@ -1452,9 +1453,9 @@ static int amdgpu_gfx_run_cleaner_shader_job(struct amdgpu_ring *ring) goto err; } - r =amdgpu_job_alloc_with_ib (ring->adev, &entity,NULL , -64 ,0 , - &job); + r =amdgpu_job_alloc_with_ib (ring->adev, &entity, + (void *)(long )atomic_inc_return (&counter), +64 ,0 , &job);if (r) goto err;
Signature · 1 line
2.34.1
PATCH 2/2 drm/amdgpu: revert "always sync the GFX pipe on ctx switch"
This reverts commit c2cc3648ba517a6c270500b5447d5a1efdad5936.
Turned out that this has some negative consequences for some workloads. Instead check if the cleaner shader should run directly.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +2 -2
@@ -191,8 +191,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, need_ctx_switch = ring->current_ctx != fence_ctx;if (ring->funcs->emit_pipeline_sync && job && ((tmp =amdgpu_sync_get_fence (&job->explicit_sync)) || - need_ctx_switch ||amdgpu_vm_need_pipeline_sync (ring, job))) { - + (amdgpu_sriov_vf (adev) && need_ctx_switch) || +amdgpu_vm_need_pipeline_sync (ring, job))) { need_pipe_sync = true;if (tmp)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
@@ -689,7 +689,7 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, patch =amdgpu_ring_init_cond_exec (ring, ring->cond_exe_gpu_addr); -if (need_pipe_sync) +if (need_pipe_sync || cleaner_shader_needed)amdgpu_ring_emit_pipeline_sync (ring);if (cleaner_shader_needed)
Signature · 1 line
2.34.1
Re: [PATCH 2/2] drm/amdgpu: revert "always sync the GFX pipe on ctx switch"
Quoted 16 lines · Christian König
This reverts commit
c2cc3648ba517a6c270500b5447d5a1efdad5936.Turned out that this has some negative consequences for some workloads. Instead check if the cleaner shader should run directly.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, · line 194
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +1
-2@@ -191,8 +191,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, need_ctx_switch = ring->current_ctx != fence_ctx; if (ring->funcs->emit_pipeline_sync && job && ((tmp = amdgpu_sync_get_fence(&job->explicit_sync)) || - need_ctx_switch ||amdgpu_vm_need_pipeline_sync (ring, job))) { - + (amdgpu_sriov_vf(adev) && need_ctx_switch) ||
Should we need to, do this context switch, only on SRIOV cases "amdgpu_sriov_vf(adev)" or even in normal BM use cases also?
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, · line 198
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +1
-0+ amdgpu_vm_need_pipeline_sync(ring, job))) { need_pipe_sync = true;if (tmp)
If yes, could we split this patch into two 1. Actuall revert 2. below part is new changes?
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, · line 692
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-1@@ -689,7 +689,7 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, patch =amdgpu_ring_init_cond_exec (ring, ring->cond_exe_gpu_addr); -if (need_pipe_sync) +if (need_pipe_sync || cleaner_shader_needed)
Here now, this pipe line synchronization was usually meant for GPU jobs? and not for client level switching? may I kno please, why it was OR'ed for even "cleaner_shader_needed"? Is that do we have any usecases like where we don't need pipeline sync in between jobs but we need to emit pipeline sync only when "cleaner_shader_needed" (ie., wrt new enforce_isolation feature)? - but even though in this "new_enforce_isolation feature" case - we would be skipping the GPU jobs level pipe line synchronization within a client? and do we forsee any synchronization/disruption issues in between jobs within a same client wrt new enforce_ioslation feature?
Best regards,
Srini
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0amdgpu_ring_emit_pipeline_sync (ring);if (cleaner_shader_needed)
Re: [PATCH 2/2] drm/amdgpu: revert "always sync the GFX pipe on ctx switch"
Am 01.04.25 um 12:50 schrieb SRINIVASAN SHANMUGAM:
Quoted 25 lines · Christian König
Quoted 17 lines
This reverts commit
c2cc3648ba517a6c270500b5447d5a1efdad5936.Turned out that this has some negative consequences for some workloads. Instead check if the cleaner shader should run directly.
Signed-off-by Christian König <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c| 4 ++--
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c| 2 +-2 files changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0@@ -191,8 +191,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, need_ctx_switch = ring->current_ctx != fence_ctx;Quoted 5 lines
if (
ring->funcs->emit_pipeline_sync&& job &&
((tmp =amdgpu_sync_get_fence(&job->explicit_sync)) || -need_ctx_switch||amdgpu_vm_need_pipeline_sync(ring, job))) { -
+ (amdgpu_sriov_vf(adev)&&need_ctx_switch) ||Should we need to, do this context switch, only on SRIOV cases "
amdgpu_sriov_vf(adev)" or even in normal BM use cases also?
Quoted 4 lines
Quoted 3 lines
+
amdgpu_vm_need_pipeline_sync(ring, job))) {need_pipe_sync= true;
if (tmp)If yes, could we split this patch into two 1. Actuall revert 2. below part is new changes?
No, splitting it into two would be incorrect since the two decisions depend on each other.
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, · line 692
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-0@@ -689,7 +689,7 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, patch = amdgpu_ring_init_cond_exec(ring, ring->cond_exe_gpu_addr); - if (need_pipe_sync) + if (need_pipe_sync || cleaner_shader_needed)Here now, this pipe line synchronization was usually meant for GPU jobs? and not for client level switching? may I kno please, why it was OR'ed for even "
cleaner_shader_needed"? Is that do we have any usecases like where we don't need pipeline sync in between jobs but we need to emit pipeline sync only when "cleaner_shader_needed" (ie., wrt newenforce_isolationfeature)? - but even though in this "new_enforce_isolationfeature" case - we would be skipping the GPU jobs level pipe line synchronization within a client? and do we forsee any synchronization/disruption issues in between jobs within a same client wrt newenforce_ioslationfeature?
Pipeline sync means we wait for the pipeline to be idle (except for our self).
This is necessary when one job depends on the results of another one, under SRIOV when switching the ring from one context to another or if the VMID is reused and we have a specific bug in the compute engine.
It is also necessary while we switch GDS, OA or GWS resources or when we want to run the cleaner shader.
I will update the code to make that a bit more easier to understand.
Regards,
Christian.
Quoted 7 lines
Best regards,
Srini
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0amdgpu_ring_emit_pipeline_sync(ring); if (cleaner_shader_needed)
Quoted 21 lines · Christian König
Otherwise triggering sysfs multiple times without other submissions in between only runs the shader once.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-0@@ -1439,6 +1439,7 @@ static int amdgpu_gfx_run_cleaner_shader_job(struct amdgpu_ring *ring)struct amdgpu_device *adev = ring->adev;struct drm_gpu_scheduler *sched = &ring->sched;struct drm_sched_entity entity; +static atomic_t counter;struct dma_fence *f;struct amdgpu_job *job;struct amdgpu_ib *ib;
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c static int amdgpu_gfx_run_cleaner_shader_job(struct amdgpu_ring *ring) · line 1458
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +3
-3@@ -1452,9 +1453,9 @@ static int amdgpu_gfx_run_cleaner_shader_job(struct amdgpu_ring *ring) goto err; } - r =amdgpu_job_alloc_with_ib (ring->adev, &entity,NULL , -64 ,0 , - &job); + r =amdgpu_job_alloc_with_ib (ring->adev, &entity, + (void *)(long )atomic_inc_return (&counter), +64 ,0 , &job);
Hi Christian,
Should we need to implement guards or checks to ensure that the counter does not excessively increment or reach an undesirable state. or resetting of the counter may be necessary?
Best regards,
Srini
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0if (r) goto err;
Am 01.04.25 um 12:32 schrieb SRINIVASAN SHANMUGAM:
Quoted 33 lines · Christian König
Quoted 21 lines
Otherwise triggering sysfs multiple times without other submissions in between only runs the shader once.
Signed-off-by Christian König <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c| 7 ++++---1 file changed, 4 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +1
-0@@ -1439,6 +1439,7 @@ static int amdgpu_gfx_run_cleaner_shader_job(struct amdgpu_ring *ring) struct amdgpu_device *adev = ring->adev; struct drm_gpu_scheduler *sched = &ring->sched; struct drm_sched_entity entity; + static atomic_t counter; struct dma_fence *f; struct amdgpu_job *job; struct amdgpu_ib *ib;drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c static int amdgpu_gfx_run_cleaner_shader_job(struct amdgpu_ring *ring) · line 1458
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +3
-2@@ -1452,9 +1453,9 @@ static int amdgpu_gfx_run_cleaner_shader_job(struct amdgpu_ring *ring) goto err; } - r = amdgpu_job_alloc_with_ib(ring->adev, &entity, NULL, - 64, 0, - &job); + r = amdgpu_job_alloc_with_ib(ring->adev, &entity, + (void *)(long)atomic_inc_return(&counter), + 64, 0, &job);Hi Christian,
Quoted 1 line
Should we need to implement guards or checks to ensure that the counter does not excessively increment or reach an undesirable state. or resetting of the counter may be necessary?
Good that you ask, but no we don't need anything like that.
Basically the owner just need to be unique, e.g. just a large random number would do it as well. And when the atomic wraps around it just goes back to zero again.
But we should probably add a comment to explain that here.
Going to update the patch.
Thanks,
Christian.
Quoted 7 lines
Best regards,
SriniQuoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0
-0if (r) goto err;