* [PATCH] amdgpu: add context creation flags in CS IOCTL
@ 2022-08-02 13:55 Shashank Sharma
2022-08-02 15:58 ` Michel Dänzer
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Shashank Sharma @ 2022-08-02 13:55 UTC (permalink / raw)
To: dri-devel, amd-gfx
Cc: Alex Deucher, Marek Olsak, Amarnath Somalapuram, Christian Koenig,
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, 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_* */
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] amdgpu: add context creation flags in CS IOCTL
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
2 siblings, 1 reply; 6+ messages in thread
From: Michel Dänzer @ 2022-08-02 15:58 UTC (permalink / raw)
To: Shashank Sharma, dri-devel, amd-gfx
Cc: Alex Deucher, Marek Olsak, Amarnath Somalapuram, Christian Koenig
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
--
Earthling Michel Dänzer | https://redhat.com
Libre software enthusiast | Mesa and Xwayland developer
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] amdgpu: add context creation flags in CS IOCTL
2022-08-02 15:58 ` Michel Dänzer
@ 2022-08-02 16:00 ` Sharma, Shashank
0 siblings, 0 replies; 6+ messages in thread
From: Sharma, Shashank @ 2022-08-02 16:00 UTC (permalink / raw)
To: Michel Dänzer, dri-devel, amd-gfx
Cc: Alex Deucher, Marek Olsak, Amarnath Somalapuram, Christian Koenig
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&data=05%7C01%7Cshashank.sharma%40amd.com%7C50e342a42eac4d4d4fd408da749fd574%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637950527087917031%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=qU41z3Hxo0jKMWgehDWLYi7r4x1QDsA%2F2KfOigj9iew%3D&reserved=0
>
>
Noted, Thanks.
Regards
Shashank
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] amdgpu: add context creation flags in CS IOCTL
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-08 6:51 ` Somalapuram, Amaranath
2022-08-08 10:59 ` Christian König
2 siblings, 0 replies; 6+ messages in thread
From: Somalapuram, Amaranath @ 2022-08-08 6:51 UTC (permalink / raw)
To: Shashank Sharma, dri-devel, amd-gfx
Cc: Alex Deucher, Marek Olsak, Amarnath Somalapuram, Christian Koenig
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_* */
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] amdgpu: add context creation flags in CS IOCTL
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-08 6:51 ` Somalapuram, Amaranath
@ 2022-08-08 10:59 ` Christian König
2022-08-08 11:46 ` Sharma, Shashank
2 siblings, 1 reply; 6+ messages in thread
From: Christian König @ 2022-08-08 10:59 UTC (permalink / raw)
To: Shashank Sharma, dri-devel, amd-gfx
Cc: Alex Deucher, Marek Olsak, Amarnath Somalapuram, Christian Koenig
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_* */
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] amdgpu: add context creation flags in CS IOCTL
2022-08-08 10:59 ` Christian König
@ 2022-08-08 11:46 ` Sharma, Shashank
0 siblings, 0 replies; 6+ messages in thread
From: Sharma, Shashank @ 2022-08-08 11:46 UTC (permalink / raw)
To: Christian König, dri-devel, amd-gfx
Cc: Alex Deucher, Marek Olsak, Amarnath Somalapuram
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_* */
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-08-08 11:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox