amdgpu: implement new CTX OP to set/get stable pstates

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
main
Samuel Pitoiset 2021-12-31 09:10:03 +01:00
parent 94bc814416
commit de84cdc563
3 changed files with 38 additions and 0 deletions

View File

@ -25,6 +25,7 @@ amdgpu_cs_ctx_create
amdgpu_cs_ctx_create2 amdgpu_cs_ctx_create2
amdgpu_cs_ctx_free amdgpu_cs_ctx_free
amdgpu_cs_ctx_override_priority amdgpu_cs_ctx_override_priority
amdgpu_cs_ctx_stable_pstate
amdgpu_cs_destroy_semaphore amdgpu_cs_destroy_semaphore
amdgpu_cs_destroy_syncobj amdgpu_cs_destroy_syncobj
amdgpu_cs_export_syncobj amdgpu_cs_export_syncobj

View File

@ -939,6 +939,21 @@ int amdgpu_cs_ctx_override_priority(amdgpu_device_handle dev,
int master_fd, int master_fd,
unsigned priority); unsigned priority);
/**
* Set or query the stable power state for GPU profiling.
*
* \param dev - \c [in] device handle
* \param op - \c [in] AMDGPU_CTX_OP_{GET,SET}_STABLE_PSTATE
* \param flags - \c [in] AMDGPU_CTX_STABLE_PSTATE_*
* \param out_flags - \c [out] output current stable pstate
*
* \return 0 on success otherwise POSIX Error code.
*/
int amdgpu_cs_ctx_stable_pstate(amdgpu_context_handle context,
uint32_t op,
uint32_t flags,
uint32_t *out_flags);
/** /**
* Query reset state for the specific GPU Context * Query reset state for the specific GPU Context
* *

View File

@ -167,6 +167,28 @@ drm_public int amdgpu_cs_ctx_override_priority(amdgpu_device_handle dev,
return 0; return 0;
} }
drm_public int amdgpu_cs_ctx_stable_pstate(amdgpu_context_handle context,
uint32_t op,
uint32_t flags,
uint32_t *out_flags)
{
union drm_amdgpu_ctx args;
int r;
if (!context)
return -EINVAL;
memset(&args, 0, sizeof(args));
args.in.op = op;
args.in.ctx_id = context->id;
args.in.flags = flags;
r = drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_CTX,
&args, sizeof(args));
if (!r && out_flags)
*out_flags = args.out.pstate.flags;
return r;
}
drm_public int amdgpu_cs_query_reset_state(amdgpu_context_handle context, drm_public int amdgpu_cs_query_reset_state(amdgpu_context_handle context,
uint32_t *state, uint32_t *hangs) uint32_t *state, uint32_t *hangs)
{ {