[PATCH] drm/amdgpu/powerplay: parse fan table for CI asics

Quan, Evan Evan.Quan at amd.com
Thu Dec 3 01:35:37 UTC 2020


[AMD Official Use Only - Internal Distribution Only]

Acked-by: Evan Quan <evan.quan at amd.com>

-----Original Message-----
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of Alex Deucher
Sent: Thursday, December 3, 2020 4:18 AM
To: amd-gfx at lists.freedesktop.org
Cc: Deucher, Alexander <Alexander.Deucher at amd.com>
Subject: [PATCH] drm/amdgpu/powerplay: parse fan table for CI asics

Set up all the parameters required for SMU fan control if supported.

Bug: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.kernel.org%2Fshow_bug.cgi%3Fid%3D201539&data=04%7C01%7Cevan.quan%40amd.com%7C5c05d069b0e04d822a1608d896ff5c89%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637425370804495239%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=WNkQfQiTDGtHx7V8pw2vntXXWeOv6KWA1qENo6wiTAw%3D&reserved=0
Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
---
 .../amd/pm/powerplay/hwmgr/processpptables.c  | 103 +++++++++++++++++-
 1 file changed, 102 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c
index 48d550d26c6a..182118e3fd5f 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c
@@ -24,6 +24,8 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/pci.h>
+
 #include <drm/amdgpu_drm.h>
 #include "processpptables.h"
 #include <atom-types.h>
@@ -980,6 +982,8 @@ static int init_thermal_controller(
 struct pp_hwmgr *hwmgr,
 const ATOM_PPLIB_POWERPLAYTABLE *powerplay_table)
 {
+struct amdgpu_device *adev = hwmgr->adev;
+
 hwmgr->thermal_controller.ucType =
 powerplay_table->sThermalController.ucType;
 hwmgr->thermal_controller.ucI2cLine =
@@ -1004,7 +1008,104 @@ static int init_thermal_controller(
    ATOM_PP_THERMALCONTROLLER_NONE != hwmgr->thermal_controller.ucType,
    PHM_PlatformCaps_ThermalController);

-hwmgr->thermal_controller.use_hw_fan_control = 1;
+        if (powerplay_table->usTableSize >= sizeof(ATOM_PPLIB_POWERPLAYTABLE3)) {
+const ATOM_PPLIB_POWERPLAYTABLE3 *powerplay_table3 =
+(const ATOM_PPLIB_POWERPLAYTABLE3 *)powerplay_table;
+
+if (0 == le16_to_cpu(powerplay_table3->usFanTableOffset)) {
+hwmgr->thermal_controller.use_hw_fan_control = 1;
+return 0;
+} else {
+const ATOM_PPLIB_FANTABLE *fan_table =
+(const ATOM_PPLIB_FANTABLE *)(((unsigned long)powerplay_table) +
+      le16_to_cpu(powerplay_table3->usFanTableOffset));
+
+if (1 <= fan_table->ucFanTableFormat) {
+hwmgr->thermal_controller.advanceFanControlParameters.ucTHyst =
+fan_table->ucTHyst;
+hwmgr->thermal_controller.advanceFanControlParameters.usTMin =
+le16_to_cpu(fan_table->usTMin);
+hwmgr->thermal_controller.advanceFanControlParameters.usTMed =
+le16_to_cpu(fan_table->usTMed);
+hwmgr->thermal_controller.advanceFanControlParameters.usTHigh =
+le16_to_cpu(fan_table->usTHigh);
+hwmgr->thermal_controller.advanceFanControlParameters.usPWMMin =
+le16_to_cpu(fan_table->usPWMMin);
+hwmgr->thermal_controller.advanceFanControlParameters.usPWMMed =
+le16_to_cpu(fan_table->usPWMMed);
+hwmgr->thermal_controller.advanceFanControlParameters.usPWMHigh =
+le16_to_cpu(fan_table->usPWMHigh);
+hwmgr->thermal_controller.advanceFanControlParameters.usTMax = 10900;
+hwmgr->thermal_controller.advanceFanControlParameters.ulCycleDelay = 100000;
+
+phm_cap_set(hwmgr->platform_descriptor.platformCaps,
+    PHM_PlatformCaps_MicrocodeFanControl);
+}
+
+if (2 <= fan_table->ucFanTableFormat) {
+const ATOM_PPLIB_FANTABLE2 *fan_table2 =
+(const ATOM_PPLIB_FANTABLE2 *)(((unsigned long)powerplay_table) +
+       le16_to_cpu(powerplay_table3->usFanTableOffset));
+hwmgr->thermal_controller.advanceFanControlParameters.usTMax =
+le16_to_cpu(fan_table2->usTMax);
+}
+
+if (3 <= fan_table->ucFanTableFormat) {
+const ATOM_PPLIB_FANTABLE3 *fan_table3 =
+(const ATOM_PPLIB_FANTABLE3 *) (((unsigned long)powerplay_table) +
+le16_to_cpu(powerplay_table3->usFanTableOffset));
+
+hwmgr->thermal_controller.advanceFanControlParameters.ucFanControlMode =
+fan_table3->ucFanControlMode;
+
+if ((3 == fan_table->ucFanTableFormat) &&
+    (0x67B1 == adev->pdev->device))
+hwmgr->thermal_controller.advanceFanControlParameters.usDefaultMaxFanPWM =
+47;
+else
+hwmgr->thermal_controller.advanceFanControlParameters.usDefaultMaxFanPWM =
+le16_to_cpu(fan_table3->usFanPWMMax);
+
+hwmgr->thermal_controller.advanceFanControlParameters.usDefaultFanOutputSensitivity =
+4836;
+hwmgr->thermal_controller.advanceFanControlParameters.usFanOutputSensitivity =
+le16_to_cpu(fan_table3->usFanOutputSensitivity);
+}
+
+if (6 <= fan_table->ucFanTableFormat) {
+const ATOM_PPLIB_FANTABLE4 *fan_table4 =
+(const ATOM_PPLIB_FANTABLE4 *)(((unsigned long)powerplay_table) +
+       le16_to_cpu(powerplay_table3->usFanTableOffset));
+
+phm_cap_set(hwmgr->platform_descriptor.platformCaps,
+    PHM_PlatformCaps_FanSpeedInTableIsRPM);
+
+hwmgr->thermal_controller.advanceFanControlParameters.usDefaultMaxFanRPM =
+le16_to_cpu(fan_table4->usFanRPMMax);
+}
+
+if (7 <= fan_table->ucFanTableFormat) {
+const ATOM_PPLIB_FANTABLE5 *fan_table5 =
+(const ATOM_PPLIB_FANTABLE5 *)(((unsigned long)powerplay_table) +
+       le16_to_cpu(powerplay_table3->usFanTableOffset));
+
+if (0x67A2 == adev->pdev->device ||
+    0x67A9 == adev->pdev->device ||
+    0x67B9 == adev->pdev->device) {
+phm_cap_set(hwmgr->platform_descriptor.platformCaps,
+    PHM_PlatformCaps_GeminiRegulatorFanControlSupport);
+hwmgr->thermal_controller.advanceFanControlParameters.usFanCurrentLow =
+le16_to_cpu(fan_table5->usFanCurrentLow);
+hwmgr->thermal_controller.advanceFanControlParameters.usFanCurrentHigh =
+le16_to_cpu(fan_table5->usFanCurrentHigh);
+hwmgr->thermal_controller.advanceFanControlParameters.usFanRPMLow =
+le16_to_cpu(fan_table5->usFanRPMLow);
+hwmgr->thermal_controller.advanceFanControlParameters.usFanRPMHigh =
+le16_to_cpu(fan_table5->usFanRPMHigh);
+}
+}
+}
+}

 return 0;
 }
--
2.25.4

_______________________________________________
amd-gfx mailing list
amd-gfx at lists.freedesktop.org
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7Cevan.quan%40amd.com%7C5c05d069b0e04d822a1608d896ff5c89%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637425370804495239%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=inchXNJJ9G5l8tyMG%2FPRHR7yXBU%2FB3btNQwIGFI4uQ8%3D&reserved=0


More information about the amd-gfx mailing list