AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Sharma, Shashank" <shashank.sharma@amd.com>
To: "Christian König" <christian.koenig@amd.com>,
	dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org
Cc: Alex Deucher <alexander.deucher@amd.com>,
	Marek Olsak <marek.olsak@amd.com>,
	Amarnath Somalapuram <amaranath.somalapuram@amd.com>
Subject: Re: [PATCH] amdgpu: add context creation flags in CS IOCTL
Date: Mon, 8 Aug 2022 13:46:25 +0200	[thread overview]
Message-ID: <57c92713-b06a-e68a-9079-72f44c2ca3b9@amd.com> (raw)
In-Reply-To: <acc970f2-632f-0372-8082-6bd54f0c7cf5@amd.com>



On 8/8/2022 12:59 PM, Christian König wrote:
> Am 02.08.22 um 15:55 schrieb Shashank Sharma:
>> This patch adds:
>> - A new input parameter "flags" in the amdgpu_ctx_create2 call.
>> - Some new flags defining workload type hints.
>> - Some change in the caller function of amdgpu_ctx_create2, to
>>    accomodate this new parameter.
>>
>> The idea is to pass the workload hints while context creation,
> 
> Bad idea.
> 
> Please take AMDGPU_CTX_OP_SET_STABLE_PSTATE and 
> AMDGPU_CTX_OP_GET_STABLE_PSTATE as blueprint for this and don't add 
> extra flags to the context creation.
> 
> Regards,
> Christian.

Hey Christian,
Noted, let me have a look at AMDGPU_CTX_OP_GET/SET_STABLE_PSTATE 
implementation.

- Shashank

> 
> 
>>   so
>> that kernel GPU scheduler can pass this information to GPU FW, which in
>> turn can adjust the GPU characterstics as per the workload type.
>>
>> Signed-off-by: Shashank Sharma <shashank.sharma@amd.com>
>> Cc: Alex Deucher <alexander.deucher@amd.com>
>> Cc: Marek Olsak <marek.olsak@amd.com>
>> Cc: Christian Koenig <christian.koenig@amd.com>
>> Cc: Amarnath Somalapuram <amaranath.somalapuram@amd.com>
>> ---
>>   amdgpu/amdgpu.h          |  2 ++
>>   amdgpu/amdgpu_cs.c       |  5 ++++-
>>   include/drm/amdgpu_drm.h | 10 +++++++++-
>>   3 files changed, 15 insertions(+), 2 deletions(-)
>>
>> diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h
>> index b118dd48..1ebb46e6 100644
>> --- a/amdgpu/amdgpu.h
>> +++ b/amdgpu/amdgpu.h
>> @@ -874,6 +874,7 @@ int amdgpu_bo_list_update(amdgpu_bo_list_handle 
>> handle,
>>    *
>>    * \param   dev      - \c [in] Device handle. See 
>> #amdgpu_device_initialize()
>>    * \param   priority - \c [in] Context creation flags. See 
>> AMDGPU_CTX_PRIORITY_*
>> + * \param   flags    - \c [in] Context flags. See AMDGPU_CTX_FLAGS_*
>>    * \param   context  - \c [out] GPU Context handle
>>    *
>>    * \return   0 on success\n
>> @@ -884,6 +885,7 @@ int amdgpu_bo_list_update(amdgpu_bo_list_handle 
>> handle,
>>   */
>>   int amdgpu_cs_ctx_create2(amdgpu_device_handle dev,
>>                uint32_t priority,
>> +             uint32_t flags,
>>                amdgpu_context_handle *context);
>>   /**
>>    * Create GPU execution Context
>> diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
>> index fad484bf..d4723ea5 100644
>> --- a/amdgpu/amdgpu_cs.c
>> +++ b/amdgpu/amdgpu_cs.c
>> @@ -44,12 +44,14 @@ static int 
>> amdgpu_cs_reset_sem(amdgpu_semaphore_handle sem);
>>    *
>>    * \param   dev      - \c [in] Device handle. See 
>> #amdgpu_device_initialize()
>>    * \param   priority - \c [in] Context creation flags. See 
>> AMDGPU_CTX_PRIORITY_*
>> + * \param   flags    - \c [in] Context flags. See AMDGPU_CTX_FLAGS_*
>>    * \param   context  - \c [out] GPU Context handle
>>    *
>>    * \return  0 on success otherwise POSIX Error code
>>   */
>>   drm_public int amdgpu_cs_ctx_create2(amdgpu_device_handle dev,
>>                        uint32_t priority,
>> +                     uint32_t flags,
>>                        amdgpu_context_handle *context)
>>   {
>>       struct amdgpu_context *gpu_context;
>> @@ -74,6 +76,7 @@ drm_public int 
>> amdgpu_cs_ctx_create2(amdgpu_device_handle dev,
>>       memset(&args, 0, sizeof(args));
>>       args.in.op = AMDGPU_CTX_OP_ALLOC_CTX;
>>       args.in.priority = priority;
>> +    args.in.flags = flags;
>>       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CTX, &args, 
>> sizeof(args));
>>       if (r)
>> @@ -97,7 +100,7 @@ error:
>>   drm_public int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
>>                       amdgpu_context_handle *context)
>>   {
>> -    return amdgpu_cs_ctx_create2(dev, AMDGPU_CTX_PRIORITY_NORMAL, 
>> context);
>> +    return amdgpu_cs_ctx_create2(dev, AMDGPU_CTX_PRIORITY_NORMAL, 0, 
>> context);
>>   }
>>   /**
>> diff --git a/include/drm/amdgpu_drm.h b/include/drm/amdgpu_drm.h
>> index 0cbd1540..d9fb1f20 100644
>> --- a/include/drm/amdgpu_drm.h
>> +++ b/include/drm/amdgpu_drm.h
>> @@ -238,10 +238,18 @@ union drm_amdgpu_bo_list {
>>   #define AMDGPU_CTX_PRIORITY_HIGH        512
>>   #define AMDGPU_CTX_PRIORITY_VERY_HIGH   1023
>> +/* GPU context workload hint bitmask */
>> +#define AMDGPU_CTX_FLAGS_WORKLOAD_HINT_MASK    0xFF
>> +#define AMDGPU_CTX_FLAGS_WORKLOAD_HINT_NONE    0
>> +#define AMDGPU_CTX_FLAGS_WORKLOAD_HINT_3D      (1 << 1)
>> +#define AMDGPU_CTX_FLAGS_WORKLOAD_HINT_VIDEO   (1 << 2)
>> +#define AMDGPU_CTX_FLAGS_WORKLOAD_HINT_VR      (1 << 3)
>> +#define AMDGPU_CTX_FLAGS_WORKLOAD_HINT_COMPUTE (1 << 4)
>> +
>>   struct drm_amdgpu_ctx_in {
>>       /** AMDGPU_CTX_OP_* */
>>       __u32    op;
>> -    /** For future use, no flags defined so far */
>> +    /** AMDGPU_CTX_FLAGS_* */
>>       __u32    flags;
>>       __u32    ctx_id;
>>       /** AMDGPU_CTX_PRIORITY_* */
> 

      reply	other threads:[~2022-08-08 11:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-02 13:55 [PATCH] amdgpu: add context creation flags in CS IOCTL Shashank Sharma
2022-08-02 15:58 ` Michel Dänzer
2022-08-02 16:00   ` Sharma, Shashank
2022-08-08  6:51 ` Somalapuram, Amaranath
2022-08-08 10:59 ` Christian König
2022-08-08 11:46   ` Sharma, Shashank [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=57c92713-b06a-e68a-9079-72f44c2ca3b9@amd.com \
    --to=shashank.sharma@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amaranath.somalapuram@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=marek.olsak@amd.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox