Support ACPI Control Method Sleep button
cover Support ACPI Control Method Sleep button
The ACPI sleep button can be implemented as a fixed hardware button or Control Method Sleep button.
The patch of implementing a fixed hardware sleep button was posted here 1). More discussions can be found here 2). Essentially, the discussion mainly focuses on whether the sleep button is implemented as a fixed hardware button or Control Method Sleep button. The latter benefits different architectures since the code can be shared among them.
This patch set implements Control Method Sleep button for both x86 and ARM platform.
For x86, a sleep button GPE event handler is implemented, so a GPE event is triggered to indicate the OSPM the sleep button is pressed. Tests have been done for Linux 6.6.0-rc2+, and Windows Server 2016, the sleep button works as expected.
For ARM, a GED event is triggered to notify the OSPM. With proper debug knobs it is possible to see the guest OSPM acknowledges the sleep event:
[ 268.429495] evregion-0119 ev_address_space_dispa: ----Entry [ 268.430480] evrgnini-0043 ev_system_memory_regio: ----Entry [ 268.431423] evrgnini-0079 ev_system_memory_regio: ----Exit- AE_OK [ 268.432303] evregion-0230 ev_address_space_dispa: Handler 0000000081544775 (@00000000e8f0a66d) Address 0000000009080000 [SystemMemory] [ 268.433943] evregion-0325 ev_address_space_dispa: ----Exit- AE_OK [ 268.434793] evmisc-0132 ev_queue_notify_reques: Dispatching Notify on [SLPB] (Device) Value 0x80 (Status Change) Node 00000000ada658b8
But that seems to be all, depicting that sleep/wakeup for ARM is broken and there are still missing some pieces of the puzzle.
Nonetheless, we would like to take this RFC as an opportunity for updates on this subject as possible roadmaps.
1) https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg06478.html
2) https://lore.kernel.org/all/[email protected]/T/#mfe24f89778020deeacfe45083f3eea3cf9f55961
Annie Li (6):
acpi: hmp/qmp: Add hmp/qmp support for system_sleep
acpi: Implement control method sleep button
test/acpi: allow DSDT table changes
acpi: Support Control Method sleep button for x86 tests/acpi/bios-tables-test: update DSDT tables for Control Method
Sleep button
acpi: Send the GPE event of suspend and wakeup for x86
Miguel Luis (5):
hw/acpi: Add ACPI GED support for the sleep event tests/acpi: allow FACP and DSDT table changes for arm/virt hw/arm: enable sleep support for arm/virt tests/acpi: Update FACP and DSDT tables for sleep button arm/virt: enable sleep support
hmp-commands.hx | 14 +++++ hw/acpi/control_method_device.c | 49 ++++++++++++++++++ hw/acpi/core.c | 17 ++++-- hw/acpi/generic_event_device.c | 9 ++++ hw/acpi/meson.build | 1 + hw/arm/virt-acpi-build.c | 13 +++++ hw/arm/virt.c | 14 ++++- hw/core/machine-hmp-cmds.c | 5 ++ hw/core/machine-qmp-cmds.c | 11 ++++ hw/i386/acpi-build.c | 9 ++++ include/hw/acpi/acpi.h | 1 + include/hw/acpi/acpi_dev_interface.h | 1 + include/hw/acpi/control_method_device.h | 20 +++++++ include/hw/acpi/generic_event_device.h | 1 + include/hw/arm/virt.h | 1 + include/monitor/hmp.h | 1 + qapi/machine.json | 18 +++++++ qapi/pragma.json | 1 + tests/data/acpi/pc/DSDT | Bin 6830 -> 7012 bytes tests/data/acpi/pc/DSDT.acpierst | Bin 6741 -> 6923 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 8155 -> 8337 bytes tests/data/acpi/pc/DSDT.bridge | Bin 13701 -> 13883 bytes tests/data/acpi/pc/DSDT.cphp | Bin 7294 -> 7476 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 8484 -> 8666 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 6781 -> 6963 bytes tests/data/acpi/pc/DSDT.hpbrroot | Bin 3337 -> 3519 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6902 -> 7084 bytes tests/data/acpi/pc/DSDT.memhp | Bin 8189 -> 8371 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 6688 -> 6870 bytes tests/data/acpi/pc/DSDT.numamem | Bin 6836 -> 7018 bytes tests/data/acpi/pc/DSDT.roothp | Bin 10623 -> 10805 bytes tests/data/acpi/q35/DSDT | Bin 8355 -> 8537 bytes tests/data/acpi/q35/DSDT.acpierst | Bin 8372 -> 8554 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9680 -> 9862 bytes tests/data/acpi/q35/DSDT.acpihmat-noinitiator | Bin 8634 -> 8816 bytes tests/data/acpi/q35/DSDT.applesmc | Bin 8401 -> 8583 bytes tests/data/acpi/q35/DSDT.bridge | Bin 11968 -> 12150 bytes tests/data/acpi/q35/DSDT.core-count | Bin 12913 -> 13095 bytes tests/data/acpi/q35/DSDT.core-count2 | Bin 33770 -> 33952 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8819 -> 9001 bytes tests/data/acpi/q35/DSDT.cxl | Bin 9713 -> 9895 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 10009 -> 10191 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 8430 -> 8612 bytes tests/data/acpi/q35/DSDT.ipmismbus | Bin 8443 -> 8625 bytes tests/data/acpi/q35/DSDT.ivrs | Bin 8372 -> 8554 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9714 -> 9896 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 9485 -> 9667 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 13208 -> 13390 bytes tests/data/acpi/q35/DSDT.noacpihp | Bin 8235 -> 8417 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 8213 -> 8395 bytes tests/data/acpi/q35/DSDT.numamem | Bin 8361 -> 8543 bytes tests/data/acpi/q35/DSDT.pvpanic-isa | Bin 8456 -> 8638 bytes tests/data/acpi/q35/DSDT.thread-count | Bin 12913 -> 13095 bytes tests/data/acpi/q35/DSDT.thread-count2 | Bin 33770 -> 33952 bytes tests/data/acpi/q35/DSDT.tis.tpm12 | Bin 8961 -> 9143 bytes tests/data/acpi/q35/DSDT.tis.tpm2 | Bin 8987 -> 9169 bytes tests/data/acpi/q35/DSDT.type4-count | Bin 18589 -> 18771 bytes tests/data/acpi/q35/DSDT.viot | Bin 9464 -> 9646 bytes tests/data/acpi/q35/DSDT.xapic | Bin 35718 -> 35900 bytes tests/data/acpi/virt/DSDT | Bin 5196 -> 5278 bytes tests/data/acpi/virt/DSDT.acpihmatvirt | Bin 5282 -> 5364 bytes tests/data/acpi/virt/DSDT.memhp | Bin 6557 -> 6639 bytes tests/data/acpi/virt/DSDT.pxb | Bin 7679 -> 7761 bytes tests/data/acpi/virt/DSDT.topology | Bin 5398 -> 5480 bytes tests/data/acpi/virt/FACP | Bin 276 -> 276 bytes 65 files changed, 181 insertions(+), 5 deletions(-) create mode 100644 hw/acpi/control_method_device.c create mode 100644 include/hw/acpi/control_method_device.h
Signature · 1 line
2.34.3
RFC PATCH 1/11 acpi: hmp/qmp: Add hmp/qmp support for system_sleep
Following hmp/qmp commands are implemented for pressing virtual sleep button,
hmp: system_sleep
qmp: { "execute": "system_sleep" }
These commands put the guest into suspend or other power states depending on the power settings inside the guest.
--- hmp-commands.hx | 14 ++++++++++++++ hw/core/machine-hmp-cmds.c | 5 +++++ hw/core/machine-qmp-cmds.c | 9 +++++++++ include/monitor/hmp.h | 1 + qapi/machine.json | 18 ++++++++++++++++++ qapi/pragma.json | 1 + 6 files changed, 48 insertions(+)
hmp-commands.hx +14 -0
@@ -652,6 +652,20 @@ SRST whether profiling is on or off. ERST + { + .name = "system_sleep", + .args_type = "", + .params = "", + .help = "send ACPI sleep event", + .cmd = hmp_system_sleep, + }, + +SRST +``system_sleep`` + Push the virtual sleep button; if supported the system will enter + an ACPI sleep state. +ERST + { .name = "system_reset", .args_type = "",
hw/core/machine-hmp-cmds.c +5 -0
@@ -185,6 +185,11 @@ void hmp_system_reset(Monitor *mon, const QDict *qdict)qmp_system_reset (NULL ); } +void hmp_system_sleep (Monitor *mon,const QDict *qdict) +{ +qmp_system_sleep (NULL ); +} +void hmp_system_powerdown (Monitor *mon,const QDict *qdict) {qmp_system_powerdown (NULL );
hw/core/machine-qmp-cmds.c +9 -0
@@ -257,6 +257,15 @@ void qmp_system_reset(Error **errp)qemu_system_reset_request (SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET ); } +void qmp_system_sleep (Error **errp) +{ +if (!qemu_wakeup_suspend_enabled ()) { +error_setg (errp, +"suspend from running is not supported by this guest" ); +return ; + } +} +void qmp_system_powerdown (Error **errp) {qemu_system_powerdown_request ();
include/monitor/hmp.h +1 -0
@@ -45,6 +45,7 @@ void hmp_quit(Monitor *mon, const QDict *qdict);void hmp_stop (Monitor *mon,const QDict *qdict);void hmp_sync_profile (Monitor *mon,const QDict *qdict);void hmp_system_reset (Monitor *mon,const QDict *qdict); +void hmp_system_sleep (Monitor *mon,const QDict *qdict);void hmp_system_powerdown (Monitor *mon,const QDict *qdict);void hmp_exit_preconfig (Monitor *mon,const QDict *qdict);void hmp_announce_self (Monitor *mon,const QDict *qdict);
qapi/machine.json +18 -0
@@ -297,6 +297,24 @@ ## { 'command': 'system_reset' } +## +# @system_sleep: +# +# Requests that a guest perform a ACPI sleep transition by pushing a virtual +# sleep button. +# +# Notes: A guest may or may not respond to this command. This command +# returning does not indicate that a guest has accepted the request +# or that it has gone to sleep. +# +# Example: +# +# -> { "execute": "system_sleep" } +# <- { "return": {} } +# +## +{ 'command': 'system_sleep' } + ## # @system_powerdown: #
qapi/pragma.json +1 -0
@@ -23,6 +23,7 @@ 'set_password', 'system_powerdown', 'system_reset', + 'system_sleep', 'system_wakeup' ], # Commands allowed to return a non-dictionary 'command-returns-exceptions': [
Signature · 1 line
2.34.3
Re: [RFC PATCH 01/11] acpi: hmp/qmp: Add hmp/qmp support for system_sleep
Hi Annie,
Quoted 24 lines · Annie Li
Following hmp/qmp commands are implemented for pressing virtual sleep button,
hmp:
system_sleep
qmp: { "execute": "system_sleep" }These commands put the guest into suspend or other power states depending on the power settings inside the guest.
Signed-off-by Annie Li <[email protected]>--- hmp-commands.hx | 14 ++++++++++++++ hw/core/machine-hmp-cmds.c | 5 +++++ hw/core/machine-qmp-cmds.c | 9 +++++++++ include/monitor/hmp.h | 1 + qapi/machine.json | 18 ++++++++++++++++++ qapi/pragma.json | 1 + 6 files changed, 48 insertions(+)index
b6d634b30d..3ac69df92f100644
qapi/machine.json line 301
Quoted 5 lines
qapi/machine.json +2
-0@@ -297,6 +297,24 @@ ## { 'command': 'system_reset' } +## +# @system_sleep:
@since 9.0
Quoted 5 lines
qapi/machine.json +5
-0+# +# Requests that a guest perform a ACPI sleep transition by pushing a virtual +# sleep button. +# +# Notes: A guest may or may not respond to this command. This command
qapi/machine.json line 316
Quoted 10 lines
qapi/machine.json +10
-0+# returning does not indicate that a guest has accepted the request +# or that it has gone to sleep. +# +# Example: +# +# -> { "execute": "system_sleep" } +# <- { "return": {} } +# +## +{ 'command': 'system_sleep' }
Do we want a 'mode' argument, starting here with control_method?
Quoted 4 lines
qapi/machine.json +1
-0+ ## # @system_powerdown: #
Re: [RFC PATCH 01/11] acpi: hmp/qmp: Add hmp/qmp support for system_sleep
Hi Philippe,
Quoted 23 lines · Philippe Mathieu-Daudé
Hi Annie,
Quoted 18 lines · Annie Li
Following hmp/qmp commands are implemented for pressing virtual sleep button,
hmp:
system_sleep
qmp: { "execute": "system_sleep" }These commands put the guest into suspend or other power states depending on the power settings inside the guest.
Signed-off-by Annie Li <[email protected]>---
hmp-commands.hx | 14 ++++++++++++++hw/core/machine-hmp-cmds.c| 5 +++++hw/core/machine-qmp-cmds.c| 9 +++++++++ include/monitor/hmp.h | 1 + qapi/machine.json | 18 ++++++++++++++++++ qapi/pragma.json | 1 +6 files changed, 48 insertions(+)
Quoted 10 lines
Quoted 8 lines
index
b6d634b30d..3ac69df92f100644qapi/machine.json +0
-0@@ -297,6 +297,24 @@ ## { 'command': 'system_reset' }+##
+# @system_sleep:@since 9.0
Nod
Quoted 12 lines
Quoted 12 lines
qapi/machine.json +2
-0+# +# Requests that a guest perform a ACPI sleep transition by pushing avirtual
qapi/machine.json +4
-0+# sleep button. +# +# Notes: A guest may or may not respond to this command. This command +# returning does not indicate that a guest has accepted therequest
qapi/machine.json +3
-0+# or that it has gone to sleep. +# +# Example:
Quoted 8 lines
qapi/machine.json line 316
Quoted 6 lines
qapi/machine.json +6
-0+# +# -> { "execute": "system_sleep" } +# <- { "return": {} } +# +## +{ 'command': 'system_sleep' }Do we want a 'mode' argument, starting here with
control_method?
As what has been discussed previously in the following thread,
https://lore.kernel.org/all/[email protected]/T/#mfe24f89778020deeacfe45083f3eea3cf9f55961
the Control Method Sleep button can be shared among various architectures. It is very likely that there will be one type of sleep button(Control Method) implemented, so the extra argument isn't necessary.
Thanks
Annie
Quoted 5 lines
Quoted 5 lines
+
##
# @system_powerdown:
#
Re: [RFC PATCH 01/11] acpi: hmp/qmp: Add hmp/qmp support for system_sleep
In reply to Annie LiYou neglected to cc: QAPI schema maintainers. I found it by chance. Next time :)
Quoted 8 lines · Annie Li
Following hmp/qmp commands are implemented for pressing virtual sleep button,
hmp:
system_sleep
qmp: { "execute": "system_sleep" }These commands put the guest into suspend or other power states depending on the power settings inside the guest.
How is this related to system_wakeup?
Quoted 15 lines
Signed-off-by Annie Li <[email protected]>--- hmp-commands.hx | 14 ++++++++++++++ hw/core/machine-hmp-cmds.c | 5 +++++ hw/core/machine-qmp-cmds.c | 9 +++++++++ include/monitor/hmp.h | 1 + qapi/machine.json | 18 ++++++++++++++++++ qapi/pragma.json | 1 + 6 files changed, 48 insertions(+)hmp-commands.hx +0
-0
hmp-commands.hx SRST · line 659
Quoted 8 lines
hmp-commands.hx +5
-0@@ -652,6 +652,20 @@ SRST whether profiling is on or off. ERST + { + .name = "system_sleep", + .args_type = "", + .params = "", + .help = "send ACPI sleep event",
Suggest "push the virtual sleep button", because it's easier to understand, and consistent with the documentation below.
Quoted 33 lines
hmp-commands.hx +9
-0+ .cmd = hmp_system_sleep, + }, + +SRST +``system_sleep`` + Push the virtual sleep button; if supported the system will enter + an ACPI sleep state. +ERST + { .name = "system_reset", .args_type = "",hw/core/machine-hmp-cmds.c +5
-0@@ -185,6 +185,11 @@ void hmp_system_reset(Monitor *mon, const QDict *qdict)qmp_system_reset (NULL ); } +void hmp_system_sleep (Monitor *mon,const QDict *qdict) +{ +qmp_system_sleep (NULL ); +} +void hmp_system_powerdown (Monitor *mon,const QDict *qdict) {qmp_system_powerdown (NULL );hw/core/machine-qmp-cmds.c +0
-0
hw/core/machine-qmp-cmds.c void qmp_system_reset(Error **errp) · line 266
Quoted 10 lines
hw/core/machine-qmp-cmds.c +7
-0@@ -257,6 +257,15 @@ void qmp_system_reset(Error **errp)qemu_system_reset_request (SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET ); } +void qmp_system_sleep (Error **errp) +{ +if (!qemu_wakeup_suspend_enabled ()) { +error_setg (errp, +"suspend from running is not supported by this guest" ); +return ; + }
This can't be right: it either fails or does nothing.
I guess you're leaving the "do something" part to later patches. That's okay, but it needs a TODO comment here, and a prominent mention in the commit message.
Quoted 22 lines
hw/core/machine-qmp-cmds.c +2
-0+} +void qmp_system_powerdown (Error **errp) {qemu_system_powerdown_request ();include/monitor/hmp.h +1
-0@@ -45,6 +45,7 @@ void hmp_quit(Monitor *mon, const QDict *qdict);void hmp_stop (Monitor *mon,const QDict *qdict);void hmp_sync_profile (Monitor *mon,const QDict *qdict);void hmp_system_reset (Monitor *mon,const QDict *qdict); +void hmp_system_sleep (Monitor *mon,const QDict *qdict);void hmp_system_powerdown (Monitor *mon,const QDict *qdict);void hmp_exit_preconfig (Monitor *mon,const QDict *qdict);void hmp_announce_self (Monitor *mon,const QDict *qdict);qapi/machine.json +0
-0
qapi/machine.json line 304
Quoted 8 lines
qapi/machine.json +5
-0@@ -297,6 +297,24 @@ ## { 'command': 'system_reset' } +## +# @system_sleep: +# +# Requests that a guest perform a ACPI sleep transition by pushing a virtual +# sleep button.
Imperative mood, please: "Request that ..."
I think "the guest" would be better.
Limit line length to 70, please.
qapi/machine.json line 308
Quoted 4 lines
qapi/machine.json +4
-0+# +# Notes: A guest may or may not respond to this command. This command +# returning does not indicate that a guest has accepted the request +# or that it has gone to sleep.
Please format like
# Notes: A guest may or may not respond to this command. This command
# returning does not indicate that a guest has accepted the request
# or that it has gone to sleep.
Quoted 17 lines
qapi/machine.json +9
-0+# +# Example: +# +# -> { "execute": "system_sleep" } +# <- { "return": {} } +# +## +{ 'command': 'system_sleep' } + ## # @system_powerdown: #qapi/pragma.json +0
-0
qapi/pragma.json line 29
Quoted 7 lines
qapi/pragma.json +1
-0@@ -23,6 +23,7 @@ 'set_password', 'system_powerdown', 'system_reset', + 'system_sleep', 'system_wakeup' ], # Commands allowed to return a non-dictionary 'command-returns-exceptions': [
I figure you spell system_sleep with '_' instead of '-' for consistency with existing system_FOO commands. That's okay, but I recommend to point it out in the commit message.
Re: [RFC PATCH 01/11] acpi: hmp/qmp: Add hmp/qmp support for system_sleep
Hi Markus,
Quoted 2 lines · Markus Armbruster
You neglected to cc: QAPI schema maintainers. I found it by chance. Next time :)
Yep, should have cc to the maintainers.
Quoted 6 lines
Quoted 3 lines · Annie Li
Following hmp/qmp commands are implemented for pressing virtual sleep button,
Quoted 6 lines
Quoted 5 lines
hmp:
system_sleep
qmp: { "execute": "system_sleep" }These commands put the guest into suspend or other power states depending on the power settings inside the guest.
How is this related to
system_wakeup?
Both 'system_sleep' and 'system_wakeup' trigger the event to notify the guest OSPM the sleep button has been pressed. 'system_wakeup' triggers wake up notification when the guest is in suspend state.
Quoted 19 lines
Quoted 19 lines
Signed-off-by Annie Li <[email protected]>--- hmp-commands.hx | 14 ++++++++++++++ hw/core/machine-hmp-cmds.c | 5 +++++ hw/core/machine-qmp-cmds.c | 9 +++++++++ include/monitor/hmp.h | 1 + qapi/machine.json | 18 ++++++++++++++++++ qapi/pragma.json | 1 + 6 files changed, 48 insertions(+)hmp-commands.hx +0
-0@@ -652,6 +652,20 @@ SRST whether profiling is on or off. ERST
Quoted 7 lines
hmp-commands.hx SRST · line 659
Quoted 5 lines
hmp-commands.hx +5
-0+ { + .name = "system_sleep", + .args_type = "", + .params = "", + .help = "send ACPI sleep event",Suggest "push the virtual sleep button", because it's easier to understand, and consistent with the documentation below.
ACK
Quoted 46 lines
Quoted 34 lines
hmp-commands.hx +9
-0+ .cmd = hmp_system_sleep, + }, + +SRST +``system_sleep`` + Push the virtual sleep button; if supported the system will enter + an ACPI sleep state. +ERST + { .name = "system_reset", .args_type = "",hw/core/machine-hmp-cmds.c +5
-0@@ -185,6 +185,11 @@ void hmp_system_reset(Monitor *mon, const QDict *qdict)qmp_system_reset (NULL ); } +void hmp_system_sleep (Monitor *mon,const QDict *qdict) +{ +qmp_system_sleep (NULL ); +} +void hmp_system_powerdown (Monitor *mon,const QDict *qdict) {qmp_system_powerdown (NULL );hw/core/machine-qmp-cmds.c +0
-0hw/core/machine-qmp-cmds.c void qmp_system_reset(Error **errp) · line 266
Quoted 10 lines
hw/core/machine-qmp-cmds.c +7
-0@@ -257,6 +257,15 @@ void qmp_system_reset(Error **errp)qemu_system_reset_request (SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET ); } +void qmp_system_sleep (Error **errp) +{ +if (!qemu_wakeup_suspend_enabled ()) { +error_setg (errp, +"suspend from running is not supported by this guest" ); +return ; + }This can't be right: it either fails or does nothing.
Quoted 1 line
I guess you're leaving the "do something" part to later patches.
Right. This patch focuses on hmp/qmp, more implementations are in patch 6.
Quoted 3 lines
That's
okay, but it needs a TODO comment here, and a prominent mention in the commit message.
Good point
Quoted 33 lines
Quoted 23 lines
hw/core/machine-qmp-cmds.c +2
-0+} +void qmp_system_powerdown (Error **errp) {qemu_system_powerdown_request ();include/monitor/hmp.h +1
-0@@ -45,6 +45,7 @@ void hmp_quit(Monitor *mon, const QDict *qdict);void hmp_stop (Monitor *mon,const QDict *qdict);void hmp_sync_profile (Monitor *mon,const QDict *qdict);void hmp_system_reset (Monitor *mon,const QDict *qdict); +void hmp_system_sleep (Monitor *mon,const QDict *qdict);void hmp_system_powerdown (Monitor *mon,const QDict *qdict);void hmp_exit_preconfig (Monitor *mon,const QDict *qdict);void hmp_announce_self (Monitor *mon,const QDict *qdict);qapi/machine.json +0
-0qapi/machine.json line 304
Quoted 8 lines
qapi/machine.json +5
-0@@ -297,6 +297,24 @@ ## { 'command': 'system_reset' } +## +# @system_sleep: +# +# Requests that a guest perform a ACPI sleep transition by pushing a virtual +# sleep button.Imperative mood, please: "Request that ..."
Quoted 3 lines
I think "the guest" would be better.
Limit line length to 70, please.
ACK
Quoted 11 lines
qapi/machine.json line 308
Quoted 5 lines
qapi/machine.json +4
-0+# +# Notes: A guest may or may not respond to this command. This command +# returning does not indicate that a guest has accepted the request +# or that it has gone to sleep.Please format like
# Notes: A guest may or may not respond to this command. This command
# returning does not indicate that a guest has accepted the request
# or that it has gone to sleep.
ACK
Quoted 18 lines
Quoted 18 lines
qapi/machine.json +9
-0+# +# Example: +# +# -> { "execute": "system_sleep" } +# <- { "return": {} } +# +## +{ 'command': 'system_sleep' } + ## # @system_powerdown: #qapi/pragma.json +0
-0@@ -23,6 +23,7 @@ 'set_password',
Quoted 8 lines
qapi/pragma.json line 29
Quoted 6 lines
qapi/pragma.json +1
-0'system_powerdown', 'system_reset', + 'system_sleep', 'system_wakeup' ], # Commands allowed to return a non-dictionary 'command-returns-exceptions': [I figure you spell
system_sleepwith '_' instead of '-' for consistency with existingsystem_FOOcommands.
Yep
Quoted 2 lines
That's okay, but I recommend to
point it out in the commit message.
Will do.
Thanks
Annie
Re: [RFC PATCH 01/11] acpi: hmp/qmp: Add hmp/qmp support for system_sleep
Quoted 15 lines · Annie.li
Hi Markus,
Quoted 2 lines · Markus Armbruster
You neglected to cc: QAPI schema maintainers. I found it by chance. Next time :)
Yep, should have cc to the maintainers.
Quoted 9 lines
Quoted 6 lines · Annie Li
Following hmp/qmp commands are implemented for pressing virtual sleep button,
hmp:
system_sleep
qmp: { "execute": "system_sleep" }
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
These commands put the guest into suspend or other power states depending on the power settings inside the guest.
How is this related to
system_wakeup?Both '
system_sleep' and 'system_wakeup' trigger the event to notify the guest OSPM the sleep button has been pressed. 'system_wakeup' triggers wake up notification when the guest is in suspend state.
Thanks. Would it make sens to work this into the QAPI schema doc comments somehow?
[...]
Re: [RFC PATCH 01/11] acpi: hmp/qmp: Add hmp/qmp support for system_sleep
Quoted 16 lines · Markus Armbruster
Quoted 14 lines · Annie.li
Hi Markus,
Quoted 2 lines · Markus Armbruster
You neglected to cc: QAPI schema maintainers. I found it by chance. Next time :)
Yep, should have cc to the maintainers.
Quoted 8 lines
Quoted 6 lines · Annie Li
Following hmp/qmp commands are implemented for pressing virtual sleep button,
hmp:
system_sleep
qmp: { "execute": "system_sleep" }
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
These commands put the guest into suspend or other power states depending on the power settings inside the guest.
How is this related to
system_wakeup?Both '
system_sleep' and 'system_wakeup' trigger the event to notify the guest OSPM the sleep button has been pressed. 'system_wakeup' triggers wake up notification when the guest is in suspend state.Thanks. Would it make sens to work this into the QAPI schema doc comments somehow?
Sure. It totally makes sense.
Annie
RFC PATCH 2/11 acpi: Implement control method sleep button
In reply to Annie LiThe control method sleep button is added, as well as its GPE event handler.
--- hw/acpi/control_method_device.c | 49 +++++++++++++++++++++++++ hw/acpi/meson.build | 1 + include/hw/acpi/control_method_device.h | 20 ++++++++++ 3 files changed, 70 insertions(+)
hw/acpi/control_method_device.c new file +49 -0
@@ -0,0 +1,49 @@ +/* +* Control method devices +* +* Copyright (C) 2023 Oracle and/or its affiliates. +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#include "qemu/osdep.h" +#include "hw/acpi/control_method_device.h" +#include "hw/mem/nvdimm.h" + +void acpi_dsdt_add_sleep_button (Aml *scope) +{ +Aml *dev =aml_device ("\\_SB." ACPI_SLEEP_BUTTON_DEVICE ); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C0E" ))); +Aml *pkg =aml_package (2 ); +aml_append (pkg,aml_int (0x01 )); +aml_append (pkg,aml_int (0x04 )); +aml_append (dev,aml_name_decl ("_PRW" , pkg)); +aml_append (dev,aml_operation_region ("\\Boo" ,AML_SYSTEM_IO , +aml_int (0x201 ),0x1 )); +Aml *field =aml_field ("\\Boo" ,AML_BYTE_ACC ,AML_NOLOCK , +AML_WRITE_AS_ZEROS ); +aml_append (field,aml_named_field ("SBP" ,1 )); +aml_append (field,aml_named_field ("SBW" ,1 )); +aml_append (dev, field); +aml_append (scope, dev); +} + +void acpi_dsdt_add_sleep_gpe_event_handler (Aml *scope) +{ +Aml *method =aml_method ("_L07" ,0 ,AML_NOTSERIALIZED ); +Aml *condition =aml_if (aml_name ("\\_SB.SLPB.SBP" )); +aml_append (condition,aml_store (aml_int (1 ),aml_name ("\\_SB.SLPB.SBP" ))); +aml_append (condition, +aml_notify (aml_name ("\\_SB." ACPI_SLEEP_BUTTON_DEVICE ), +aml_int (0x80 ))); +aml_append (method, condition); + condition =aml_if (aml_name ("\\_SB.SLPB.SBW" )); +aml_append (condition,aml_store (aml_int (1 ),aml_name ("\\_SB.SLPB.SBW" ))); +aml_append (condition, +aml_notify (aml_name ("\\_SB." ACPI_SLEEP_BUTTON_DEVICE ), +aml_int (0x2 ))); +aml_append (method, condition); +aml_append (scope, method); +}
hw/acpi/meson.build +1 -0
@@ -16,6 +16,7 @@ acpi_ss.add(when: 'CONFIG_ACPI_PCI', if_true: files('pci.c')) acpi_ss.add(when: 'CONFIG_ACPI_CXL', if_true: files('cxl.c'), if_false: files('cxl-stub.c')) acpi_ss.add(when: 'CONFIG_ACPI_VMGENID', if_true: files('vmgenid.c')) acpi_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: files('generic_event_device.c')) +acpi_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: files('control_method_device.c')) acpi_ss.add(when: 'CONFIG_ACPI_HMAT', if_true: files('hmat.c')) acpi_ss.add(when: 'CONFIG_ACPI_APEI', if_true: files('ghes.c'), if_false: files('ghes-stub.c')) acpi_ss.add(when: 'CONFIG_ACPI_PIIX4', if_true: files('piix4.c'))
include/hw/acpi/control_method_device.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* Control method devices +* +* Copyright (C) 2023 Oracle and/or its affiliates. +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + + +#ifndef HW_ACPI_CONTROL_METHOD_DEVICE_H +#define HW_ACPI_CONTROL_NETHOD_DEVICE_H + +#define ACPI_SLEEP_BUTTON_DEVICE "SLPB" + +void acpi_dsdt_add_sleep_button (Aml *scope); +void acpi_dsdt_add_sleep_gpe_event_handler (Aml *scope); + +#endif
Signature · 1 line
2.34.3
RFC PATCH 3/11 test/acpi: allow DSDT table changes
In reply to Annie LiList various DSDT files allowed to be changed intests/qtest/bios-tables-test-allowed-diff.h
--- tests/qtest/bios-tables-test-allowed-diff.h | 41 +++++++++++++++++++++ 1 file changed, 41 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +41 -0
@@ -1 +1,42 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/DSDT" , +"tests/data/acpi/pc/DSDT.acpierst" , +"tests/data/acpi/pc/DSDT.acpihmat" , +"tests/data/acpi/pc/DSDT.bridge" , +"tests/data/acpi/pc/DSDT.cphp" , +"tests/data/acpi/pc/DSDT.dimmpxm" , +"tests/data/acpi/pc/DSDT.hpbridge" , +"tests/data/acpi/pc/DSDT.hpbrroot" , +"tests/data/acpi/pc/DSDT.ipmikcs" , +"tests/data/acpi/pc/DSDT.memhp" , +"tests/data/acpi/pc/DSDT.nohpet" , +"tests/data/acpi/pc/DSDT.numamem" , +"tests/data/acpi/pc/DSDT.roothp" , +"tests/data/acpi/q35/DSDT" , +"tests/data/acpi/q35/DSDT.acpierst" , +"tests/data/acpi/q35/DSDT.acpihmat" , +"tests/data/acpi/q35/DSDT.acpihmat-noinitiator" , +"tests/data/acpi/q35/DSDT.applesmc" , +"tests/data/acpi/q35/DSDT.bridge" , +"tests/data/acpi/q35/DSDT.core-count" , +"tests/data/acpi/q35/DSDT.core-count2" , +"tests/data/acpi/q35/DSDT.cphp" , +"tests/data/acpi/q35/DSDT.cxl" , +"tests/data/acpi/q35/DSDT.dimmpxm" , +"tests/data/acpi/q35/DSDT.ipmibt" , +"tests/data/acpi/q35/DSDT.ipmismbus" , +"tests/data/acpi/q35/DSDT.ivrs" , +"tests/data/acpi/q35/DSDT.memhp" , +"tests/data/acpi/q35/DSDT.mmio64" , +"tests/data/acpi/q35/DSDT.multi-bridge" , +"tests/data/acpi/q35/DSDT.noacpihp" , +"tests/data/acpi/q35/DSDT.nohpet" , +"tests/data/acpi/q35/DSDT.numamem" , +"tests/data/acpi/q35/DSDT.pvpanic-isa" , +"tests/data/acpi/q35/DSDT.thread-count" , +"tests/data/acpi/q35/DSDT.thread-count2" , +"tests/data/acpi/q35/DSDT.tis.tpm12" , +"tests/data/acpi/q35/DSDT.tis.tpm2" , +"tests/data/acpi/q35/DSDT.type4-count" , +"tests/data/acpi/q35/DSDT.viot" , +"tests/data/acpi/q35/DSDT.xapic",
Signature · 1 line
2.34.3
RFC PATCH 4/11 acpi: Support Control Method sleep button for x86
In reply to Annie LiAdd Control Method Sleep button and its GPE event handler for x86.
--- hw/i386/acpi-build.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/i386/acpi-build.c +9 -0
@@ -40,6 +40,7 @@#include "hw/acpi/acpi_aml_interface.h" #include "hw/input/i8042.h" #include "hw/acpi/memory_hotplug.h" +#include "hw/acpi/control_method_device.h" #include "sysemu/tpm.h" #include "hw/acpi/tpm.h" #include "hw/acpi/vmgenid.h"
@@ -1537,6 +1538,14 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, }aml_append (dsdt, scope); + sb_scope =aml_scope ("_SB" ); +acpi_dsdt_add_sleep_button (sb_scope); +aml_append (dsdt, sb_scope); + + scope =aml_scope ("\\_GPE" ); +acpi_dsdt_add_sleep_gpe_event_handler (scope); +aml_append (dsdt, scope); +if (pcmc->legacy_cpu_hotplug) {build_legacy_cpu_hotplug_aml (dsdt, machine, pm->cpu_hp_io_base); }else {
Signature · 1 line
2.34.3
RFC PATCH 5/11 tests/acpi/bios-tables-test: update DSDT tables for Control Method Sleep button
In reply to Annie LiUpdate various DSDT tables and empty bios-tables-test-allowed-diff.h
Following the step 5 and 6 in tests/qtest/bios-tables-test.c, the changes in the tables are:
DSDT:
/*
* Intel ACPI Component Architecture
* AML/ASL+ Disassembler version 20210604 (64-bit version)
* Copyright (c) 2000 - 2021 Intel Corporation
*
* Disassembling to symbolic ASL+ operators
*
- * Disassembly of tests/data/acpi/pc/DSDT, Mon Dec 4 15:52:25 2023
+ * Disassembly of /tmp/aml-LRMEF2, Mon Dec 4 15:52:25 2023 *
* Original Table Header:
* Signature "DSDT"
- * Length 0x00001AAE (6830)
+ * Length 0x00001B64 (7012)
* Revision 0x01 **** 32-bit table (V1), no 64-bit math support
- * Checksum 0x0B
+ * Checksum 0x14
* OEM ID "BOCHS "
* OEM Table ID "BXPC "
* OEM Revision 0x00000001 (1)
* Compiler ID "BXPC"
* Compiler Version 0x00000001 (1)
*/
DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)
{
Scope (\)
{
OperationRegion (DBG, SystemIO, 0x0402, One)
Field (DBG, ByteAcc, NoLock, Preserve)
{
DBGB, 8
}@@ -488,32 +488,69 @@
{
Memory32Fixed (ReadOnly,
0xFED00000, // Address Base
0x00000400, // Address Length
)
})
}
}
Scope (_GPE)
{
Name (_HID, "ACPI0006" /* GPE Block Device */) // _HID: Hardware ID
}
Scope (_SB)
{
+ Device (\_SB.SLPB)
+ {
+ Name (_HID, EisaId ("PNP0C0E") /* Sleep Button Device */) // _HID: Hardware ID
+ Name (_PRW, Package (0x02) // _PRW: Power Resources for Wake
+ {
+ One,
+ 0x04
+ })
+ OperationRegion (\B**, SystemIO, 0x0201, One)
+ Field (\B**, ByteAcc, NoLock, WriteAsZeros)
+ {
+ SBP, 1,
+ SBW, 1+ }
+ }
+ }
+
+ Scope (\_GPE)
+ {
+ Method (_L07, 0, NotSerialized) // _Lxx: Level-Triggered GPE, xx=0x00-0xFF
+ {
+ If (\_SB.SLPB.SBP)
+ {
+ \_SB.SLPB.SBP = One
+ Notify (\_SB.SLPB, 0x80) // Status Change
+ }
+
+ If (\_SB.SLPB.SBW)
+ {
+ \_SB.SLPB.SBW = One
+ Notify (\_SB.SLPB, 0x02) // Device Wake
+ }
+ }
+ }
+
+ Scope (_SB)
+ {
Device (\_SB.PCI0.PRES)
{
Name (_HID, EisaId ("PNP0A06") /* Generic Container Device */) // _HID: Hardware ID
Name (_UID, "CPU Hotplug resources") // _UID: Unique ID
Mutex (CPLK, 0x00)
Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
{
IO (Decode16,
0xAF00, // Range Minimum
0xAF00, // Range Maximum
0x01, // Alignment
0x0C, // Length
)
})
OperationRegion (PRST, SystemIO, 0xAF00, 0x0C)
Field (PRST, ByteAcc, NoLock, WriteAsZeros)--- tests/data/acpi/pc/DSDT | Bin 6830 -> 7012 bytes tests/data/acpi/pc/DSDT.acpierst | Bin 6741 -> 6923 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 8155 -> 8337 bytes tests/data/acpi/pc/DSDT.bridge | Bin 13701 -> 13883 bytes tests/data/acpi/pc/DSDT.cphp | Bin 7294 -> 7476 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 8484 -> 8666 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 6781 -> 6963 bytes tests/data/acpi/pc/DSDT.hpbrroot | Bin 3337 -> 3519 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6902 -> 7084 bytes tests/data/acpi/pc/DSDT.memhp | Bin 8189 -> 8371 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 6688 -> 6870 bytes tests/data/acpi/pc/DSDT.numamem | Bin 6836 -> 7018 bytes tests/data/acpi/pc/DSDT.roothp | Bin 10623 -> 10805 bytes tests/data/acpi/q35/DSDT | Bin 8355 -> 8537 bytes tests/data/acpi/q35/DSDT.acpierst | Bin 8372 -> 8554 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9680 -> 9862 bytes tests/data/acpi/q35/DSDT.acpihmat-noinitiator | Bin 8634 -> 8816 bytes tests/data/acpi/q35/DSDT.applesmc | Bin 8401 -> 8583 bytes tests/data/acpi/q35/DSDT.bridge | Bin 11968 -> 12150 bytes tests/data/acpi/q35/DSDT.core-count | Bin 12913 -> 13095 bytes tests/data/acpi/q35/DSDT.core-count2 | Bin 33770 -> 33952 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8819 -> 9001 bytes tests/data/acpi/q35/DSDT.cxl | Bin 9713 -> 9895 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 10009 -> 10191 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 8430 -> 8612 bytes tests/data/acpi/q35/DSDT.ipmismbus | Bin 8443 -> 8625 bytes tests/data/acpi/q35/DSDT.ivrs | Bin 8372 -> 8554 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9714 -> 9896 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 9485 -> 9667 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 13208 -> 13390 bytes tests/data/acpi/q35/DSDT.noacpihp | Bin 8235 -> 8417 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 8213 -> 8395 bytes tests/data/acpi/q35/DSDT.numamem | Bin 8361 -> 8543 bytes tests/data/acpi/q35/DSDT.pvpanic-isa | Bin 8456 -> 8638 bytes tests/data/acpi/q35/DSDT.thread-count | Bin 12913 -> 13095 bytes tests/data/acpi/q35/DSDT.thread-count2 | Bin 33770 -> 33952 bytes tests/data/acpi/q35/DSDT.tis.tpm12 | Bin 8961 -> 9143 bytes tests/data/acpi/q35/DSDT.tis.tpm2 | Bin 8987 -> 9169 bytes tests/data/acpi/q35/DSDT.type4-count | Bin 18589 -> 18771 bytes tests/data/acpi/q35/DSDT.viot | Bin 9464 -> 9646 bytes tests/data/acpi/q35/DSDT.xapic | Bin 35718 -> 35900 bytes tests/qtest/bios-tables-test-allowed-diff.h | 41 ------------------ 42 files changed, 41 deletions(-)
tests/data/acpi/pc/DSDT binary +0 -0
tests/data/acpi/pc/DSDT.acpierst binary +0 -0
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
tests/data/acpi/pc/DSDT.bridge binary +0 -0
tests/data/acpi/pc/DSDT.cphp binary +0 -0
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
tests/data/acpi/pc/DSDT.hpbrroot binary +0 -0
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
tests/data/acpi/pc/DSDT.memhp binary +0 -0
tests/data/acpi/pc/DSDT.nohpet binary +0 -0
tests/data/acpi/pc/DSDT.numamem binary +0 -0
tests/data/acpi/pc/DSDT.roothp binary +0 -0
tests/data/acpi/q35/DSDT binary +0 -0
tests/data/acpi/q35/DSDT.acpierst binary +0 -0
tests/data/acpi/q35/DSDT.acpihmat binary +0 -0
tests/data/acpi/q35/DSDT.acpihmat-noinitiator binary +0 -0
tests/data/acpi/q35/DSDT.applesmc binary +0 -0
tests/data/acpi/q35/DSDT.bridge binary +0 -0
tests/data/acpi/q35/DSDT.core-count binary +0 -0
tests/data/acpi/q35/DSDT.core-count2 binary +0 -0
tests/data/acpi/q35/DSDT.cphp binary +0 -0
tests/data/acpi/q35/DSDT.cxl binary +0 -0
tests/data/acpi/q35/DSDT.dimmpxm binary +0 -0
tests/data/acpi/q35/DSDT.ipmibt binary +0 -0
tests/data/acpi/q35/DSDT.ipmismbus binary +0 -0
tests/data/acpi/q35/DSDT.ivrs binary +0 -0
tests/data/acpi/q35/DSDT.memhp binary +0 -0
tests/data/acpi/q35/DSDT.mmio64 binary +0 -0
tests/data/acpi/q35/DSDT.multi-bridge binary +0 -0
tests/data/acpi/q35/DSDT.noacpihp binary +0 -0
tests/data/acpi/q35/DSDT.nohpet binary +0 -0
tests/data/acpi/q35/DSDT.numamem binary +0 -0
tests/data/acpi/q35/DSDT.pvpanic-isa binary +0 -0
tests/data/acpi/q35/DSDT.thread-count binary +0 -0
tests/data/acpi/q35/DSDT.thread-count2 binary +0 -0
tests/data/acpi/q35/DSDT.tis.tpm12 binary +0 -0
tests/data/acpi/q35/DSDT.tis.tpm2 binary +0 -0
tests/data/acpi/q35/DSDT.type4-count binary +0 -0
tests/data/acpi/q35/DSDT.viot binary +0 -0
tests/data/acpi/q35/DSDT.xapic binary +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +0 -41
42 lines not on this page · raw message
Signature · 1 line
2.34.3
RFC PATCH 6/11 acpi: Send the GPE event of suspend and wakeup for x86
In reply to Annie LiThe GPE event is triggered to notify the guest to suspend or wakeup itself. This patch removes the previous implementation of QEMU_WAKEUP_REASON_OTHER pretending the resume was caused by power button.
--- hw/acpi/core.c | 17 +++++++++++++---- hw/core/machine-qmp-cmds.c | 2 ++ include/hw/acpi/acpi.h | 1 + include/hw/acpi/acpi_dev_interface.h | 1 + 4 files changed, 17 insertions(+), 4 deletions(-)
hw/acpi/core.c +13 -4
@@ -354,6 +354,16 @@ int acpi_get_slic_oem(AcpiSlicOem *oem)return -1 ; } +void acpi_send_sleep_wakeup_event (void ) +{ +Object *obj =object_resolve_path_type ("" ,TYPE_ACPI_DEVICE_IF ,NULL ); + +if (obj) { +/* Send _GPE.L07 event */ +acpi_send_event (DEVICE (obj),ACPI_SLEEP_STATUS ); + } +} +static void acpi_notify_wakeup (Notifier *notifier,void *data) {ACPIREGS *ar =container_of (notifier,ACPIREGS , wakeup);
@@ -369,10 +379,9 @@ static void acpi_notify_wakeup(Notifier *notifier, void *data) (ACPI_BITMASK_WAKE_STATUS |ACPI_BITMASK_TIMER_STATUS );break ;case QEMU_WAKEUP_REASON_OTHER : -/* ACPI_BITMASK_WAKE_STATUS should be set on resume. -Pretend that resume was caused by power button */ - ar->pm1.evt.sts |= - (ACPI_BITMASK_WAKE_STATUS |ACPI_BITMASK_POWER_BUTTON_STATUS ); +/* ACPI_BITMASK_WAKE_STATUS should be set on resume. */ + ar->pm1.evt.sts |=ACPI_BITMASK_WAKE_STATUS ; +acpi_send_sleep_wakeup_event ();break ;default :break ;
hw/core/machine-qmp-cmds.c +2 -0
@@ -9,6 +9,7 @@#include "qemu/osdep.h" #include "hw/acpi/vmgenid.h" +#include "hw/acpi/acpi.h" #include "hw/boards.h" #include "hw/intc/intc.h" #include "hw/mem/memory-device.h"
@@ -264,6 +265,7 @@ void qmp_system_sleep(Error **errp) "suspend from running is not supported by this guest");return ; } +acpi_send_sleep_wakeup_event (); }void qmp_system_powerdown (Error **errp)
include/hw/acpi/acpi.h +1 -0
@@ -181,6 +181,7 @@ uint32_t acpi_gpe_ioport_readb(ACPIREGS *ar, uint32_t addr);void acpi_send_gpe_event (ACPIREGS *ar,qemu_irq irq,AcpiEventStatusBits status); +void acpi_send_sleep_wakeup_event (void );void acpi_update_sci (ACPIREGS *acpi_regs,qemu_irq irq);
include/hw/acpi/acpi_dev_interface.h +1 -0
@@ -13,6 +13,7 @@ typedef enum {ACPI_NVDIMM_HOTPLUG_STATUS =16 ,ACPI_VMGENID_CHANGE_STATUS =32 ,ACPI_POWER_DOWN_STATUS =64 , +ACPI_SLEEP_STATUS =128 , } AcpiEventStatusBits;#define TYPE_ACPI_DEVICE_IF "acpi-device-interface"
Signature · 1 line
2.34.3
RFC PATCH 7/11 hw/acpi: Add ACPI GED support for the sleep event
In reply to Annie LiFrom: Miguel Luis <[email protected]>
Add support for ACPI GED sleep event on the ACPI device interface so that HW-reduced systems can enable guests to sleep.
--- hw/acpi/generic_event_device.c | 9 +++++++++ include/hw/acpi/generic_event_device.h | 1 + 2 files changed, 10 insertions(+)
hw/acpi/generic_event_device.c +9 -0
@@ -13,6 +13,7 @@#include "qapi/error.h" #include "hw/acpi/acpi.h" #include "hw/acpi/generic_event_device.h" +#include "hw/acpi/control_method_device.h" #include "hw/irq.h" #include "hw/mem/pc-dimm.h" #include "hw/mem/nvdimm.h"
@@ -25,6 +26,7 @@ static const uint32_t ged_supported_events[] = {ACPI_GED_MEM_HOTPLUG_EVT ,ACPI_GED_PWR_DOWN_EVT ,ACPI_GED_NVDIMM_HOTPLUG_EVT , + ACPI_GED_SLEEP_EVT, };/*
@@ -117,6 +119,11 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev,aml_notify (aml_name ("\\_SB.NVDR" ), aml_int(0x80)));break ; +case ACPI_GED_SLEEP_EVT : +aml_append (if_ctx, +aml_notify (aml_name (ACPI_SLEEP_BUTTON_DEVICE ), +aml_int (0x80 ))); +break ;default :/* * Please make sure all the events in ged_supported_events[]
@@ -284,6 +291,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev) sel =ACPI_GED_MEM_HOTPLUG_EVT ; }else if (ev &ACPI_POWER_DOWN_STATUS ) { sel =ACPI_GED_PWR_DOWN_EVT ; + }else if (ev &ACPI_SLEEP_STATUS ) { + sel =ACPI_GED_SLEEP_EVT ; }else if (ev &ACPI_NVDIMM_HOTPLUG_STATUS ) { sel =ACPI_GED_NVDIMM_HOTPLUG_EVT ; }else {
include/hw/acpi/generic_event_device.h +1 -0
@@ -95,6 +95,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(AcpiGedState, ACPI_GED)#define ACPI_GED_MEM_HOTPLUG_EVT 0x1#define ACPI_GED_PWR_DOWN_EVT 0x2#define ACPI_GED_NVDIMM_HOTPLUG_EVT 0x4 +#define ACPI_GED_SLEEP_EVT 0x8 typedef struct GEDState { MemoryRegion evt;
Signature · 1 line
2.34.3
RFC PATCH 8/11 tests/acpi: allow FACP and DSDT table changes for arm/virt
In reply to Annie LiFrom: Miguel Luis <[email protected]>
List changed files for FACP and DSDT table changes for the arm/virt.
--- tests/qtest/bios-tables-test-allowed-diff.h | 7 +++++++ 1 file changed, 7 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +7 -0
@@ -1 +1,8 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/virt/DSDT" , +"tests/data/acpi/virt/DSDT.acpihmatvirt" , +"tests/data/acpi/virt/DSDT.memhp" , +"tests/data/acpi/virt/DSDT.pxb" , +"tests/data/acpi/virt/DSDT.topology" , +"tests/data/acpi/virt/FACP", +
Signature · 1 line
2.34.3
RFC PATCH 9/11 hw/arm: enable sleep support for arm/virt
In reply to Annie LiFrom: Miguel Luis <[email protected]>
Include the ACPI control method device into arm/virt ACPI tables and the corresponding handling which enables triggering the event.
--- hw/arm/virt-acpi-build.c | 13 +++++++++++++ hw/arm/virt.c | 13 ++++++++++++- include/hw/arm/virt.h | 1 + 3 files changed, 26 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +13 -0
@@ -42,6 +42,7 @@#include "hw/acpi/pci.h" #include "hw/acpi/memory_hotplug.h" #include "hw/acpi/generic_event_device.h" +#include "hw/acpi/control_method_device.h" #include "hw/acpi/tpm.h" #include "hw/acpi/hmat.h" #include "hw/pci/pcie_host.h"
@@ -816,6 +817,17 @@ static void build_fadt_rev6(GArray *table_data, BIOSLinker *linker, .rev = 6, .minor_ver = 0, .flags = 1 << ACPI_FADT_F_HW_REDUCED_ACPI, +/* ACPI 5.0: 4.8.3.7 Sleep Control and Status Registers */ + .sleep_ctl = { + .space_id = AML_AS_SYSTEM_MEMORY, + .bit_width = 8, + .address = vms->memmap[VIRT_ACPI_GED].base + ACPI_GED_REG_SLEEP_CTL, + }, + .sleep_sts = { + .space_id = AML_AS_SYSTEM_MEMORY, + .bit_width = 8, + .address = vms->memmap[VIRT_ACPI_GED].base + ACPI_GED_REG_SLEEP_STS, + }, .xdsdt_tbl_offset = &dsdt_tbl_offset, };
@@ -890,6 +902,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) }acpi_dsdt_add_power_button (scope); +acpi_dsdt_add_sleep_button (scope);#ifdef CONFIG_TPM acpi_dsdt_add_tpm (scope, vms);#endif
hw/arm/virt.c +12 -1
@@ -644,7 +644,7 @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms)DeviceState *dev;MachineState *ms =MACHINE (vms);int irq = vms->irqmap[VIRT_ACPI_GED ]; -uint32_t event =ACPI_GED_PWR_DOWN_EVT ; +uint32_t event =ACPI_GED_PWR_DOWN_EVT |ACPI_GED_SLEEP_EVT ;if (ms->ram_slots) { event |=ACPI_GED_MEM_HOTPLUG_EVT ;
@@ -931,6 +931,14 @@ static void create_rtc(const VirtMachineState *vms)g_free (nodename); } +static void virt_sleep_req (Notifier *n,void *opaque) +{ +VirtMachineState *s =container_of (n, VirtMachineState, sleep_notifier); + +if (s->acpi_dev) { +acpi_send_event (s->acpi_dev,ACPI_SLEEP_STATUS ); + } +}static DeviceState *gpio_key_dev;static void virt_powerdown_req (Notifier *n,void *opaque) {
@@ -2299,6 +2307,9 @@ static void machvirt_init(MachineState *machine)create_gpio_devices (vms,VIRT_SECURE_GPIO , secure_sysmem); } +/* connect sleep request */ + vms->sleep_notifier.notify = virt_sleep_req; +/* connect powerdown request */ vms->powerdown_notifier.notify = virt_powerdown_req;qemu_register_powerdown_notifier (&vms->powerdown_notifier);
include/hw/arm/virt.h +1 -0
@@ -170,6 +170,7 @@ struct VirtMachineState {DeviceState *gic;DeviceState *acpi_dev;Notifier powerdown_notifier; +Notifier sleep_notifier;PCIBus *bus;char *oem_id;char *oem_table_id;
Signature · 1 line
2.34.3
RFC PATCH 10/11 tests/acpi: Update FACP and DSDT tables for sleep button
In reply to Annie LiFrom: Miguel Luis <[email protected]>
*
* ACPI Data Table [FACP]
*
* Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue */
[000h 0000 4] Signature : "FACP" [Fixed ACPI Description Table (FADT)] [004h 0004 4] Table Length : 00000114 [008h 0008 1] Revision : 06 -[009h 0009 1] Checksum : 15 +[009h 0009 1] Checksum : E2 [00Ah 0010 6] Oem ID : "BOCHS " [010h 0016 8] Oem Table ID : "BXPC " [018h 0024 4] Oem Revision : 00000001 [01Ch 0028 4] Asl Compiler ID : "BXPC" [020h 0032 4] Asl Compiler Revision : 00000001
[024h 0036 4] FACS Address : 00000000 [028h 0040 4] DSDT Address : 00000000 [02Ch 0044 1] Model : 00 [02Dh 0045 1] PM Profile : 00 [Unspecified] [02Eh 0046 2] SCI Interrupt : 0000 [030h 0048 4] SMI Command Port : 00000000 [034h 0052 1] ACPI Enable Value : 00 [035h 0053 1] ACPI Disable Value : 00 [036h 0054 1] S4BIOS Command : 00 [037h 0055 1] P-State Control : 00 @@ -148,50 +148,50 @@ [0DCh 0220 1] Space ID : 00 [SystemMemory] [0DDh 0221 1] Bit Width : 00 [0DEh 0222 1] Bit Offset : 00 [0DFh 0223 1] Encoded Access Width : 00 [Undefined/Legacy] [0E0h 0224 8] Address : 0000000000000000
[0E8h 0232 12] GPE1 Block : [Generic Address Structure]
[0E8h 0232 1] Space ID : 00 [SystemMemory] [0E9h 0233 1] Bit Width : 00 [0EAh 0234 1] Bit Offset : 00 [0EBh 0235 1] Encoded Access Width : 00 [Undefined/Legacy] [0ECh 0236 8] Address : 0000000000000000
[0F4h 0244 12] Sleep Control Register : [Generic Address Structure]
[0F4h 0244 1] Space ID : 00 [SystemMemory] -[0F5h 0245 1] Bit Width : 00 +[0F5h 0245 1] Bit Width : 08 [0F6h 0246 1] Bit Offset : 00 [0F7h 0247 1] Encoded Access Width : 00 [Undefined/Legacy] -[0F8h 0248 8] Address : 0000000000000000 +[0F8h 0248 8] Address : 0000000009080000
[100h 0256 12] Sleep Status Register : [Generic Address Structure]
[100h 0256 1] Space ID : 00 [SystemMemory] -[101h 0257 1] Bit Width : 00 +[101h 0257 1] Bit Width : 08 [102h 0258 1] Bit Offset : 00 [103h 0259 1] Encoded Access Width : 00 [Undefined/Legacy] -[104h 0260 8] Address : 0000000000000000 +[104h 0260 8] Address : 0000000009080001
[10Ch 0268 8] Hypervisor ID : 00000000554D4551
Raw Table Data: Length 276 (0x114)
- 0000: 46 41 43 50 14 01 00 00 06 15 42 4F 43 48 53 20 // FACP......BOCHS
+ 0000: 46 41 43 50 14 01 00 00 06 E2 42 4F 43 48 53 20 // FACP......BOCHS
0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43 // BXPC ....BXPC
0020: 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
0070: 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
0080: 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
00A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
00B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
00C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
00D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
00E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
- 00F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................
- 0100: 00 00 00 00 00 00 00 00 00 00 00 00 51 45 4D 55 // ............QEMU
+ 00F0: 00 00 00 00 00 08 00 00 00 00 08 09 00 00 00 00 // ................
+ 0100: 00 08 00 00 01 00 08 09 00 00 00 00 51 45 4D 55 // ............QEMU
0110: 00 00 00 00 // .... *
* Original Table Header:
* Signature "DSDT"
- * Length 0x0000144C (5196)
+ * Length 0x0000149E (5278)
* Revision 0x02
- * Checksum 0x9F
+ * Checksum 0x2B
* OEM ID "BOCHS "
* OEM Table ID "BXPC "
* OEM Revision 0x00000001 (1)
* Compiler ID "BXPC"
* Compiler Version 0x00000001 (1)
*/
DefinitionBlock ("", "DSDT", 2, "BOCHS ", "BXPC ", 0x00000001)
{
Scope (\_SB)
{
Device (C000)
{
Name (_HID, "ACPI0007" /* Processor Device */) // _HID: Hardware ID
Name (_UID, Zero) // _UID: Unique ID
}@@ -1876,27 +1876,48 @@
0x00000029,
}
})
OperationRegion (EREG, SystemMemory, 0x09080000, 0x04)
Field (EREG, DWordAcc, NoLock, WriteAsZeros)
{
ESEL, 32
}
Method (_EVT, 1, Serialized) // _EVT: Event
{
Local0 = ESEL /* \_SB_.GED_.ESEL */
If (((Local0 & 0x02) == 0x02))
{
Notify (PWRB, 0x80) // Status Change
}+
+ If (((Local0 & 0x08) == 0x08))
+ {
+ Notify (SLPB, 0x80) // Status Change
+ }
}
}
Device (PWRB)
{
Name (_HID, "PNP0C0C" /* Power Button Device */) // _HID: Hardware ID
Name (_UID, Zero) // _UID: Unique ID
}
+
+ Device (\_SB.SLPB)
+ {
+ Name (_HID, EisaId ("PNP0C0E") /* Sleep Button Device */) // _HID: Hardware ID
+ Name (_PRW, Package (0x02) // _PRW: Power Resources for Wake
+ {
+ One,
+ 0x04
+ })
+ OperationRegion (\B**, SystemIO, 0x0201, One)
+ Field (\B**, ByteAcc, NoLock, WriteAsZeros)
+ {
+ SBP, 1,
+ SBW, 1
+ }
+ }
}}
--- tests/data/acpi/virt/DSDT | Bin 5196 -> 5278 bytes tests/data/acpi/virt/DSDT.acpihmatvirt | Bin 5282 -> 5364 bytes tests/data/acpi/virt/DSDT.memhp | Bin 6557 -> 6639 bytes tests/data/acpi/virt/DSDT.pxb | Bin 7679 -> 7761 bytes tests/data/acpi/virt/DSDT.topology | Bin 5398 -> 5480 bytes tests/data/acpi/virt/FACP | Bin 276 -> 276 bytes tests/qtest/bios-tables-test-allowed-diff.h | 7 ------- 7 files changed, 7 deletions(-)
tests/data/acpi/virt/DSDT binary +0 -0
tests/data/acpi/virt/DSDT.acpihmatvirt binary +0 -0
tests/data/acpi/virt/DSDT.memhp binary +0 -0
tests/data/acpi/virt/DSDT.pxb binary +0 -0
tests/data/acpi/virt/DSDT.topology binary +0 -0
tests/data/acpi/virt/FACP binary +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +0 -7
@@ -1,8 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/virt/DSDT" , -"tests/data/acpi/virt/DSDT.acpihmatvirt" , -"tests/data/acpi/virt/DSDT.memhp" , -"tests/data/acpi/virt/DSDT.pxb" , -"tests/data/acpi/virt/DSDT.topology" , -"tests/data/acpi/virt/FACP", -
Signature · 1 line
2.34.3
RFC PATCH 11/11 arm/virt: enable sleep support
In reply to Annie LiFrom: Miguel Luis <[email protected]>
This is for reference that qmp_system_sleep relies on wakeup support delegated by qemu_wakeup_suspend_enabled() hence the need for calling qemu_register_wakeup_support().
--- hw/arm/virt.c | 1 + 1 file changed, 1 insertion(+)
hw/arm/virt.c +1 -0
@@ -2309,6 +2309,7 @@ static void machvirt_init(MachineState *machine)/* connect sleep request */ vms->sleep_notifier.notify = virt_sleep_req; +qemu_register_wakeup_support ();/* connect powerdown request */ vms->powerdown_notifier.notify = virt_powerdown_req;
Signature · 1 line
2.34.3