Page MenuHomeFreeBSD

amdsmu: Get and expose sysctls for metrics about last sleep
Needs ReviewPublic

Authored by obiwac_gmail.com on Wed, Jan 29, 4:14 PM.

Details

Reviewers
jhb
jkim
cem
imp
Summary

Get "log" address with the SMU_MSG_LOG_GETDRAM_ADDR_HI/LO commands. From this, we dump & read metrics about residency in various sleep states (SW DRIPS, S0i2, and S0i3), as well as active durations for the IP blocks on the CPU during the last sleep. On Linux, these fields are called "time condition not met", but I couldn't find any information about what these conditions are. All these metrics are exposed under the dev.amdsmu.0.metrics node.

This is useful for debugging sleep as the residency registers in the _LPI object are not populated (at least on my Phoenix machine).

A dev.amdsmu.0.ip_blocks.XXX node is also created for each IP block, with children for the current active state and time spent active during the last sleep.

I will add an amdsmu(4) manpage on this stack describing what I know about the SMU and documenting these sysctls.

Test Plan

I have tested this on the Framework 13 AMD Ryzen 7040 series (Phoenix), with SMU firmware version 76.70.0:

% sysctl dev.amdsmu.0
dev.amdsmu.0.metrics.total_time_in_sw_drips: 0
dev.amdsmu.0.metrics.time_last_in_sw_drips: 0
dev.amdsmu.0.metrics.total_time_in_s0i3: 0
dev.amdsmu.0.metrics.time_last_in_s0i3: 0
dev.amdsmu.0.metrics.total_time_resuming: 0
dev.amdsmu.0.metrics.time_last_resuming: 0
dev.amdsmu.0.metrics.total_time_entering_s0i3: 0
dev.amdsmu.0.metrics.time_last_entering_s0i3: 0
dev.amdsmu.0.metrics.time_last_in_s0i2: 0
dev.amdsmu.0.metrics.s0i3_last_entry_status: 0
dev.amdsmu.0.metrics.hint_count: 0
dev.amdsmu.0.metrics.table_version: 3
dev.amdsmu.0.ip_blocks.UMSCH.last_time: 0
dev.amdsmu.0.ip_blocks.UMSCH.active: 1
dev.amdsmu.0.ip_blocks.IPU.last_time: 0
dev.amdsmu.0.ip_blocks.IPU.active: 1
dev.amdsmu.0.ip_blocks.JPEG.last_time: 0
dev.amdsmu.0.ip_blocks.JPEG.active: 1
dev.amdsmu.0.ip_blocks.MPM.last_time: 0
dev.amdsmu.0.ip_blocks.MPM.active: 1
dev.amdsmu.0.ip_blocks.USB4_1.last_time: 0
dev.amdsmu.0.ip_blocks.USB4_1.active: 1
dev.amdsmu.0.ip_blocks.USB4_0.last_time: 6442461721
dev.amdsmu.0.ip_blocks.USB4_0.active: 1
dev.amdsmu.0.ip_blocks.USB3_4.last_time: 0
dev.amdsmu.0.ip_blocks.USB3_4.active: 1
dev.amdsmu.0.ip_blocks.USB3_3.last_time: 0
dev.amdsmu.0.ip_blocks.USB3_3.active: 1
dev.amdsmu.0.ip_blocks.USB3_2.last_time: 0
dev.amdsmu.0.ip_blocks.USB3_2.active: 0
dev.amdsmu.0.ip_blocks.LAPIC.last_time: 0
dev.amdsmu.0.ip_blocks.LAPIC.active: 0
dev.amdsmu.0.ip_blocks.USB3_1.last_time: 0
dev.amdsmu.0.ip_blocks.USB3_1.active: 1
dev.amdsmu.0.ip_blocks.USB3_0.last_time: 0
dev.amdsmu.0.ip_blocks.USB3_0.active: 1
dev.amdsmu.0.ip_blocks.DF.last_time: 0
dev.amdsmu.0.ip_blocks.DF.active: 1
dev.amdsmu.0.ip_blocks.NBIO.last_time: 0
dev.amdsmu.0.ip_blocks.NBIO.active: 0
dev.amdsmu.0.ip_blocks.ISP.last_time: 0
dev.amdsmu.0.ip_blocks.ISP.active: 1
dev.amdsmu.0.ip_blocks.VCN.last_time: 0
dev.amdsmu.0.ip_blocks.VCN.active: 1
dev.amdsmu.0.ip_blocks.ACP.last_time: 0
dev.amdsmu.0.ip_blocks.ACP.active: 1
dev.amdsmu.0.ip_blocks.VDD.last_time: 0
dev.amdsmu.0.ip_blocks.VDD.active: 1
dev.amdsmu.0.ip_blocks.GFX.last_time: 0
dev.amdsmu.0.ip_blocks.GFX.active: 0
dev.amdsmu.0.ip_blocks.CPU.last_time: 0
dev.amdsmu.0.ip_blocks.CPU.active: 0
dev.amdsmu.0.ip_blocks.DISPLAY.last_time: 0
dev.amdsmu.0.ip_blocks.DISPLAY.active: 1
dev.amdsmu.0.version_revision: 0
dev.amdsmu.0.version_minor: 70
dev.amdsmu.0.version_major: 76
dev.amdsmu.0.program: 0
dev.amdsmu.0.%parent: hostb0
dev.amdsmu.0.%pnpinfo: 
dev.amdsmu.0.%location: 
dev.amdsmu.0.%driver: amdsmu
dev.amdsmu.0.%desc:

Note that I'm not getting any of the total active times for the IP blocks, as they return garbage on my system. Also the USB4_0 IP block active time during last sleep fluctuates between garbage and the total time spent in SW DRIPS for some reason. I'm getting the same results on Linux so I'm going to chalk this up to firmware weirdness.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 62090
Build 58974: arc lint + arc unit