drm/amd: Add a helper to tell whether an IP block HW is enabled
Subsystems (3)
PATCH 1/2 drm/amd: Add a helper to tell whether an IP block HW is enabled
There is already a helper for telling if a block is valid, but if IP handling wants to check if it's HW is enabled no such helper exists.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -372,6 +372,8 @@ void amdgpu_device_ip_get_clockgating_state(struct amdgpu_device *adev, u64 *flags);int amdgpu_device_ip_wait_for_idle (struct amdgpu_device *adev,enum amd_ip_block_type block_type); +bool amdgpu_device_ip_is_hw (struct amdgpu_device *adev, +enum amd_ip_block_type block_type);bool amdgpu_device_ip_is_valid (struct amdgpu_device *adev,enum amd_ip_block_type block_type);int amdgpu_ip_block_suspend (struct amdgpu_ip_block *ip_block);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +22 -1
@@ -2380,7 +2380,7 @@ int amdgpu_device_ip_wait_for_idle(struct amdgpu_device *adev, }/** -* amdgpu_device_ip_is_valid - is the hardware IP enabled +* amdgpu_device_ip_is_hw - is the hardware IP enabled * * @adev: amdgpu_device pointer * @block_type: Type of hardware IP (SMU, GFX, UVD, etc.)
@@ -2388,6 +2388,27 @@ int amdgpu_device_ip_wait_for_idle(struct amdgpu_device *adev,* Check if the hardware IP is enable or not. * Returns true if it the IP is enable, false if not. */ +bool amdgpu_device_ip_is_hw (struct amdgpu_device *adev, +enum amd_ip_block_type block_type) +{ +int i; + +for (i =0 ; i < adev->num_ip_blocks; i++) { +if (adev->ip_blocks[i].version->type == block_type) +return adev->ip_blocks[i].status.hw; + } +return false; +} + +/** +* amdgpu_device_ip_is_valid - is the hardware IP valid +* +* @adev: amdgpu_device pointer +* @block_type: Type of hardware IP (SMU, GFX, UVD, etc.) +* +* Check if the hardware IP is valid or not. +* Returns true if it the IP is valid, false if not. +*/ bool amdgpu_device_ip_is_valid (struct amdgpu_device *adev,enum amd_ip_block_type block_type) {
Signature · 1 line
2.51.0
PATCH 2/2 drm/amd/display: Check if display HW is enabled in amdgpu_dm_atomic_check()
[Why]
If userspace hasn't frozen user processes (like systemd does with user.slice) then an aborted hibernate could give control back to userspace before display hardware is resumed. IoW an atomic commit could be done while the hardware is in D3, which could hang a system.
[How]
Add a check whether the IP block hardware is ready to the atomic check handler and return a failure. Userspace shouldn't do an atomic commit if the atomic check fails.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +5 -0
@@ -12014,6 +12014,11 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,trace_amdgpu_dm_atomic_check_begin (state); +if (WARN_ON (unlikely (!amdgpu_device_ip_is_hw (adev,AMD_IP_BLOCK_TYPE_DCE )))) { + ret = -ENXIO ; + goto fail; + } + ret =drm_atomic_helper_check_modeset (dev, state);if (ret) {drm_dbg_atomic (dev,"drm_atomic_helper_check_modeset() failed\n" );
Signature · 1 line
2.51.0
Harry Wentland
maintainerRe: [PATCH 2/2] drm/amd/display: Check if display HW is enabled in amdgpu_dm_atomic_check()
Quoted 22 lines · Mario Limonciello
[Why]
If userspace hasn't frozen user processes (like systemd does with user.slice) then an aborted hibernate could give control back to userspace before display hardware is resumed. IoW an atomic commit could be done while the hardware is in D3, which could hang a system.[How]
Add a check whether the IP block hardware is ready to the atomic check handler and return a failure. Userspace shouldn't do an atomic commit if the atomic check fails.Signed-off-by Mario Limonciello <[email protected]>--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int amdgpu_dm_atomic_check(struct drm_device *dev, · line 12018
Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-0@@ -12014,6 +12014,11 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,trace_amdgpu_dm_atomic_check_begin (state); +if (WARN_ON (unlikely (!amdgpu_device_ip_is_hw (adev,AMD_IP_BLOCK_TYPE_DCE )))) { + ret = -ENXIO ;
ENXIO means no such device or address. Wouldn't that potentially confuse userspace when they debug issues where we return ENXIO? My understanding is that this is a transient error, so maybe an -EBUSY might be better?
Harry
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3
-0+ goto fail; + } + ret =drm_atomic_helper_check_modeset (dev, state);if (ret) {drm_dbg_atomic (dev,"drm_atomic_helper_check_modeset() failed\n" );
Re: [PATCH 2/2] drm/amd/display: Check if display HW is enabled in amdgpu_dm_atomic_check()
Quoted 34 lines · Harry Wentland
Quoted 22 lines · Mario Limonciello
[Why]
If userspace hasn't frozen user processes (like systemd does with user.slice) then an aborted hibernate could give control back to userspace before display hardware is resumed. IoW an atomic commit could be done while the hardware is in D3, which could hang a system.[How]
Add a check whether the IP block hardware is ready to the atomic check handler and return a failure. Userspace shouldn't do an atomic commit if the atomic check fails.Signed-off-by Mario Limonciello <[email protected]>--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int amdgpu_dm_atomic_check(struct drm_device *dev, · line 12018
Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-0@@ -12014,6 +12014,11 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,trace_amdgpu_dm_atomic_check_begin (state); +if (WARN_ON (unlikely (!amdgpu_device_ip_is_hw (adev,AMD_IP_BLOCK_TYPE_DCE )))) { + ret = -ENXIO ;ENXIO means no such device or address. Wouldn't that potentially confuse userspace when they debug issues where we return ENXIO? My understanding is that this is a transient error, so maybe an
-EBUSYmight be better?
Quoted 2 lines
Harry
Thanks, that makes a lot of sense. I'll update and resend.
Quoted 7 lines
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3
-0+ goto fail; + } + ret =drm_atomic_helper_check_modeset (dev, state);if (ret) {drm_dbg_atomic (dev,"drm_atomic_helper_check_modeset() failed\n" );