Page MenuHomeFreeBSD

acpi: Don't attach a "wake" sysctl node to devices without the ACPI flags IVAR
ClosedPublic

Authored by jhb on Fri, Feb 27, 3:52 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Mar 18, 3:37 PM
Unknown Object (File)
Wed, Mar 18, 3:47 AM
Unknown Object (File)
Wed, Mar 18, 3:44 AM
Unknown Object (File)
Sat, Mar 14, 2:04 AM
Unknown Object (File)
Fri, Mar 13, 2:05 PM
Unknown Object (File)
Mon, Mar 9, 8:25 PM
Unknown Object (File)
Sat, Mar 7, 4:17 PM
Unknown Object (File)
Thu, Mar 5, 3:07 AM

Details

Summary

Not all bus drivers for ACPI-aware devices implement the ACPI flags
IVAR used by the acpi_wake_set_sysctl handler. In some cases this may
be a feature as some new-bus devices share the same ACPI handle (e.g.
a pcibX device and its child pciY device) which can lead to confusing
results (e.g. setting the sysctl on pciY changes the behavior of the
parent pcibX device, but the "wake" sysctl for pcibX won't reflect the
new behavior, or reflect the device's state).

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Fri, Feb 27, 3:52 PM
jhb created this revision.

Oof! I'll give this diff a shot on my MBP!

ngie added a subscriber: pho.

My MacBookPro13,1 no longer panics when I run sysctl dev.pci..

@pho : would it make sense to make this a regression test?

This revision is now accepted and ready to land.Fri, Feb 27, 6:57 PM

Oddly enough, this may have also fixed some of the sysctl issues with asmc(4) on my MBP13,1 as asmc(4) is an acpi(4) consumer. It was previously complaining about bogus duplicate OIDs, but I figured that was something that I did on the branch, not an issue with acpi(4).
I'll check on my MBP16,1 as well and report back.
CC: @guest-seuros

Oddly enough, this may have also fixed some of the sysctl issues with asmc(4) on my MBP13,1 as asmc(4) is an acpi(4) consumer. It was previously complaining about bogus duplicate OIDs, but I figured that was something that I did on the branch, not an issue with acpi(4).
I'll check on my MBP16,1 as well and report back.
CC: @guest-seuros

Nevermind. The duplicate temp sensor sysctl(9) OID messages are there still (still poking around trying to fix that on my branch).

My MacBookPro13,1 no longer panics when I run sysctl dev.pci..

@pho : would it make sense to make this a regression test?

There is already a "sysctl -a" scenario that triggers the panic:

root@mercat1:~ # cd /usr/src/tools/test/stress2/misc
root@mercat1:/usr/src/tools/test/stress2/misc # ./sysctl2.sh
panic: acpi_get_flags failed for pci8 on bus pcib8, error = 2

This change fixes the panic for me.

In D55562#1271486, @pho wrote:

My MacBookPro13,1 no longer panics when I run sysctl dev.pci..

@pho : would it make sense to make this a regression test?

There is already a "sysctl -a" scenario that triggers the panic:

root@mercat1:~ # cd /usr/src/tools/test/stress2/misc
root@mercat1:/usr/src/tools/test/stress2/misc # ./sysctl2.sh
panic: acpi_get_flags failed for pci8 on bus pcib8, error = 2

This change fixes the panic for me.

Cool -- thanks for verifying!

Hmm... atopcase(4) still panicked with a similar issue (once I figured out that I needed to add ig4 to my KERNCONF). This may have also occurred because my Mac had low battery and the hardware sends out events at the hardware level to OSes to suspend the host (there's always a chance that this is a bug with atopcase(4)).

IMG_8774.jpg (674×973 px, 275 KB)

Hmm... atopcase(4) still panicked with a similar issue (once I figured out that I needed to add ig4 to my KERNCONF). This may have also occurred because my Mac had low battery and the hardware sends out events at the hardware level to OSes to suspend the host (there's always a chance that this is a bug with atopcase(4)).

This is probably because of the acpi_get_flags() call in acpi_wake_{sleep,run}_prep(). We should be checking if we have ACPI_IVAR_FLAGS in those functions too, or be doing something like D55609.

I think the former is the better solution, because otherwise we're still creating the sysctls even if the driver doesn't support this ivar.

Hmm... atopcase(4) still panicked with a similar issue (once I figured out that I needed to add ig4 to my KERNCONF). This may have also occurred because my Mac had low battery and the hardware sends out events at the hardware level to OSes to suspend the host (there's always a chance that this is a bug with atopcase(4)).

This is probably because of the acpi_get_flags() call in acpi_wake_{sleep,run}_prep(). We should be checking if we have ACPI_IVAR_FLAGS in those functions too, or be doing something like D55609.

I think the former is the better solution, because otherwise we're still creating the sysctls even if the driver doesn't support this ivar.

See earlier in the review stack. The first commit is supposed to fix the panic by making the IVAR global. The later parts of this stack are refinements to fix an oddity in how this sysctl worked on PCI buses (where we duplicated it).

ah, right, sorry, I didn't see there were other revisions