Cannot get ACPI GPEs and notifications to work
Posted: Sat Sep 12, 2020 8:32 am
Hi guys,
recently I've been working to get ACPI fully working on my kernel, Tilck.
Of course, I decided to integrate ACPICA and implement the OS services layer, instead of doing everything by myself.
Anyway, after fixing several bugs, I believe that now my OSL layer works fine and all the ACPI initialization steps pass without any errors.
I've tried that on VMs and on multiple HW machines. I'm able to walk through all the ACPI namespace, read tables, evaluate method objects etc.
Everything looks good.
Now, Iet's get to the point. The first thing I wanted to do after initializing the ACPI subsystem was to handle some basic events like press on the power button and lid switch events.
I was easily able to receive fixed events when the power button is pressed, but I've found no way so far to get any type of notifications or general purpose events (GPEs).
Let me describe the initialization steps:
While for the power button I get fixed events and I'm not sure if I should be able get notifications / GPEs at all, for the lid switch there are no fixed events
and notifications are the only thing to expect. Let me clarify this: in my understanding (maybe completely wrong), the existence of an object with HID=PNP0C0C
in the namespace, supersedes the ACPI_FADT_POWER_BUTTON flag in FADT, meaning I should expect it to send me (OSPM) GPEs, not fixed events,
even if `fadt->Flags & ACPI_FADT_POWER_BUTTON` is 0. Is that correct?
Anyway, the main point is: I don't get any kind of other events except for fixed events.
No GPEs, no notifications.
Additional details As part of the debugging, I've installed also a global event handler and I've registered
an IRQ handler of my own (in addition to ACPICA's one) to see when I get SCI interrupts. Well, for fixed
events that happens regularly: I observe both the IRQ and the event in the global event handler but,
I get absolutely nothing when I close and re-open my laptop's lid.
The last thing I tried is to call power button's and lit switch's _PRW method with AcpiEvaluateObject(),
process the output and then I called AcpiSetupGpeForWake(), hopefully in a correct way. But that had
no effect. Still no GPEs/notifications.
I believe there's something important I'm missing, but I cannot figure out what that might be.
I'd really appreciate an advice from someone having much more experience with ACPI than me.
I don't exclude at all that there might be a bug somewhere in my code leading to this behavior but,
the fact that I don't get any errors at all (while before when I had bugs, I got plenty of errors) and that
the SCI interrupt works correctly along with fixed events makes me believe that there's something to
enable or configure. Of course, if there's an actual bug, that's the worst case because without any errors
it would be much harder to debug.
If anyone's interested, my code is in the acpi7 (temporary) branch of: https://github.com/vvaltchev/tilck,
but again, I'm not asking anyone to debug my code, of course. Mostly, I'm looking for hints.
Thank you very much, in advance.
Vlad
recently I've been working to get ACPI fully working on my kernel, Tilck.
Of course, I decided to integrate ACPICA and implement the OS services layer, instead of doing everything by myself.
Anyway, after fixing several bugs, I believe that now my OSL layer works fine and all the ACPI initialization steps pass without any errors.
I've tried that on VMs and on multiple HW machines. I'm able to walk through all the ACPI namespace, read tables, evaluate method objects etc.
Everything looks good.
Now, Iet's get to the point. The first thing I wanted to do after initializing the ACPI subsystem was to handle some basic events like press on the power button and lid switch events.
I was easily able to receive fixed events when the power button is pressed, but I've found no way so far to get any type of notifications or general purpose events (GPEs).
Let me describe the initialization steps:
Code: Select all
1. AcpiInitializeSubsystem()
2. AcpiInitializeTables()
3. AcpiLoadTables()
4. AcpiEnableSubsystem()
5. AcpiInitializeObjects()
6. Here I walk the whole namespace and I install notify handlers for
HID=PNP0C0C (power button) and HID=PNP0C0D (lid switch)
using AcpiInstallNotifyHandler(), without errors, of course.
7. Register a fixed event handler for the power button (according to FADT's flags)
8. Here I've installed a global event handler, for debugging purposes
9. AcpiUpdateAllGpes()
and notifications are the only thing to expect. Let me clarify this: in my understanding (maybe completely wrong), the existence of an object with HID=PNP0C0C
in the namespace, supersedes the ACPI_FADT_POWER_BUTTON flag in FADT, meaning I should expect it to send me (OSPM) GPEs, not fixed events,
even if `fadt->Flags & ACPI_FADT_POWER_BUTTON` is 0. Is that correct?
Anyway, the main point is: I don't get any kind of other events except for fixed events.
No GPEs, no notifications.
Additional details As part of the debugging, I've installed also a global event handler and I've registered
an IRQ handler of my own (in addition to ACPICA's one) to see when I get SCI interrupts. Well, for fixed
events that happens regularly: I observe both the IRQ and the event in the global event handler but,
I get absolutely nothing when I close and re-open my laptop's lid.
The last thing I tried is to call power button's and lit switch's _PRW method with AcpiEvaluateObject(),
process the output and then I called AcpiSetupGpeForWake(), hopefully in a correct way. But that had
no effect. Still no GPEs/notifications.
I believe there's something important I'm missing, but I cannot figure out what that might be.
I'd really appreciate an advice from someone having much more experience with ACPI than me.
I don't exclude at all that there might be a bug somewhere in my code leading to this behavior but,
the fact that I don't get any errors at all (while before when I had bugs, I got plenty of errors) and that
the SCI interrupt works correctly along with fixed events makes me believe that there's something to
enable or configure. Of course, if there's an actual bug, that's the worst case because without any errors
it would be much harder to debug.
If anyone's interested, my code is in the acpi7 (temporary) branch of: https://github.com/vvaltchev/tilck,
but again, I'm not asking anyone to debug my code, of course. Mostly, I'm looking for hints.
Thank you very much, in advance.
Vlad