Page MenuHomeFreeBSD

amdsmu: Sleep entry/exit hints for PMFW
ClosedPublic

Authored by obiwac on Jan 29 2025, 9:19 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Mar 4, 12:55 PM
Unknown Object (File)
Tue, Mar 3, 9:07 PM
Unknown Object (File)
Mon, Mar 2, 9:32 AM
Unknown Object (File)
Sun, Mar 1, 8:05 PM
Unknown Object (File)
Sun, Mar 1, 5:13 PM
Unknown Object (File)
Sun, Mar 1, 1:14 AM
Unknown Object (File)
Sun, Mar 1, 1:11 AM
Unknown Object (File)
Fri, Feb 27, 10:00 PM

Details

Summary

amdsmu_suspend and amdsmu_resume for sending hints to the AMD SMU power management firmware (PMFW) that we are entering and exiting sleep. We also dump sleep metrics once we tell it we're exiting sleep, so the relevant metrics are updated.

If building for ACPI, set the ACPI_PMC suspend and resume methods added in D48735. These are then called in the acpi_EnterSleepState() function after the SPMC's suspend method (if there is one) and before its resume method respectively.

I don't love the idea of stuffing acpi_EnterSleepState() with all these PMC method calls, but not sure what a more elegant solution to this is. The SMU calls must necessarily be done after and before the equivalent SPMC calls respectively.

Test Plan

I have tested this on the Framework 13 AMD Ryzen 7040 series (Phoenix):

% sysctl dev.amdsmu.0.metrics  
dev.amdsmu.0.metrics.total_time_in_sw_drips: 136191457
dev.amdsmu.0.metrics.time_last_in_sw_drips: 136191457
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: 1
dev.amdsmu.0.metrics.table_version: 3

(Metrics after suspending-to-idle once for a little over 2 min.)

Diff Detail

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

Event Timeline

Pass errors along in enter/exit functions

once added in D48735, this should use the PMC interface too

Use new acpi_pmc interface (see D48735) instead of new methods on device interface, and generally simplify how this is being called in acpi_EnterSleepState().

obiwac added a reviewer: olce.

Include opt_acpi.h for DEV_ACPI

Use eventhandler hooks instead of acpi_pmc interface.

Use acpi_pmc_suspend/acpi_pmc_resume to acpi_late_suspend/acpi_early_resume respectively (at request of olce@).

Rename hooks again + don't check EVENTHANDLER_REGISTER

Don't need to check for NULL if EVENTHANDLER_REGISTER never returns it anyway.

Looks good (some minor remarks in inline comments).

I have a question related to amdsmu but not the change here: Given the logic in amdsmu_cmd(), I concur that the SMU will always return again the same result when re-reading SMU_REG_RESPONSE without any intervening command (except perhaps on a previous timeout)?

sys/kern/bus_if.m
34

(I know it's slightly annoying, but) please commit that separately.

sys/modules/amdsmu/Makefile
11–12

I'd put addition of opt_acpi.h on a separate SRCS+= line.

I have a question related to amdsmu but not the change here: Given the logic in amdsmu_cmd(), I concur that the SMU will always return again the same result when re-reading SMU_REG_RESPONSE without any intervening command (except perhaps on a previous timeout)?

If you're referring to the fact we're clearing it, yeah, just tried it out and, at least on my machine (Phoenix), SMU_REG_RESPONSE contains the same value before setting to SMU_RES_WAIT as the previous call.

sys/kern/bus_if.m
34

i will :)

obiwac marked an inline comment as done.

formatting

This revision is now accepted and ready to land.Wed, Mar 4, 3:27 PM
This revision was automatically updated to reflect the committed changes.