From nobody Wed Nov 12 03:45:52 2025 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=1567587893; cv=none; d=zoho.com; s=zohoarc; b=ZvBUc9r9M/RzKC+HcCMaHCRBmBUtpxRIbv48GM6mUCtytsvyzxRDXXTbvP13MIsVXCdxV4ilPcC78iUaVEStxMQHaxW21zWeOY4AT2Pio7DucNUM47ANEG57IKwUBy0TDR1KE3BHAMz27tVCz3Tyvk4OjiJt29A7NKubzDFsTBA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567587893; 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=PM1/LUgcWXIf/SWOn6r2EggZ/2GWbVEYgiv/xNig5kY=; b=V9eXSCYN6Sa1sE1/MQ35U8ccNHxxIBPmE1itt0txxPfufOAWaA+Iz4g7JzOFY6SD/GRNey8nZeLKxBJwNQpq5Lq07pw+ScIynpPCFfQ7wQ02u7EpJ3z2HeznJZ413i0yvZY6Rfn/vF7YMGvBtQNcFNicLXsF4jRrlJZYTEnQT5c= 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 1567587893342321.75616195570433; Wed, 4 Sep 2019 02:04:53 -0700 (PDT) Received: from localhost ([::1]:54772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5RDf-0004xZ-V5 for importer@patchew.org; Wed, 04 Sep 2019 05:04:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38673) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5R7D-0007Xu-S3 for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:58:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5R7B-0007Hq-9w for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:58:11 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2260 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5R78-0007Ft-00; Wed, 04 Sep 2019 04:58:06 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 1588BE67DB0E507DBD76; Wed, 4 Sep 2019 16:58:04 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Wed, 4 Sep 2019 16:57:53 +0800 From: Shameer Kolothum To: , , , Date: Wed, 4 Sep 2019 09:56:26 +0100 Message-ID: <20190904085629.13872-9-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> References: <20190904085629.13872-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 v10 08/11] 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 Reviewed-by: Eric Auger Reviewed-by: Igor Mammedov --- v9 --> v10 -Eric's R-by v8 --> v9 -Re-arranged patches 8 & 9 from v8 based on Igor's comments. 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 | 8 ++++++++ hw/arm/virt-acpi-build.c | 6 +++--- hw/arm/virt.c | 16 +++++++++++----- include/hw/acpi/acpi_dev_interface.h | 1 + include/hw/acpi/generic_event_device.h | 3 +++ 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index f81d966058..47e178c583 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -22,6 +22,7 @@ =20 static const uint32_t ged_supported_events[] =3D { ACPI_GED_MEM_HOTPLUG_EVT, + ACPI_GED_PWR_DOWN_EVT, }; =20 /* @@ -104,6 +105,11 @@ void build_ged_aml(Aml *table, const char *name, Hotpl= ugHandler *hotplug_dev, aml_append(if_ctx, aml_call0(MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD)); break; + case ACPI_GED_PWR_DOWN_EVT: + aml_append(if_ctx, + aml_notify(aml_name(ACPI_POWER_BUTTON_DEVICE), + aml_int(0x80))); + break; default: /* * Please make sure all the events in ged_supported_events= [] @@ -190,6 +196,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 a4872a0b00..bbf7f6fafa 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -50,7 +50,6 @@ #include "migration/vmstate.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) { @@ -740,13 +739,14 @@ 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, memmap[VIRT_ACPI_GED].base); + } 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 89ee37d7de..32208e1058 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -532,7 +532,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 qdev_create(NULL, TYPE_ACPI_GED); qdev_prop_set_uint32(dev, "ged-event", event); @@ -787,8 +787,14 @@ static void create_rtc(const VirtMachineState *vms, qe= mu_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); + + 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) @@ -1716,10 +1722,10 @@ static void machvirt_init(MachineState *machine) =20 create_pcie(vms, pic); =20 - create_gpio(vms, pic); - 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 */ diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_de= v_interface.h index 0ba90effd2..a2a12af9b9 100644 --- a/include/hw/acpi/acpi_dev_interface.h +++ b/include/hw/acpi/acpi_dev_interface.h @@ -13,6 +13,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/acpi/generic_event_device.h b/include/hw/acpi/gener= ic_event_device.h index 2049e8d873..d157eac088 100644 --- a/include/hw/acpi/generic_event_device.h +++ b/include/hw/acpi/generic_event_device.h @@ -62,6 +62,8 @@ #include "hw/sysbus.h" #include "hw/acpi/memory_hotplug.h" =20 +#define ACPI_POWER_BUTTON_DEVICE "PWRB" + #define TYPE_ACPI_GED "acpi-ged" #define ACPI_GED(obj) \ OBJECT_CHECK(AcpiGedState, (obj), TYPE_ACPI_GED) @@ -79,6 +81,7 @@ * through GED. */ #define ACPI_GED_MEM_HOTPLUG_EVT 0x1 +#define ACPI_GED_PWR_DOWN_EVT 0x2 =20 typedef struct GEDState { MemoryRegion io; --=20 2.17.1