drm/amdgpu: Change unique_id to use IP_VERSION
Subsystems (3)
PATCH 1/2 drm/amdgpu: Change unique_id to use IP_VERSION
This is transitioning throughout amdgpu, so we may as well get it started now. This also cleans up the logic on what IP_VERSIONs do or don't support unique_id.
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +8 -4
@@ -1987,11 +1987,15 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_if (adev->flags &AMD_IS_APU ) *states =ATTR_STATE_UNSUPPORTED ; }else if (DEVICE_ATTR_IS (unique_id)) { -if (asic_type !=CHIP_VEGA10 && - asic_type !=CHIP_VEGA20 && - asic_type !=CHIP_ARCTURUS && - asic_type !=CHIP_ALDEBARAN ) +switch (adev->ip_versions[GC_HWIP ][0 ]) { +case IP_VERSION (9 ,0 ,1 ): +case IP_VERSION (9 ,4 ,0 ): +case IP_VERSION (9 ,4 ,1 ): +case IP_VERSION (9 ,4 ,2 ): + *states =ATTR_STATE_SUPPORTED ; +default : *states =ATTR_STATE_UNSUPPORTED ; + } }else if (DEVICE_ATTR_IS (pp_features)) {if (adev->flags &AMD_IS_APU || asic_type <CHIP_VEGA10 ) *states =ATTR_STATE_UNSUPPORTED ;
Signature · 1 line
2.25.1
PATCH 2/2 drm/amdgpu: Add unique_id support for sienna cichlid
This is being added to SMU Metrics, so add the required tie-ins in the kernel. Also create the corresponding unique_id sysfs file.
v2: Add FW version check, remove SMU mutex
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 1 + .../pmfw_if/smu11_driver_if_sienna_cichlid.h | 12 +++++-- .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 35 +++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
@@ -1992,6 +1992,7 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_case IP_VERSION (9 ,4 ,0 ):case IP_VERSION (9 ,4 ,1 ):case IP_VERSION (9 ,4 ,2 ): +case IP_VERSION (10 ,3 ,0 ): *states =ATTR_STATE_SUPPORTED ;default : *states =ATTR_STATE_UNSUPPORTED ;
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h +10 -2
@@ -1419,8 +1419,12 @@ typedef struct {uint8_t PcieRate ;uint8_t PcieWidth ;uint16_t AverageGfxclkFrequencyTarget; -uint16_t Padding16_2; +//PMFW-8711 +uint32_t PublicSerialNumLower32; +uint32_t PublicSerialNumUpper32; + +uint16_t Padding16_2; } SmuMetrics_t; typedef struct {
@@ -1476,8 +1480,12 @@ typedef struct {uint8_t PcieRate ;uint8_t PcieWidth ;uint16_t AverageGfxclkFrequencyTarget; -uint16_t Padding16_2; +//PMFW-8711 +uint32_t PublicSerialNumLower32; +uint32_t PublicSerialNumUpper32; + +uint16_t Padding16_2; } SmuMetrics_V2_t; typedef struct {
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +35 -0
@@ -481,6 +481,40 @@ static int sienna_cichlid_setup_pptable(struct smu_context *smu)return sienna_cichlid_patch_pptable_quirk (smu); } +static void sienna_cichlid_get_unique_id (struct smu_context *smu) +{ +struct amdgpu_device *adev = smu->adev; +struct smu_table_context *smu_table = &smu->smu_table; +SmuMetrics_t *metrics = + &(((SmuMetricsExternal_t *)(smu_table->metrics_table))->SmuMetrics); +SmuMetrics_V2_t *metrics_v2 = + &(((SmuMetricsExternal_t *)(smu_table->metrics_table))->SmuMetrics_V2); +uint32_t upper32 =0 , lower32 =0 ; +int ret; + +/* Only supported as of version 0.58.83.0 */ +if (smu->smc_fw_version <0x3A5300 ) +return ; + + ret =smu_cmn_get_metrics_table (smu,NULL , false); +if (ret) + goto out_unlock; + +bool use_metrics_v2 = ((smu->adev->ip_versions[MP1_HWIP ][0 ] ==IP_VERSION (11 ,0 ,7 )) && + (smu->smc_fw_version >=0x3A4300 )) ? true : false; + + upper32 = use_metrics_v2 ? metrics_v2->PublicSerialNumUpper32 : + metrics->PublicSerialNumUpper32; + lower32 = use_metrics_v2 ? metrics_v2->PublicSerialNumLower32 : + metrics->PublicSerialNumLower32; + +out_unlock: + + adev->unique_id = ((uint64_t )upper32 <<32 ) | lower32; +if (adev->serial[0 ] =='\0' ) +sprintf (adev->serial,"%016llx" , adev->unique_id); +} +static int sienna_cichlid_tables_init (struct smu_context *smu) {struct smu_table_context *smu_table = &smu->smu_table;
@@ -4182,6 +4216,7 @@ static const struct pptable_funcs sienna_cichlid_ppt_funcs = { .get_ecc_info = sienna_cichlid_get_ecc_info, .get_default_config_table_settings = sienna_cichlid_get_default_config_table_settings, .set_config_table = sienna_cichlid_set_config_table, + .get_unique_id = sienna_cichlid_get_unique_id, };void sienna_cichlid_set_ppt_funcs (struct smu_context *smu)
Signature · 1 line
2.25.1
[Public]
Series is:
________________________________
From: amd-gfx <[email protected]> on behalf of Kent Russell <[email protected]>
Sent: Monday, March 28, 2022 9:06 AM
To: [email protected] <[email protected]>
Cc: Russell, Kent <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Change unique_id to use IP_VERSION
This is transitioning throughout amdgpu, so we may as well get it started now. This also cleans up the logic on what IP_VERSIONs do or don't support unique_id.
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +8 -4
@@ -1987,11 +1987,15 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_if (adev->flags &AMD_IS_APU ) *states =ATTR_STATE_UNSUPPORTED ; }else if (DEVICE_ATTR_IS (unique_id)) { -if (asic_type !=CHIP_VEGA10 && - asic_type !=CHIP_VEGA20 && - asic_type !=CHIP_ARCTURUS && - asic_type !=CHIP_ALDEBARAN ) +switch (adev->ip_versions[GC_HWIP ][0 ]) { +case IP_VERSION (9 ,0 ,1 ): +case IP_VERSION (9 ,4 ,0 ): +case IP_VERSION (9 ,4 ,1 ): +case IP_VERSION (9 ,4 ,2 ): + *states =ATTR_STATE_SUPPORTED ; +default : *states =ATTR_STATE_UNSUPPORTED ; + } }else if (DEVICE_ATTR_IS (pp_features)) {if (adev->flags &AMD_IS_APU || asic_type <CHIP_VEGA10 ) *states =ATTR_STATE_UNSUPPORTED ;
--
2.25.1
Russell, Kent
Reviewed-by Alex Deucher[Public]
Thanks Alex. Sending out a 3rd version shortly with a couple style fixes due to rebasing onto Lijo's work.
Kent
From: Deucher, Alexander <[email protected]>
Sent: Monday, March 28, 2022 9:45 AM
To: Russell, Kent <[email protected]>; [email protected]
Subject: Re: [PATCH 1/2] drm/amdgpu: Change unique_id to use IP_VERSION
[Public]
Series is:
________________________________
From: amd-gfx <[email protected]<mailto:[email protected]>> on behalf of Kent Russell <[email protected]<mailto:[email protected]>>
Sent: Monday, March 28, 2022 9:06 AM
To: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Cc: Russell, Kent <[email protected]<mailto:[email protected]>>
Subject: [PATCH 1/2] drm/amdgpu: Change unique_id to use IP_VERSION
This is transitioning throughout amdgpu, so we may as well get it started now. This also cleans up the logic on what IP_VERSIONs do or don't support unique_id.
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +8 -4
@@ -1987,11 +1987,15 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_if (adev->flags &AMD_IS_APU ) *states =ATTR_STATE_UNSUPPORTED ; }else if (DEVICE_ATTR_IS (unique_id)) { -if (asic_type !=CHIP_VEGA10 && - asic_type !=CHIP_VEGA20 && - asic_type !=CHIP_ARCTURUS && - asic_type !=CHIP_ALDEBARAN ) +switch (adev->ip_versions[GC_HWIP ][0 ]) { +case IP_VERSION (9 ,0 ,1 ): +case IP_VERSION (9 ,4 ,0 ): +case IP_VERSION (9 ,4 ,1 ): +case IP_VERSION (9 ,4 ,2 ): + *states =ATTR_STATE_SUPPORTED ; +default : *states =ATTR_STATE_UNSUPPORTED ; + } }else if (DEVICE_ATTR_IS (pp_features)) {if (adev->flags &AMD_IS_APU || asic_type <CHIP_VEGA10 ) *states =ATTR_STATE_UNSUPPORTED ;
--
2.25.1