Page MenuHomeFreeBSD

acpi: Fix panic on poweroff
AbandonedPublic

Authored by obiwac on Sep 17 2025, 9:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Oct 15, 6:58 AM
Unknown Object (File)
Mon, Oct 13, 7:36 AM
Unknown Object (File)
Fri, Oct 10, 4:17 AM
Unknown Object (File)
Fri, Oct 10, 4:17 AM
Unknown Object (File)
Fri, Oct 10, 4:17 AM
Unknown Object (File)
Fri, Oct 10, 4:17 AM
Unknown Object (File)
Thu, Oct 9, 11:01 PM
Unknown Object (File)
Mon, Oct 6, 11:28 AM

Details

Summary
Previously we were erroneously passing the device softc to
acpi_stype_to_sstate in acpi_wake/run_sleep_prep instead of the ACPI
bus device softc.

Now, we pass the ACPI bus device softc when walking devices to prep for
sleep/wake.

Use the opportunity to pass the stype instead of the ACPI S-state to
acpi_wake_prep_walk.

PR: 289634
Sponsored by: The FreeBSD Foundation

Diff Detail

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

Event Timeline

Is the proper fix "just" to plumb the acpi softc through acpi_wake_prep_walk()->AcpiWalkNamespace()->acpi_wake_prep()->...? That doesn't seem too painful.

I'm ok with this patch as an intermediate step to fix the panics, but the above should also be straightforward.

yeah you're absolutely right, I thought acpi_shutdown's dev was a device but its the actual bus of course so this is easy. Will do that in a minute

it's been a really long day, sorry I missed this :D

bz added inline comments.
sys/dev/acpica/acpivar.h
137 ↗(On Diff #162298)

Is there a reason to not keep this file-local in acpi.c?

sys/dev/acpica/acpivar.h
137 ↗(On Diff #162298)

I could but I saw that no other structs were being kept file-local so I decided to put this here.

But none of these are entirely local actually so I'll move this to acpi.c.

Move struct acpi_wake_prep_context out of acpivar.h

obiwac added inline comments.
sys/dev/acpica/acpivar.h
137 ↗(On Diff #162298)

actually struct acpi_interface was, my bad.

This patch fixes panic. Please push it when it's ready.

Edit: Unfortunately, suspend is still broken, PC wakes up immediately.

This patch fixes panic. Please push it when it's ready.

Edit: Unfortunately, suspend is still broken, PC wakes up immediately.

Okay, but this is a separate issue I guess. This is going to be hard for me to debug as I do not have an S3 machine. Are you willing to try some patches out for me to fix this issue? Also, can you send me your kernel logs (obiwac@freebsd.org)?

In the meantime I'll just revert the changes which touch the ACPI logic.

markj added inline comments.
sys/dev/acpica/acpi.c
3765

Stylistically this looks a bit weird. More typical would be something like

struct acpi_wake_prep_context *ctx = context;

if (AcpiGbl_SystemAwakeAndRunning)
    acpi_wake_sleep_prep(ctx->sc, handle, ctx->stype);
else
    acpi_wake_run_prep(ctx->sc, handle, ctx->stype);

or declare more local variables after, struct acpi_softc *sc = ctx->sc; etc.

This revision is now accepted and ready to land.Thu, Sep 18, 12:38 PM
madpilot added a subscriber: madpilot.

I finally tested this and works fine for me.

I'm sorry I was unable to test it earlier!

I finally tested this and works fine for me.

I'm sorry I was unable to test it earlier!

Don't worry about it, I wasn't behind my computer today anyways. Thanks for testing!

these changes have been rolled into D52705 because the original commit that had these changes had to be reverted anyways.

obiwac added inline comments.
sys/dev/acpica/acpi.c
3765

applied this change in D52705