aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
diff options
context:
space:
mode:
authorKent Russell <kent.russell@amd.com>2019-05-15 08:35:29 -0400
committerAlex Deucher <alexander.deucher@amd.com>2019-05-24 13:25:32 -0400
commitfb2dbfd2427e82ae63742f667cda19f1af6b77c2 (patch)
tree21fdc009cce43601cf7a582d0dbb82aa4a68b8d5 /drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
parent460960587ae80802c76384b0580ed9c89e6e4bb7 (diff)
drm/amdgpu: Add Unique Identifier sysfs file unique_id v2
Add a file that provides a Unique ID for the GPU. This will persist across machines and is guaranteed to be unique. This is only available for GFX9 and newer, so older ASICs will not have this file in the sysfs pool v2: Store it in adev for ASICs that don't have a hwmgr Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Kent Russell <kent.russell@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index adba9ea03e63..a73e1903d29b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -1368,6 +1368,29 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,
1368 count0, count1, pcie_get_mps(adev->pdev)); 1368 count0, count1, pcie_get_mps(adev->pdev));
1369} 1369}
1370 1370
1371/**
1372 * DOC: unique_id
1373 *
1374 * The amdgpu driver provides a sysfs API for providing a unique ID for the GPU
1375 * The file unique_id is used for this.
1376 * This will provide a Unique ID that will persist from machine to machine
1377 *
1378 * NOTE: This will only work for GFX9 and newer. This file will be absent
1379 * on unsupported ASICs (GFX8 and older)
1380 */
1381static ssize_t amdgpu_get_unique_id(struct device *dev,
1382 struct device_attribute *attr,
1383 char *buf)
1384{
1385 struct drm_device *ddev = dev_get_drvdata(dev);
1386 struct amdgpu_device *adev = ddev->dev_private;
1387
1388 if (adev->unique_id)
1389 return snprintf(buf, PAGE_SIZE, "%016llx\n", adev->unique_id);
1390
1391 return 0;
1392}
1393
1371static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR, amdgpu_get_dpm_state, amdgpu_set_dpm_state); 1394static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR, amdgpu_get_dpm_state, amdgpu_set_dpm_state);
1372static DEVICE_ATTR(power_dpm_force_performance_level, S_IRUGO | S_IWUSR, 1395static DEVICE_ATTR(power_dpm_force_performance_level, S_IRUGO | S_IWUSR,
1373 amdgpu_get_dpm_forced_performance_level, 1396 amdgpu_get_dpm_forced_performance_level,
@@ -1418,6 +1441,7 @@ static DEVICE_ATTR(pcie_bw, S_IRUGO, amdgpu_get_pcie_bw, NULL);
1418static DEVICE_ATTR(ppfeatures, S_IRUGO | S_IWUSR, 1441static DEVICE_ATTR(ppfeatures, S_IRUGO | S_IWUSR,
1419 amdgpu_get_ppfeature_status, 1442 amdgpu_get_ppfeature_status,
1420 amdgpu_set_ppfeature_status); 1443 amdgpu_set_ppfeature_status);
1444static DEVICE_ATTR(unique_id, S_IRUGO, amdgpu_get_unique_id, NULL);
1421 1445
1422static ssize_t amdgpu_hwmon_show_temp(struct device *dev, 1446static ssize_t amdgpu_hwmon_show_temp(struct device *dev,
1423 struct device_attribute *attr, 1447 struct device_attribute *attr,
@@ -2814,6 +2838,12 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
2814 return ret; 2838 return ret;
2815 } 2839 }
2816 } 2840 }
2841 if (adev->unique_id)
2842 ret = device_create_file(adev->dev, &dev_attr_unique_id);
2843 if (ret) {
2844 DRM_ERROR("failed to create device file unique_id\n");
2845 return ret;
2846 }
2817 ret = amdgpu_debugfs_pm_init(adev); 2847 ret = amdgpu_debugfs_pm_init(adev);
2818 if (ret) { 2848 if (ret) {
2819 DRM_ERROR("Failed to register debugfs file for dpm!\n"); 2849 DRM_ERROR("Failed to register debugfs file for dpm!\n");
@@ -2875,6 +2905,8 @@ void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev)
2875 device_remove_file(adev->dev, &dev_attr_mem_busy_percent); 2905 device_remove_file(adev->dev, &dev_attr_mem_busy_percent);
2876 if (!(adev->flags & AMD_IS_APU)) 2906 if (!(adev->flags & AMD_IS_APU))
2877 device_remove_file(adev->dev, &dev_attr_pcie_bw); 2907 device_remove_file(adev->dev, &dev_attr_pcie_bw);
2908 if (adev->unique_id)
2909 device_remove_file(adev->dev, &dev_attr_unique_id);
2878 if ((adev->asic_type >= CHIP_VEGA10) && 2910 if ((adev->asic_type >= CHIP_VEGA10) &&
2879 !(adev->flags & AMD_IS_APU)) 2911 !(adev->flags & AMD_IS_APU))
2880 device_remove_file(adev->dev, &dev_attr_ppfeatures); 2912 device_remove_file(adev->dev, &dev_attr_ppfeatures);