AMDGPU_CTX_OP_GET_STABLE_PSTATE is an unusual uapi - it will check whether the context id exist, but otherwise does nothing with it. In other words, the uapi has historically been implemented as being able to query the global device state, as long as the caller supplies a random valid context id.
Lets just document this and later figure out if it can be changed to either more permissive (don't check context id), or more restrictive (only allow queries from contexts which have overriden the performance state). Signed-off-by: Tvrtko Ursulin <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index 941cb80cab4e..a1ef7c67b87a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c @@ -614,6 +614,14 @@ static int amdgpu_ctx_stable_pstate(struct amdgpu_device *adev, if (!ctx) return -EINVAL; + /* + * The get path is odd in this uapi - it will check whether the context + * id exist, but otherwise does nothing with it. In other words, the + * uapi has historically been implemented as being able to query the + * global device state, as long as the caller supplies a random valid + * context id. + */ + if (set) r = amdgpu_ctx_set_stable_pstate(ctx, *stable_pstate); else -- 2.54.0
