drm/amd/powerplay: use hardware fan control if no powerplay fan table
authorEvan Quan <evan.quan@amd.com>
Thu, 27 Jun 2019 03:01:04 +0000 (11:01 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 1 Jul 2019 14:14:05 +0000 (09:14 -0500)
Otherwise, you may get divided-by-zero error or corrput the SMU fan
control feature.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Tested-by: Slava Abramov <slava.abramov@amd.com>
Acked-by: Slava Abramov <slava.abramov@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c

index ae64ff7153d627857624e7e0289d7270c36ca467..1cd5a8b5cdc179a30d231cdd1079fec8b410373f 100644 (file)
@@ -916,8 +916,10 @@ static int init_thermal_controller(
                        PHM_PlatformCaps_ThermalController
                  );
 
-       if (0 == powerplay_table->usFanTableOffset)
+       if (0 == powerplay_table->usFanTableOffset) {
+               hwmgr->thermal_controller.use_hw_fan_control = 1;
                return 0;
+       }
 
        fan_table = (const PPTable_Generic_SubTable_Header *)
                (((unsigned long)powerplay_table) +
index c92999aac07c9984d39a8314be242d977606b439..eccb26fddbd0dffecfdb9f324c9aabf3532a16a9 100644 (file)
@@ -694,6 +694,7 @@ struct pp_thermal_controller_info {
        uint8_t ucType;
        uint8_t ucI2cLine;
        uint8_t ucI2cAddress;
+       uint8_t use_hw_fan_control;
        struct pp_fan_info fanInfo;
        struct pp_advance_fan_control_parameters advanceFanControlParameters;
 };
index 2d4cfe14f72e03353c84aad2835a41ed91d85f44..29e641c6a5db46c595c272166e9b77ec9a795c2c 100644 (file)
@@ -2092,6 +2092,10 @@ static int polaris10_thermal_setup_fan_table(struct pp_hwmgr *hwmgr)
                return 0;
        }
 
+       /* use hardware fan control */
+       if (hwmgr->thermal_controller.use_hw_fan_control)
+               return 0;
+
        tmp64 = hwmgr->thermal_controller.advanceFanControlParameters.
                        usPWMMin * duty100;
        do_div(tmp64, 10000);