qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 09/11] hw/arm: enable sleep support for arm/virt
Date: Fri, 27 Sep 2024 14:39:04 -0400	[thread overview]
Message-ID: <20240927183906.1248-10-annie.li@oracle.com> (raw)
In-Reply-To: <20240927183906.1248-1-annie.li@oracle.com>

From: Miguel Luis <miguel.luis@oracle.com>

Include the ACPI control method device into arm/virt ACPI tables and the
corresponding handling which enables triggering the event.

Signed-off-by: Miguel Luis <miguel.luis@oracle.com>
---
 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(-)

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index f76fb117ad..ef68d69024 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -41,6 +41,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"
@@ -779,6 +780,17 @@ static void build_fadt_rev6(GArray *table_data, BIOSLinker *linker,
         .rev = 6,
         .minor_ver = 3,
         .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,
     };
 
@@ -858,6 +870,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
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 687fe0bb8b..6be80f042f 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -677,7 +677,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;
@@ -996,6 +996,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)
 {
@@ -2393,6 +2401,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);
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
index a4d937ed45..75725d8740 100644
--- a/include/hw/arm/virt.h
+++ b/include/hw/arm/virt.h
@@ -175,6 +175,7 @@ struct VirtMachineState {
     DeviceState *gic;
     DeviceState *acpi_dev;
     Notifier powerdown_notifier;
+    Notifier sleep_notifier;
     PCIBus *bus;
     char *oem_id;
     char *oem_table_id;
-- 
2.43.5



  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 ` [RFC V2 PATCH 06/11] acpi: Send the GPE event of suspend and wakeup for x86 Annie Li
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 ` Annie Li [this message]
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-10-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).