drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_thermal.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_thermal.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_thermal.c- Extension
.c- Size
- 14446 bytes
- Lines
- 475
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/div64.hsmu7_thermal.hsmu7_hwmgr.hsmu7_common.h
Detected Declarations
function filesfunction smu7_fan_ctrl_get_fan_speed_pwmfunction smu7_fan_ctrl_get_fan_speed_rpmfunction smu7_fan_ctrl_set_static_modefunction smu7_fan_ctrl_set_default_modefunction smu7_fan_ctrl_start_smc_fan_controlfunction smu7_fan_ctrl_stop_smc_fan_controlfunction smu7_fan_ctrl_set_fan_speed_pwmfunction smu7_fan_ctrl_reset_fan_speed_to_defaultfunction smu7_fan_ctrl_set_fan_speed_rpmfunction smu7_thermal_get_temperaturefunction smu7_thermal_set_temperature_rangefunction smu7_thermal_initializefunction smu7_thermal_enable_alertfunction smu7_thermal_disable_alertfunction smu7_thermal_stop_thermal_controllerfunction smu7_thermal_start_smc_fan_controlfunction smu7_start_thermal_controllerfunction smu7_thermal_ctrl_uninitialize_thermal_controller
Annotated Snippet
#include <asm/div64.h>
#include "smu7_thermal.h"
#include "smu7_hwmgr.h"
#include "smu7_common.h"
int smu7_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr,
struct phm_fan_speed_info *fan_speed_info)
{
if (hwmgr->thermal_controller.fanInfo.bNoFan)
return -ENODEV;
fan_speed_info->supports_percent_read = true;
fan_speed_info->supports_percent_write = true;
fan_speed_info->min_percent = 0;
fan_speed_info->max_percent = 100;
if (PP_CAP(PHM_PlatformCaps_FanSpeedInTableIsRPM) &&
hwmgr->thermal_controller.fanInfo.ucTachometerPulsesPerRevolution) {
fan_speed_info->supports_rpm_read = true;
fan_speed_info->supports_rpm_write = true;
fan_speed_info->min_rpm = hwmgr->thermal_controller.fanInfo.ulMinRPM;
fan_speed_info->max_rpm = hwmgr->thermal_controller.fanInfo.ulMaxRPM;
} else {
fan_speed_info->min_rpm = 0;
fan_speed_info->max_rpm = 0;
}
return 0;
}
int smu7_fan_ctrl_get_fan_speed_pwm(struct pp_hwmgr *hwmgr,
uint32_t *speed)
{
uint32_t duty100;
uint32_t duty;
uint64_t tmp64;
if (hwmgr->thermal_controller.fanInfo.bNoFan)
return -ENODEV;
duty100 = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
CG_FDO_CTRL1, FMAX_DUTY100);
duty = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
CG_THERMAL_STATUS, FDO_PWM_DUTY);
if (duty100 == 0)
return -EINVAL;
tmp64 = (uint64_t)duty * 255;
do_div(tmp64, duty100);
*speed = min_t(uint32_t, tmp64, 255);
return 0;
}
int smu7_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t *speed)
{
uint32_t tach_period;
uint32_t crystal_clock_freq;
if (hwmgr->thermal_controller.fanInfo.bNoFan ||
!hwmgr->thermal_controller.fanInfo.ucTachometerPulsesPerRevolution)
return -ENODEV;
tach_period = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
CG_TACH_STATUS, TACH_PERIOD);
if (tach_period == 0)
return -EINVAL;
crystal_clock_freq = amdgpu_asic_get_xclk((struct amdgpu_device *)hwmgr->adev);
*speed = 60 * crystal_clock_freq * 10000 / tach_period;
return 0;
}
/**
* smu7_fan_ctrl_set_static_mode - Set Fan Speed Control to static mode, so that the user can decide what speed to use.
* @hwmgr: the address of the powerplay hardware manager.
* @mode: the fan control mode, 0 default, 1 by percent, 5, by RPM
* Exception: Should always succeed.
*/
int smu7_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, uint32_t mode)
{
if (hwmgr->fan_ctrl_is_in_default_mode) {
hwmgr->fan_ctrl_default_mode =
PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
CG_FDO_CTRL2, FDO_PWM_MODE);
Annotation
- Immediate include surface: `asm/div64.h`, `smu7_thermal.h`, `smu7_hwmgr.h`, `smu7_common.h`.
- Detected declarations: `function files`, `function smu7_fan_ctrl_get_fan_speed_pwm`, `function smu7_fan_ctrl_get_fan_speed_rpm`, `function smu7_fan_ctrl_set_static_mode`, `function smu7_fan_ctrl_set_default_mode`, `function smu7_fan_ctrl_start_smc_fan_control`, `function smu7_fan_ctrl_stop_smc_fan_control`, `function smu7_fan_ctrl_set_fan_speed_pwm`, `function smu7_fan_ctrl_reset_fan_speed_to_default`, `function smu7_fan_ctrl_set_fan_speed_rpm`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.