[PATCH 1/2] drm/amdgpu: use a dummy owner for sysfs triggered cleaner shaders

Christian König ckoenig.leichtzumerken at gmail.com
Tue Apr 1 11:09:23 UTC 2025


Am 01.04.25 um 12:32 schrieb SRINIVASAN SHANMUGAM:
> On 3/31/2025 6:31 PM, Christian König wrote:
>> Otherwise triggering sysfs multiple times without other submissions in
>> between only runs the shader once.
>>
>> Signed-off-by: Christian König <christian.koenig at amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 7 ++++---
>>   1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
>> index f64675b2ab75..9d81eeef61e8 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
>> @@ -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);
>
> 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?

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.

>
> Best regards,
> Srini
>
>>       if (r)
>>           goto err;
>>   



More information about the amd-gfx mailing list