Home

Awesome

ryzen_nb_smu

A fight against Ryzen NorthBridge SMU

Further usage and other information is still under research.

PR and discussions are welcomed.

Background

Some how, I deterimined the method of commiunication between processor and SMU on northbridge of Ryzen processor, so it would be possible to change some power and frequency related settings in OS. Especially for Mobile Raven Ridge platform.

Utils

kmod_pp

Kernel Module to dump and modify pptable.

(Not working, under research)

TODO: Determine why we can't dump pptable

smu_test.c

A userspace tool to make smu service request

Communication Protcol

The registers, RAM and ROM of SMU is wrapped by a couple of register in NorthBridge PCI Config Space.

To communicate with SMU, the procossor need send a service request to SMU by write values to SMU registers.

There are 8 32-bit registers related with service register, MSG, 6×ARG and REP.

MSG is the ID of service request, 6*ARGS are arguments, REP is respond of service request.

Progress of a service request

A table of request ID for MP1

NameIDNote
TestMessage0x1
GetSmuVersion0x2
GetBiosIfVersion0x3
GetNameString0x4
EnableSmuFeatures0x5
DisableSmuFeatures0x6
DramLogSetDramAddrHigh0x7
DramLogSetDramAddrLow0x8
DramLogSetDramSize0x9
DxioTestMessage0xA
ReadCoreCacWeightRegister0xB
SleepEntry0xC
SetGbeStatus0xD
PowerUpGfx0xE
PowerUpSata0xF
PowerDownSata0x10
DisableSataController0x11
SetBiosDramAddrHigh0x12
SetBiosDramAddrLow0x13
SetToolsDramAddrHigh0x14
SetToolsDramAddrLow0x15
TransferTableSmu2Dram0x16
TransferTableDram2Smu0x17
PowerSourceAC0x18
PowerSourceDC0x19
SetSustainedPowerLimit0x1A
SetFastPPTLimit0x1B
SetSlowPPTLimit0x1C
SetSlowPPTTimeConstant0x1D
SetStapmTimeConstant0x1E
SetTctlMax0x1F
SetVrmCurrentLimit0x20
SetVrmSocCurrentLimit0x21
SetVrmMaximumCurrentLimit0x22
SetVrmSocMaximumCurrentLimit0x23
SetPSI0CurrentLimit0x24
SetPSI0SocCurrentLimit0x25
SetProchotDeassertionRampTime0x26
UpdateSkinTempError0x27
SetGpuApertureLow0x28
SetGpuApertureHigh0x29
StartGpuLink0x2A
StopGpuLink0x2B
UsbD3Entry0x2C
UsbD3Exit0x2D
UsbInit0x2E
AcBtcStartCal0x2F
AcBtcStopCal0x30
AcBtcEndCal0x31
DcBtc0x32
BtcRestoreOnS3Resume0x33
SetGpuDeviceId0x34
SetUlvVidOffset0x35
DisablePSI0x36
EnablePostCode0x37
UsbConfigUpdate0x38
SetupUSB31ControllerTrap0x39
SetVddOffVid0x3A
SetVminFrequency0x3B
SetFrequencyMax0x3C
SetGfxclkOverdriveByFreqVid0x3D
PowerGateXgbe0x3E
OC_Disable0x3F
OC_VoltageMax0x40
OC_FrequencyMax0x41
EnableCC6Filter0x42
GetSustainedPowerAndThmLimit0x43
SetSoftMaxCCLK0x44
SetSoftMinCCLK0x45
SetSoftMaxGfxClk0x46
SetSoftMinGfxClk0x47
SetSoftMaxSocclkByFreq0x48
SetSoftMinSocclkByFreq0x49
SetSoftMaxFclkByFreq0x4A
SetSoftMinFclkByFreq0x4B
SetSoftMaxVcn0x4C
SetSoftMinVcn0x4D
SetSoftMaxLclk0x4E
SetSoftMinLclk0x4F
Message_Count0x50

About "Get" Commands

You can get SMU answer from reading arguments after command. Then decode them or it will be clear result

A table of REP code

NameID
OK0x1
Failed0xFF
UnknownCmd0xFE
CmdRejectedPrereq0xFD
CmdRejectedBusy0xFC

A table of SMU Feature ID

NameBit = argsNote
CCLK_CONTROLLER0 = 1CPU Clock controller - CPU will always work at 1600MHz
FAN_CONTROLLER1 = 2Fan will be always 4400 RPM or more
DATA_CALCULATION2 = 4Disable or Enable CPU power states. No more changing powers (besides STAPM) and voltages are static
PPT3 = 8Disable or Enable Slow and Fast Power Limits
TDC4 = 10Disable or Enable TDC Current limits
THERMAL5 = 20CPU, SoC and iGPU temperature controller disabling
FIT6 = 40Monitors reliability and failure predictions
EDC7 = 80Nothing happens
PLL_POWER_DOWN8 = 100Power down state of phase-locked loops to save power
ULV9 = 200ULV voltage for power saving mode enablement
VDDOFF10 = 400Voltage rail off DEBUG PStates voltage control
VCN_DPM11 = 800Locking max VCN clock to 400 MHz while disabled
ACP_DPM12 = 1000Locking NB-Azalia (audio over iGPU) to 400 MHz wh disabl
ISP_DPM13 = 2000Locking Image Signal Processor to 100 MHz if disabled
FCLK_DPM14 = 4000FCLK clock locking? After disabling
SOCCLK_DPM15 = 8000Locking max SoC clock to 200 MHz while disabled
MP0CLK_DPM16 = 10000MP0 clocks group clock locking? After disabling
LCLK_DPM17 = 20000Data Latch clock locking? After disabling
SHUBCLK_DPM18 = 40000System hub clock locking? After disabling
DCEFCLK_DPM19 = 80000Nothing happens
GFX_DPM20 = 100000Locking max iGPU clock to 400 MHz while disabled
DS_GFXCLK21 = 200000Allow change GFX_CLK from SMU
DS_SOCCLK22 = 400000Allow change SOC_CLK from SMU
DS_LCLK23 = 800000Allow change LCLK from SMU
DS_DCEFCLK24 = 1000000Allow change DCEFCLK from SMU
DS_SHUBCLK25 = 2000000Allow change SystemHUB_CLK from SMU
RM26 = 4000000Resource management engine?
S0i227 = 8000000Pstate S0i2 for low power idle
WHISPER_MODE28 = 10000000Whisper event start-stop
DS_FCLK29 = 20000000Allow change FCLK from SMU
DS_SMNCLK30 = 40000000Allow change SystemManagementNetworkCLK from SMU
DS_MP1CLK31 = 80000000Allow change MP1 Clocks group from SMU
DS_MP0CLK32 = 0,1Allow change MP0 Clocks group from SMU
MGCG33 = 0,2MemoryGenericClockGating?
DS_FUSE_SRAM34 = 0,4Deep sleep strate for fuse SRAM from SMU
GFX_CKS35 = 0,8DISABLING WILL DISABLE THE GPU!
PSI036 = 0,10PSI0 Currents group
PROCHOT37 = 0,20Disabling will disable PROCHOT and CPU CAN WORK ON 400 MHZ!
CPUOFF38 = 0,40Disabling will disable C-States
STAPM39 = 0,80Disabling will disable STAPM
CORE_CSTATES40 = 0,100Disabling will disable C-States
GFX_DUTY_CYCLE41 = 0,200Duty Cycle for iGPU control
AA_MODE42 = 0,400Enabling will give some performance boost
LIVMIN43 = 0,800Minimum live voltage for RV2
RLC_PACE44 = 0,1000RLC (Run Length Coding) pacing for RV2

-These can be enabled with EnableSmuFeatures (0x5) or disabled with DisableSmuFeatures (0x6)

Example

To enable feature set command to 0x5 and in arguments send value from table args (after "="). For examle to enable STAPM feature you need to send MP1 command 0x5 with arguments 0,80 (send 0 to zero argument and 80 to first, "," is a separator beetwen arguments

PPtable

PowerPlay Table

A table to storage power management information

See AMDGPU Powerplay for more information

Now no way to get RX Vega Mobile Power Play from system

Firmware

Grab from BIOS, reverse engineering in progesss.(Help wanted)

Credit