From nobody Fri May 3 12:33:47 2024 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=1558542413; cv=none; d=zoho.com; s=zohoarc; b=JYMy//e5XdRDJ0IR9uCUUjy9sXnf3D/811yarPd+AvX0ujbEXZuP/8klcOyY7vor5bBcduhib2Kf8Rn3W9fBTk3z8VFSlQaYwuD21HjpmM4cmdFlpJcqHy+wUuxqVd7tidseLxdPznP/Cn+81+LGG4vrIrxcapFvRJaVmxMP9BM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558542413; 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=5OyPRKUvPWlqPts8WPwjgnK5LqQaGszysIk4I/17EWY=; b=h7ac0l5WcKKab1u/hyfrBTg/weQNHeqGQDsOeF5DXHnFX+EBmHfRxbO6BgONfwCPD22TriIeolbbTbD9WfdRhFswYqlXf7o49RfyTp2Ps1bvTtYCrta62YjDdf43Hsn8iCTVZHoDLObwuIKMRcj7K5JY++xN9/LEiV+8sGLheno= 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 1558542412964613.8089165906879; Wed, 22 May 2019 09:26:52 -0700 (PDT) Received: from localhost ([127.0.0.1]:47538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTU4j-0007ez-Fa for importer@patchew.org; Wed, 22 May 2019 12:26:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTU2r-0006OE-Cc for qemu-devel@nongnu.org; Wed, 22 May 2019 12:24:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTU2o-0001Ka-VR for qemu-devel@nongnu.org; Wed, 22 May 2019 12:24:49 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2216 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTU2k-00010W-NQ; Wed, 22 May 2019 12:24:42 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 3EEDD931BB072AF82B76; Thu, 23 May 2019 00:24:37 +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; Thu, 23 May 2019 00:24:00 +0800 From: Shameer Kolothum To: , , , Date: Wed, 22 May 2019 17:22:45 +0100 Message-ID: <20190522162252.28568-2-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190522162252.28568-1-shameerali.kolothum.thodi@huawei.com> References: <20190522162252.28568-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.190 Subject: [Qemu-devel] [PATCH v5 1/8] hw/acpi: Make ACPI IO address space configurable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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 is in preparation for adding support for ARM64 platforms where it doesn't use port mapped IO for ACPI IO space. Also move few MEMORY_* definitions to header so that other memory hotplug event signalling mechanisms (eg. Generic Event Device on HW-reduced acpi platforms) can use the same from their respective event handler code. Signed-off-by: Shameer Kolothum Reviewed-by: Eric Auger Reviewed-by: Igor Mammedov Tested-by: Eric Auger --- hw/acpi/memory_hotplug.c | 25 ++++++++++++++----------- hw/i386/acpi-build.c | 3 ++- include/hw/acpi/memory_hotplug.h | 9 +++++++-- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 297812d5f7..c724f5f1e4 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -29,12 +29,9 @@ #define MEMORY_SLOT_PROXIMITY_METHOD "MPXM" #define MEMORY_SLOT_EJECT_METHOD "MEJ0" #define MEMORY_SLOT_NOTIFY_METHOD "MTFY" -#define MEMORY_SLOT_SCAN_METHOD "MSCN" #define MEMORY_HOTPLUG_DEVICE "MHPD" -#define MEMORY_HOTPLUG_IO_LEN 24 -#define MEMORY_DEVICES_CONTAINER "\\_SB.MHPC" =20 -static uint16_t memhp_io_base; +static hwaddr memhp_io_base; =20 static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev) { @@ -209,7 +206,7 @@ static const MemoryRegionOps acpi_memory_hotplug_ops = =3D { }; =20 void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, - MemHotplugState *state, uint16_t io_base) + MemHotplugState *state, hwaddr io_base) { MachineState *machine =3D MACHINE(qdev_get_machine()); =20 @@ -342,7 +339,8 @@ const VMStateDescription vmstate_memory_hotplug =3D { =20 void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, const char *res_root, - const char *event_handler_method) + const char *event_handler_method, + AmlRegionSpace rs) { int i; Aml *ifctx; @@ -365,14 +363,19 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr= _mem, aml_name_decl("_UID", aml_string("Memory hotplug resources"))); =20 crs =3D aml_resource_template(); - aml_append(crs, - aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0, - MEMORY_HOTPLUG_IO_LEN) - ); + if (rs =3D=3D AML_SYSTEM_IO) { + aml_append(crs, + aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0, + MEMORY_HOTPLUG_IO_LEN) + ); + } else { + aml_append(crs, aml_memory32_fixed(memhp_io_base, + MEMORY_HOTPLUG_IO_LEN, AML_READ_WRITE)); + } aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs)); =20 aml_append(mem_ctrl_dev, aml_operation_region( - MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO, + MEMORY_HOTPLUG_IO_REGION, rs, aml_int(memhp_io_base), MEMORY_HOTPLUG_IO_LEN) ); =20 diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index b4ec14e349..fe263fd558 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1864,7 +1864,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base, "\\_SB.PCI0", "\\_GPE._E02"); } - build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0", "\\_GPE._E03"); + build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0", + "\\_GPE._E03", AML_SYSTEM_IO); =20 scope =3D aml_scope("_GPE"); { diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotp= lug.h index 77c65765d6..e3a4b89235 100644 --- a/include/hw/acpi/memory_hotplug.h +++ b/include/hw/acpi/memory_hotplug.h @@ -5,6 +5,10 @@ #include "hw/acpi/acpi.h" #include "hw/acpi/aml-build.h" =20 +#define MEMORY_SLOT_SCAN_METHOD "MSCN" +#define MEMORY_DEVICES_CONTAINER "\\_SB.MHPC" +#define MEMORY_HOTPLUG_IO_LEN 24 + /** * MemStatus: * @is_removing: the memory device in slot has been requested to be ejecte= d. @@ -29,7 +33,7 @@ typedef struct MemHotplugState { } MemHotplugState; =20 void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, - MemHotplugState *state, uint16_t io_base); + MemHotplugState *state, hwaddr io_base); =20 void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem= _st, DeviceState *dev, Error **errp); @@ -48,5 +52,6 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACP= IOSTInfoList ***list); =20 void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, const char *res_root, - const char *event_handler_method); + const char *event_handler_method, + AmlRegionSpace rs); #endif --=20 2.17.1 From nobody Fri May 3 12:33:47 2024 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=1558542455; cv=none; d=zoho.com; s=zohoarc; b=B23jQ+F9l3v5Q2Iry9L4Ty+969E110IDX5thAqK9z0h6UgbtUPrV+284NBSfrlwWwEjMqlj99ELEc6OZLgcjsY/50sYvFK4FDI9zTs6fTKym1ahLtPYR30/etrzZIACCKeMuAq+ZUXjrd3hyv/jPNzQVvUdg+aLk2zpbOXiS6RE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558542455; 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=tH6RMAJrmzrPb+/L7KoeTD30P3yxyJiMKEugfjArIKM=; b=HuO6RVZ2jXq/L7NcgiJmFe4WubKvndcn3Bdj8S4XcLd43PeaGRSl6sE6HrmmzibBPWBen7/FMvmrceonKlfy6WSM88UUMqedI9W7cktKnakWcBy6es18GMNzA18FszddA8QB26c3GQPFd4+fjSLJjSmCSe00SZ/0WODJTnD14rs= 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 1558542455943477.2990946511561; Wed, 22 May 2019 09:27:35 -0700 (PDT) Received: from localhost ([127.0.0.1]:47542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTU5Q-0008OG-Tx for importer@patchew.org; Wed, 22 May 2019 12:27:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTU3A-0006eW-QW for qemu-devel@nongnu.org; Wed, 22 May 2019 12:25:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTU39-0002Aq-To for qemu-devel@nongnu.org; Wed, 22 May 2019 12:25:08 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2218 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTU37-00020t-Ci; Wed, 22 May 2019 12:25:05 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D491ED543854AA74BCF7; Thu, 23 May 2019 00:25:02 +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; Thu, 23 May 2019 00:24:03 +0800 From: Shameer Kolothum To: , , , Date: Wed, 22 May 2019 17:22:46 +0100 Message-ID: <20190522162252.28568-3-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190522162252.28568-1-shameerali.kolothum.thodi@huawei.com> References: <20190522162252.28568-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.190 Subject: [Qemu-devel] [PATCH v5 2/8] hw/acpi: Do not create memory hotplug method when handler is not defined X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Samuel Ortiz With Hardware-reduced ACPI, the GED device will manage ACPI hotplug entirely. As a consequence, make the memory specific events AML generation optional. The code will only be added when the method name is not NULL. Signed-off-by: Samuel Ortiz Signed-off-by: Shameer Kolothum Reviewed-by: Eric Auger Reviewed-by: Igor Mammedov Tested-by: Eric Auger --- hw/acpi/memory_hotplug.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index c724f5f1e4..7e30e6f886 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -719,10 +719,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr= _mem, } aml_append(table, dev_container); =20 - method =3D aml_method(event_handler_method, 0, AML_NOTSERIALIZED); - aml_append(method, - aml_call0(MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD)); - aml_append(table, method); + if (event_handler_method) { + method =3D aml_method(event_handler_method, 0, AML_NOTSERIALIZED); + aml_append(method, aml_call0(MEMORY_DEVICES_CONTAINER "." + MEMORY_SLOT_SCAN_METHOD)); + aml_append(table, method); + } =20 g_free(mhp_res_path); } --=20 2.17.1 From nobody Fri May 3 12:33:47 2024 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=1558542643; cv=none; d=zoho.com; s=zohoarc; b=IYv08o+X6A3ZPjjj4aO1p22WAVJBpghOj3qKCQhRrx3NvUm+GpSYt5noPgbCg9KV4YVp8rJKAlQry1Zk4/sDId351g8dYCT+bNAhucrdhfK3OebafvDpwq5q/+pPWpP3NfMYDFT9470HE/1EBTuFzZhDlkD2Sh7KmKj7f+JmlPQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558542643; 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=5/c7fjKa7GPe+PWfmi9akeJmDzqd9W4ERDHFwo+sQnA=; b=Cj8pQ1l+zSb5G9b/g8hmk/DxaqPb+u3b41m3o2VnmwycQYL+KMfm/nT301vmoSay4NiLFQGovDBt9yPJ4Nx//NREHEHrNLmsoYntVuLekLvzSAwjg4MU+4am6mHBTfbd1WW/N9wqOG6Y0tI7l6QNsUBRSHkKD+DQfTdmVvHjzQM= 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 1558542643399472.18600273825916; Wed, 22 May 2019 09:30:43 -0700 (PDT) Received: from localhost ([127.0.0.1]:47609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTU8T-0002dY-AQ for importer@patchew.org; Wed, 22 May 2019 12:30:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTU3G-0006lK-Ku for qemu-devel@nongnu.org; Wed, 22 May 2019 12:25:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTU3D-0002HH-14 for qemu-devel@nongnu.org; Wed, 22 May 2019 12:25:14 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2219 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTU37-00020w-DM; Wed, 22 May 2019 12:25:05 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id DB7FA4E2F9514A2C03F4; Thu, 23 May 2019 00:25:02 +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; Thu, 23 May 2019 00:24:07 +0800 From: Shameer Kolothum To: , , , Date: Wed, 22 May 2019 17:22:47 +0100 Message-ID: <20190522162252.28568-4-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190522162252.28568-1-shameerali.kolothum.thodi@huawei.com> References: <20190522162252.28568-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.190 Subject: [Qemu-devel] [PATCH v5 3/8] hw/acpi: Add ACPI Generic Event Device Support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Samuel Ortiz The ACPI Generic Event Device (GED) is a hardware-reduced specific device[ACPI v6.1 Section 5.6.9] that handles all platform events, including the hotplug ones.This patch generates the AML code that defines GEDs. Platforms need to specify their own GED Event bitmap to describe what kind of events they want to support through GED. Also this uses a a single interrupt for the GED device, relying on IO memory region to communicate the type of device affected by the interrupt. This way, we can support up to 32 events with a unique interrupt. This supports only memory hotplug for now. Signed-off-by: Samuel Ortiz Signed-off-by: Sebastien Boeuf Signed-off-by: Shameer Kolothum Reviewed-by: Eric Auger Tested-by: Eric Auger --- v4-->v5 -Removed gsi/irq routing code. -Changed GED Event array to bitmap. -Added Migration support. --- hw/acpi/Kconfig | 4 + hw/acpi/Makefile.objs | 1 + hw/acpi/generic_event_device.c | 332 +++++++++++++++++++++++++ include/hw/acpi/generic_event_device.h | 102 ++++++++ 4 files changed, 439 insertions(+) create mode 100644 hw/acpi/generic_event_device.c create mode 100644 include/hw/acpi/generic_event_device.h diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig index eca3beed75..01a8b41ef5 100644 --- a/hw/acpi/Kconfig +++ b/hw/acpi/Kconfig @@ -27,3 +27,7 @@ config ACPI_VMGENID bool default y depends on PC + +config ACPI_HW_REDUCED + bool + depends on ACPI diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs index 2d46e3789a..b753232323 100644 --- a/hw/acpi/Makefile.objs +++ b/hw/acpi/Makefile.objs @@ -6,6 +6,7 @@ common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) +=3D memory_hotplu= g.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) +=3D cpu.o common-obj-$(CONFIG_ACPI_NVDIMM) +=3D nvdimm.o common-obj-$(CONFIG_ACPI_VMGENID) +=3D vmgenid.o +common-obj-$(CONFIG_ACPI_HW_REDUCED) +=3D generic_event_device.o common-obj-$(call lnot,$(CONFIG_ACPI_X86)) +=3D acpi-stub.o =20 common-obj-y +=3D acpi_interface.o diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c new file mode 100644 index 0000000000..914fe64716 --- /dev/null +++ b/hw/acpi/generic_event_device.c @@ -0,0 +1,332 @@ +/* + * + * Copyright (c) 2018 Intel Corporation + * Copyright (c) 2019 Huawei Technologies R & D (UK) Ltd + * Written by Samuel Ortiz, Shameer Kolothum + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "exec/address-spaces.h" +#include "hw/sysbus.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/generic_event_device.h" +#include "hw/mem/pc-dimm.h" +#include "qemu/error-report.h" + +static const uint32_t ged_supported_events[] =3D { + ACPI_GED_MEM_HOTPLUG_EVT, +}; + +/* + * The ACPI Generic Event Device (GED) is a hardware-reduced specific + * device[ACPI v6.1 Section 5.6.9] that handles all platform events, + * including the hotplug ones. Platforms need to specify their own + * GED Event bitmap to describe what kind of events they want to support + * through GED. This routine uses a single interrupt for the GED device, + * relying on IO memory region to communicate the type of device + * affected by the interrupt. This way, we can support up to 32 events + * with a unique interrupt. + */ +void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_d= ev, + uint32_t ged_irq, AmlRegionSpace rs) +{ + AcpiGedState *s =3D ACPI_GED(hotplug_dev); + Aml *crs =3D aml_resource_template(); + Aml *evt, *field; + Aml *dev =3D aml_device("%s", name); + Aml *evt_sel =3D aml_local(0); + Aml *esel =3D aml_name(AML_GED_EVT_SEL); + + assert(s->ged_base); + + /* _CRS interrupt */ + aml_append(crs, aml_interrupt(AML_CONSUMER, AML_EDGE, AML_ACTIVE_HIGH, + AML_EXCLUSIVE, &ged_irq, 1)); + + aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0013"))); + aml_append(dev, aml_name_decl("_UID", aml_string(GED_DEVICE))); + aml_append(dev, aml_name_decl("_CRS", crs)); + + /* Append IO region */ + aml_append(dev, aml_operation_region(AML_GED_EVT_REG, rs, + aml_int(s->ged_base + ACPI_GED_EVT_SEL_OFFSET), + ACPI_GED_EVT_SEL_LEN)); + field =3D aml_field(AML_GED_EVT_REG, AML_DWORD_ACC, AML_NOLOCK, + AML_WRITE_AS_ZEROS); + aml_append(field, aml_named_field(AML_GED_EVT_SEL, + ACPI_GED_EVT_SEL_LEN * BITS_PER_BYTE= )); + aml_append(dev, field); + + /* + * For each GED event we: + * - Add a conditional block for each event, inside a loop. + * - Call a method for each supported GED event type. + * + * The resulting ASL code looks like: + * + * Local0 =3D ESEL + * If ((Local0 & One) =3D=3D One) + * { + * MethodEvent0() + * } + * + * If ((Local0 & 0x2) =3D=3D 0x2) + * { + * MethodEvent1() + * } + * ... + */ + evt =3D aml_method("_EVT", 1, AML_SERIALIZED); + { + Aml *if_ctx; + uint32_t i; + uint32_t ged_events =3D ctpop32(s->ged_event_bitmap); + + /* Local0 =3D ESEL */ + aml_append(evt, aml_store(esel, evt_sel)); + + for (i =3D 0; i < ARRAY_SIZE(ged_supported_events) && ged_events; = i++) { + uint32_t event =3D s->ged_event_bitmap & ged_supported_events[= i]; + + if (!event) { + continue; + } + + if_ctx =3D aml_if(aml_equal(aml_and(evt_sel, aml_int(event), N= ULL), + aml_int(event))); + switch (event) { + case ACPI_GED_MEM_HOTPLUG_EVT: + aml_append(if_ctx, aml_call0(MEMORY_DEVICES_CONTAINER "." + MEMORY_SLOT_SCAN_METHOD)); + break; + default: + /* + * Please make sure all the events in ged_supported_events= [] + * are handled above. + */ + g_assert_not_reached(); + } + + aml_append(evt, if_ctx); + ged_events--; + } + + if (ged_events) { + error_report("GED: Unsupported events specified"); + exit(1); + } + } + + /* Append _EVT method */ + aml_append(dev, evt); + + aml_append(table, dev); +} + +/* Memory read by the GED _EVT AML dynamic method */ +static uint64_t ged_read(void *opaque, hwaddr addr, unsigned size) +{ + uint64_t val =3D 0; + GEDState *ged_st =3D opaque; + + switch (addr) { + case ACPI_GED_EVT_SEL_OFFSET: + /* Read the selector value and reset it */ + qemu_mutex_lock(&ged_st->lock); + val =3D ged_st->sel; + ged_st->sel =3D 0; + qemu_mutex_unlock(&ged_st->lock); + break; + default: + break; + } + + return val; +} + +/* Nothing is expected to be written to the GED memory region */ +static void ged_write(void *opaque, hwaddr addr, uint64_t data, + unsigned int size) +{ +} + +static const MemoryRegionOps ged_ops =3D { + .read =3D ged_read, + .write =3D ged_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, +}; + +static void acpi_ged_event(AcpiGedState *s, uint32_t sel) +{ + GEDState *ged_st =3D &s->ged_state; + /* + * Set the GED IRQ selector to the expected device type value. This + * way, the ACPI method will be able to trigger the right code based + * on a unique IRQ. + */ + qemu_mutex_lock(&ged_st->lock); + ged_st->sel |=3D sel; + qemu_mutex_unlock(&ged_st->lock); + + /* Trigger the event by sending an interrupt to the guest. */ + qemu_irq_pulse(s->irq); +} + +static void acpi_ged_init(MemoryRegion *as, DeviceState *dev, GEDState *ge= d_st) +{ + AcpiGedState *s =3D ACPI_GED(dev); + + assert(s->ged_base); + + qemu_mutex_init(&ged_st->lock); + memory_region_init_io(&ged_st->io, OBJECT(dev), &ged_ops, ged_st, + TYPE_ACPI_GED, ACPI_GED_REG_LEN); + memory_region_add_subregion(as, s->ged_base, &ged_st->io); + qdev_init_gpio_out_named(DEVICE(s), &s->irq, "ged-irq", 1); +} + +static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + AcpiGedState *s =3D ACPI_GED(hotplug_dev); + + if (s->memhp_state.is_enabled && + object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, + dev, errp); + } else { + error_setg(errp, "virt: device plug request for unsupported device" + " type: %s", object_get_typename(OBJECT(dev))); + } +} + +static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev) +{ + AcpiGedState *s =3D ACPI_GED(adev); + uint32_t sel; + + if (ev & ACPI_MEMORY_HOTPLUG_STATUS) { + sel =3D ACPI_GED_MEM_HOTPLUG_EVT; + } else { + /* Unknown event. Return without generating interrupt. */ + return; + } + + /* + * We inject the hotplug interrupt. The IRQ selector will make + * the difference from the ACPI table. + */ + acpi_ged_event(s, sel); +} + +static void acpi_ged_device_realize(DeviceState *dev, Error **errp) +{ + AcpiGedState *s =3D ACPI_GED(dev); + + if (s->memhp_state.is_enabled) { + acpi_memory_hotplug_init(get_system_memory(), OBJECT(dev), + &s->memhp_state, + s->memhp_base); + } + + acpi_ged_init(get_system_memory(), dev, &s->ged_state); +} + +static Property acpi_ged_properties[] =3D { + /* + * Memory hotplug base address is a property of GED here, + * because GED handles memory hotplug event and MEMORY_HOTPLUG_DEVICE + * gets initialized when GED device is realized. + */ + DEFINE_PROP_UINT64("memhp-base", AcpiGedState, memhp_base, 0), + DEFINE_PROP_BOOL("memory-hotplug-support", AcpiGedState, + memhp_state.is_enabled, true), + DEFINE_PROP_UINT64("ged-base", AcpiGedState, ged_base, 0), + DEFINE_PROP_UINT32("ged-event", AcpiGedState, ged_event_bitmap, 0), + DEFINE_PROP_END_OF_LIST(), +}; + +static bool vmstate_test_use_memhp(void *opaque) +{ + AcpiGedState *s =3D opaque; + return s->memhp_state.is_enabled; +} + +static const VMStateDescription vmstate_memhp_state =3D { + .name =3D "acpi-ged/memhp", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D vmstate_test_use_memhp, + .fields =3D (VMStateField[]) { + VMSTATE_MEMORY_HOTPLUG(memhp_state, AcpiGedState), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_ged_state =3D { + .name =3D "acpi-ged-state", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(sel, GEDState), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_acpi_ged =3D { + .name =3D "acpi-ged", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT(ged_state, AcpiGedState, 1, vmstate_ged_state, GEDS= tate), + VMSTATE_END_OF_LIST(), + }, + .subsections =3D (const VMStateDescription * []) { + &vmstate_memhp_state, + NULL + } +}; + +static void acpi_ged_class_init(ObjectClass *class, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(class); + HotplugHandlerClass *hc =3D HOTPLUG_HANDLER_CLASS(class); + AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_CLASS(class); + + dc->desc =3D "ACPI"; + dc->props =3D acpi_ged_properties; + dc->realize =3D acpi_ged_device_realize; + dc->vmsd =3D &vmstate_acpi_ged; + + hc->plug =3D acpi_ged_device_plug_cb; + + adevc->send_event =3D acpi_ged_send_event; +} + +static const TypeInfo acpi_ged_info =3D { + .name =3D TYPE_ACPI_GED, + .parent =3D TYPE_DEVICE, + .instance_size =3D sizeof(AcpiGedState), + .class_init =3D acpi_ged_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_HOTPLUG_HANDLER }, + { TYPE_ACPI_DEVICE_IF }, + { } + } +}; + +static void acpi_ged_register_types(void) +{ + type_register_static(&acpi_ged_info); +} + +type_init(acpi_ged_register_types) diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/gener= ic_event_device.h new file mode 100644 index 0000000000..f69d084c89 --- /dev/null +++ b/include/hw/acpi/generic_event_device.h @@ -0,0 +1,102 @@ +/* + * + * Copyright (c) 2018 Intel Corporation + * Copyright (c) 2019 Huawei Technologies R & D (UK) Ltd + * Written by Samuel Ortiz, Shameer Kolothum + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * The ACPI Generic Event Device (GED) is a hardware-reduced specific + * device[ACPI v6.1 Section 5.6.9] that handles all platform events, + * including the hotplug ones. Generic Event Device allows platforms + * to handle interrupts in ACPI ASL statements. It follows a very + * similar approach like the _EVT method from GPIO events. All + * interrupts are listed in _CRS and the handler is written in _EVT + * method. Here, we use a single interrupt for the GED device, relying + * on IO memory region to communicate the type of device affected by + * the interrupt. This way, we can support up to 32 events with a + * unique interrupt. + * + * Here is an example. + * + * Device (\_SB.GED) + * { + * Name (_HID, "ACPI0013") + * Name (_UID, Zero) + * Name (_CRS, ResourceTemplate () + * { + * Interrupt (ResourceConsumer, Edge, ActiveHigh, Exclusive, ,, ) + * { + * 0x00000029, + * } + * }) + * OperationRegion (EREG, SystemMemory, 0x09080000, 0x04) + * Field (EREG, DWordAcc, NoLock, WriteAsZeros) + * { + * ESEL, 32 + * } + * + * Method (_EVT, 1, Serialized) // _EVT: Event + * { + * Local0 =3D ESEL // ESEL =3D IO memory region which specifies the + * // device type. + * If (((Local0 & One) =3D=3D One)) + * { + * MethodEvent1() + * } + * If ((Local0 & 0x2) =3D=3D 0x2) + * { + * MethodEvent2() + * } + * ... + * } + * } + * + */ + +#ifndef HW_ACPI_GED_H +#define HW_ACPI_GED_H + +#include "hw/acpi/memory_hotplug.h" + +#define TYPE_ACPI_GED "acpi-ged" +#define ACPI_GED(obj) \ + OBJECT_CHECK(AcpiGedState, (obj), TYPE_ACPI_GED) + +#define ACPI_GED_EVT_SEL_OFFSET 0x0 +#define ACPI_GED_EVT_SEL_LEN 0x4 +#define ACPI_GED_REG_LEN 0x4 + +#define GED_DEVICE "GED" +#define AML_GED_EVT_REG "EREG" +#define AML_GED_EVT_SEL "ESEL" + +/* + * Platforms need to specify the GED event bitmap + * to describe what kind of events they want to support + * through GED. + */ +#define ACPI_GED_MEM_HOTPLUG_EVT 0x1 + +typedef struct GEDState { + MemoryRegion io; + uint32_t sel; + QemuMutex lock; +} GEDState; + +typedef struct AcpiGedState { + DeviceClass parent_obj; + MemHotplugState memhp_state; + hwaddr memhp_base; + hwaddr ged_base; + GEDState ged_state; + uint32_t ged_event_bitmap; + qemu_irq irq; +} AcpiGedState; + +void build_ged_aml(Aml *table, const char* name, HotplugHandler *hotplug_d= ev, + uint32_t ged_irq, AmlRegionSpace rs); + +#endif --=20 2.17.1 From nobody Fri May 3 12:33:47 2024 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=1558542441; cv=none; d=zoho.com; s=zohoarc; b=ly8JS6rc8ctJehxB271swpq/fJgQCIpZMzxBWPMQZNUov5udjzFearLIbeQgbF0Dl/rtmtatMHQQVBi6jWU9Pv9YI/X06St3mXN7SxYzLEM52SeTP4qCA8O/gfuVAftQRdmMTOGM4kyGZhg03WMiDaTkqWgMaEMIlsJWrNT9RQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558542441; 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=06gr7u84c/u5ao3PvbiO1JfDLihIWMzSANyB2KasOco=; b=UZMzE2Df83U3rzGV0UYlAqP49E2WamBfJICFDzIwdEcbbgxBMmxH0J9+tR4dtA1+ObBMeMXBiydLYv9GYXxtgCujzAOuJFVZXRfPz/aWiJOJLv2Lw+QqzY9+84MMFSUzb9pNG2TmjKt4zBu7OI6hQQbST4Y3kSXyHXgAVWkwlKE= 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 1558542441298255.09571497156173; Wed, 22 May 2019 09:27:21 -0700 (PDT) Received: from localhost ([127.0.0.1]:47540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTU5C-0008AX-Bh for importer@patchew.org; Wed, 22 May 2019 12:27:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTU3B-0006fb-Mq for qemu-devel@nongnu.org; Wed, 22 May 2019 12:25:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTU3A-0002CU-IK for qemu-devel@nongnu.org; Wed, 22 May 2019 12:25:09 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2217 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTU37-00020r-C1; Wed, 22 May 2019 12:25:05 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id E75E063B0C1F6DEEE152; Thu, 23 May 2019 00:25:02 +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; Thu, 23 May 2019 00:24:10 +0800 From: Shameer Kolothum To: , , , Date: Wed, 22 May 2019 17:22:48 +0100 Message-ID: <20190522162252.28568-5-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190522162252.28568-1-shameerali.kolothum.thodi@huawei.com> References: <20190522162252.28568-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.190 Subject: [Qemu-devel] [PATCH v5 4/8] hw/arm/virt: Add memory hotplug framework X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Eric Auger This patch adds the memory hot-plug/hot-unplug infrastructure in machvirt. The device memory is not yet exposed to the Guest either through DT or ACPI and hence both cold/hot plug of memory is explicitly disabled for now. Signed-off-by: Eric Auger Signed-off-by: Kwangwoo Lee Signed-off-by: Shameer Kolothum Tested-by: Eric Auger --- hw/arm/Kconfig | 2 ++ hw/arm/virt.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index af8cffde9c..6ef22439b5 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -19,6 +19,8 @@ config ARM_VIRT select PLATFORM_BUS select SMBIOS select VIRTIO_MMIO + select MEM_DEVICE + select DIMM =20 config CHEETAH bool diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 5331ab71e2..3df8c389ff 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -62,6 +62,8 @@ #include "hw/arm/smmuv3.h" #include "hw/acpi/acpi.h" #include "target/arm/internals.h" +#include "hw/mem/pc-dimm.h" +#include "hw/mem/nvdimm.h" =20 #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -1862,6 +1864,40 @@ static const CPUArchIdList *virt_possible_cpu_arch_i= ds(MachineState *ms) return ms->possible_cpus; } =20 +static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState = *dev, + Error **errp) +{ + + /* + * The device memory is not yet exposed to the Guest either through + * DT or ACPI and hence both cold/hot plug of memory is explicitly + * disabled for now. + */ + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + error_setg(errp, "memory cold/hot plug is not yet supported"); + return; + } + + pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), NULL, errp); +} + +static void virt_memory_plug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); + + pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), NULL); + +} + +static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + virt_memory_pre_plug(hotplug_dev, dev, errp); + } +} + static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -1873,12 +1909,23 @@ static void virt_machine_device_plug_cb(HotplugHand= ler *hotplug_dev, SYS_BUS_DEVICE(dev)); } } + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + virt_memory_plug(hotplug_dev, dev, errp); + } +} + +static void virt_machine_device_unplug_request_cb(HotplugHandler *hotplug_= dev, + DeviceState *dev, Error **errp) +{ + error_setg(errp, "device unplug request for unsupported device" + " type: %s", object_get_typename(OBJECT(dev))); } =20 static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *mach= ine, DeviceState *dev) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE) || + (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) { return HOTPLUG_HANDLER(machine); } =20 @@ -1942,7 +1989,9 @@ static void virt_machine_class_init(ObjectClass *oc, = void *data) mc->kvm_type =3D virt_kvm_type; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler =3D virt_machine_get_hotplug_handler; + hc->pre_plug =3D virt_machine_device_pre_plug_cb; hc->plug =3D virt_machine_device_plug_cb; + hc->unplug_request =3D virt_machine_device_unplug_request_cb; } =20 static void virt_instance_init(Object *obj) --=20 2.17.1 From nobody Fri May 3 12:33:47 2024 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=1558542615; cv=none; d=zoho.com; s=zohoarc; b=dh0vy2r5pmN+Y37uYfM/nqbyN7PIlCGQ3WWAUzdAALNQ0ewTV42WuumptCM9qBIFAW3G643PaXH6F/GB9WLsye7jWYo92woQZjZczUtWRgfljNdkwR//SUHSZa8woD5HNvAmrz+FCLoda5jaf5nPINK8YuTM7XsJfvYYShNLCac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558542615; 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=K+pYikhwfKxwgEZBT62k6t8KcS7/ujPAtrFa0VEVEoo=; b=BDXdoFNzR5hdcnnlSfiTGbDkejcfIofluJdfAhJII4lFe4o33NnQZHelIrKTw3e9y3PFoxmTVXOrk1aG+6PiSfspLgtXezYRNrqexrJ3g2YN51GdhB2/wE1hL8JHxprq/AG5KQ1p8KDyix8CD4Drw2l4kN8QFjQrLm3YT973Q4g= 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 1558542615155583.8117244659885; Wed, 22 May 2019 09:30:15 -0700 (PDT) Received: from localhost ([127.0.0.1]:47581 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTU7x-0002BC-47 for importer@patchew.org; Wed, 22 May 2019 12:30:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTU3D-0006hh-OJ for qemu-devel@nongnu.org; Wed, 22 May 2019 12:25:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTU3B-0002E8-CJ for qemu-devel@nongnu.org; Wed, 22 May 2019 12:25:11 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2221 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTU37-00021K-M7; Wed, 22 May 2019 12:25:06 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id ED8BB931B80DBFD8117F; Thu, 23 May 2019 00:25:02 +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; Thu, 23 May 2019 00:24:14 +0800 From: Shameer Kolothum To: , , , Date: Wed, 22 May 2019 17:22:49 +0100 Message-ID: <20190522162252.28568-6-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190522162252.28568-1-shameerali.kolothum.thodi@huawei.com> References: <20190522162252.28568-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.190 Subject: [Qemu-devel] [PATCH v5 5/8] hw/arm/virt: Enable device memory cold/hot plug with ACPI boot X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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 initializes the GED device with base memory and irq, configures ged memory hotplug event and builds the corresponding aml code. With this, both hot and cold plug of device memory is enabled now for Guest with ACPI boot. Memory cold plug support with Guest DT boot is not yet supported. Signed-off-by: Shameer Kolothum Reviewed-by: Eric Auger Tested-by: Eric Auger --- v4-->v5 -Removed gsi/ged-irq routing instead set irq directly. -Create GED only for ACPI case. --- hw/arm/Kconfig | 2 ++ hw/arm/virt-acpi-build.c | 14 ++++++++++++ hw/arm/virt.c | 48 ++++++++++++++++++++++++++++++++++------ include/hw/arm/virt.h | 3 +++ 4 files changed, 60 insertions(+), 7 deletions(-) diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 6ef22439b5..4bb498d093 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -21,6 +21,8 @@ config ARM_VIRT select VIRTIO_MMIO select MEM_DEVICE select DIMM + select ACPI_MEMORY_HOTPLUG + select ACPI_HW_REDUCED =20 config CHEETAH bool diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index bf9c0bc2f4..5abab6dfcd 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -40,6 +40,8 @@ #include "hw/loader.h" #include "hw/hw.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/memory_hotplug.h" +#include "hw/acpi/generic_event_device.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/arm/virt.h" @@ -727,6 +729,7 @@ static void build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { Aml *scope, *dsdt; + MachineState *ms =3D MACHINE(vms); const MemMapEntry *memmap =3D vms->memmap; const int *irqmap =3D vms->irqmap; =20 @@ -751,6 +754,17 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Vir= tMachineState *vms) 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); + } + + if (vms->acpi_dev && ms->ram_slots) { + build_memory_hotplug_aml(scope, ms->ram_slots, "\\_SB", NULL, + AML_SYSTEM_MEMORY); + } + acpi_dsdt_add_power_button(scope); =20 aml_append(dsdt, scope); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 3df8c389ff..8dfd7537b9 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -64,6 +64,7 @@ #include "target/arm/internals.h" #include "hw/mem/pc-dimm.h" #include "hw/mem/nvdimm.h" +#include "hw/acpi/generic_event_device.h" =20 #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -134,6 +135,8 @@ static const MemMapEntry base_memmap[] =3D { [VIRT_GPIO] =3D { 0x09030000, 0x00001000 }, [VIRT_SECURE_UART] =3D { 0x09040000, 0x00001000 }, [VIRT_SMMU] =3D { 0x09050000, 0x00020000 }, + [VIRT_PCDIMM_ACPI] =3D { 0x09070000, MEMORY_HOTPLUG_IO_LEN }, + [VIRT_ACPI_GED] =3D { 0x09080000, ACPI_GED_REG_LEN }, [VIRT_MMIO] =3D { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that siz= e */ [VIRT_PLATFORM_BUS] =3D { 0x0c000000, 0x02000000 }, @@ -169,6 +172,7 @@ static const int a15irqmap[] =3D { [VIRT_PCIE] =3D 3, /* ... to 6 */ [VIRT_GPIO] =3D 7, [VIRT_SECURE_UART] =3D 8, + [VIRT_ACPI_GED] =3D 9, [VIRT_MMIO] =3D 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */ [VIRT_GIC_V2M] =3D 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */ [VIRT_SMMU] =3D 74, /* ...to 74 + NUM_SMMU_IRQS - 1 */ @@ -517,6 +521,25 @@ static void fdt_add_pmu_nodes(const VirtMachineState *= vms) } } =20 +static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq= *pic) +{ + DeviceState *dev; + int irq =3D vms->irqmap[VIRT_ACPI_GED]; + uint32_t event =3D ACPI_GED_MEM_HOTPLUG_EVT; + + dev =3D DEVICE(object_new(TYPE_ACPI_GED)); + qdev_prop_set_uint64(dev, "memhp-base", + vms->memmap[VIRT_PCDIMM_ACPI].base); + qdev_prop_set_uint64(dev, "ged-base", vms->memmap[VIRT_ACPI_GED].base); + qdev_prop_set_uint32(dev, "ged-event", event); + object_property_add_child(qdev_get_machine(), "acpi-ged", + OBJECT(dev), NULL); + qdev_init_nofail(dev); + qdev_connect_gpio_out_named(dev, "ged-irq", 0, pic[irq]); + + return dev; +} + static void create_its(VirtMachineState *vms, DeviceState *gicdev) { const char *itsclass =3D its_class_name(); @@ -1689,6 +1712,10 @@ static void machvirt_init(MachineState *machine) =20 create_gpio(vms, pic); =20 + if (aarch64 && firmware_loaded && acpi_enabled) { + vms->acpi_dev =3D create_acpi_ged(vms, pic); + } + /* 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. @@ -1867,27 +1894,34 @@ static const CPUArchIdList *virt_possible_cpu_arch_= ids(MachineState *ms) static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState = *dev, Error **errp) { + VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); + const bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); =20 - /* - * The device memory is not yet exposed to the Guest either through - * DT or ACPI and hence both cold/hot plug of memory is explicitly - * disabled for now. - */ - if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { - error_setg(errp, "memory cold/hot plug is not yet supported"); + if (is_nvdimm) { + error_setg(errp, "nvdimm is not yet supported"); return; } =20 + if (!vms->acpi_dev) { + error_setg(errp, "memory hotplug is not enabled: missing acpi devi= ce"); + return; + } + + hotplug_handler_pre_plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, errp); + pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), NULL, errp); } =20 static void virt_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { + HotplugHandlerClass *hhc; VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); =20 pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), NULL); =20 + hhc =3D HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev); + hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, NULL); } =20 static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 424070924e..f004c5cf72 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -78,6 +78,8 @@ enum { VIRT_GPIO, VIRT_SECURE_UART, VIRT_SECURE_MEM, + VIRT_PCDIMM_ACPI, + VIRT_ACPI_GED, VIRT_LOWMEMMAP_LAST, }; =20 @@ -134,6 +136,7 @@ typedef struct { uint32_t iommu_phandle; int psci_conduit; hwaddr highest_gpa; + DeviceState *acpi_dev; } VirtMachineState; =20 #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) --=20 2.17.1 From nobody Fri May 3 12:33:47 2024 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=1558542589; cv=none; d=zoho.com; s=zohoarc; b=Pf4ugmFQFvuUp572GTDJraT4jqHa0lcZKXGmdkEY8AaHP/NHDYM4jjVlfMq7e/SstyQTNSF5qkh8Y7WToi1KO9xryafDLywsNlSBUp1/SuhI0BKmNuESWBGGAaw7IdFQbz5dncVSWOMhP91U/NcqYWSKq9V4QWHhkEpDUdcVgws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558542589; 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=QXlurv/4ojK8WxcvnGeCJceAKwKXdlYhaLDEYFGN3w4=; b=bCIIjtEw0vePFUs5DI9+qt9jAyUYw2s+GWmnN5pSZggHukNN5NVJ22OGwc7XAdzSKWK0k7LIYjeNNgOuhmqbSZUniKt5/b4zdnoZnceDKzav9kmJbqqPikswnm3PX2RpBRGvKv/YjDdUtf2c5H2brgNYAf7rq4qHgJ7HK6ZBVsw= 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 1558542589688778.640005457418; Wed, 22 May 2019 09:29:49 -0700 (PDT) Received: from localhost ([127.0.0.1]:47579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTU7Y-0001vW-LB for importer@patchew.org; Wed, 22 May 2019 12:29:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTU3A-0006ed-TK for qemu-devel@nongnu.org; Wed, 22 May 2019 12:25:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTU39-0002B5-Uw for qemu-devel@nongnu.org; Wed, 22 May 2019 12:25:08 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2220 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTU37-00020y-Es; Wed, 22 May 2019 12:25:05 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 009938A783217CACB063; Thu, 23 May 2019 00:25:03 +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; Thu, 23 May 2019 00:24:17 +0800 From: Shameer Kolothum To: , , , Date: Wed, 22 May 2019 17:22:50 +0100 Message-ID: <20190522162252.28568-7-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190522162252.28568-1-shameerali.kolothum.thodi@huawei.com> References: <20190522162252.28568-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.190 Subject: [Qemu-devel] [PATCH v5 6/8] hw/arm/virt-acpi-build: Add PC-DIMM in SRAT X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Generate Memory Affinity Structures for PC-DIMM ranges. Signed-off-by: Shameer Kolothum Signed-off-by: Eric Auger Reviewed-by: Igor Mammedov Tested-by: Eric Auger --- hw/arm/virt-acpi-build.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 5abab6dfcd..ed8e0cee3a 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -518,6 +518,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) int i, srat_start; uint64_t mem_base; MachineClass *mc =3D MACHINE_GET_CLASS(vms); + MachineState *ms =3D MACHINE(vms); const CPUArchIdList *cpu_list =3D mc->possible_cpu_arch_ids(MACHINE(vm= s)); =20 srat_start =3D table_data->len; @@ -543,6 +544,14 @@ build_srat(GArray *table_data, BIOSLinker *linker, Vir= tMachineState *vms) } } =20 + if (ms->device_memory) { + numamem =3D acpi_data_push(table_data, sizeof *numamem); + build_srat_memory(numamem, ms->device_memory->base, + memory_region_size(&ms->device_memory->mr), + nb_numa_nodes - 1, + MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED= ); + } + build_header(linker, table_data, (void *)(table_data->data + srat_star= t), "SRAT", table_data->len - srat_start, 3, NULL, NULL); } --=20 2.17.1 From nobody Fri May 3 12:33:47 2024 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=1558542745; cv=none; d=zoho.com; s=zohoarc; b=KM2ZJ2DZiGHAjOQ28mOm+00KnM+WyOH0BTiYiB79ISHinWyXmB7VhzH7r+pobtoju9OfrodjrNxVT495c7aVRN2UP5b8lRZ0s4a7hat4iIRNSFyjUd0NvoSMHxLvbwlhb+ziRyp0Njk7yCz8RbA3A+thQtHkKmBK1xHsm3t6oQY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558542745; 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=Pwb9q4QtlNBkVBSO7MkBF7O1RNSrzNskjk4MrHbVg6Y=; b=UCeVbb9gGlKsBAXZRsYQndjJ5sU+0vNm0dGeVYZcbwadbS+H+uebpN83E/T1032X3buIWzWcbGGtM3ynyLgg7NH/jin79YrF8lhUlHkdIm0n9y1QplTzK2iYFpSS2qalIr5kGMsJkFyIOaMj8XhIba0fMTn9Od6Dn0YcGTqKpWo= 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558542745702207.7331324574095; Wed, 22 May 2019 09:32:25 -0700 (PDT) Received: from localhost ([127.0.0.1]:47633 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTUA7-0003pm-Jg for importer@patchew.org; Wed, 22 May 2019 12:32:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTU3G-0006lO-L7 for qemu-devel@nongnu.org; Wed, 22 May 2019 12:25:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTU3E-0002KW-LB for qemu-devel@nongnu.org; Wed, 22 May 2019 12:25:14 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2223 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTU3A-000271-Ia; Wed, 22 May 2019 12:25:09 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 0689F80F60C90003982B; Thu, 23 May 2019 00:25:03 +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; Thu, 23 May 2019 00:24:21 +0800 From: Shameer Kolothum To: , , , Date: Wed, 22 May 2019 17:22:51 +0100 Message-ID: <20190522162252.28568-8-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190522162252.28568-1-shameerali.kolothum.thodi@huawei.com> References: <20190522162252.28568-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.190 Subject: [Qemu-devel] [PATCH v5 7/8] hw/acpi: Add system power down support to GED X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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 Tested-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 914fe64716..27c1bb40d4 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -20,6 +20,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= [] @@ -228,6 +234,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); @@ -239,6 +252,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 From nobody Fri May 3 12:33:47 2024 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=1558542862; cv=none; d=zoho.com; s=zohoarc; b=VnHrb3AIfVpXOeve8djJifgaFrRb+M3w4GIlAi0II5CHUZnJg5bPgNugm8QmHVLcMraWrNshQHNViM74lxNHCmBkdIjn6OUpbJuxPhlUBqG6AloUPtKpt0UKNNNe1CuYeB01uB7xEJJ7g+XeQHgHtyekvDnGtgzvx00xuA4Cfjc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558542862; 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=rYWUu1LkdEmOD+uNli1EMWjjMW1a35NXTYx9MXlUKe4=; b=RkF9q87lyoUb7YEHXXcLseYxYAezwJLT7IUT/obrhSV1ZXN+q6z7k8392vC4J27GXVS/eAdkmH8uZvSwZrWfM2+N9SNYuyX8govPhWK6xsPzXATicW6CXxslS0RhAvcQZ+QGTuieLnGQaqv+uwIq+9ZheNd8oRo5UFFTi9FIZcc= 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 1558542862964588.343467157515; Wed, 22 May 2019 09:34:22 -0700 (PDT) Received: from localhost ([127.0.0.1]:47649 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTUBx-0004zG-19 for importer@patchew.org; Wed, 22 May 2019 12:34:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTU3G-0006lP-L9 for qemu-devel@nongnu.org; Wed, 22 May 2019 12:25:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTU3D-0002J2-Ss for qemu-devel@nongnu.org; Wed, 22 May 2019 12:25:14 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2222 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTU3A-000270-2S; Wed, 22 May 2019 12:25:08 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 0CEED676E2640AC55D0D; Thu, 23 May 2019 00:25:03 +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; Thu, 23 May 2019 00:24:24 +0800 From: Shameer Kolothum To: , , , Date: Wed, 22 May 2019 17:22:52 +0100 Message-ID: <20190522162252.28568-9-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190522162252.28568-1-shameerali.kolothum.thodi@huawei.com> References: <20190522162252.28568-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.190 Subject: [Qemu-devel] [PATCH v5 8/8] hw/arm: Use GED for system_powerdown event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Use GED for system_powerdown event instead of GPIO for ACPI. Guest boot with DT still uses GPIO. Signed-off-by: Shameer Kolothum Reviewed-by: Eric Auger Tested-by: Eric Auger --- hw/arm/virt-acpi-build.c | 37 +------------------------------------ hw/arm/virt.c | 7 +++---- 2 files changed, 4 insertions(+), 40 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index ed8e0cee3a..f23b276d77 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) { @@ -328,37 +327,6 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMap= Entry *memmap, aml_append(scope, dev); } =20 -static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap, - uint32_t gpio_irq) -{ - Aml *dev =3D aml_device("GPO0"); - aml_append(dev, aml_name_decl("_HID", aml_string("ARMH0061"))); - aml_append(dev, aml_name_decl("_ADR", aml_int(0))); - aml_append(dev, aml_name_decl("_UID", aml_int(0))); - - Aml *crs =3D aml_resource_template(); - aml_append(crs, aml_memory32_fixed(gpio_memmap->base, gpio_memmap->siz= e, - AML_READ_WRITE)); - aml_append(crs, aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH, - AML_EXCLUSIVE, &gpio_irq, 1)); - aml_append(dev, aml_name_decl("_CRS", crs)); - - Aml *aei =3D aml_resource_template(); - /* Pin 3 for power button */ - const uint32_t pin_list[1] =3D {3}; - aml_append(aei, aml_gpio_int(AML_CONSUMER, AML_EDGE, AML_ACTIVE_HIGH, - AML_EXCLUSIVE, AML_PULL_UP, 0, pin_list, = 1, - "GPO0", NULL, 0)); - aml_append(dev, aml_name_decl("_AEI", aei)); - - /* _E03 is handle for power button */ - Aml *method =3D aml_method("_E03", 0, AML_NOTSERIALIZED); - aml_append(method, aml_notify(aml_name(ACPI_POWER_BUTTON_DEVICE), - aml_int(0x80))); - aml_append(dev, method); - aml_append(scope, dev); -} - static void acpi_dsdt_add_power_button(Aml *scope) { Aml *dev =3D aml_device(ACPI_POWER_BUTTON_DEVICE); @@ -761,9 +729,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *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) { + acpi_dsdt_add_power_button(scope); build_ged_aml(scope, "\\_SB."GED_DEVICE, HOTPLUG_HANDLER(vms->acpi_dev), irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE, AML_SYSTEM_MEM= ORY); @@ -774,8 +741,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) AML_SYSTEM_MEMORY); } =20 - acpi_dsdt_add_power_button(scope); - aml_append(dsdt, scope); =20 /* copy AML table into ACPI tables blob and patch header there */ diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 8dfd7537b9..bb83160888 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -525,7 +525,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", @@ -1710,12 +1710,11 @@ static void machvirt_init(MachineState *machine) =20 create_pcie(vms, pic); =20 - create_gpio(vms, pic); - if (aarch64 && firmware_loaded && acpi_enabled) { vms->acpi_dev =3D create_acpi_ged(vms, pic); + } else { + create_gpio(vms, pic); } - /* 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. --=20 2.17.1