Skip to contentSkip to conversation

drm/amdgpu: Use switch case for unique_id

PATCH In review Kent Russell 3 participants 9 messages Mar 28, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdgpu: Use switch case for unique_id

To ease readability, use switch to set unique_id as supported for the supported IP_VERSIONs, and set it to unsupported by default for all other ASICs.
This makes it easier to add IP_VERSIONs later on, and makes it obvious that it is not supported by default, instead of the current logic that assumes that it is supported unless it is not one of the specified IP_VERSIONs.

v2: Rebase onto previous IP_VERSION change

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +9 -4
index 9ce597ded31d..4151db2678fb 100644
@@ -1988,11 +1988,16 @@ 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 (gc_ver != IP_VERSION(9, 0, 1) &&
-		    gc_ver != IP_VERSION(9, 4, 0) &&
-		    gc_ver != IP_VERSION(9, 4, 1) &&
-		    gc_ver != IP_VERSION(9, 4, 2))
+		switch (gc_ver) {
+		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;
+			break;
+		default:
 			*states = ATTR_STATE_UNSUPPORTED;
+		}
 	} else if (DEVICE_ATTR_IS(pp_features)) {
 		if (adev->flags & AMD_IS_APU || gc_ver < IP_VERSION(9, 0, 0))
 			*states = ATTR_STATE_UNSUPPORTED;
Signature · 1 line
2.25.1
#1 lore raw

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
v3: Fix style warning

---
 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   | 36 +++++++++++++++++++
 3 files changed, 47 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
index 4151db2678fb..4a9aabc16fbc 100644
@@ -1993,6 +1993,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;
 			break;
 		default:
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h +10 -2
index 3e4a314ef925..58f977320d06 100644
@@ -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 +36 -0
index 38f04836c82f..550458f6246a 100644
@@ -481,6 +481,41 @@ 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;
+	bool use_metrics_v2;
+	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;
+
+	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 +4217,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
#2 lore raw

Re: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

Quoted 45 lines · Kent Russell

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
v3: Fix style warning

---
  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   | 36 +++++++++++++++++++
  3 files changed, 47 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
index 4151db2678fb..4a9aabc16fbc 100644
@@ -1993,6 +1993,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;
  			break;
  		default:
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h +5 -1
index 3e4a314ef925..58f977320d06 100644
@@ -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 {

drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h typedef struct { · line 1487

Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h +4 -1
@@ -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;
+

Is this the case for other ASICs also which share the metrics data with Sienna?

Quoted 18 lines
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h +1 -0
+  uint16_t Padding16_2;
  } SmuMetrics_V2_t;
 
  typedef struct {
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +6 -0
index 38f04836c82f..550458f6246a 100644
@@ -481,6 +481,41 @@ 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);

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_setup_pptable(struct smu_context *smu) · line 499

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +10 -0
+	SmuMetrics_V2_t *metrics_v2 =
+		&(((SmuMetricsExternal_t *)(smu_table->metrics_table))->SmuMetrics_V2);
+	uint32_t upper32 = 0, lower32 = 0;
+	bool use_metrics_v2;
+	int ret;
+
+	/* Only supported as of version 0.58.83.0 */
+	if (smu->smc_fw_version < 0x3A5300)
+		return;
+

Since this is shared with other ASICs, I guess this check itself may not be enough. This function may be skipped if it's not MP1 11.0.7 or GC 10.3.0?

Thanks,
Lijo

Quoted 31 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +20 -0
+	ret = smu_cmn_get_metrics_table(smu, NULL, false);
+	if (ret)
+		goto out_unlock;
+
+	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 +4217,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)
#3 lore raw

RE: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

[AMD Official Use Only]

Responses inline

Quoted 64 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, March 28, 2022 11:18 AM
To: Russell, Kent <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

Quoted 8 lines · Kent Russell

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
v3: Fix style warning

Review

Quoted 7 lines
---
  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   | 36 +++++++++++++++++++
  3 files changed, 47 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/pm/amdgpu_pm.c

drivers/gpu/drm/amd/pm/amdgpu_pm.c static int default_attr_update(struct amdgpu_device *adev,

Quoted 4 lines

index 4151db2678fb..4a9aabc16fbc 100644

drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
@@ -1993,6 +1993,7 @@ static int default_attr_update(struct amdgpu_device *adev,

struct amdgpu_device_

Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
            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;
                    break;
            default:

diff --git

a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h

Quoted 23 lines

index 3e4a314ef925..58f977320d06 100644

drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h +5 -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;
 
Quoted 7 lines

drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h typedef struct { · line 1426

Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h +4 -0
+  //PMFW-8711
+  uint32_t PublicSerialNumLower32;
+  uint32_t PublicSerialNumUpper32;
+

Is this the case for other ASICs also which share the metrics data with Sienna?

No, only for Sienna Cichlid. The PMFW guys didn't implement it for Navy Flounder or Dimgrey Cavefish.

Quoted 26 lines

Review

Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h +1 -0
+  uint16_t Padding16_2;
  } SmuMetrics_V2_t;
 
  typedef struct {
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_setup_pptable(struct smu_context

Quoted 4 lines

index 38f04836c82f..550458f6246a 100644

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -0
@@ -481,6 +481,41 @@ static int sienna_cichlid_setup_pptable(struct smu_context

*smu)

Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +11 -0
    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;
+   bool use_metrics_v2;
+   int ret;
Quoted 9 lines

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_setup_pptable(struct smu_context *smu) · line 499

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +5 -0
+
+   /* Only supported as of version 0.58.83.0 */
+   if (smu->smc_fw_version < 0x3A5300)
+           return;
+

Since this is shared with other ASICs, I guess this check itself may not be enough. This function may be skipped if it's not MP1 11.0.7 or GC 10.3.0?

Since the sysfs file is only supported on Sienna Cichlid (10.3.0), is it a concern since the tie-in won't exist on the other SMU11-based ASICs? And this function is only referenced by sienna_cichlid, unless I misunderstood something (and someone else uses sienna_cichlid_tables_init).

Kent

Quoted 36 lines

Thanks,
Lijo

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_setup_pptable(struct smu_context *smu)

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +5 -0
+   ret = smu_cmn_get_metrics_table(smu, NULL, false);
+   if (ret)
+           goto out_unlock;
+
+   use_metrics_v2 = ((smu->adev->ip_versions[MP1_HWIP][0] == IP_VERSION(11, 0,

7)) &&

Quoted 18 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +14 -0
+           (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;

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static const struct pptable_funcs sienna_cichlid_ppt_funcs = { · line 4218

Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -0
@@ -4182,6 +4217,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,

Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +1 -0
    .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)
#4 lore raw

Re: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

Quoted 114 lines · Kent

[AMD Official Use Only]

Responses inline

Quoted 64 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, March 28, 2022 11:18 AM
To: Russell, Kent <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

Quoted 8 lines · Kent Russell

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
v3: Fix style warning

Review

Quoted 7 lines
---
   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   | 36 +++++++++++++++++++
   3 files changed, 47 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/pm/amdgpu_pm.c

drivers/gpu/drm/amd/pm/amdgpu_pm.c static int default_attr_update(struct amdgpu_device *adev,

Quoted 4 lines

index 4151db2678fb..4a9aabc16fbc 100644

drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
@@ -1993,6 +1993,7 @@ static int default_attr_update(struct amdgpu_device *adev,

struct amdgpu_device_

Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
             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;
                     break;
             default:

diff --git

a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h

Quoted 23 lines

index 3e4a314ef925..58f977320d06 100644

drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h +5 -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;
 
Quoted 7 lines

drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h typedef struct { · line 1426

Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h +4 -0
+  //PMFW-8711
+  uint32_t PublicSerialNumLower32;
+  uint32_t PublicSerialNumUpper32;
+

Is this the case for other ASICs also which share the metrics data with Sienna?

No, only for Sienna Cichlid. The PMFW guys didn't implement it for Navy Flounder or Dimgrey Cavefish.

Quoted 26 lines

Review

Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h +1 -0
+  uint16_t Padding16_2;
   } SmuMetrics_V2_t;
 
   typedef struct {
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_setup_pptable(struct smu_context

Quoted 4 lines

index 38f04836c82f..550458f6246a 100644

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -0
@@ -481,6 +481,41 @@ static int sienna_cichlid_setup_pptable(struct smu_context

*smu)

Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +11 -0
     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;
+   bool use_metrics_v2;
+   int ret;
Quoted 9 lines

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_setup_pptable(struct smu_context *smu) · line 499

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +5 -0
+
+   /* Only supported as of version 0.58.83.0 */
+   if (smu->smc_fw_version < 0x3A5300)
+           return;
+

Since this is shared with other ASICs, I guess this check itself may not be enough. This function may be skipped if it's not MP1 11.0.7 or GC 10.3.0?

Quoted 2 lines

Since the sysfs file is only supported on Sienna Cichlid (10.3.0), is it a concern since the tie-in won't exist on the other SMU11-based ASICs? And this function is only referenced by sienna_cichlid, unless I misunderstood something (and someone else uses sienna_cichlid_tables_init).

This function also gets called as part of common init sequence - smu_get_unique_id.
If PMFW version of Navi Flounder/Dimgrey ASIC is greater than Sienna, then it may go to the path which is not intended to be executed on that ASIC.

Thanks,
Lijo

Quoted 38 lines

Kent

Quoted 36 lines

Thanks,
Lijo

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_setup_pptable(struct smu_context *smu)

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +5 -0
+   ret = smu_cmn_get_metrics_table(smu, NULL, false);
+   if (ret)
+           goto out_unlock;
+
+   use_metrics_v2 = ((smu->adev->ip_versions[MP1_HWIP][0] == IP_VERSION(11, 0,

7)) &&

Quoted 18 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +14 -0
+           (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;

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static const struct pptable_funcs sienna_cichlid_ppt_funcs = { · line 4218

Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -0
@@ -4182,6 +4217,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,

Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +1 -0
     .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)
#5 lore raw

RE: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

[AMD Official Use Only]

Quoted 132 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, March 28, 2022 11:48 AM
To: Russell, Kent <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

Quoted 43 lines · Kent

[AMD Official Use Only]

Responses inline

Quoted 39 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, March 28, 2022 11:18 AM
To: Russell, Kent <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

Quoted 8 lines · Kent Russell

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
v3: Fix style warning

Review

Quoted 7 lines
---
   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   | 36 +++++++++++++++++++
   3 files changed, 47 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/pm/amdgpu_pm.c

drivers/gpu/drm/amd/pm/amdgpu_pm.c static int default_attr_update(struct amdgpu_device *adev,

Quoted 4 lines

index 4151db2678fb..4a9aabc16fbc 100644

drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
@@ -1993,6 +1993,7 @@ static int default_attr_update(struct amdgpu_device *adev,

struct amdgpu_device_

Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
             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;
                     break;
             default:

diff --git

Quoted 5 lines
Quoted 5 lines

a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h

Quoted 3 lines

index 3e4a314ef925..58f977320d06 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h
+++

b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h

Quoted 28 lines
Quoted 20 lines
Quoted 20 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +5 -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;
 
Quoted 7 lines

drivers/gpu/drm/amd/pm/amdgpu_pm.c typedef struct { · line 1487

Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +4 -0
+  //PMFW-8711
+  uint32_t PublicSerialNumLower32;
+  uint32_t PublicSerialNumUpper32;
+

Is this the case for other ASICs also which share the metrics data with Sienna?

Quoted 1 line

No, only for Sienna Cichlid. The PMFW guys didn't implement it for Navy Flounder or

Dimgrey Cavefish.

Quoted 37 lines
Quoted 27 lines

Review

Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+  uint16_t Padding16_2;
   } SmuMetrics_V2_t;
 
   typedef struct {
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_setup_pptable(struct smu_context

Quoted 4 lines

index 38f04836c82f..550458f6246a 100644

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -0
@@ -481,6 +481,41 @@ static int sienna_cichlid_setup_pptable(struct smu_context

*smu)

Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +11 -0
     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;
+   bool use_metrics_v2;
+   int ret;
Quoted 9 lines

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_setup_pptable(struct smu_context *smu) · line 499

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +5 -0
+
+   /* Only supported as of version 0.58.83.0 */
+   if (smu->smc_fw_version < 0x3A5300)
+           return;
+

Since this is shared with other ASICs, I guess this check itself may not be enough. This function may be skipped if it's not MP1 11.0.7 or GC 10.3.0?

Quoted 1 line

Since the sysfs file is only supported on Sienna Cichlid (10.3.0), is it a concern since the tie-

in won't exist on the other SMU11-based ASICs? And this function is only referenced by sienna_cichlid, unless I misunderstood something (and someone else uses sienna_cichlid_tables_init).

Quoted 1 line
Quoted 5 lines

This function also gets called as part of common init sequence - smu_get_unique_id.
If PMFW version of Navi Flounder/Dimgrey ASIC is greater than Sienna, then it may go to the path which is not intended to be executed on that ASIC.

Would it be sufficient to just confirm the IP_VERSION here too then?
e.g.
/* Only supported as of version 0.58.83.0 and only on Sienna Cichlid (GC 10.3.0)*/ if (smu->smc_fw_version < 0x3A5300 || adev->ip_versions[GC_HWIP][0] != IP_VERSION(10, 3, 0))

          return;

Thus the FW has to be that version, and the IP_VERSION has to be 10.3 ? Or is there a better method to use? Thanks!

Kent

Quoted 42 lines

Thanks,
Lijo

Quoted 38 lines

Kent

Quoted 36 lines

Thanks,
Lijo

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_setup_pptable(struct smu_context *smu)

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +5 -0
+   ret = smu_cmn_get_metrics_table(smu, NULL, false);
+   if (ret)
+           goto out_unlock;
+
+   use_metrics_v2 = ((smu->adev->ip_versions[MP1_HWIP][0] == IP_VERSION(11, 0,

7)) &&

Quoted 18 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +14 -0
+           (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;

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static const struct pptable_funcs sienna_cichlid_ppt_funcs = { · line 4218

Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -0
@@ -4182,6 +4217,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,

Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +1 -0
     .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)
#6 lore raw

Re: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

[AMD Official Use Only]

Yes, that check looks good.

A couple of other things -

PMFW ticket as a comment is not needed.
I remember Satish updating the same struct for smartshift related data. Some additional fields added towards the end. Not sure if Sienna struct also carries those fields. Regardless, you may check if that affects the placement of serial number fields (whether before or after those fields).

Thanks,
Lijo
________________________________
From: Russell, Kent <[email protected]>
Sent: Monday, March 28, 2022 9:23:36 PM
To: Lazar, Lijo <[email protected]>; [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>
Subject: RE: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

[AMD Official Use Only]

Quoted 132 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, March 28, 2022 11:48 AM
To: Russell, Kent <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

Quoted 43 lines · Kent

[AMD Official Use Only]

Responses inline

Quoted 39 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, March 28, 2022 11:18 AM
To: Russell, Kent <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

Quoted 8 lines · Kent Russell

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
v3: Fix style warning

Review

Quoted 7 lines
---
   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   | 36 +++++++++++++++++++
   3 files changed, 47 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/pm/amdgpu_pm.c

drivers/gpu/drm/amd/pm/amdgpu_pm.c static int default_attr_update(struct amdgpu_device *adev,

Quoted 4 lines

index 4151db2678fb..4a9aabc16fbc 100644

drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
@@ -1993,6 +1993,7 @@ static int default_attr_update(struct amdgpu_device *adev,

struct amdgpu_device_

Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
             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;
                     break;
             default:

diff --git

Quoted 5 lines
Quoted 5 lines

a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h

Quoted 3 lines

index 3e4a314ef925..58f977320d06 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h
+++

b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h

Quoted 28 lines
Quoted 20 lines
Quoted 20 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +5 -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;
 
Quoted 7 lines

drivers/gpu/drm/amd/pm/amdgpu_pm.c typedef struct { · line 1487

Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +4 -0
+  //PMFW-8711
+  uint32_t PublicSerialNumLower32;
+  uint32_t PublicSerialNumUpper32;
+

Is this the case for other ASICs also which share the metrics data with Sienna?

Quoted 1 line

No, only for Sienna Cichlid. The PMFW guys didn't implement it for Navy Flounder or

Dimgrey Cavefish.

Quoted 37 lines
Quoted 27 lines

Review

Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+  uint16_t Padding16_2;
   } SmuMetrics_V2_t;
 
   typedef struct {
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_setup_pptable(struct smu_context

Quoted 4 lines

index 38f04836c82f..550458f6246a 100644

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -0
@@ -481,6 +481,41 @@ static int sienna_cichlid_setup_pptable(struct smu_context

*smu)

Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +11 -0
     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;
+   bool use_metrics_v2;
+   int ret;
Quoted 9 lines

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_setup_pptable(struct smu_context *smu) · line 499

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +5 -0
+
+   /* Only supported as of version 0.58.83.0 */
+   if (smu->smc_fw_version < 0x3A5300)
+           return;
+

Since this is shared with other ASICs, I guess this check itself may not be enough. This function may be skipped if it's not MP1 11.0.7 or GC 10.3.0?

Quoted 1 line

Since the sysfs file is only supported on Sienna Cichlid (10.3.0), is it a concern since the tie-

in won't exist on the other SMU11-based ASICs? And this function is only referenced by sienna_cichlid, unless I misunderstood something (and someone else uses sienna_cichlid_tables_init).

Quoted 1 line
Quoted 5 lines

This function also gets called as part of common init sequence - smu_get_unique_id.
If PMFW version of Navi Flounder/Dimgrey ASIC is greater than Sienna, then it may go to the path which is not intended to be executed on that ASIC.

Would it be sufficient to just confirm the IP_VERSION here too then?
e.g.
/* Only supported as of version 0.58.83.0 and only on Sienna Cichlid (GC 10.3.0)*/ if (smu->smc_fw_version < 0x3A5300 || adev->ip_versions[GC_HWIP][0] != IP_VERSION(10, 3, 0))

          return;

Thus the FW has to be that version, and the IP_VERSION has to be 10.3 ? Or is there a better method to use? Thanks!

Kent

Quoted 42 lines

Thanks,
Lijo

Quoted 38 lines

Kent

Quoted 36 lines

Thanks,
Lijo

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_setup_pptable(struct smu_context *smu)

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +5 -0
+   ret = smu_cmn_get_metrics_table(smu, NULL, false);
+   if (ret)
+           goto out_unlock;
+
+   use_metrics_v2 = ((smu->adev->ip_versions[MP1_HWIP][0] == IP_VERSION(11, 0,

7)) &&

Quoted 18 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +14 -0
+           (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;

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static const struct pptable_funcs sienna_cichlid_ppt_funcs = { · line 4218

Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -0
@@ -4182,6 +4217,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,

Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +1 -0
     .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)
#7 lore raw

RE: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

[AMD Official Use Only]

Thanks Lijo, I'll do another revision to drop the PMFW ticket (I saw it higher up and thought it was standard practice). Once the PMFW gets officially released I'll test it out and make sure that it doesn't get corrupted. I would assume that it would continue to work, but it's been a while since it was first confirmed by the PMFW dev I was working with.

Kent

From: Lazar, Lijo <[email protected]>
Sent: Monday, March 28, 2022 12:08 PM
To: Russell, Kent <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

[AMD Official Use Only]

Yes, that check looks good.

A couple of other things -

PMFW ticket as a comment is not needed.
I remember Satish updating the same struct for smartshift related data. Some additional fields added towards the end. Not sure if Sienna struct also carries those fields. Regardless, you may check if that affects the placement of serial number fields (whether before or after those fields).

Thanks,
Lijo
________________________________
From: Russell, Kent <[email protected]<mailto:[email protected]>>
Sent: Monday, March 28, 2022 9:23:36 PM
To: Lazar, Lijo <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Cc: Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: RE: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

[AMD Official Use Only]

Quoted 132 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]<mailto:[email protected]>>
Sent: Monday, March 28, 2022 11:48 AM
To: Russell, Kent <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>
Cc: Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

Quoted 43 lines · Kent

[AMD Official Use Only]

Responses inline

Quoted 39 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]<mailto:[email protected]>>
Sent: Monday, March 28, 2022 11:18 AM
To: Russell, Kent <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>
Cc: Deucher, Alexander <[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH 2/2] drm/amdgpu: Add unique_id support for sienna cichlid

Quoted 8 lines · Kent Russell

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
v3: Fix style warning

Review

Quoted 7 lines
---
   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   | 36 +++++++++++++++++++
   3 files changed, 47 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/pm/amdgpu_pm.c

drivers/gpu/drm/amd/pm/amdgpu_pm.c static int default_attr_update(struct amdgpu_device *adev,

Quoted 4 lines

index 4151db2678fb..4a9aabc16fbc 100644

drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
@@ -1993,6 +1993,7 @@ static int default_attr_update(struct amdgpu_device *adev,

struct amdgpu_device_

Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
             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;
                     break;
             default:

diff --git

Quoted 5 lines
Quoted 5 lines

a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h

Quoted 3 lines

index 3e4a314ef925..58f977320d06 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h
+++

b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h

Quoted 28 lines
Quoted 20 lines
Quoted 20 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +5 -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;
 
Quoted 7 lines

drivers/gpu/drm/amd/pm/amdgpu_pm.c typedef struct { · line 1487

Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +4 -0
+  //PMFW-8711
+  uint32_t PublicSerialNumLower32;
+  uint32_t PublicSerialNumUpper32;
+

Is this the case for other ASICs also which share the metrics data with Sienna?

Quoted 1 line

No, only for Sienna Cichlid. The PMFW guys didn't implement it for Navy Flounder or

Dimgrey Cavefish.

Quoted 37 lines
Quoted 27 lines

Review

Quoted 7 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+  uint16_t Padding16_2;
   } SmuMetrics_V2_t;
 
   typedef struct {
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_setup_pptable(struct smu_context

Quoted 4 lines

index 38f04836c82f..550458f6246a 100644

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -0
@@ -481,6 +481,41 @@ static int sienna_cichlid_setup_pptable(struct smu_context

*smu)

Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +11 -0
     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;
+   bool use_metrics_v2;
+   int ret;
Quoted 9 lines

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_setup_pptable(struct smu_context *smu) · line 499

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +5 -0
+
+   /* Only supported as of version 0.58.83.0 */
+   if (smu->smc_fw_version < 0x3A5300)
+           return;
+

Since this is shared with other ASICs, I guess this check itself may not be enough. This function may be skipped if it's not MP1 11.0.7 or GC 10.3.0?

Quoted 1 line

Since the sysfs file is only supported on Sienna Cichlid (10.3.0), is it a concern since the tie-

in won't exist on the other SMU11-based ASICs? And this function is only referenced by sienna_cichlid, unless I misunderstood something (and someone else uses sienna_cichlid_tables_init).

Quoted 1 line
Quoted 5 lines

This function also gets called as part of common init sequence - smu_get_unique_id.
If PMFW version of Navi Flounder/Dimgrey ASIC is greater than Sienna, then it may go to the path which is not intended to be executed on that ASIC.

Would it be sufficient to just confirm the IP_VERSION here too then?
e.g.
/* Only supported as of version 0.58.83.0 and only on Sienna Cichlid (GC 10.3.0)*/ if (smu->smc_fw_version < 0x3A5300 || adev->ip_versions[GC_HWIP][0] != IP_VERSION(10, 3, 0))

          return;

Thus the FW has to be that version, and the IP_VERSION has to be 10.3 ? Or is there a better method to use? Thanks!

Kent

Quoted 42 lines

Thanks,
Lijo

Quoted 38 lines

Kent

Quoted 36 lines

Thanks,
Lijo

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_setup_pptable(struct smu_context *smu)

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +5 -0
+   ret = smu_cmn_get_metrics_table(smu, NULL, false);
+   if (ret)
+           goto out_unlock;
+
+   use_metrics_v2 = ((smu->adev->ip_versions[MP1_HWIP][0] == IP_VERSION(11, 0,

7)) &&

Quoted 18 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +14 -0
+           (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;

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static const struct pptable_funcs sienna_cichlid_ppt_funcs = { · line 4218

Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -0
@@ -4182,6 +4217,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,

Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +1 -0
     .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)