All of lore.kernel.org
 help / color / mirror / Atom feed
From: SRINIVASAN SHANMUGAM <srinivasan.shanmugam@amd.com>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>,
	amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/amdgpu: use a dummy owner for sysfs triggered cleaner shaders v2
Date: Thu, 3 Apr 2025 19:26:48 +0530	[thread overview]
Message-ID: <5ee1c26a-2b9c-4527-a6ad-e344f1ef5b32@amd.com> (raw)
In-Reply-To: <fa41a078-c0ba-4e32-8580-13130d3b33f7@gmail.com>


On 4/3/2025 2:40 PM, Christian König wrote:
> Am 03.04.25 um 05:15 schrieb SRINIVASAN SHANMUGAM:
>> On 4/2/2025 7:32 PM, Christian König wrote:
>>> Otherwise triggering sysfs multiple times without other submissions in
>>> between only runs the shader once.
>>>
>>> v2: add some comment
>>>
>>> Signed-off-by: Christian König <christian.koenig@amd.com>
>>> ---
>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 14 +++++++++++---
>>>    1 file changed, 11 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..9a24be43e035 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
>>> @@ -1439,9 +1439,11 @@ 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;
>>> +    void * owner;
>>>        int i, r;
>>>          /* Initialize the scheduler entity */
>>> @@ -1452,9 +1454,15 @@ 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);
>>> +    /*
>>> +     * Use some unique dummy value as the owner to make sure we execute
>>> +     * the cleaner shader on each submission. The value just need to change
>>> +     * for each submission and is otherwise meaningless.
>>> +     */
>>> +    owner = (unsigned long)atomic_inc_return(&counter),
>> Should this "atomic_inc_return()" needs to be casted to (void*), as it is return type is int?
> No, I had that in the first version of the patch but it's actually sufficient to cast it to a long (which has the same number of bits as void*).
Thus, the use of a static atomic counter allows the driver to pass a 
unique identifier (owner) to each job that triggers the cleaner shader. 
This approach is crucial because it avoids the potential problem of 
running the shader multiple times without other submissions in between 
(since each run requires this unique submission context).

With that casting fixed, this patch is:

Reviewed-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
>
> Regards,
> Christian.
>
>> Regards,
>> Srini
>>
>>> +
>>> +    r = amdgpu_job_alloc_with_ib(ring->adev, &entity, owner,
>>> +                     64, 0, &job);
>>>        if (r)
>>>            goto err;
>>>    

      reply	other threads:[~2025-04-03 13:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-02 14:02 [PATCH 1/2] drm/amdgpu: use a dummy owner for sysfs triggered cleaner shaders v2 Christian König
2025-04-02 14:02 ` [PATCH 2/2] drm/amdgpu: cleanup amdgpu_vm_flush v2 Christian König
2025-04-04  5:15   ` SRINIVASAN SHANMUGAM
2025-04-03  3:15 ` [PATCH 1/2] drm/amdgpu: use a dummy owner for sysfs triggered cleaner shaders v2 SRINIVASAN SHANMUGAM
2025-04-03  9:10   ` Christian König
2025-04-03 13:56     ` SRINIVASAN SHANMUGAM [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5ee1c26a-2b9c-4527-a6ad-e344f1ef5b32@amd.com \
    --to=srinivasan.shanmugam@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=ckoenig.leichtzumerken@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.