From nobody Tue Feb 10 20:09:21 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=1561466488; cv=none; d=zoho.com; s=zohoarc; b=bErWSzfMvp2PWO6cx+MCBvy122hQSXmEAL+/LiVaw+hzYMpfauwPtCMY/6Ds0bxmqHxbsE85R8HbUsVqpGFhlhoAPn2NAxJdtvJkYB8CXFKXHrDS8cjKYXPBbIJb7DjWWO+oRIEhnuizu6edKXR2kHgHKtSMagUbJyprF3tTW8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561466488; 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=jRLuuv3sLKJ4MMZy9mT+7kth4Pq48ndqHe9l3GxCZLw=; b=GgJjW2YDr5lOjbbCbwmEqCULIaRYJ7B78dLaMFkderN05ztbDW1P6Ti1aejKAK9OGKw0oKRns/1ytLJBpCyJ2KZ6v2TAkZQbU0ThVpjMIfZadVmwA+QHHfGEtMb0/iSifBO8i2uihVFeLle/00HE+s++G45mZMLtpZ61BfkhuNI= 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 1561466488278374.28602096108784; Tue, 25 Jun 2019 05:41:28 -0700 (PDT) Received: from localhost ([::1]:59768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfklL-0007VX-97 for importer@patchew.org; Tue, 25 Jun 2019 08:41:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36607) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkNE-0007OM-4y for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:16:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfkNC-0004cr-2H for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:16:31 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:54734 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hfkN3-0004Ex-J5; Tue, 25 Jun 2019 08:16:23 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 99F7B2D2E6848C930D19; Tue, 25 Jun 2019 20:15:59 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Tue, 25 Jun 2019 20:15:50 +0800 From: Shameer Kolothum To: , , , Date: Tue, 25 Jun 2019 13:14:20 +0100 Message-ID: <20190625121421.22280-8-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> References: <20190625121421.22280-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.35 Subject: [Qemu-devel] [PATCH v6 7/8] hw/acpi: Add system power down support to GED 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" This adds support to use GED for system power down event. Signed-off-by: Shameer Kolothum Reviewed-by: Eric Auger --- hw/acpi/generic_event_device.c | 16 ++++++++++++++++ include/hw/acpi/generic_event_device.h | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 2a83d68e82..2bd786b7ab 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -19,6 +19,7 @@ =20 static const uint32_t ged_supported_events[] =3D { ACPI_GED_MEM_HOTPLUG_EVT, + ACPI_GED_PWR_DOWN_EVT, }; =20 /* @@ -103,6 +104,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= [] @@ -232,6 +238,13 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, Ac= piEventStatusBits ev) acpi_ged_event(s, sel); } =20 +static void acpi_ged_pm_powerdown_req(Notifier *n, void *opaque) +{ + AcpiGedState *s =3D container_of(n, AcpiGedState, powerdown_notifier); + + acpi_ged_event(s, ACPI_GED_PWR_DOWN_EVT); +} + static void acpi_ged_device_realize(DeviceState *dev, Error **errp) { AcpiGedState *s =3D ACPI_GED(dev); @@ -243,6 +256,9 @@ static void acpi_ged_device_realize(DeviceState *dev, E= rror **errp) } =20 acpi_ged_init(get_system_memory(), dev, &s->ged_state); + + s->powerdown_notifier.notify =3D acpi_ged_pm_powerdown_req; + qemu_register_powerdown_notifier(&s->powerdown_notifier); } =20 static Property acpi_ged_properties[] =3D { diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/gener= ic_event_device.h index f69d084c89..9e63b72cb9 100644 --- a/include/hw/acpi/generic_event_device.h +++ b/include/hw/acpi/generic_event_device.h @@ -61,6 +61,8 @@ =20 #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; @@ -88,6 +91,7 @@ typedef struct GEDState { =20 typedef struct AcpiGedState { DeviceClass parent_obj; + Notifier powerdown_notifier; MemHotplugState memhp_state; hwaddr memhp_base; hwaddr ged_base; --=20 2.17.1