drm/amdgpu: Add sysfs interface for gc reset mask

Add two sysfs interfaces for gfx and compute:
gfx_reset_mask
compute_reset_mask

These interfaces are read-only and show the resets supported by the IP.
For example, full adapter reset (mode1/mode2/BACO/etc),
soft reset, queue reset, and pipe reset.

V2: the sysfs node returns a text string instead of some flags (Christian)
v3: add a generic helper which takes the ring as parameter
    and print the strings in the order they are applied (Christian)

    check amdgpu_gpu_recovery  before creating sysfs file itself,
    and initialize supported_reset_types in IP version files (Lijo)
v4: Fixing uninitialized variables (Tim)

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Suggested-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Tim Huang <tim.huang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Jesse.zhang@amd.com
2024-11-05 15:22:56 +08:00
committed by Alex Deucher
parent f4a3246a2c
commit 6c8d1f4b04
9 changed files with 172 additions and 0 deletions

View File

@@ -6715,3 +6715,47 @@ uint32_t amdgpu_device_wait_on_rreg(struct amdgpu_device *adev,
}
return ret;
}
ssize_t amdgpu_get_soft_full_reset_mask(struct amdgpu_ring *ring)
{
ssize_t size = 0;
if (!ring || !ring->adev)
return size;
if (amdgpu_device_should_recover_gpu(ring->adev))
size |= AMDGPU_RESET_TYPE_FULL;
if (unlikely(!ring->adev->debug_disable_soft_recovery) &&
!amdgpu_sriov_vf(ring->adev) && ring->funcs->soft_recovery)
size |= AMDGPU_RESET_TYPE_SOFT_RESET;
return size;
}
ssize_t amdgpu_show_reset_mask(char *buf, uint32_t supported_reset)
{
ssize_t size = 0;
if (supported_reset == 0) {
size += sysfs_emit_at(buf, size, "unsupported");
size += sysfs_emit_at(buf, size, "\n");
return size;
}
if (supported_reset & AMDGPU_RESET_TYPE_SOFT_RESET)
size += sysfs_emit_at(buf, size, "soft ");
if (supported_reset & AMDGPU_RESET_TYPE_PER_QUEUE)
size += sysfs_emit_at(buf, size, "queue ");
if (supported_reset & AMDGPU_RESET_TYPE_PER_PIPE)
size += sysfs_emit_at(buf, size, "pipe ");
if (supported_reset & AMDGPU_RESET_TYPE_FULL)
size += sysfs_emit_at(buf, size, "full ");
size += sysfs_emit_at(buf, size, "\n");
return size;
}