Entry point to powergate a particular instance of an IP. Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx> --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 36 ++++++++++++++++++++++ drivers/gpu/drm/amd/include/amd_shared.h | 3 ++ 3 files changed, 43 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index acb6d49bd00c..9a74cf9962f7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -364,6 +364,10 @@ int amdgpu_device_ip_set_clockgating_state(void *dev, int amdgpu_device_ip_set_powergating_state(void *dev, enum amd_ip_block_type block_type, enum amd_powergating_state state); +int amdgpu_device_ip_set_powergating_state_inst(void *dev, + enum amd_ip_block_type block_type, + enum amd_powergating_state state, + int inst); void amdgpu_device_ip_get_clockgating_state(struct amdgpu_device *adev, u64 *flags); int amdgpu_device_ip_wait_for_idle(struct amdgpu_device *adev, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 343c9f2ab1a0..6a1c6dae6309 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -2164,6 +2164,42 @@ int amdgpu_device_ip_set_clockgating_state(void *dev, return r; } +/** + * amdgpu_device_ip_set_powergating_state_inst - set the PG state for an instance of an IP + * + * @dev: amdgpu_device pointer + * @block_type: Type of hardware IP (SMU, GFX, UVD, etc.) + * @state: powergating state (gate or ungate) + * @inst: IP instance to target + * + * Sets the requested powergating state for the selected instance of + * the hardware IP specified. + * Returns the error code from the last instance. + */ +int amdgpu_device_ip_set_powergating_state_inst(void *dev, + enum amd_ip_block_type block_type, + enum amd_powergating_state state, + int inst) +{ + struct amdgpu_device *adev = dev; + int i, r = 0; + + for (i = 0; i < adev->num_ip_blocks; i++) { + if (!adev->ip_blocks[i].status.valid) + continue; + if (adev->ip_blocks[i].version->type != block_type) + continue; + if (!adev->ip_blocks[i].version->funcs->set_powergating_state_inst) + continue; + r = adev->ip_blocks[i].version->funcs->set_powergating_state_inst( + &adev->ip_blocks[i], state, inst); + if (r) + DRM_ERROR("set_powergating_state_inst of IP block <%s> %d failed %d\n", + adev->ip_blocks[i].version->funcs->name, inst, r); + } + return r; +} + /** * amdgpu_device_ip_set_powergating_state - set the PG state * diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h index 98d9e840b0e2..a31a3018a5eb 100644 --- a/drivers/gpu/drm/amd/include/amd_shared.h +++ b/drivers/gpu/drm/amd/include/amd_shared.h @@ -405,6 +405,9 @@ struct amd_ip_funcs { enum amd_clockgating_state state); int (*set_powergating_state)(struct amdgpu_ip_block *ip_block, enum amd_powergating_state state); + int (*set_powergating_state_inst)(struct amdgpu_ip_block *ip_block, + enum amd_powergating_state state, + int inst); void (*get_clockgating_state)(void *handle, u64 *flags); void (*dump_ip_state)(struct amdgpu_ip_block *ip_block); void (*print_ip_state)(struct amdgpu_ip_block *ip_block, struct drm_printer *p); -- 2.47.0