diff mbox series

amdgpu: add context creation flags in CS IOCTL

Message ID 20220802135558.6324-1-shashank.sharma@amd.com (mailing list archive)
State New, archived
Headers show
Series amdgpu: add context creation flags in CS IOCTL | expand

Commit Message

Sharma, Shashank Aug. 2, 2022, 1:55 p.m. UTC
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, 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(-)

Comments

Michel Dänzer Aug. 2, 2022, 3:58 p.m. UTC | #1
On 2022-08-02 15:55, Shashank Sharma wrote:
> 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, 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 +++++++++-

See include/drm/README on how to handle changes to include/drm/*_drm.h .


Also, libdrm changes are now reviewed and merged as GitLab merge requests: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests
Sharma, Shashank Aug. 2, 2022, 4 p.m. UTC | #2
On 8/2/2022 5:58 PM, Michel Dänzer wrote:
> On 2022-08-02 15:55, Shashank Sharma wrote:
>> 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, 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 +++++++++-
> 
> See include/drm/README on how to handle changes to include/drm/*_drm.h .

> 
> Also, libdrm changes are now reviewed and merged as GitLab merge requests: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.freedesktop.org%2Fmesa%2Fdrm%2F-%2Fmerge_requests&amp;data=05%7C01%7Cshashank.sharma%40amd.com%7C50e342a42eac4d4d4fd408da749fd574%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637950527087917031%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=qU41z3Hxo0jKMWgehDWLYi7r4x1QDsA%2F2KfOigj9iew%3D&amp;reserved=0
> 
> 
Noted, Thanks.

Regards
Shashank
Somalapuram, Amaranath Aug. 8, 2022, 6:51 a.m. UTC | #3
On 8/2/2022 7:25 PM, Shashank Sharma wrote:
> 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, 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);

How do we set workload hint from application, amdgpu_cs_ctx_create show 
have flag ?

Regards,
S.Amarnath
>   }
>   
>   /**
> 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_* */
Christian König Aug. 8, 2022, 10:59 a.m. UTC | #4
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.


>   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_* */
Sharma, Shashank Aug. 8, 2022, 11:46 a.m. UTC | #5
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_* */
>
diff mbox series

Patch

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_* */