aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
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
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')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c32
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c9
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c10
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c10
5 files changed, 63 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 38e782dee478..58f8f132904d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -957,6 +957,8 @@ struct amdgpu_device {
957 long sdma_timeout; 957 long sdma_timeout;
958 long video_timeout; 958 long video_timeout;
959 long compute_timeout; 959 long compute_timeout;
960
961 uint64_t unique_id;
960}; 962};
961 963
962static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev) 964static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev)
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);
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
index 9585ba51d853..ce6aeb5a0362 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
@@ -356,6 +356,7 @@ static void vega10_init_dpm_defaults(struct pp_hwmgr *hwmgr)
356 struct vega10_hwmgr *data = hwmgr->backend; 356 struct vega10_hwmgr *data = hwmgr->backend;
357 int i; 357 int i;
358 uint32_t sub_vendor_id, hw_revision; 358 uint32_t sub_vendor_id, hw_revision;
359 uint32_t top32, bottom32;
359 struct amdgpu_device *adev = hwmgr->adev; 360 struct amdgpu_device *adev = hwmgr->adev;
360 361
361 vega10_initialize_power_tune_defaults(hwmgr); 362 vega10_initialize_power_tune_defaults(hwmgr);
@@ -499,6 +500,14 @@ static void vega10_init_dpm_defaults(struct pp_hwmgr *hwmgr)
499 (hw_revision == 0) && 500 (hw_revision == 0) &&
500 (sub_vendor_id != 0x1002)) 501 (sub_vendor_id != 0x1002))
501 data->smu_features[GNLD_PCC_LIMIT].supported = true; 502 data->smu_features[GNLD_PCC_LIMIT].supported = true;
503
504 /* Get the SN to turn into a Unique ID */
505 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumTop32);
506 top32 = smum_get_argument(hwmgr);
507 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumBottom32);
508 bottom32 = smum_get_argument(hwmgr);
509
510 adev->unique_id = ((uint64_t)bottom32 << 32) | top32;
502} 511}
503 512
504#ifdef PPLIB_VEGA10_EVV_SUPPORT 513#ifdef PPLIB_VEGA10_EVV_SUPPORT
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c
index 1a909dda37c7..efb6d3762feb 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c
@@ -289,6 +289,8 @@ static int vega12_set_features_platform_caps(struct pp_hwmgr *hwmgr)
289static void vega12_init_dpm_defaults(struct pp_hwmgr *hwmgr) 289static void vega12_init_dpm_defaults(struct pp_hwmgr *hwmgr)
290{ 290{
291 struct vega12_hwmgr *data = (struct vega12_hwmgr *)(hwmgr->backend); 291 struct vega12_hwmgr *data = (struct vega12_hwmgr *)(hwmgr->backend);
292 struct amdgpu_device *adev = hwmgr->adev;
293 uint32_t top32, bottom32;
292 int i; 294 int i;
293 295
294 data->smu_features[GNLD_DPM_PREFETCHER].smu_feature_id = 296 data->smu_features[GNLD_DPM_PREFETCHER].smu_feature_id =
@@ -353,6 +355,14 @@ static void vega12_init_dpm_defaults(struct pp_hwmgr *hwmgr)
353 ((data->registry_data.disallowed_features >> i) & 1) ? 355 ((data->registry_data.disallowed_features >> i) & 1) ?
354 false : true; 356 false : true;
355 } 357 }
358
359 /* Get the SN to turn into a Unique ID */
360 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumTop32);
361 top32 = smum_get_argument(hwmgr);
362 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumBottom32);
363 bottom32 = smum_get_argument(hwmgr);
364
365 adev->unique_id = ((uint64_t)bottom32 << 32) | top32;
356} 366}
357 367
358static int vega12_set_private_data_based_on_pptable(struct pp_hwmgr *hwmgr) 368static int vega12_set_private_data_based_on_pptable(struct pp_hwmgr *hwmgr)
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
index d18f34d4a51e..f27c6fbb192e 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
@@ -324,6 +324,8 @@ static int vega20_set_features_platform_caps(struct pp_hwmgr *hwmgr)
324static void vega20_init_dpm_defaults(struct pp_hwmgr *hwmgr) 324static void vega20_init_dpm_defaults(struct pp_hwmgr *hwmgr)
325{ 325{
326 struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend); 326 struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend);
327 struct amdgpu_device *adev = hwmgr->adev;
328 uint32_t top32, bottom32;
327 int i; 329 int i;
328 330
329 data->smu_features[GNLD_DPM_PREFETCHER].smu_feature_id = 331 data->smu_features[GNLD_DPM_PREFETCHER].smu_feature_id =
@@ -393,6 +395,14 @@ static void vega20_init_dpm_defaults(struct pp_hwmgr *hwmgr)
393 ((data->registry_data.disallowed_features >> i) & 1) ? 395 ((data->registry_data.disallowed_features >> i) & 1) ?
394 false : true; 396 false : true;
395 } 397 }
398
399 /* Get the SN to turn into a Unique ID */
400 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumTop32);
401 top32 = smum_get_argument(hwmgr);
402 smum_send_msg_to_smc(hwmgr, PPSMC_MSG_ReadSerialNumBottom32);
403 bottom32 = smum_get_argument(hwmgr);
404
405 adev->unique_id = ((uint64_t)bottom32 << 32) | top32;
396} 406}
397 407
398static int vega20_set_private_data_based_on_pptable(struct pp_hwmgr *hwmgr) 408static int vega20_set_private_data_based_on_pptable(struct pp_hwmgr *hwmgr)