From nobody Tue Feb 10 23:33:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1564138153; cv=none; d=zoho.com; s=zohoarc; b=ZU/6zKWF6ikS9ZFSYN/QMKdMljIS5fofJv0yH/kPLabjkXnfAIE6f9GYDAY7Mm1tJEMOBYXgfN8ThEDVJZ3her60h2JlbjID97pzBoV5zO0v/tLytJiRnNaStlhJdU1ErTgf0TOYq0akJTmrU+jRx5RZJ5eDzDm6Lmq8IKH57B0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564138153; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=a3WcM1zWIiZpcOkCenZL1JNKr5ezn59ob7s9u8kx38s=; b=mVS9HH5dLZhQU9nDezv5wV46oy0lQLZVLLsQkOzuunGx6+B7iRs5+XEuqi2265CsZz5jB/NqtxEznCu8ZZoxmTg4rZ7L+F5JVgSGLrGnlhk4G+NyvzO+2SEq3JrWub+SfCgyzfOpal96pvKYV8ajtQDEC1mcW3pb5ebVH+lv16Q= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564138153760964.3966623852353; Fri, 26 Jul 2019 03:49:13 -0700 (PDT) Received: from localhost ([::1]:38328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxmh-0006hC-KL for importer@patchew.org; Fri, 26 Jul 2019 06:49:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43579) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxkq-0000DE-Hd for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:47:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqxko-0007Ia-3x for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:47:15 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2243 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hqxkX-0006on-CY; Fri, 26 Jul 2019 06:46:59 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 4964D8CBD32DD9E3B5DA; Fri, 26 Jul 2019 18:46:46 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.439.0; Fri, 26 Jul 2019 18:46:36 +0800 From: Shameer Kolothum To: , , , Date: Fri, 26 Jul 2019 11:45:19 +0100 Message-ID: <20190726104519.23812-10-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190726104519.23812-1-shameerali.kolothum.thodi@huawei.com> References: <20190726104519.23812-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.191 Subject: [Qemu-devel] [PATCH-for-4.2 v8 9/9] hw/arm: Use GED for system_powerdown event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For machines 4.2 or higher with ACPI boot use GED for system_powerdown event instead of GPIO. Guest boot with DT still uses GPIO. Signed-off-by: Shameer Kolothum --- v7 --> v8 -Retained gpio based system_powerdown support for machines < 4.2. -Reuse of virt_powerdown_req() for ACPI GED use. -Dropped Eric's R-by for now because of above. --- hw/acpi/generic_event_device.c | 2 ++ hw/arm/virt-acpi-build.c | 6 +++--- hw/arm/virt.c | 27 ++++++++++++++++----------- include/hw/acpi/acpi_dev_interface.h | 1 + include/hw/arm/virt.h | 1 + 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 0b3214eff4..f00b0ab14b 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -205,6 +205,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, Acp= iEventStatusBits ev) =20 if (ev & ACPI_MEMORY_HOTPLUG_STATUS) { sel =3D ACPI_GED_MEM_HOTPLUG_EVT; + } else if (ev & ACPI_POWER_DOWN_STATUS) { + sel =3D ACPI_GED_PWR_DOWN_EVT; } else { /* Unknown event. Return without generating interrupt. */ warn_report("GED: Unsupported event %d. No irq injected", ev); diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 75657caa36..31bf2bf775 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -49,7 +49,6 @@ #include "kvm_arm.h" =20 #define ARM_SPI_BASE 32 -#define ACPI_POWER_BUTTON_DEVICE "PWRB" =20 static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) { @@ -739,12 +738,13 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPO= RTS); acpi_dsdt_add_pci(scope, memmap, (irqmap[VIRT_PCIE] + ARM_SPI_BASE), vms->highmem, vms->highmem_ecam); - acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], - (irqmap[VIRT_GPIO] + ARM_SPI_BASE)); if (vms->acpi_dev) { build_ged_aml(scope, "\\_SB."GED_DEVICE, HOTPLUG_HANDLER(vms->acpi_dev), irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE, AML_SYSTEM_MEM= ORY); + } else { + acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], + (irqmap[VIRT_GPIO] + ARM_SPI_BASE)); } =20 if (vms->acpi_dev && ms->ram_slots) { diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 41386a6eb7..73a758d9a9 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -528,7 +528,7 @@ static inline DeviceState *create_acpi_ged(VirtMachineS= tate *vms, qemu_irq *pic) { DeviceState *dev; int irq =3D vms->irqmap[VIRT_ACPI_GED]; - uint32_t event =3D ACPI_GED_MEM_HOTPLUG_EVT; + uint32_t event =3D ACPI_GED_MEM_HOTPLUG_EVT | ACPI_GED_PWR_DOWN_EVT; =20 dev =3D DEVICE(object_new(TYPE_ACPI_GED)); qdev_prop_set_uint64(dev, "memhp-base", @@ -784,13 +784,15 @@ static void create_rtc(const VirtMachineState *vms, q= emu_irq *pic) static DeviceState *gpio_key_dev; static void virt_powerdown_req(Notifier *n, void *opaque) { - /* use gpio Pin 3 for power button event */ - qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1); -} + VirtMachineState *s =3D container_of(n, VirtMachineState, powerdown_no= tifier); =20 -static Notifier virt_system_powerdown_notifier =3D { - .notify =3D virt_powerdown_req -}; + if (s->acpi_dev) { + acpi_send_event(s->acpi_dev, ACPI_POWER_DOWN_STATUS); + } else { + /* use gpio Pin 3 for power button event */ + qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1); + } +} =20 static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) { @@ -833,9 +835,6 @@ static void create_gpio(const VirtMachineState *vms, qe= mu_irq *pic) qemu_fdt_setprop_cells(vms->fdt, "/gpio-keys/poweroff", "gpios", phandle, 3, 0); =20 - /* connect powerdown request */ - qemu_register_powerdown_notifier(&virt_system_powerdown_notifier); - g_free(nodename); } =20 @@ -1721,12 +1720,18 @@ static void machvirt_init(MachineState *machine) =20 create_pcie(vms, pic); =20 - create_gpio(vms, pic); =20 if (has_ged && aarch64 && firmware_loaded && acpi_enabled) { vms->acpi_dev =3D create_acpi_ged(vms, pic); + } else { + create_gpio(vms, pic); } =20 + /* connect powerdown request */ + vms->powerdown_notifier.notify =3D virt_powerdown_req; + qemu_register_powerdown_notifier(&vms->powerdown_notifier); + + /* Create mmio transports, so the user can create virtio backends * (which will be automatically plugged in to the transports). If * no backend is created the transport will just sit harmlessly idle. diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_de= v_interface.h index 43ff119179..adcb3a816c 100644 --- a/include/hw/acpi/acpi_dev_interface.h +++ b/include/hw/acpi/acpi_dev_interface.h @@ -11,6 +11,7 @@ typedef enum { ACPI_MEMORY_HOTPLUG_STATUS =3D 8, ACPI_NVDIMM_HOTPLUG_STATUS =3D 16, ACPI_VMGENID_CHANGE_STATUS =3D 32, + ACPI_POWER_DOWN_STATUS =3D 64, } AcpiEventStatusBits; =20 #define TYPE_ACPI_DEVICE_IF "acpi-device-interface" diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 577ee49b4b..0b41083e9d 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -137,6 +137,7 @@ typedef struct { int psci_conduit; hwaddr highest_gpa; DeviceState *acpi_dev; + Notifier powerdown_notifier; } VirtMachineState; =20 #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) --=20 2.17.1