Skip to contentSkip to conversation

drm/amd/pm: correct the checks for fan attributes support

PATCH In review Evan Quan 2 participants 7 messages Jan 10, 2022 – Jan 11, 2022

Subsystems (3)
lore
Share & tools
lore

Evan Quan

author
#0 lore raw

PATCH 1/1 drm/amd/pm: correct the checks for fan attributes support

Before we relied on the return values from the corresponding interfaces. That is with low efficiency. And the wrong intermediate variable used makes the fan mode stuck at manual mode which then causes overheating in 3D graphics tests.

Change-Id Ia93ccf3b929c12e6d10b50c8f3596783ac63f0e3
---
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c     | 23 +++++++++++++++++++++++
 drivers/gpu/drm/amd/pm/amdgpu_pm.c      | 20 ++++++++++----------
 drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 12 ++++++++++++
 3 files changed, 45 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +23 -0
index 68d2e80a673b..e732418a9558 100644
@@ -1547,3 +1547,26 @@ int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,
 
 	return ret;
 }
+
+int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device *adev,
+					  enum fan_operation_id id)
+{
+	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+
+	switch (id) {
+	case FAN_CONTROL_MODE_RETRIEVING:
+		return pp_funcs->get_fan_control_mode ? 1 : 0;
+	case FAN_CONTROL_MODE_SETTING:
+		return pp_funcs->set_fan_control_mode ? 1 : 0;
+	case FAN_SPEED_PWM_RETRIEVING:
+		return pp_funcs->get_fan_speed_pwm ? 1 : 0;
+	case FAN_SPEED_PWM_SETTING:
+		return pp_funcs->set_fan_speed_pwm ? 1 : 0;
+	case FAN_SPEED_RPM_RETRIEVING:
+		return pp_funcs->get_fan_speed_rpm ? 1 : 0;
+	case FAN_SPEED_RPM_SETTING:
+		return pp_funcs->set_fan_speed_rpm ? 1 : 0;
+	default:
+		return 0;
+	}
+}
drivers/gpu/drm/amd/pm/amdgpu_pm.c +10 -10
index d3eab245e0fe..57721750c51a 100644
@@ -3263,15 +3263,15 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
 		return 0;
 
 	/* mask fan attributes if we have no bindings for this asic to expose */
-	if (((amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL) &&
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_PWM_RETRIEVING) &&
 	      attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't query fan */
-	    ((amdgpu_dpm_get_fan_control_mode(adev, &speed) == -EOPNOTSUPP) &&
+	    (!amdgpu_dpm_is_fan_operation_supported(adev, FAN_CONTROL_MODE_RETRIEVING) &&
 	     attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't query state */
 		effective_mode &= ~S_IRUGO;
 
-	if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL) &&
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_PWM_SETTING) &&
 	      attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't manage fan */
-	      ((amdgpu_dpm_set_fan_control_mode(adev, speed) == -EOPNOTSUPP) &&
+	    (!amdgpu_dpm_is_fan_operation_supported(adev, FAN_CONTROL_MODE_SETTING) &&
 	      attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't manage state */
 		effective_mode &= ~S_IWUSR;
 
@@ -3291,16 +3291,16 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
 		return 0;
 
 	/* hide max/min values if we can't both query and manage the fan */
-	if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL) &&
-	      (amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL) &&
-	      (amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL) &&
-	      (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL)) &&
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_PWM_SETTING) &&
+	     !amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_PWM_RETRIEVING) &&
+	     !amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_RPM_SETTING) &&
+	     !amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_RPM_RETRIEVING)) &&
 	    (attr == &sensor_dev_attr_pwm1_max.dev_attr.attr ||
 	     attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))
 		return 0;
 
-	if ((amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL) &&
-	     (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL) &&
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_RPM_SETTING) &&
+	     !amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_RPM_RETRIEVING)) &&
 	     (attr == &sensor_dev_attr_fan1_max.dev_attr.attr ||
 	     attr == &sensor_dev_attr_fan1_min.dev_attr.attr))
 		return 0;
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +12 -0
index ba857ca75392..9e18151a3c46 100644
@@ -330,6 +330,16 @@ struct amdgpu_pm {
 	bool			pp_force_state_enabled;
 };
 
+enum fan_operation_id
+{
+	FAN_CONTROL_MODE_RETRIEVING = 0,
+	FAN_CONTROL_MODE_SETTING    = 1,
+	FAN_SPEED_PWM_RETRIEVING    = 2,
+	FAN_SPEED_PWM_SETTING       = 3,
+	FAN_SPEED_RPM_RETRIEVING    = 4,
+	FAN_SPEED_RPM_SETTING       = 5,
+};
+
 u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev);
 int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors sensor,
 			   void *data, uint32_t *size);
@@ -510,4 +520,6 @@ enum pp_smu_status amdgpu_dpm_get_uclk_dpm_states(struct amdgpu_device *adev,
 						  unsigned int *num_states);
 int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,
 				   struct dpm_clocks *clock_table);
+int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device *adev,
+					  enum fan_operation_id id);
 #endif
Signature · 1 line
2.29.0
#1 lore raw
Quoted 49 lines · Evan Quan

Before we relied on the return values from the corresponding interfaces. That is with low efficiency. And the wrong intermediate variable used makes the fan mode stuck at manual mode which then causes overheating in 3D graphics tests.

Change-Id Ia93ccf3b929c12e6d10b50c8f3596783ac63f0e3
---
  drivers/gpu/drm/amd/pm/amdgpu_dpm.c     | 23 +++++++++++++++++++++++
  drivers/gpu/drm/amd/pm/amdgpu_pm.c      | 20 ++++++++++----------
  drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 12 ++++++++++++
  3 files changed, 45 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +23 -0
index 68d2e80a673b..e732418a9558 100644
@@ -1547,3 +1547,26 @@ int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,
 
  	return ret;
  }
+
+int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device *adev,
+					  enum fan_operation_id id)
+{
+	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+
+	switch (id) {
+	case FAN_CONTROL_MODE_RETRIEVING:
+		return pp_funcs->get_fan_control_mode ? 1 : 0;
+	case FAN_CONTROL_MODE_SETTING:
+		return pp_funcs->set_fan_control_mode ? 1 : 0;
+	case FAN_SPEED_PWM_RETRIEVING:
+		return pp_funcs->get_fan_speed_pwm ? 1 : 0;
+	case FAN_SPEED_PWM_SETTING:
+		return pp_funcs->set_fan_speed_pwm ? 1 : 0;
+	case FAN_SPEED_RPM_RETRIEVING:
+		return pp_funcs->get_fan_speed_rpm ? 1 : 0;
+	case FAN_SPEED_RPM_SETTING:
+		return pp_funcs->set_fan_speed_rpm ? 1 : 0;
+	default:
+		return 0;
+	}
+}
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
index d3eab245e0fe..57721750c51a 100644

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj, · line 3266

Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -1
@@ -3263,15 +3263,15 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
  		return 0;
 
  	/* mask fan attributes if we have no bindings for this asic to expose */
-	if (((amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL) &&
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_PWM_RETRIEVING) &&

As per the current logic, it's really checking the hardware registers. For ex: we could have some SKUs that have PMFW based fan control and for some other SKUs, AIBs could be having a different cooling solution which doesn't make use of PMFW.

Quoted 16 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +3 -3
  	      attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't query fan */
-	    ((amdgpu_dpm_get_fan_control_mode(adev, &speed) == -EOPNOTSUPP) &&
+	    (!amdgpu_dpm_is_fan_operation_supported(adev, FAN_CONTROL_MODE_RETRIEVING) &&
  	     attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't query state */
  		effective_mode &= ~S_IRUGO;
 
-	if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL) &&
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_PWM_SETTING) &&
  	      attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't manage fan */
-	      ((amdgpu_dpm_set_fan_control_mode(adev, speed) == -EOPNOTSUPP) &&
+	    (!amdgpu_dpm_is_fan_operation_supported(adev, FAN_CONTROL_MODE_SETTING) &&
  	      attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't manage state */
  		effective_mode &= ~S_IWUSR;
 
@@ -3291,16 +3291,16 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
  		return 0;

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj, · line 3297

Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +4 -4
 
  	/* hide max/min values if we can't both query and manage the fan */
-	if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL) &&
-	      (amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL) &&
-	      (amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL) &&
-	      (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL)) &&
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_PWM_SETTING) &&
+	     !amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_PWM_RETRIEVING) &&
+	     !amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_RPM_SETTING) &&
+	     !amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_RPM_RETRIEVING)) &&

If this is the case, I think we should set pm.no_fan since nothing is possible.

Thanks,
Lijo

Quoted 40 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +2 -2
  	    (attr == &sensor_dev_attr_pwm1_max.dev_attr.attr ||
  	     attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))
  		return 0;
 
-	if ((amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL) &&
-	     (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL) &&
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_RPM_SETTING) &&
+	     !amdgpu_dpm_is_fan_operation_supported(adev, FAN_SPEED_RPM_RETRIEVING)) &&
  	     (attr == &sensor_dev_attr_fan1_max.dev_attr.attr ||
  	     attr == &sensor_dev_attr_fan1_min.dev_attr.attr))
  		return 0;
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +12 -0
index ba857ca75392..9e18151a3c46 100644
@@ -330,6 +330,16 @@ struct amdgpu_pm {
  	bool			pp_force_state_enabled;
  };
 
+enum fan_operation_id
+{
+	FAN_CONTROL_MODE_RETRIEVING = 0,
+	FAN_CONTROL_MODE_SETTING    = 1,
+	FAN_SPEED_PWM_RETRIEVING    = 2,
+	FAN_SPEED_PWM_SETTING       = 3,
+	FAN_SPEED_RPM_RETRIEVING    = 4,
+	FAN_SPEED_RPM_SETTING       = 5,
+};
+
  u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev);
  int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors sensor,
  			   void *data, uint32_t *size);
@@ -510,4 +520,6 @@ enum pp_smu_status amdgpu_dpm_get_uclk_dpm_states(struct amdgpu_device *adev,
  						  unsigned int *num_states);
  int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,
  				   struct dpm_clocks *clock_table);
+int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device *adev,
+					  enum fan_operation_id id);
  #endif
author
#2 lore raw

[AMD Official Use Only]

Quoted 69 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, January 10, 2022 3:36 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes support

Quoted 3 lines · Evan Quan

Before we relied on the return values from the corresponding interfaces. That is with low efficiency. And the wrong intermediate variable used makes the fan mode stuck at manual mode which then causes overheating

in

Quoted 6 lines

3D graphics tests.

Change-Id Ia93ccf3b929c12e6d10b50c8f3596783ac63f0e3
---
  drivers/gpu/drm/amd/pm/amdgpu_dpm.c     | 23

+++++++++++++++++++++++

Review

Quoted 5 lines
  drivers/gpu/drm/amd/pm/amdgpu_pm.c      | 20 ++++++++++----------
  drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 12 ++++++++++++
  3 files changed, 45 insertions(+), 10 deletions(-)
(quoted diff) +0 -0

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

drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_dpm_clock_table(struct

Quoted 4 lines

index 68d2e80a673b..e732418a9558 100644

drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0 -0
@@ -1547,3 +1547,26 @@ int amdgpu_dpm_get_dpm_clock_table(struct

amdgpu_device *adev,

drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,

Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2 -0
  	return ret;
  }
+
+int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device

*adev,

Review

Quoted 22 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +21 -0
+					  enum fan_operation_id id)
+{
+	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+
+	switch (id) {
+	case FAN_CONTROL_MODE_RETRIEVING:
+		return pp_funcs->get_fan_control_mode ? 1 : 0;
+	case FAN_CONTROL_MODE_SETTING:
+		return pp_funcs->set_fan_control_mode ? 1 : 0;
+	case FAN_SPEED_PWM_RETRIEVING:
+		return pp_funcs->get_fan_speed_pwm ? 1 : 0;
+	case FAN_SPEED_PWM_SETTING:
+		return pp_funcs->set_fan_speed_pwm ? 1 : 0;
+	case FAN_SPEED_RPM_RETRIEVING:
+		return pp_funcs->get_fan_speed_rpm ? 1 : 0;
+	case FAN_SPEED_RPM_SETTING:
+		return pp_funcs->set_fan_speed_rpm ? 1 : 0;
+	default:
+		return 0;
+	}
+}
(quoted diff) +0 -0

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

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t

Quoted 4 lines

index d3eab245e0fe..57721750c51a 100644

drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
@@ -3263,15 +3263,15 @@ static umode_t

hwmon_attributes_visible(struct kobject *kobj,

Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
  		return 0;
 
Quoted 8 lines

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3265

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
  	/* mask fan attributes if we have no bindings for this asic to expose

*/

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3266

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	if (((amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3266

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_RETRIEVING) &&

As per the current logic, it's really checking the hardware registers.

[Quan, Evan] I probably should mention the "current" version you see now is actually a regression introduced by the commit below:
801771de0331 drm/amd/pm: do not expose power implementation details to amdgpu_pm.c

The very early version(which works good) is something like below:
- if (!is_support_sw_smu(adev)) {
- /* mask fan attributes if we have no bindings for this asic to expose */
- if ((!adev->powerplay.pp_funcs->get_fan_speed_pwm &&
- attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't query fan */
- (!adev->powerplay.pp_funcs->get_fan_control_mode &&
- attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't query state */
- effective_mode &= ~S_IRUGO;

So, the changes here are really just back to old working version. It aims to provide a quick fix for the failures reported by CQE.

Quoted 46 lines

For ex: we could have some SKUs that have PMFW based fan control and for some other SKUs, AIBs could be having a different cooling solution which doesn't make use of PMFW.

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3267

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
  	      attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't query

fan */

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3268

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	    ((amdgpu_dpm_get_fan_control_mode(adev, &speed) == -

EOPNOTSUPP) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3268

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	    (!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_CONTROL_MODE_RETRIEVING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3269

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
  	     attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't

query state */

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,

Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
  		effective_mode &= ~S_IRUGO;
 
-	if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3272

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3273

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
  	      attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't

manage fan */

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3274

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      ((amdgpu_dpm_set_fan_control_mode(adev, speed) == -

EOPNOTSUPP) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3274

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	    (!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_CONTROL_MODE_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3275

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
  	      attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't

manage state */

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t

Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
  		effective_mode &= ~S_IWUSR;
 
@@ -3291,16 +3291,16 @@ static umode_t

hwmon_attributes_visible(struct kobject *kobj,

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,

Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
  		return 0;
 
  	/* hide max/min values if we can't both query and manage the fan */
-	if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      (amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      (amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL))

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3294

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_RETRIEVING) &&

Quoted 7 lines

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_RETRIEVING)) &&

If this is the case, I think we should set pm.no_fan since nothing is possible.

[Quan, Evan] Yep, I agree a more optimized version should be something like that. Let's take this a quick solution and do further optimizations later.

BR
Evan

Quoted 52 lines

Thanks,
Lijo

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,

Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
  	    (attr == &sensor_dev_attr_pwm1_max.dev_attr.attr ||
  	     attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))
  		return 0;
 
-	if ((amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	     (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3302

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_RETRIEVING)) &&

Review

Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
  	     (attr == &sensor_dev_attr_fan1_max.dev_attr.attr ||
  	     attr == &sensor_dev_attr_fan1_min.dev_attr.attr))
  		return 0;
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h

Quoted 9 lines

index ba857ca75392..9e18151a3c46 100644

drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2 -0
@@ -330,6 +330,16 @@ struct amdgpu_pm {
  	bool			pp_force_state_enabled;
  };
 
+enum fan_operation_id
+{

drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h struct amdgpu_pm { · line 344

Quoted 10 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +8 -0
+	FAN_CONTROL_MODE_RETRIEVING = 0,
+	FAN_CONTROL_MODE_SETTING    = 1,
+	FAN_SPEED_PWM_RETRIEVING    = 2,
+	FAN_SPEED_PWM_SETTING       = 3,
+	FAN_SPEED_RPM_RETRIEVING    = 4,
+	FAN_SPEED_RPM_SETTING       = 5,
+};
+
  u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev);
  int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum

amd_pp_sensors sensor,

drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h enum pp_smu_status

Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0 -0
  			   void *data, uint32_t *size);
@@ -510,4 +520,6 @@ enum pp_smu_status

amdgpu_dpm_get_uclk_dpm_states(struct amdgpu_device *adev,

drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h enum pp_smu_status amdgpu_dpm_get_uclk_dpm_states(struct amdgpu_device *adev,

Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1 -0
  						  unsigned int *num_states);
  int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,
  				   struct dpm_clocks *clock_table);
+int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device

*adev,

Quoted 3 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1 -0
+					  enum fan_operation_id id);
  #endif
#3 lore raw
Quoted 93 lines · Evan

[AMD Official Use Only]

Quoted 69 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, January 10, 2022 3:36 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes support

Quoted 3 lines · Evan Quan

Before we relied on the return values from the corresponding interfaces. That is with low efficiency. And the wrong intermediate variable used makes the fan mode stuck at manual mode which then causes overheating

in

Quoted 6 lines

3D graphics tests.

Change-Id Ia93ccf3b929c12e6d10b50c8f3596783ac63f0e3
---
   drivers/gpu/drm/amd/pm/amdgpu_dpm.c     | 23

+++++++++++++++++++++++

Review

Quoted 5 lines
   drivers/gpu/drm/amd/pm/amdgpu_pm.c      | 20 ++++++++++----------
   drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 12 ++++++++++++
   3 files changed, 45 insertions(+), 10 deletions(-)
(quoted diff) +0 -0

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

drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_dpm_clock_table(struct

Quoted 4 lines

index 68d2e80a673b..e732418a9558 100644

drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0 -0
@@ -1547,3 +1547,26 @@ int amdgpu_dpm_get_dpm_clock_table(struct

amdgpu_device *adev,

drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,

Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2 -0
   	return ret;
   }
+
+int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device

*adev,

Review

Quoted 22 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +21 -0
+					  enum fan_operation_id id)
+{
+	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+
+	switch (id) {
+	case FAN_CONTROL_MODE_RETRIEVING:
+		return pp_funcs->get_fan_control_mode ? 1 : 0;
+	case FAN_CONTROL_MODE_SETTING:
+		return pp_funcs->set_fan_control_mode ? 1 : 0;
+	case FAN_SPEED_PWM_RETRIEVING:
+		return pp_funcs->get_fan_speed_pwm ? 1 : 0;
+	case FAN_SPEED_PWM_SETTING:
+		return pp_funcs->set_fan_speed_pwm ? 1 : 0;
+	case FAN_SPEED_RPM_RETRIEVING:
+		return pp_funcs->get_fan_speed_rpm ? 1 : 0;
+	case FAN_SPEED_RPM_SETTING:
+		return pp_funcs->set_fan_speed_rpm ? 1 : 0;
+	default:
+		return 0;
+	}
+}
(quoted diff) +0 -0

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

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t

Quoted 4 lines

index d3eab245e0fe..57721750c51a 100644

drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
@@ -3263,15 +3263,15 @@ static umode_t

hwmon_attributes_visible(struct kobject *kobj,

Quoted 2 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
   		return 0;
 
Quoted 8 lines

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3265

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
   	/* mask fan attributes if we have no bindings for this asic to expose

*/

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3266

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	if (((amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3266

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_RETRIEVING) &&

As per the current logic, it's really checking the hardware registers.

[Quan, Evan] I probably should mention the "current" version you see now is actually a regression introduced by the commit below:
801771de0331 drm/amd/pm: do not expose power implementation details to amdgpu_pm.c

The very early version(which works good) is something like below:

(quoted diff) +0 -7
-       if (!is_support_sw_smu(adev)) {
-               /* mask fan attributes if we have no bindings for this asic to expose */
-               if ((!adev->powerplay.pp_funcs->get_fan_speed_pwm &&
-                    attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't query fan */
-                   (!adev->powerplay.pp_funcs->get_fan_control_mode &&
-                    attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't query state */
-                       effective_mode &= ~S_IRUGO;
Quoted 1 line

So, the changes here are really just back to old working version. It aims to provide a quick fix for the failures reported by CQE.

I see. Could you model on it based on below one? This is preferrable rather than introducing new API.

drm/amdgpu/pm: Don't show pp_power_profile_mode for unsupported devices.

Thanks,
Lijo

Quoted 110 lines
Quoted 46 lines

For ex: we could have some SKUs that have PMFW based fan control and for some other SKUs, AIBs could be having a different cooling solution which doesn't make use of PMFW.

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3267

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
   	      attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't query

fan */

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3268

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	    ((amdgpu_dpm_get_fan_control_mode(adev, &speed) == -

EOPNOTSUPP) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3268

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	    (!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_CONTROL_MODE_RETRIEVING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3269

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
   	     attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't

query state */

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,

Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
   		effective_mode &= ~S_IRUGO;
 
-	if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3272

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3273

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
   	      attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't

manage fan */

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3274

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      ((amdgpu_dpm_set_fan_control_mode(adev, speed) == -

EOPNOTSUPP) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3274

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	    (!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_CONTROL_MODE_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3275

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
   	      attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't

manage state */

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t

Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
   		effective_mode &= ~S_IWUSR;
 
@@ -3291,16 +3291,16 @@ static umode_t

hwmon_attributes_visible(struct kobject *kobj,

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,

Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
   		return 0;
 
   	/* hide max/min values if we can't both query and manage the fan */
-	if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      (amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      (amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL))

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3294

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_RETRIEVING) &&

Quoted 7 lines

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_RETRIEVING)) &&

If this is the case, I think we should set pm.no_fan since nothing is possible.

[Quan, Evan] Yep, I agree a more optimized version should be something like that. Let's take this a quick solution and do further optimizations later.

BR
Evan

Quoted 52 lines

Thanks,
Lijo

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,

Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
   	    (attr == &sensor_dev_attr_pwm1_max.dev_attr.attr ||
   	     attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))
   		return 0;
 
-	if ((amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	     (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3302

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_RETRIEVING)) &&

Review

Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
   	     (attr == &sensor_dev_attr_fan1_max.dev_attr.attr ||
   	     attr == &sensor_dev_attr_fan1_min.dev_attr.attr))
   		return 0;
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h

Quoted 9 lines

index ba857ca75392..9e18151a3c46 100644

drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2 -0
@@ -330,6 +330,16 @@ struct amdgpu_pm {
   	bool			pp_force_state_enabled;
   };
 
+enum fan_operation_id
+{

drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h struct amdgpu_pm { · line 344

Quoted 10 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +8 -0
+	FAN_CONTROL_MODE_RETRIEVING = 0,
+	FAN_CONTROL_MODE_SETTING    = 1,
+	FAN_SPEED_PWM_RETRIEVING    = 2,
+	FAN_SPEED_PWM_SETTING       = 3,
+	FAN_SPEED_RPM_RETRIEVING    = 4,
+	FAN_SPEED_RPM_SETTING       = 5,
+};
+
   u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev);
   int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum

amd_pp_sensors sensor,

drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h enum pp_smu_status

Quoted 2 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0 -0
   			   void *data, uint32_t *size);
@@ -510,4 +520,6 @@ enum pp_smu_status

amdgpu_dpm_get_uclk_dpm_states(struct amdgpu_device *adev,

drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h enum pp_smu_status amdgpu_dpm_get_uclk_dpm_states(struct amdgpu_device *adev,

Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1 -0
   						  unsigned int *num_states);
   int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,
   				   struct dpm_clocks *clock_table);
+int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device

*adev,

Quoted 3 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1 -0
+					  enum fan_operation_id id);
   #endif
author
#4 lore raw

[AMD Official Use Only]

Quoted 113 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, January 10, 2022 4:31 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes support

Quoted 31 lines · Evan

[AMD Official Use Only]

Quoted 27 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, January 10, 2022 3:36 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes support

Quoted 4 lines · Evan Quan

Before we relied on the return values from the corresponding interfaces. That is with low efficiency. And the wrong intermediate variable used makes the fan mode stuck at manual mode which then causes overheating

in

Quoted 6 lines

3D graphics tests.

Change-Id Ia93ccf3b929c12e6d10b50c8f3596783ac63f0e3
---
   drivers/gpu/drm/amd/pm/amdgpu_dpm.c     | 23

+++++++++++++++++++++++

Quoted 4 lines
   drivers/gpu/drm/amd/pm/amdgpu_pm.c      | 20 ++++++++++----------
   drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 12 ++++++++++++
   3 files changed, 45 insertions(+), 10 deletions(-)
Quoted 6 lines
Quoted 6 lines

Review

Quoted 1 line
(quoted diff) +0 -0

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

drivers/gpu/drm/amd/pm/amdgpu_dpm.c int

Quoted 4 lines

index 68d2e80a673b..e732418a9558 100644

drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0 -0
@@ -1547,3 +1547,26 @@ int

amdgpu_dpm_get_dpm_clock_table(struct

Quoted 39 lines
Quoted 39 lines

amdgpu_device *adev,

drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,

Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2 -0
   	return ret;
   }
+
+int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device

*adev,

Review

Quoted 22 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +21 -0
+					  enum fan_operation_id id)
+{
+	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+
+	switch (id) {
+	case FAN_CONTROL_MODE_RETRIEVING:
+		return pp_funcs->get_fan_control_mode ? 1 : 0;
+	case FAN_CONTROL_MODE_SETTING:
+		return pp_funcs->set_fan_control_mode ? 1 : 0;
+	case FAN_SPEED_PWM_RETRIEVING:
+		return pp_funcs->get_fan_speed_pwm ? 1 : 0;
+	case FAN_SPEED_PWM_SETTING:
+		return pp_funcs->set_fan_speed_pwm ? 1 : 0;
+	case FAN_SPEED_RPM_RETRIEVING:
+		return pp_funcs->get_fan_speed_rpm ? 1 : 0;
+	case FAN_SPEED_RPM_SETTING:
+		return pp_funcs->set_fan_speed_rpm ? 1 : 0;
+	default:
+		return 0;
+	}
+}
(quoted diff) +0 -0

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

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t

Quoted 4 lines

index d3eab245e0fe..57721750c51a 100644

drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
@@ -3263,15 +3263,15 @@ static umode_t

hwmon_attributes_visible(struct kobject *kobj,

Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
   		return 0;
 
   	/* mask fan attributes if we have no bindings for this asic to

expose

Quoted 8 lines
Quoted 7 lines

*/

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	if (((amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL)

&&

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_RETRIEVING) &&

As per the current logic, it's really checking the hardware registers.

[Quan, Evan] I probably should mention the "current" version you see now

is actually a regression introduced by the commit below:

Quoted 1 line

801771de0331 drm/amd/pm: do not expose power implementation details

to

Review

Quoted 5 lines

amdgpu_pm.c

The very early version(which works good) is something like below:

(quoted diff) +0 -2
-       if (!is_support_sw_smu(adev)) {
-               /* mask fan attributes if we have no bindings for this asic to expose

*/

Review

Quoted 2 lines
(quoted diff) +0 -2
-               if ((!adev->powerplay.pp_funcs->get_fan_speed_pwm &&
-                    attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't

query fan */

Review

Quoted 2 lines
(quoted diff) +0 -2
-                   (!adev->powerplay.pp_funcs->get_fan_control_mode &&
-                    attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't

query state */

Quoted 2 lines

- effective_mode &= ~S_IRUGO;

Quoted 8 lines
Quoted 1 line

So, the changes here are really just back to old working version. It aims to

provide a quick fix for the failures reported by CQE.

I see. Could you model on it based on below one? This is preferrable rather than introducing new API.

drm/amdgpu/pm: Don't show pp_power_profile_mode for unsupported devices.

[Quan, Evan] In fact, those piece of code from the mentioned change was updated as below

        } else if (DEVICE_ATTR_IS(pp_power_profile_mode)) {
                if (amdgpu_dpm_get_power_profile_mode(adev, NULL) == -EOPNOTSUPP)
                        *states = ATTR_STATE_UNSUPPORTED;
        }

As the access for adev->powerplay.pp_funcs from amdgpu_pm.c was forbidden after the pm cleanups. So, we have to rely on some (new)API in amdgpu_dpm.c to do those checks.

A more proper way to cleanup all those attributes support checks stuff is to have a flag like "adev->pm.sysfs_attribtues_flags".
It labels all those sysfs attributes supported on each ASIC. However, considering the ASICs involved and the difference between them, that may be not an easy job.

BR
Evan

Quoted 119 lines

Thanks,
Lijo

Quoted 49 lines
Quoted 49 lines

For ex: we could have some SKUs that have PMFW based fan control and for some other SKUs, AIBs could be having a different cooling solution which doesn't make use of PMFW.

Quoted 2 lines
   	      attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't

query

fan */

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	    ((amdgpu_dpm_get_fan_control_mode(adev, &speed) == -

EOPNOTSUPP) &&

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	    (!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_CONTROL_MODE_RETRIEVING) &&

Quoted 2 lines
   	     attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /*

can't

query state */

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

Quoted 3 lines
   		effective_mode &= ~S_IRUGO;
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)

&&

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_SETTING) &&

Quoted 1 line
   	      attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't

manage fan */

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      ((amdgpu_dpm_set_fan_control_mode(adev, speed) == -

EOPNOTSUPP) &&

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	    (!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_CONTROL_MODE_SETTING) &&

Quoted 2 lines
   	      attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /*

can't

manage state */

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t

Quoted 3 lines
   		effective_mode &= ~S_IWUSR;
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
@@ -3291,16 +3291,16 @@ static umode_t

hwmon_attributes_visible(struct kobject *kobj,

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,

Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
   		return 0;
 
   	/* hide max/min values if we can't both query and manage the fan */
-	if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      (amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      (amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL))

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3294

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_RETRIEVING) &&

Quoted 8 lines
Quoted 7 lines

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_RETRIEVING)) &&

If this is the case, I think we should set pm.no_fan since nothing is possible.

[Quan, Evan] Yep, I agree a more optimized version should be something

like that.

Quoted 46 lines

Let's take this a quick solution and do further optimizations later.

BR
Evan

Quoted 42 lines

Thanks,
Lijo

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,

Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
   	    (attr == &sensor_dev_attr_pwm1_max.dev_attr.attr ||
   	     attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))
   		return 0;
 
-	if ((amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	     (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3302

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_RETRIEVING)) &&

Review

Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
   	     (attr == &sensor_dev_attr_fan1_max.dev_attr.attr ||
   	     attr == &sensor_dev_attr_fan1_min.dev_attr.attr))
   		return 0;
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h

Quoted 9 lines

index ba857ca75392..9e18151a3c46 100644

drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2 -0
@@ -330,6 +330,16 @@ struct amdgpu_pm {
   	bool			pp_force_state_enabled;
   };
 
+enum fan_operation_id
+{

drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h struct amdgpu_pm { · line 344

Quoted 10 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +8 -0
+	FAN_CONTROL_MODE_RETRIEVING = 0,
+	FAN_CONTROL_MODE_SETTING    = 1,
+	FAN_SPEED_PWM_RETRIEVING    = 2,
+	FAN_SPEED_PWM_SETTING       = 3,
+	FAN_SPEED_RPM_RETRIEVING    = 4,
+	FAN_SPEED_RPM_SETTING       = 5,
+};
+
   u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev);
   int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum

amd_pp_sensors sensor,

Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0 -0
   			   void *data, uint32_t *size); @@ -510,4 +520,6 @@

enum

Quoted 10 lines
Quoted 10 lines
Quoted 1 line

pp_smu_status

amdgpu_dpm_get_uclk_dpm_states(struct amdgpu_device *adev,

Quoted 4 lines
   						  unsigned int *num_states);
   int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,
   				   struct dpm_clocks *clock_table);

+int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device

*adev,

Quoted 3 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1 -0
+					  enum fan_operation_id id);
   #endif
#5 lore raw
Quoted 125 lines · Evan

[AMD Official Use Only]

Quoted 113 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, January 10, 2022 4:31 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes support

Quoted 31 lines · Evan

[AMD Official Use Only]

Quoted 27 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, January 10, 2022 3:36 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes support

Quoted 4 lines · Evan Quan

Before we relied on the return values from the corresponding interfaces. That is with low efficiency. And the wrong intermediate variable used makes the fan mode stuck at manual mode which then causes overheating

in

Quoted 6 lines

3D graphics tests.

Change-Id Ia93ccf3b929c12e6d10b50c8f3596783ac63f0e3
---
    drivers/gpu/drm/amd/pm/amdgpu_dpm.c     | 23

+++++++++++++++++++++++

Quoted 4 lines
    drivers/gpu/drm/amd/pm/amdgpu_pm.c      | 20 ++++++++++----------
    drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 12 ++++++++++++
    3 files changed, 45 insertions(+), 10 deletions(-)
Quoted 6 lines
Quoted 6 lines

Review

Quoted 1 line
(quoted diff) +0 -0

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

drivers/gpu/drm/amd/pm/amdgpu_dpm.c int

Quoted 4 lines

index 68d2e80a673b..e732418a9558 100644

drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0 -0
@@ -1547,3 +1547,26 @@ int

amdgpu_dpm_get_dpm_clock_table(struct

Quoted 39 lines
Quoted 39 lines

amdgpu_device *adev,

drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,

Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2 -0
    	return ret;
    }
+
+int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device

*adev,

Review

Quoted 22 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +21 -0
+					  enum fan_operation_id id)
+{
+	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+
+	switch (id) {
+	case FAN_CONTROL_MODE_RETRIEVING:
+		return pp_funcs->get_fan_control_mode ? 1 : 0;
+	case FAN_CONTROL_MODE_SETTING:
+		return pp_funcs->set_fan_control_mode ? 1 : 0;
+	case FAN_SPEED_PWM_RETRIEVING:
+		return pp_funcs->get_fan_speed_pwm ? 1 : 0;
+	case FAN_SPEED_PWM_SETTING:
+		return pp_funcs->set_fan_speed_pwm ? 1 : 0;
+	case FAN_SPEED_RPM_RETRIEVING:
+		return pp_funcs->get_fan_speed_rpm ? 1 : 0;
+	case FAN_SPEED_RPM_SETTING:
+		return pp_funcs->set_fan_speed_rpm ? 1 : 0;
+	default:
+		return 0;
+	}
+}
(quoted diff) +0 -0

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

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t

Quoted 4 lines

index d3eab245e0fe..57721750c51a 100644

drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
@@ -3263,15 +3263,15 @@ static umode_t

hwmon_attributes_visible(struct kobject *kobj,

Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
    		return 0;
 
    	/* mask fan attributes if we have no bindings for this asic to

expose

Quoted 8 lines
Quoted 7 lines

*/

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	if (((amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL)

&&

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_RETRIEVING) &&

As per the current logic, it's really checking the hardware registers.

[Quan, Evan] I probably should mention the "current" version you see now

is actually a regression introduced by the commit below:

Quoted 1 line

801771de0331 drm/amd/pm: do not expose power implementation details

to

Review

Quoted 5 lines

amdgpu_pm.c

The very early version(which works good) is something like below:

(quoted diff) +0 -2
-       if (!is_support_sw_smu(adev)) {
-               /* mask fan attributes if we have no bindings for this asic to expose

*/

Review

Quoted 2 lines
(quoted diff) +0 -2
-               if ((!adev->powerplay.pp_funcs->get_fan_speed_pwm &&
-                    attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't

query fan */

Review

Quoted 2 lines
(quoted diff) +0 -2
-                   (!adev->powerplay.pp_funcs->get_fan_control_mode &&
-                    attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't

query state */

Quoted 2 lines

- effective_mode &= ~S_IRUGO;

Quoted 8 lines
Quoted 1 line

So, the changes here are really just back to old working version. It aims to

provide a quick fix for the failures reported by CQE.

I see. Could you model on it based on below one? This is preferrable rather than introducing new API.

drm/amdgpu/pm: Don't show pp_power_profile_mode for unsupported devices.

Quoted 8 lines

[Quan, Evan] In fact, those piece of code from the mentioned change was updated as below

         } else if (DEVICE_ATTR_IS(pp_power_profile_mode)) {
                 if (amdgpu_dpm_get_power_profile_mode(adev, NULL) == -EOPNOTSUPP)
                         *states = ATTR_STATE_UNSUPPORTED;
         }

As the access for adev->powerplay.pp_funcs from amdgpu_pm.c was forbidden after the pm cleanups. So, we have to rely on some (new)API in amdgpu_dpm.c to do those checks.

To be clear, the model is to use a dummy call to check if the API is implemented -

	amdgpu_dpm_get_fan_speed_rpm(adev, NULL) == -EOPNOTSUPP
	amdgpu_dpm_set_fan_speed_rpm(adev, -1) == -EOPNOTSUPP

That is better instead of adding another API and flags for each set/get API.

Thanks,
Lijo

Quoted 124 lines

A more proper way to cleanup all those attributes support checks stuff is to have a flag like "adev->pm.sysfs_attribtues_flags".
It labels all those sysfs attributes supported on each ASIC. However, considering the ASICs involved and the difference between them, that may be not an easy job.

BR
Evan

Quoted 119 lines

Thanks,
Lijo

Quoted 49 lines
Quoted 49 lines

For ex: we could have some SKUs that have PMFW based fan control and for some other SKUs, AIBs could be having a different cooling solution which doesn't make use of PMFW.

Quoted 2 lines
    	      attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't

query

fan */

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	    ((amdgpu_dpm_get_fan_control_mode(adev, &speed) == -

EOPNOTSUPP) &&

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	    (!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_CONTROL_MODE_RETRIEVING) &&

Quoted 2 lines
    	     attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /*

can't

query state */

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

Quoted 3 lines
    		effective_mode &= ~S_IRUGO;
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)

&&

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_SETTING) &&

Quoted 1 line
    	      attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't

manage fan */

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      ((amdgpu_dpm_set_fan_control_mode(adev, speed) == -

EOPNOTSUPP) &&

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	    (!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_CONTROL_MODE_SETTING) &&

Quoted 2 lines
    	      attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /*

can't

manage state */

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t

Quoted 3 lines
    		effective_mode &= ~S_IWUSR;
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
@@ -3291,16 +3291,16 @@ static umode_t

hwmon_attributes_visible(struct kobject *kobj,

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,

Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
    		return 0;
 
    	/* hide max/min values if we can't both query and manage the fan */
-	if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      (amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      (amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL))

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3294

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_RETRIEVING) &&

Quoted 8 lines
Quoted 7 lines

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_RETRIEVING)) &&

If this is the case, I think we should set pm.no_fan since nothing is possible.

[Quan, Evan] Yep, I agree a more optimized version should be something

like that.

Quoted 46 lines

Let's take this a quick solution and do further optimizations later.

BR
Evan

Quoted 42 lines

Thanks,
Lijo

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,

Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
    	    (attr == &sensor_dev_attr_pwm1_max.dev_attr.attr ||
    	     attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))
    		return 0;
 
-	if ((amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	     (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -EINVAL)

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3302

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_RETRIEVING)) &&

Review

Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
    	     (attr == &sensor_dev_attr_fan1_max.dev_attr.attr ||
    	     attr == &sensor_dev_attr_fan1_min.dev_attr.attr))
    		return 0;
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h

Quoted 9 lines

index ba857ca75392..9e18151a3c46 100644

drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2 -0
@@ -330,6 +330,16 @@ struct amdgpu_pm {
    	bool			pp_force_state_enabled;
    };
 
+enum fan_operation_id
+{

drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h struct amdgpu_pm { · line 344

Quoted 10 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +8 -0
+	FAN_CONTROL_MODE_RETRIEVING = 0,
+	FAN_CONTROL_MODE_SETTING    = 1,
+	FAN_SPEED_PWM_RETRIEVING    = 2,
+	FAN_SPEED_PWM_SETTING       = 3,
+	FAN_SPEED_RPM_RETRIEVING    = 4,
+	FAN_SPEED_RPM_SETTING       = 5,
+};
+
    u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev);
    int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum

amd_pp_sensors sensor,

Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0 -0
    			   void *data, uint32_t *size); @@ -510,4 +520,6 @@

enum

Quoted 10 lines
Quoted 10 lines
Quoted 1 line

pp_smu_status

amdgpu_dpm_get_uclk_dpm_states(struct amdgpu_device *adev,

Quoted 4 lines
    						  unsigned int *num_states);
    int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,
    				   struct dpm_clocks *clock_table);

+int amdgpu_dpm_is_fan_operation_supported(struct amdgpu_device

*adev,

Quoted 3 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1 -0
+					  enum fan_operation_id id);
    #endif
author
#6 lore raw

[AMD Official Use Only]

Quoted 160 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, January 11, 2022 11:32 AM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes support

Quoted 23 lines · Evan

[AMD Official Use Only]

Quoted 19 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, January 10, 2022 4:31 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes support

Quoted 8 lines · Evan

[AMD Official Use Only]

Quoted 4 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, January 10, 2022 3:36 PM
To: Quan, Evan <[email protected]>; amd-

[email protected]

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: correct the checks for fan attributes support

Quoted 1 line · Evan Quan

Before we relied on the return values from the corresponding

interfaces.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

That is with low efficiency. And the wrong intermediate variable used makes the fan mode stuck at manual mode which then causes overheating

in

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

3D graphics tests.

Change-Id Ia93ccf3b929c12e6d10b50c8f3596783ac63f0e3
---
    drivers/gpu/drm/amd/pm/amdgpu_dpm.c     | 23

+++++++++++++++++++++++

Quoted 1 line
    drivers/gpu/drm/amd/pm/amdgpu_pm.c      | 20 ++++++++++-------

---

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines

Review

Quoted 4 lines
    drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 12 ++++++++++++
    3 files changed, 45 insertions(+), 10 deletions(-)
(quoted diff) +0 -0

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

drivers/gpu/drm/amd/pm/amdgpu_dpm.c int

Quoted 4 lines

index 68d2e80a673b..e732418a9558 100644

drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0 -0
@@ -1547,3 +1547,26 @@ int

amdgpu_dpm_get_dpm_clock_table(struct

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

amdgpu_device *adev,

drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,

Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +2 -0
    	return ret;
    }
+
+int amdgpu_dpm_is_fan_operation_supported(struct

amdgpu_device

Quoted 30 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

*adev,

drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device *adev,

Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +3 -0
+					  enum fan_operation_id id)
+{
+	const struct amd_pm_funcs *pp_funcs = adev-

powerplay.pp_funcs;

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines

Review

Quoted 19 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +18 -0
+
+	switch (id) {
+	case FAN_CONTROL_MODE_RETRIEVING:
+		return pp_funcs->get_fan_control_mode ? 1 : 0;
+	case FAN_CONTROL_MODE_SETTING:
+		return pp_funcs->set_fan_control_mode ? 1 : 0;
+	case FAN_SPEED_PWM_RETRIEVING:
+		return pp_funcs->get_fan_speed_pwm ? 1 : 0;
+	case FAN_SPEED_PWM_SETTING:
+		return pp_funcs->set_fan_speed_pwm ? 1 : 0;
+	case FAN_SPEED_RPM_RETRIEVING:
+		return pp_funcs->get_fan_speed_rpm ? 1 : 0;
+	case FAN_SPEED_RPM_SETTING:
+		return pp_funcs->set_fan_speed_rpm ? 1 : 0;
+	default:
+		return 0;
+	}
+}
(quoted diff) +0 -0

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

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t

Quoted 4 lines

index d3eab245e0fe..57721750c51a 100644

drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
@@ -3263,15 +3263,15 @@ static umode_t

hwmon_attributes_visible(struct kobject *kobj,

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
    		return 0;
 
    	/* mask fan attributes if we have no bindings for this asic

to expose

*/

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	if (((amdgpu_dpm_get_fan_speed_pwm(adev, &speed) ==

-EINVAL)

Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

&&

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_RETRIEVING) &&

As per the current logic, it's really checking the hardware registers.

[Quan, Evan] I probably should mention the "current" version you see now

is actually a regression introduced by the commit below:

Quoted 1 line

801771de0331 drm/amd/pm: do not expose power implementation

details

Quoted 6 lines
Quoted 6 lines

to

Quoted 5 lines

amdgpu_pm.c

The very early version(which works good) is something like below:

(quoted diff) +0 -2
-       if (!is_support_sw_smu(adev)) {
-               /* mask fan attributes if we have no bindings for this asic to

expose

Quoted 6 lines
Quoted 6 lines

*/

Review

Quoted 2 lines
(quoted diff) +0 -2
-               if ((!adev->powerplay.pp_funcs->get_fan_speed_pwm &&
-                    attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /* can't

query fan */

Quoted 2 lines
(quoted diff) +0 -2
-                   (!adev->powerplay.pp_funcs->get_fan_control_mode &&
-                    attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /*

can't

Quoted 5 lines
Quoted 5 lines

query state */

Quoted 4 lines

- effective_mode &= ~S_IRUGO;

So, the changes here are really just back to old working version. It aims to

Quoted 8 lines
Quoted 7 lines

provide a quick fix for the failures reported by CQE.

I see. Could you model on it based on below one? This is preferrable rather than introducing new API.

drm/amdgpu/pm: Don't show pp_power_profile_mode for unsupported devices.

[Quan, Evan] In fact, those piece of code from the mentioned change was

updated as below

Quoted 2 lines
         } else if (DEVICE_ATTR_IS(pp_power_profile_mode)) {
                 if (amdgpu_dpm_get_power_profile_mode(adev, NULL) == -

EOPNOTSUPP)

Quoted 3 lines
                         *states = ATTR_STATE_UNSUPPORTED;
         }

As the access for adev->powerplay.pp_funcs from amdgpu_pm.c was

forbidden after the pm cleanups.

Quoted 1 line

So, we have to rely on some (new)API in amdgpu_dpm.c to do those

checks.

Quoted 1 line
Quoted 7 lines

To be clear, the model is to use a dummy call to check if the API is implemented -

	amdgpu_dpm_get_fan_speed_rpm(adev, NULL) == -EOPNOTSUPP
	amdgpu_dpm_set_fan_speed_rpm(adev, -1) == -EOPNOTSUPP

That is better instead of adding another API and flags for each set/get API.

[Quan, Evan] I see. OK, I can refactor this patch that way.

BR
Evan

Quoted 149 lines

Thanks,
Lijo

Quoted 1 line

A more proper way to cleanup all those attributes support checks stuff is to

have a flag like "adev->pm.sysfs_attribtues_flags".

Quoted 1 line

It labels all those sysfs attributes supported on each ASIC. However,

considering the ASICs involved and the difference between them, that may be not an easy job.

Quoted 12 lines

BR
Evan

Quoted 9 lines

Thanks,
Lijo

Quoted 5 lines
Quoted 5 lines

For ex: we could have some SKUs that have PMFW based fan control and for some other SKUs, AIBs could be having a different cooling solution which doesn't make use of PMFW.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
    	      attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /*

can't query

fan */

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	    ((amdgpu_dpm_get_fan_control_mode(adev, &speed) ==

-

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

EOPNOTSUPP) &&

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	    (!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_CONTROL_MODE_RETRIEVING) &&

Quoted 1 line
    	     attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr))

/*

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

can't

query state */

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

Quoted 3 lines
    		effective_mode &= ~S_IRUGO;
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -

EINVAL)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

&&

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_SETTING) &&

Quoted 2 lines
    	      attr == &sensor_dev_attr_pwm1.dev_attr.attr) || /*

can't

manage fan */

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      ((amdgpu_dpm_set_fan_control_mode(adev, speed) ==

-

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

EOPNOTSUPP) &&

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

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	    (!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_CONTROL_MODE_SETTING) &&

Quoted 1 line
    	      attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr))

/*

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line

can't

manage state */

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t

Quoted 3 lines
    		effective_mode &= ~S_IWUSR;
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
@@ -3291,16 +3291,16 @@ static umode_t

hwmon_attributes_visible(struct kobject *kobj,

Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
    		return 0;
 
    	/* hide max/min values if we can't both query and manage

the fan */

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3294

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	if (((amdgpu_dpm_set_fan_speed_pwm(adev, speed) == -

EINVAL)

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      (amdgpu_dpm_get_fan_speed_pwm(adev, &speed) == -

EINVAL)

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      (amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -

EINVAL)

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	      (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -

EINVAL))

Quoted 20 lines
Quoted 20 lines
Quoted 7 lines
Quoted 7 lines

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3294

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3295

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_PWM_RETRIEVING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3296

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_SETTING) &&

Quoted 7 lines
Quoted 5 lines

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3297

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_RETRIEVING)) &&

If this is the case, I think we should set pm.no_fan since nothing is possible.

[Quan, Evan] Yep, I agree a more optimized version should be something

like that.

Quoted 5 lines

Let's take this a quick solution and do further optimizations later.

BR
Evan

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Thanks,
Lijo

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t hwmon_attributes_visible(struct kobject *kobj,

Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
    	    (attr == &sensor_dev_attr_pwm1_max.dev_attr.attr ||
    	     attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))
    		return 0;
 
-	if ((amdgpu_dpm_set_fan_speed_rpm(adev, speed) == -

EINVAL)

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -1
-	     (amdgpu_dpm_get_fan_speed_rpm(adev, &speed) == -

EINVAL)

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines

&&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3302

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	if ((!amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_SETTING) &&

drivers/gpu/drm/amd/pm/amdgpu_pm.c static umode_t · line 3303

Quoted 1 line
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
+	     !amdgpu_dpm_is_fan_operation_supported(adev,

FAN_SPEED_RPM_RETRIEVING)) &&

Review

Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
    	     (attr == &sensor_dev_attr_fan1_max.dev_attr.attr ||
    	     attr == &sensor_dev_attr_fan1_min.dev_attr.attr))
    		return 0;
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h

Quoted 9 lines

index ba857ca75392..9e18151a3c46 100644

drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +2 -0
@@ -330,6 +330,16 @@ struct amdgpu_pm {
    	bool			pp_force_state_enabled;
    };
 
+enum fan_operation_id
+{

drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h struct amdgpu_pm { · line 344

Quoted 10 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +8 -0
+	FAN_CONTROL_MODE_RETRIEVING = 0,
+	FAN_CONTROL_MODE_SETTING    = 1,
+	FAN_SPEED_PWM_RETRIEVING    = 2,
+	FAN_SPEED_PWM_SETTING       = 3,
+	FAN_SPEED_RPM_RETRIEVING    = 4,
+	FAN_SPEED_RPM_SETTING       = 5,
+};
+
    u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev);
    int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum

amd_pp_sensors sensor,

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h struct amdgpu_pm { · line 345

Quoted 1 line
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0 -0
    			   void *data, uint32_t *size); @@ -510,4

+520,6 @@

Quoted 4 lines
Quoted 4 lines

enum

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

pp_smu_status

amdgpu_dpm_get_uclk_dpm_states(struct amdgpu_device *adev,

Quoted 1 line

unsigned int

*num_states);

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

int amdgpu_dpm_get_dpm_clock_table(struct amdgpu_device

*adev,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
    				   struct dpm_clocks *clock_table);

+int amdgpu_dpm_is_fan_operation_supported(struct

amdgpu_device

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

*adev,

Quoted 3 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1 -0
+					  enum fan_operation_id id);
    #endif