Page MenuHomeFreeBSD

acpi_powerres: Fix turning off power resources on first D-state switch
Needs ReviewPublic

Authored by obiwac_gmail.com on Jan 8 2025, 11:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 22, 5:51 AM
Unknown Object (File)
Mar 24 2025, 4:25 AM
Unknown Object (File)
Mar 16 2025, 2:37 AM
Unknown Object (File)
Feb 19 2025, 9:19 PM
Unknown Object (File)
Feb 16 2025, 9:23 PM
Unknown Object (File)
Feb 4 2025, 7:14 PM
Unknown Object (File)
Jan 30 2025, 2:14 AM
Unknown Object (File)
Jan 29 2025, 12:18 PM
Subscribers

Details

Summary

The power resource dependencies for each _PRx object are discovered and cached in ac_prx on the power consumer struct (struct acpi_powerconsumer) when a power consumer is registered. This is done in acpi_pwr_get_power_resources. ACPI guarantees these _PRx objects will evaluate to the same thing each time they are called.

This discovery process also registers those power resources, which were previously only registered when they were referenced by the relevant _PRx object for the target D-state when switching. This meant that the first D-state switch for a power consumer would not turn off any power resources as they wouldn't have been registered yet. This revision fixes this.

ac_prx will be used by subsequent patches.

This was split out from D48294.

Sponsored by: The FreeBSD Foundation

Test Plan

I have tested this on the Framework 13 AMD Ryzen 7040 series. All devices are able to suspend/resume fine.

I don't know if this will make a significant difference, but since devices will now go into D3cold (the power resources under _PR3 wouldn't be turned off previously, which is needed for D3cold), this might make suspended devices use less power (devctl suspend/resume <device>).

Diff Detail

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

Event Timeline

sys/dev/acpica/acpi_powerres.c
277

reslist_object leaked

281

Style: 4 space indent, not open paren indent, here and elsewhere.

329

You're ignoring errors here. Why have them returned?
And when you can't allocate memory or whatever, what's the right evasive action?