drm/amdgpu: Add sysfs interface for sdma reset mask

Add the sysfs interface for sdma:
sdma_reset_mask

The interface is 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)

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-04 13:15:49 +08:00
committed by Alex Deucher
parent edd345f7ef
commit 59fd50b866
6 changed files with 112 additions and 0 deletions

View File

@@ -413,3 +413,44 @@ void amdgpu_debugfs_sdma_sched_mask_init(struct amdgpu_device *adev)
&amdgpu_debugfs_sdma_sched_mask_fops);
#endif
}
static ssize_t amdgpu_get_sdma_reset_mask(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct drm_device *ddev = dev_get_drvdata(dev);
struct amdgpu_device *adev = drm_to_adev(ddev);
if (!adev)
return -ENODEV;
return amdgpu_show_reset_mask(buf, adev->sdma.supported_reset);
}
static DEVICE_ATTR(sdma_reset_mask, 0444,
amdgpu_get_sdma_reset_mask, NULL);
int amdgpu_sdma_sysfs_reset_mask_init(struct amdgpu_device *adev)
{
int r = 0;
if (!amdgpu_gpu_recovery)
return r;
if (adev->sdma.num_instances) {
r = device_create_file(adev->dev, &dev_attr_sdma_reset_mask);
if (r)
return r;
}
return r;
}
void amdgpu_sdma_sysfs_reset_mask_fini(struct amdgpu_device *adev)
{
if (!amdgpu_gpu_recovery)
return;
if (adev->sdma.num_instances)
device_remove_file(adev->dev, &dev_attr_sdma_reset_mask);
}