From: Annie Li <annie.li@oracle.com>
To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, imammedo@redhat.com
Cc: dave@treblig.org, mst@redhat.com, anisinha@redhat.com,
shannon.zhaosl@gmail.com, peter.maydell@linaro.org,
eduardo@habkost.net, marcel.apfelbaum@gmail.com,
philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com,
pbonzini@redhat.com, richard.henderson@linaro.org,
eblake@redhat.com, armbru@redhat.com, annie.li@oracle.com,
miguel.luis@oracle.com
Subject: [RFC V2 PATCH 06/11] acpi: Send the GPE event of suspend and wakeup for x86
Date: Fri, 27 Sep 2024 14:39:01 -0400 [thread overview]
Message-ID: <20240927183906.1248-7-annie.li@oracle.com> (raw)
In-Reply-To: <20240927183906.1248-1-annie.li@oracle.com>
The GPE event is triggered to notify the guest to suppend or
wakeup itself.
Signed-off-by: Annie Li <annie.li@oracle.com>
---
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(-)
diff --git a/hw/acpi/core.c b/hw/acpi/core.c
index ec5e127d17..e5c3ff9a54 100644
--- a/hw/acpi/core.c
+++ b/hw/acpi/core.c
@@ -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;
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 770f8189ba..010bba05f3 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -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"
@@ -283,6 +284,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)
diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h
index e0e51e85b4..07e31aa138 100644
--- a/include/hw/acpi/acpi.h
+++ b/include/hw/acpi/acpi.h
@@ -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);
diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
index 68d9d15f50..1cb050cd3a 100644
--- a/include/hw/acpi/acpi_dev_interface.h
+++ b/include/hw/acpi/acpi_dev_interface.h
@@ -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"
--
2.43.5
next prev parent reply other threads:[~2024-09-27 18:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-27 18:38 [RFC V2 PATCH 00/11] Support ACPI Control Method Sleep button Annie Li
2024-09-27 18:38 ` [RFC V2 PATCH 01/11] acpi: hmp/qmp: Add hmp/qmp support for system_sleep Annie Li
2024-10-07 12:44 ` Igor Mammedov
2024-10-08 15:21 ` Annie Li
2024-09-27 18:38 ` [RFC V2 PATCH 02/11] acpi: Implement control method sleep button Annie Li
2024-10-07 12:59 ` Igor Mammedov
2024-10-08 15:22 ` Annie Li
2024-10-11 12:10 ` Igor Mammedov
2024-09-27 18:38 ` [RFC V2 PATCH 03/11] test/acpi: allow DSDT table changes Annie Li
2024-09-27 18:38 ` [RFC V2 PATCH 04/11] acpi: Support Control Method sleep button for x86 Annie Li
2024-10-07 13:32 ` Igor Mammedov
2024-10-08 15:33 ` Annie Li
2024-09-27 18:39 ` [RFC V2 PATCH 05/11] tests/acpi: Update DSDT tables for Control method sleep button Annie Li
2024-09-27 18:39 ` Annie Li [this message]
2024-09-27 18:39 ` [RFC V2 PATCH 07/11] hw/acpi: Add ACPI GED support for the sleep event Annie Li
2024-09-27 18:39 ` [RFC V2 PATCH 08/11] tests/acpi: allow FACP and DSDT table changes for arm/virt Annie Li
2024-09-27 18:39 ` [RFC V2 PATCH 09/11] hw/arm: enable sleep support " Annie Li
2024-09-27 18:39 ` [RFC V2 PATCH 10/11] tests/acpi: Update FACP and DSDT tables for sleep button Annie Li
2024-09-27 18:39 ` [RFC V2 PATCH 11/11] arm/virt: enable sleep support Annie Li
2024-10-08 11:53 ` Peter Maydell
2024-10-10 12:43 ` Miguel Luis
2024-10-07 13:41 ` [RFC V2 PATCH 00/11] Support ACPI Control Method Sleep button Igor Mammedov
2024-10-08 15:21 ` Annie Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240927183906.1248-7-annie.li@oracle.com \
--to=annie.li@oracle.com \
--cc=anisinha@redhat.com \
--cc=armbru@redhat.com \
--cc=dave@treblig.org \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=imammedo@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=miguel.luis@oracle.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=shannon.zhaosl@gmail.com \
--cc=wangyanan55@huawei.com \
--cc=zhao1.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).