From patchwork Fri Sep 27 18:39:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Annie Li X-Patchwork-Id: 13814495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D854FCDD1D3 for ; Fri, 27 Sep 2024 18:41:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1suFtR-000842-F6; Fri, 27 Sep 2024 14:40:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1suFtE-0007qD-1H; Fri, 27 Sep 2024 14:40:29 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1suFtC-0002KN-8t; Fri, 27 Sep 2024 14:40:27 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48RHMbn2032355; Fri, 27 Sep 2024 18:40:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :reply-to:mime-version:content-transfer-encoding; s= corp-2023-11-20; bh=mbjiV8400H7bzf4lI60mywWUq/qn6oPHqXerlfqzuaU=; b= fs/766anhsB7deUwEbFakfH9ZUYUwjXpIe1wpv+uflFmesuwm+zM7ur0DTHsiqq/ 2/6gaqMsr0scU0xRvMa16sc3s566vgUMfcadGis0VLLurI9P5p8C2VIINLmWiy7G PTesTPF9WYeeONrPlT24rbGf2FLxGQdXy+E/OwLH8qq5AKKLCI4k3kCInTRiaygh 4FUrjF2MRCjyCJsic6yK3RhKpecCEqyI1o3IIFc81BInwJ99phED8KG0K6BvrO9O +KMGx/zwM30z5yvSbzwJtzWEJmWSF3jYd2oTIl0b7iHE0tvhfSKmgJsqdils14Bf FCrvDrjcTnIzOt7wZmTYmQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41sp1ar9e7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 27 Sep 2024 18:40:19 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 48RHkEV3032954; Fri, 27 Sep 2024 18:40:17 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41smkm8gqy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 27 Sep 2024 18:40:17 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 48RIdIol009004; Fri, 27 Sep 2024 18:40:17 GMT Received: from localhost.localdomain (dhcp-10-175-14-34.vpn.oracle.com [10.175.14.34]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 41smkm8ff6-10; Fri, 27 Sep 2024 18:40:16 +0000 From: Annie Li 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 Message-ID: <20240927183906.1248-10-annie.li@oracle.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240927183906.1248-1-annie.li@oracle.com> References: <20240927183906.1248-1-annie.li@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-27_06,2024-09-27_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2408220000 definitions=main-2409270135 X-Proofpoint-ORIG-GUID: 8bwulBmtk26lQ1F8CScoJaJboc2LWne8 X-Proofpoint-GUID: 8bwulBmtk26lQ1F8CScoJaJboc2LWne8 Received-SPF: pass client-ip=205.220.165.32; envelope-from=annie.li@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: miguel.luis@oracle.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Miguel Luis 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 --- 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;