Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: Add unique_id and serial_number for Arcturus v3

Add support for unique_id and serial_number, as these are now
the same value, and will be for future ASICs as well.

v2: Explicitly create unique_id only for VG10/20/ARC
v3: Change set_unique_id to get_unique_id for clarity

Signed-off-by: Kent Russell <kent.russell@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Kent Russell and committed by
Alex Deucher
81a16241 bce9ff0e

+40 -1
+3 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
··· 1940 1940 if (adev->flags & AMD_IS_APU) 1941 1941 *states = ATTR_STATE_UNSUPPORTED; 1942 1942 } else if (DEVICE_ATTR_IS(unique_id)) { 1943 - if (!adev->unique_id) 1943 + if (asic_type != CHIP_VEGA10 && 1944 + asic_type != CHIP_VEGA20 && 1945 + asic_type != CHIP_ARCTURUS) 1944 1946 *states = ATTR_STATE_UNSUPPORTED; 1945 1947 } else if (DEVICE_ATTR_IS(pp_features)) { 1946 1948 if (adev->flags & AMD_IS_APU || asic_type < CHIP_VEGA10)
+2
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
··· 793 793 if (!smu->pm_enabled) 794 794 return 0; 795 795 796 + smu_get_unique_id(smu); 797 + 796 798 smu_handle_task(&adev->smu, 797 799 smu->smu_dpm.dpm_level, 798 800 AMD_PP_TASK_COMPLETE_INIT,
+32
drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
··· 2262 2262 i2c_del_adapter(control); 2263 2263 } 2264 2264 2265 + static void arcturus_get_unique_id(struct smu_context *smu) 2266 + { 2267 + struct amdgpu_device *adev = smu->adev; 2268 + uint32_t top32, bottom32, smu_version, size; 2269 + char sn[16]; 2270 + uint64_t id; 2271 + 2272 + if (smu_get_smc_version(smu, NULL, &smu_version)) { 2273 + pr_warn("Failed to get smu version, cannot get unique_id or serial_number\n"); 2274 + return; 2275 + } 2276 + 2277 + /* PPSMC_MSG_ReadSerial* is supported by 54.23.0 and onwards */ 2278 + if (smu_version < 0x361700) { 2279 + pr_warn("ReadSerial is only supported by PMFW 54.23.0 and onwards\n"); 2280 + return; 2281 + } 2282 + 2283 + /* Get the SN to turn into a Unique ID */ 2284 + smu_send_smc_msg(smu, SMU_MSG_ReadSerialNumTop32, &top32); 2285 + smu_send_smc_msg(smu, SMU_MSG_ReadSerialNumBottom32, &bottom32); 2286 + 2287 + id = ((uint64_t)bottom32 << 32) | top32; 2288 + adev->unique_id = id; 2289 + /* For Arcturus-and-later, unique_id == serial_number, so convert it to a 2290 + * 16-digit HEX string for convenience and backwards-compatibility 2291 + */ 2292 + size = sprintf(sn, "%llx", id); 2293 + memcpy(adev->serial, &sn, size); 2294 + } 2295 + 2265 2296 static bool arcturus_is_baco_supported(struct smu_context *smu) 2266 2297 { 2267 2298 struct amdgpu_device *adev = smu->adev; ··· 2447 2416 .dpm_set_uvd_enable = arcturus_dpm_set_uvd_enable, 2448 2417 .i2c_eeprom_init = arcturus_i2c_eeprom_control_init, 2449 2418 .i2c_eeprom_fini = arcturus_i2c_eeprom_control_fini, 2419 + .get_unique_id = arcturus_get_unique_id, 2450 2420 .init_microcode = smu_v11_0_init_microcode, 2451 2421 .load_microcode = smu_v11_0_load_microcode, 2452 2422 .init_smc_tables = smu_v11_0_init_smc_tables,
+1
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
··· 495 495 int (*update_pcie_parameters)(struct smu_context *smu, uint32_t pcie_gen_cap, uint32_t pcie_width_cap); 496 496 int (*i2c_eeprom_init)(struct i2c_adapter *control); 497 497 void (*i2c_eeprom_fini)(struct i2c_adapter *control); 498 + void (*get_unique_id)(struct smu_context *smu); 498 499 int (*get_dpm_clock_table)(struct smu_context *smu, struct dpm_clocks *clock_table); 499 500 int (*init_microcode)(struct smu_context *smu); 500 501 int (*load_microcode)(struct smu_context *smu);
+2
drivers/gpu/drm/amd/powerplay/smu_internal.h
··· 218 218 ((smu)->ppt_funcs->i2c_eeprom_init ? (smu)->ppt_funcs->i2c_eeprom_init((control)) : 0) 219 219 #define smu_i2c_eeprom_fini(smu, control) \ 220 220 ((smu)->ppt_funcs->i2c_eeprom_fini ? (smu)->ppt_funcs->i2c_eeprom_fini((control)) : 0) 221 + #define smu_get_unique_id(smu) \ 222 + ((smu)->ppt_funcs->get_unique_id ? (smu)->ppt_funcs->get_unique_id((smu)) : 0) 221 223 222 224 #define smu_log_thermal_throttling(smu) \ 223 225 ((smu)->ppt_funcs->log_thermal_throttling_event ? (smu)->ppt_funcs->log_thermal_throttling_event((smu)) : 0)