drm/amd/pm: Update hw mon attributes for GC version 9.4.3
authorAsad Kamal <asad.kamal@amd.com>
Fri, 3 Mar 2023 04:20:21 +0000 (12:20 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 9 Jun 2023 13:54:48 +0000 (09:54 -0400)
Update hw mon attributes for GC Version 9.4.3 to valid ones
on APU and Non APU systems

v2: Group checks along existing one
Added power limit & mclock for gc version 9.4.3

Signed-off-by: Asad Kamal <asad.kamal@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/amdgpu_pm.c

index 58c2246..385d83e 100644 (file)
@@ -3362,7 +3362,8 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
                return 0;
 
        /* Skip crit temp on APU */
-       if ((adev->flags & AMD_IS_APU) && (adev->family >= AMDGPU_FAMILY_CZ) &&
+       if ((((adev->flags & AMD_IS_APU) && (adev->family >= AMDGPU_FAMILY_CZ)) ||
+           (gc_ver == IP_VERSION(9, 4, 3))) &&
            (attr == &sensor_dev_attr_temp1_crit.dev_attr.attr ||
             attr == &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr))
                return 0;
@@ -3395,9 +3396,10 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
              attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't manage state */
                effective_mode &= ~S_IWUSR;
 
-       /* In the case of APUs, this is only implemented on Vangogh */
+       /* not implemented yet for APUs other than GC 10.3.1 (vangogh) and 9.4.3 */
        if (((adev->family == AMDGPU_FAMILY_SI) ||
-            ((adev->flags & AMD_IS_APU) && (gc_ver != IP_VERSION(10, 3, 1)))) &&
+            ((adev->flags & AMD_IS_APU) && (gc_ver != IP_VERSION(10, 3, 1)) &&
+             (gc_ver != IP_VERSION(9, 4, 3)))) &&
            (attr == &sensor_dev_attr_power1_cap_max.dev_attr.attr ||
             attr == &sensor_dev_attr_power1_cap_min.dev_attr.attr ||
             attr == &sensor_dev_attr_power1_cap.dev_attr.attr ||
@@ -3426,25 +3428,39 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
                return 0;
 
        if ((adev->family == AMDGPU_FAMILY_SI ||        /* not implemented yet */
-            adev->family == AMDGPU_FAMILY_KV) &&       /* not implemented yet */
+            adev->family == AMDGPU_FAMILY_KV ||        /* not implemented yet */
+            (gc_ver == IP_VERSION(9, 4, 3))) &&
            (attr == &sensor_dev_attr_in0_input.dev_attr.attr ||
             attr == &sensor_dev_attr_in0_label.dev_attr.attr))
                return 0;
 
-       /* only APUs have vddnb */
-       if (!(adev->flags & AMD_IS_APU) &&
+       /* only APUs other than gc 9,4,3 have vddnb */
+       if ((!(adev->flags & AMD_IS_APU) || (gc_ver == IP_VERSION(9, 4, 3))) &&
            (attr == &sensor_dev_attr_in1_input.dev_attr.attr ||
             attr == &sensor_dev_attr_in1_label.dev_attr.attr))
                return 0;
 
-       /* no mclk on APUs */
-       if ((adev->flags & AMD_IS_APU) &&
+       /* no mclk on APUs other than gc 9,4,3*/
+       if (((adev->flags & AMD_IS_APU) && (gc_ver != IP_VERSION(9, 4, 3))) &&
            (attr == &sensor_dev_attr_freq2_input.dev_attr.attr ||
             attr == &sensor_dev_attr_freq2_label.dev_attr.attr))
                return 0;
 
-       /* only SOC15 dGPUs support hotspot and mem temperatures */
        if (((adev->flags & AMD_IS_APU) || gc_ver < IP_VERSION(9, 0, 0)) &&
+           (gc_ver != IP_VERSION(9, 4, 3)) &&
+           (attr == &sensor_dev_attr_temp2_input.dev_attr.attr ||
+            attr == &sensor_dev_attr_temp2_label.dev_attr.attr))
+               return 0;
+
+       /* Only hotspot temperature for gc 9,4,3*/
+       if ((gc_ver == IP_VERSION(9, 4, 3)) &&
+           (attr == &sensor_dev_attr_temp1_input.dev_attr.attr ||
+            attr == &sensor_dev_attr_temp1_label.dev_attr.attr))
+               return 0;
+
+       /* only SOC15 dGPUs support hotspot and mem temperatures */
+       if (((adev->flags & AMD_IS_APU) || gc_ver < IP_VERSION(9, 0, 0) ||
+           (gc_ver == IP_VERSION(9, 4, 3))) &&
            (attr == &sensor_dev_attr_temp2_crit.dev_attr.attr ||
             attr == &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr ||
             attr == &sensor_dev_attr_temp3_crit.dev_attr.attr ||
@@ -3452,9 +3468,7 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
             attr == &sensor_dev_attr_temp1_emergency.dev_attr.attr ||
             attr == &sensor_dev_attr_temp2_emergency.dev_attr.attr ||
             attr == &sensor_dev_attr_temp3_emergency.dev_attr.attr ||
-            attr == &sensor_dev_attr_temp2_input.dev_attr.attr ||
             attr == &sensor_dev_attr_temp3_input.dev_attr.attr ||
-            attr == &sensor_dev_attr_temp2_label.dev_attr.attr ||
             attr == &sensor_dev_attr_temp3_label.dev_attr.attr))
                return 0;