<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important"> if (adev->asic_type
> CHIP_VEGA20) {</span><br>
<span style="font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important">+ if (gc_ver !=
IP_VERSION(9, 4, 0) && mp1_ver > IP_VERSION(9, 0, 0)) {</span><br style="font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255)">
<span style="font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important"> /* VCN
clocks */</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
[kevin]:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
please put some comments here (why mp1_ver and gc_ver is needed both), it can help developer to understand some backgrounds.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
thanks.<br>
<br>
Reviewed-by: Kevin Wang <kevinyang.wang@amd.com></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important"> </span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Best Regards,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Kevin</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Lazar, Lijo <Lijo.Lazar@amd.com><br>
<b>Sent:</b> Friday, March 25, 2022 4:31 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Zhang, Hawking <Hawking.Zhang@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Wang, Yang(Kevin) <KevinYang.Wang@amd.com>; Quan, Evan <Evan.Quan@amd.com><br>
<b>Subject:</b> [PATCH] drm/amd/pm: Check feature support using IP version</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">Instead of ASIC type, use GC and MP1 IP versions for feature support checks.<br>
<br>
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com><br>
---<br>
drivers/gpu/drm/amd/pm/amdgpu_pm.c | 72 ++++++++++++++++--------------<br>
1 file changed, 39 insertions(+), 33 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c<br>
index 5cd67ddf8495..f89e0ff3f5a4 100644<br>
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c<br>
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c<br>
@@ -1954,8 +1954,9 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_<br>
uint32_t mask, enum amdgpu_device_attr_states *states)<br>
{<br>
struct device_attribute *dev_attr = &attr->dev_attr;<br>
+ uint32_t mp1_ver = adev->ip_versions[MP1_HWIP][0];<br>
+ uint32_t gc_ver = adev->ip_versions[GC_HWIP][0];<br>
const char *attr_name = dev_attr->attr.name;<br>
- enum amd_asic_type asic_type = adev->asic_type;<br>
<br>
if (!(attr->flags & mask)) {<br>
*states = ATTR_STATE_UNSUPPORTED;<br>
@@ -1965,53 +1966,55 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_<br>
#define DEVICE_ATTR_IS(_name) (!strcmp(attr_name, #_name))<br>
<br>
if (DEVICE_ATTR_IS(pp_dpm_socclk)) {<br>
- if (asic_type < CHIP_VEGA10)<br>
+ if (gc_ver < IP_VERSION(9, 0, 0))<br>
*states = ATTR_STATE_UNSUPPORTED;<br>
} else if (DEVICE_ATTR_IS(pp_dpm_dcefclk)) {<br>
- if (asic_type < CHIP_VEGA10 ||<br>
- asic_type == CHIP_ARCTURUS ||<br>
- asic_type == CHIP_ALDEBARAN)<br>
+ if (gc_ver < IP_VERSION(9, 0, 0) ||<br>
+ gc_ver == IP_VERSION(9, 4, 1) ||<br>
+ gc_ver == IP_VERSION(9, 4, 2))<br>
*states = ATTR_STATE_UNSUPPORTED;<br>
} else if (DEVICE_ATTR_IS(pp_dpm_fclk)) {<br>
- if (asic_type < CHIP_VEGA20)<br>
+ if (mp1_ver < IP_VERSION(10, 0, 0))<br>
*states = ATTR_STATE_UNSUPPORTED;<br>
} else if (DEVICE_ATTR_IS(pp_od_clk_voltage)) {<br>
*states = ATTR_STATE_UNSUPPORTED;<br>
if (amdgpu_dpm_is_overdrive_supported(adev))<br>
*states = ATTR_STATE_SUPPORTED;<br>
} else if (DEVICE_ATTR_IS(mem_busy_percent)) {<br>
- if (adev->flags & AMD_IS_APU || asic_type == CHIP_VEGA10)<br>
+ if (adev->flags & AMD_IS_APU || gc_ver == IP_VERSION(9, 0, 1))<br>
*states = ATTR_STATE_UNSUPPORTED;<br>
} else if (DEVICE_ATTR_IS(pcie_bw)) {<br>
/* PCIe Perf counters won't work on APU nodes */<br>
if (adev->flags & AMD_IS_APU)<br>
*states = ATTR_STATE_UNSUPPORTED;<br>
} else if (DEVICE_ATTR_IS(unique_id)) {<br>
- if (asic_type != CHIP_VEGA10 &&<br>
- asic_type != CHIP_VEGA20 &&<br>
- asic_type != CHIP_ARCTURUS &&<br>
- asic_type != CHIP_ALDEBARAN)<br>
+ if (gc_ver != IP_VERSION(9, 0, 1) &&<br>
+ gc_ver != IP_VERSION(9, 4, 0) &&<br>
+ gc_ver != IP_VERSION(9, 4, 1) &&<br>
+ gc_ver != IP_VERSION(9, 4, 2))<br>
*states = ATTR_STATE_UNSUPPORTED;<br>
} else if (DEVICE_ATTR_IS(pp_features)) {<br>
- if (adev->flags & AMD_IS_APU || asic_type < CHIP_VEGA10)<br>
+ if (adev->flags & AMD_IS_APU || gc_ver < IP_VERSION(9, 0, 0))<br>
*states = ATTR_STATE_UNSUPPORTED;<br>
} else if (DEVICE_ATTR_IS(gpu_metrics)) {<br>
- if (asic_type < CHIP_VEGA12)<br>
+ if (gc_ver < IP_VERSION(9, 1, 0))<br>
*states = ATTR_STATE_UNSUPPORTED;<br>
} else if (DEVICE_ATTR_IS(pp_dpm_vclk)) {<br>
- if (!(asic_type == CHIP_VANGOGH || asic_type == CHIP_SIENNA_CICHLID))<br>
+ if (!(gc_ver == IP_VERSION(10, 3, 1) ||<br>
+ gc_ver == IP_VERSION(10, 3, 0)))<br>
*states = ATTR_STATE_UNSUPPORTED;<br>
} else if (DEVICE_ATTR_IS(pp_dpm_dclk)) {<br>
- if (!(asic_type == CHIP_VANGOGH || asic_type == CHIP_SIENNA_CICHLID))<br>
+ if (!(gc_ver == IP_VERSION(10, 3, 1) ||<br>
+ gc_ver == IP_VERSION(10, 3, 0)))<br>
*states = ATTR_STATE_UNSUPPORTED;<br>
} else if (DEVICE_ATTR_IS(pp_power_profile_mode)) {<br>
if (amdgpu_dpm_get_power_profile_mode(adev, NULL) == -EOPNOTSUPP)<br>
*states = ATTR_STATE_UNSUPPORTED;<br>
}<br>
<br>
- switch (asic_type) {<br>
- case CHIP_ARCTURUS:<br>
- case CHIP_ALDEBARAN:<br>
+ switch (gc_ver) {<br>
+ case IP_VERSION(9, 4, 1):<br>
+ case IP_VERSION(9, 4, 2):<br>
/* the Mi series card does not support standalone mclk/socclk/fclk level setting */<br>
if (DEVICE_ATTR_IS(pp_dpm_mclk) ||<br>
DEVICE_ATTR_IS(pp_dpm_socclk) ||<br>
@@ -2026,7 +2029,7 @@ static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_<br>
<br>
if (DEVICE_ATTR_IS(pp_dpm_dcefclk)) {<br>
/* SMU MP1 does not support dcefclk level setting */<br>
- if (asic_type >= CHIP_NAVI10) {<br>
+ if (gc_ver >= IP_VERSION(10, 0, 0)) {<br>
dev_attr->attr.mode &= ~S_IWUGO;<br>
dev_attr->store = NULL;<br>
}<br>
@@ -2864,8 +2867,9 @@ static ssize_t amdgpu_hwmon_show_power_label(struct device *dev,<br>
char *buf)<br>
{<br>
struct amdgpu_device *adev = dev_get_drvdata(dev);<br>
+ uint32_t gc_ver = adev->ip_versions[GC_HWIP][0];<br>
<br>
- if (adev->asic_type == CHIP_VANGOGH)<br>
+ if (gc_ver == IP_VERSION(10, 3, 1))<br>
return sysfs_emit(buf, "%s\n",<br>
to_sensor_dev_attr(attr)->index == PP_PWR_TYPE_FAST ?<br>
"fastPPT" : "slowPPT");<br>
@@ -3177,6 +3181,7 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,<br>
struct device *dev = kobj_to_dev(kobj);<br>
struct amdgpu_device *adev = dev_get_drvdata(dev);<br>
umode_t effective_mode = attr->mode;<br>
+ uint32_t gc_ver = adev->ip_versions[GC_HWIP][0];<br>
<br>
/* under multi-vf mode, the hwmon attributes are all not supported */<br>
if (amdgpu_sriov_vf(adev) && !amdgpu_sriov_is_pp_one_vf(adev))<br>
@@ -3245,18 +3250,18 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,<br>
attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't manage state */<br>
effective_mode &= ~S_IWUSR;<br>
<br>
+ /* not implemented yet for GC 10.3.1 APUs */<br>
if (((adev->family == AMDGPU_FAMILY_SI) ||<br>
- ((adev->flags & AMD_IS_APU) &&<br>
- (adev->asic_type != CHIP_VANGOGH))) && /* not implemented yet */<br>
+ ((adev->flags & AMD_IS_APU) && (gc_ver != IP_VERSION(10, 3, 1)))) &&<br>
(attr == &sensor_dev_attr_power1_cap_max.dev_attr.attr ||<br>
- attr == &sensor_dev_attr_power1_cap_min.dev_attr.attr||<br>
+ attr == &sensor_dev_attr_power1_cap_min.dev_attr.attr ||<br>
attr == &sensor_dev_attr_power1_cap.dev_attr.attr ||<br>
attr == &sensor_dev_attr_power1_cap_default.dev_attr.attr))<br>
return 0;<br>
<br>
+ /* not implemented yet for APUs having <= GC 9.3.0 */<br>
if (((adev->family == AMDGPU_FAMILY_SI) ||<br>
- ((adev->flags & AMD_IS_APU) &&<br>
- (adev->asic_type < CHIP_RENOIR))) && /* not implemented yet */<br>
+ ((adev->flags & AMD_IS_APU) && (gc_ver < IP_VERSION(9, 3, 0)))) &&<br>
(attr == &sensor_dev_attr_power1_average.dev_attr.attr))<br>
return 0;<br>
<br>
@@ -3294,8 +3299,7 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,<br>
return 0;<br>
<br>
/* only SOC15 dGPUs support hotspot and mem temperatures */<br>
- if (((adev->flags & AMD_IS_APU) ||<br>
- adev->asic_type < CHIP_VEGA10) &&<br>
+ if (((adev->flags & AMD_IS_APU) || gc_ver < IP_VERSION(9, 0, 0)) &&<br>
(attr == &sensor_dev_attr_temp2_crit.dev_attr.attr ||<br>
attr == &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr ||<br>
attr == &sensor_dev_attr_temp3_crit.dev_attr.attr ||<br>
@@ -3310,13 +3314,13 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,<br>
return 0;<br>
<br>
/* only Vangogh has fast PPT limit and power labels */<br>
- if (!(adev->asic_type == CHIP_VANGOGH) &&<br>
+ if (!(gc_ver == IP_VERSION(10, 3, 1)) &&<br>
(attr == &sensor_dev_attr_power2_average.dev_attr.attr ||<br>
- attr == &sensor_dev_attr_power2_cap_max.dev_attr.attr ||<br>
+ attr == &sensor_dev_attr_power2_cap_max.dev_attr.attr ||<br>
attr == &sensor_dev_attr_power2_cap_min.dev_attr.attr ||<br>
- attr == &sensor_dev_attr_power2_cap.dev_attr.attr ||<br>
- attr == &sensor_dev_attr_power2_cap_default.dev_attr.attr ||<br>
- attr == &sensor_dev_attr_power2_label.dev_attr.attr))<br>
+ attr == &sensor_dev_attr_power2_cap.dev_attr.attr ||<br>
+ attr == &sensor_dev_attr_power2_cap_default.dev_attr.attr ||<br>
+ attr == &sensor_dev_attr_power2_label.dev_attr.attr))<br>
return 0;<br>
<br>
return effective_mode;<br>
@@ -3421,6 +3425,8 @@ static void amdgpu_debugfs_prints_cpu_info(struct seq_file *m,<br>
<br>
static int amdgpu_debugfs_pm_info_pp(struct seq_file *m, struct amdgpu_device *adev)<br>
{<br>
+ uint32_t mp1_ver = adev->ip_versions[MP1_HWIP][0];<br>
+ uint32_t gc_ver = adev->ip_versions[GC_HWIP][0];<br>
uint32_t value;<br>
uint64_t value64 = 0;<br>
uint32_t query = 0;<br>
@@ -3467,7 +3473,7 @@ static int amdgpu_debugfs_pm_info_pp(struct seq_file *m, struct amdgpu_device *a<br>
if (!amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_ENABLED_SMC_FEATURES_MASK, (void *)&value64, &size))<br>
seq_printf(m, "SMC Feature Mask: 0x%016llx\n", value64);<br>
<br>
- if (adev->asic_type > CHIP_VEGA20) {<br>
+ if (gc_ver != IP_VERSION(9, 4, 0) && mp1_ver > IP_VERSION(9, 0, 0)) {<br>
/* VCN clocks */<br>
if (!amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_VCN_POWER_STATE, (void *)&value, &size)) {<br>
if (!value) {<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>