From patchwork Fri Jul 26 10:45:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 169797 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12862957ilk; Fri, 26 Jul 2019 03:47:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkX8ySjTc9Ad0+xmOXZXfynQPO9Jmj+l3GfFlG6X3JZP5PmwyHP1Zhn+L8pdanbYMw7GyI X-Received: by 2002:ac8:41ce:: with SMTP id o14mr63016657qtm.92.1564138021745; Fri, 26 Jul 2019 03:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564138021; cv=none; d=google.com; s=arc-20160816; b=UJYDxPeEsvcDfYfx0lP3fUzowXWwLJspn9M4m3J9howUank5Rq6VMbxfjbUUJNJ2gj s7fi/ychnJ7YingOBMqIJngmBQlU3bgnn1yQGBQ0Yp5+BUKqKOEUxF1LwQ0oAaR/UCux MAxtIIpspVCUDiIc1oVuREAmV9bfSmLS+IXUWCJr/RXC6RnZQgmRCufLzG8gfGJAvpyX trhQF9zHryZd/ljkHls0a3sU0vn4UyqV1M8zZXaMihtBP9Huz9apGB8Kx6MeLE1LAqHj YtmENEUYZT/vPBkAT5PpTTOEjwpKYzVkMiF09Vbj/IVxA3MXZAoguGIHG0HN2uBEizYc HuMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=fCAcr3SQoySbxDRPihYG1Acv2DCv3JxTKf6tQuYpde0=; b=sWKMv5Y7jYYtTyOgVG0bXjnRto6VQmdp16I7HuABpOhb/HLc9VaXzcfmDfJRFUCzb5 3PiexLo29kVE5+tA3J5LGiiU0sexG6B2Na9S9Kuxe/Do8qEepR1Q6ql4vMZSybmk1EeG o855raF65wcUwOOCadfc/BwqzBnSUGFOpqHX4uE/+rUdrUbbyOx28dBQTTXWb9sOc+44 61+7tfJ9dK17YTMje6A6qT4pPR8ZJV+/VwpABfZGvoGZyiSBsjsx4ZOknPyK8l0pL/1v SjpOguU6NlB1MAlQTYgPCpB5tC6ouykxPGjPaLN3o9cZ4tPpQH1fInWWrExPhlwjsj13 omOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s5si11442581qts.160.2019.07.26.03.47.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jul 2019 03:47:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:38248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxkY-0006oq-2D for patch@linaro.org; Fri, 26 Jul 2019 06:46:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42706) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxkA-0006bj-1Q for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:46:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqxk7-0005ur-LK for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:46:32 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:51362 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hqxk2-0004qi-38; Fri, 26 Jul 2019 06:46:26 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 1B53BFFF014820808553; Fri, 26 Jul 2019 18:46:16 +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:09 +0800 From: Shameer Kolothum To: , , , Date: Fri, 26 Jul 2019 11:45:11 +0100 Message-ID: <20190726104519.23812-2-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.32 Subject: [Qemu-devel] [PATCH-for-4.2 v8 1/9] hw/acpi: Make ACPI IO address space configurable 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- 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(-) -- 2.17.1 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" -static uint16_t memhp_io_base; +static hwaddr memhp_io_base; static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev) { @@ -209,7 +206,7 @@ static const MemoryRegionOps acpi_memory_hotplug_ops = { }; void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, - MemHotplugState *state, uint16_t io_base) + MemHotplugState *state, hwaddr io_base) { MachineState *machine = MACHINE(qdev_get_machine()); @@ -342,7 +339,8 @@ const VMStateDescription vmstate_memory_hotplug = { 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"))); crs = aml_resource_template(); - aml_append(crs, - aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0, - MEMORY_HOTPLUG_IO_LEN) - ); + if (rs == 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)); 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) ); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index d281ffa89e..4aae365347 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1865,7 +1865,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); scope = aml_scope("_GPE"); { diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.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" +#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 ejected. @@ -29,7 +33,7 @@ typedef struct MemHotplugState { } MemHotplugState; void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, - MemHotplugState *state, uint16_t io_base); + MemHotplugState *state, hwaddr io_base); 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, ACPIOSTInfoList ***list); 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 From patchwork Fri Jul 26 10:45:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 169798 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12863062ilk; Fri, 26 Jul 2019 03:47:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxY7bfKW52K25+WwO8eYKXgq0nEJ4xxUexPkH8L1gqAUO+niF9mOWUliruy76QL6yd2TbLL X-Received: by 2002:a0c:aff8:: with SMTP id t53mr68642503qvc.47.1564138029766; Fri, 26 Jul 2019 03:47:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564138029; cv=none; d=google.com; s=arc-20160816; b=G+cDQ8tr1ILxggOHvhrFNle2Q2ZuC2FwpCBqLs1XZo0bcHu8XDkeVSk4VIgOCOfDA+ Q+vk2HAkwxnm0t+0aAXtUQbGywN20eyqns0LVMOesavY/qrFk66OIHrZyPQqGvuqqECL ornQBJj70f17DxPygN79zAp4Iv0m5EcwYc8iq4i/QGsRUSMayjp8x+/JZt9fLHJ4Ndsb KGZyE/KGcS1HMqt4JMeeeuS7pXd0vHT/Bmw4OOYdKiGDFyerQeAeGwAawUI9H9/dwvba 91W0vsSU6gQIcN4Qyfea8kCqjdQpQNHs2Vj7+/9jcQC2KxRcNB+fm/cfdpuvR0siTn80 /n+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=rCWHrMBZftcnydBxe20riTAsROaY/Psm0j7VxlBy/YM=; b=GNQivTrFOiHQwbTKId93Ho27nD5KnG4X7VWiOyUxbMdVeTPnrpYijiMXS0y6bpGMat cV3lKfxtpe6NBuGQvVpa7Z+xS2rcct3KfIOqRhQma5y+lnBHz60gyjHQRLCYoZAqngPq iEasrvMbRcTXQjwfy7Fw/r5v30PD7Pu/ht4oGqZkHI6B/prZqKYYNPGsg7zXAJkqbrzt Tbbd9jEAeM9NLAO3swJAf3bbqpUATOVCjzjDx93LOotjWoopTxql2nuAMjkYBj+8tZ1Z IAPRzZbgcMBzLBKey77YnMd4TXuxCXBcbSN4I27+6QoKUd1KZaf2DOMzZ9HnpFzAkOTR miPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 25si30376698qty.236.2019.07.26.03.47.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jul 2019 03:47:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:38250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxkg-0006uc-6j for patch@linaro.org; Fri, 26 Jul 2019 06:47:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42845) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxkD-0006cE-9h for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:46:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqxkB-00069Z-5c for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:46:36 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2242 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hqxk3-0005C9-HO; Fri, 26 Jul 2019 06:46:27 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id E92EB5B47EB6A29C04DD; Fri, 26 Jul 2019 18:46:20 +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:12 +0800 From: Shameer Kolothum To: , , , Date: Fri, 26 Jul 2019 11:45:12 +0100 Message-ID: <20190726104519.23812-3-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 2/9] hw/acpi: Do not create memory hotplug method when handler is not defined 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- hw/acpi/memory_hotplug.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) -- 2.17.1 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); - method = 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 = aml_method(event_handler_method, 0, AML_NOTSERIALIZED); + aml_append(method, aml_call0(MEMORY_DEVICES_CONTAINER "." + MEMORY_SLOT_SCAN_METHOD)); + aml_append(table, method); + } g_free(mhp_res_path); } From patchwork Fri Jul 26 10:45:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 169800 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12863529ilk; Fri, 26 Jul 2019 03:47:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0At2iwV5AEQj1AUPRycE+mQE7v5TEs69fM8jbyGZPT1HPkbZhtXPpDXuG0+9yq/Kxg0rW X-Received: by 2002:a17:906:6c16:: with SMTP id j22mr72511708ejr.307.1564138057713; Fri, 26 Jul 2019 03:47:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564138057; cv=none; d=google.com; s=arc-20160816; b=yxuUuQXlyaeM+nkMk2r0ZEfOUxzEvWbBMNWkygyBDeeDSj92Rt2TWfVeVhK0wcS05O uVf6rIgWTqPvPzOLyhiL5WXb2h60UWnkgwELl+aidG+UldbOm9jUnRVlbYj1lRcU7/E7 snMAmag4UQYpzh2WiOjD5dh++2VgMUDgXOFsWqozCRM/GQs45UpOGo2SNMjTZKdfJKkk izUkrbl8vU5d5TMUE+qwWKdU/64XajrW6mm0gBXkqEuYSpHngQ8nKTuuQ2SuLV2+fjh4 1z+yrhFsCaUrmS2MD3s57u6zxooHnb6sfmo/a+peoHE7Jqi8A00FN1JrJIU3R+tt9HeD /VhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=J517Srabu8sqoqLPc+ToXxYyyd4UW/gkYeJxddGPlok=; b=0QpxrI46oNa1888juYvfnZvIKtYPmYJ++avuktPnEmcAgSU3/ZLzHE+v0crOEkNWsP 5+Ac78c7z4UGi0LzgvO0Jq5LGUCyfenmtm+Plsa5IMkdAnO9GVeucd265V6Netcn4TsF F6CLz2GiBDDluUJIjezcYTjmI34YtL4Ju+sT1Fu7b9oNoXbZyDZKBfg9sLnu40WjMYj8 94AhPGa4CjTiKPd8bQlA1UH6/JsBO0FQ+peRZBFBKCTq5ZtaPnnByV3EQb1//CIRdzlz Wj2fLhvtUeXKB700dk8j3pfUVw9/0MbD/s4OI+SB2UM65rLbgbs4lMuVV5UHmSNtPqlI X03w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m41si12976899edd.186.2019.07.26.03.47.37 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jul 2019 03:47:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:38280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxl7-0000up-BF for patch@linaro.org; Fri, 26 Jul 2019 06:47:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43027) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxkG-0006nD-Oj for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:46:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqxkE-0006OM-LF for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:46:40 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:36844 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hqxk7-0005ba-F6; Fri, 26 Jul 2019 06:46:32 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 05EF4D43F1B3EC6B2338; Fri, 26 Jul 2019 18:46:26 +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:15 +0800 From: Shameer Kolothum To: , , , Date: Fri, 26 Jul 2019 11:45:13 +0100 Message-ID: <20190726104519.23812-4-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.35 Subject: [Qemu-devel] [PATCH-for-4.2 v8 3/9] hw/acpi: Add ACPI Generic Event Device Support 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- v7 --> v8. -Removed qemu_mutex_lock() across the ged state selector access. -Rephrased comments section in acpi_ged_send_event(). -Moved acpi_ged_event() code into acpi_ged_send_event(). -Added check for memhp_base and ged_base in realize(). --- hw/acpi/Kconfig | 4 + hw/acpi/Makefile.objs | 1 + hw/acpi/generic_event_device.c | 322 +++++++++++++++++++++++++ include/hw/acpi/generic_event_device.h | 100 ++++++++ 4 files changed, 427 insertions(+) create mode 100644 hw/acpi/generic_event_device.c create mode 100644 include/hw/acpi/generic_event_device.h -- 2.17.1 diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig index 7c59cf900b..12e3f1e86e 100644 --- a/hw/acpi/Kconfig +++ b/hw/acpi/Kconfig @@ -31,3 +31,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 9bb2101e3b..655a9c1973 100644 --- a/hw/acpi/Makefile.objs +++ b/hw/acpi/Makefile.objs @@ -6,6 +6,7 @@ common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu.o common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o common-obj-$(CONFIG_ACPI_VMGENID) += vmgenid.o +common-obj-$(CONFIG_ACPI_HW_REDUCED) += generic_event_device.o common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o common-obj-y += 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..7902e9d706 --- /dev/null +++ b/hw/acpi/generic_event_device.c @@ -0,0 +1,322 @@ +/* + * + * 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/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[] = { + 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_dev, + uint32_t ged_irq, AmlRegionSpace rs) +{ + AcpiGedState *s = ACPI_GED(hotplug_dev); + Aml *crs = aml_resource_template(); + Aml *evt, *field; + Aml *dev = aml_device("%s", name); + Aml *evt_sel = aml_local(0); + Aml *esel = 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 = 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 = ESEL + * If ((Local0 & One) == One) + * { + * MethodEvent0() + * } + * + * If ((Local0 & 0x2) == 0x2) + * { + * MethodEvent1() + * } + * ... + */ + evt = aml_method("_EVT", 1, AML_SERIALIZED); + { + Aml *if_ctx; + uint32_t i; + uint32_t ged_events = ctpop32(s->ged_event_bitmap); + + /* Local0 = ESEL */ + aml_append(evt, aml_store(esel, evt_sel)); + + for (i = 0; i < ARRAY_SIZE(ged_supported_events) && ged_events; i++) { + uint32_t event = s->ged_event_bitmap & ged_supported_events[i]; + + if (!event) { + continue; + } + + if_ctx = aml_if(aml_equal(aml_and(evt_sel, aml_int(event), NULL), + 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 = 0; + GEDState *ged_st = opaque; + + switch (addr) { + case ACPI_GED_EVT_SEL_OFFSET: + /* Read the selector value and reset it */ + val = ged_st->sel; + ged_st->sel = 0; + 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 = { + .read = ged_read, + .write = ged_write, + .endianness = DEVICE_LITTLE_ENDIAN, + .valid = { + .min_access_size = 4, + .max_access_size = 4, + }, +}; + +static void acpi_ged_init(MemoryRegion *as, DeviceState *dev, GEDState *ged_st) +{ + AcpiGedState *s = ACPI_GED(dev); + + memory_region_init_io(&ged_st->io, OBJECT(dev), &ged_ops, ged_st, + TYPE_ACPI_GED, ACPI_GED_EVT_SEL_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 = ACPI_GED(hotplug_dev); + + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + if (s->memhp_state.is_enabled) { + acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp); + } else { + error_setg(errp, + "memory hotplug is not enabled: %s.memory-hotplug-support " + "is not set", object_get_typename(OBJECT(s))); + } + } 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 = ACPI_GED(adev); + GEDState *ged_st = &s->ged_state; + uint32_t sel; + + if (ev & ACPI_MEMORY_HOTPLUG_STATUS) { + sel = ACPI_GED_MEM_HOTPLUG_EVT; + } else { + /* Unknown event. Return without generating interrupt. */ + warn_report("GED: Unsupported event %d. No irq injected", ev); + return; + } + + /* + * Set the GED selector field to communicate the event type. + * This will be read by GED aml code to select the appropriate + * event method. + */ + ged_st->sel |= sel; + + /* Trigger the event by sending an interrupt to the guest. */ + qemu_irq_pulse(s->irq); +} + +static void acpi_ged_device_realize(DeviceState *dev, Error **errp) +{ + AcpiGedState *s = ACPI_GED(dev); + + assert(s->ged_base); + acpi_ged_init(get_system_memory(), dev, &s->ged_state); + + if (s->memhp_state.is_enabled) { + assert(s->memhp_base); + acpi_memory_hotplug_init(get_system_memory(), OBJECT(dev), + &s->memhp_state, + s->memhp_base); + } +} + +static Property acpi_ged_properties[] = { + /* + * Memory hotplug base address is a property of GED here, + * because GED handles memory hotplug event and acpi-mem-hotplug + * memory region 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 = opaque; + return s->memhp_state.is_enabled; +} + +static const VMStateDescription vmstate_memhp_state = { + .name = "acpi-ged/memhp", + .version_id = 1, + .minimum_version_id = 1, + .needed = vmstate_test_use_memhp, + .fields = (VMStateField[]) { + VMSTATE_MEMORY_HOTPLUG(memhp_state, AcpiGedState), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_ged_state = { + .name = "acpi-ged-state", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT32(sel, GEDState), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_acpi_ged = { + .name = "acpi-ged", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_STRUCT(ged_state, AcpiGedState, 1, vmstate_ged_state, GEDState), + VMSTATE_END_OF_LIST(), + }, + .subsections = (const VMStateDescription * []) { + &vmstate_memhp_state, + NULL + } +}; + +static void acpi_ged_class_init(ObjectClass *class, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(class); + HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(class); + AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_CLASS(class); + + dc->desc = "ACPI Generic Event Device"; + dc->props = acpi_ged_properties; + dc->realize = acpi_ged_device_realize; + dc->vmsd = &vmstate_acpi_ged; + + hc->plug = acpi_ged_device_plug_cb; + + adevc->send_event = acpi_ged_send_event; +} + +static const TypeInfo acpi_ged_info = { + .name = TYPE_ACPI_GED, + .parent = TYPE_DEVICE, + .instance_size = sizeof(AcpiGedState), + .class_init = acpi_ged_class_init, + .interfaces = (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/generic_event_device.h new file mode 100644 index 0000000000..f0152b0018 --- /dev/null +++ b/include/hw/acpi/generic_event_device.h @@ -0,0 +1,100 @@ +/* + * + * 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 = ESEL // ESEL = IO memory region which specifies the + * // device type. + * If (((Local0 & One) == One)) + * { + * MethodEvent1() + * } + * If ((Local0 & 0x2) == 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 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; +} 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_dev, + uint32_t ged_irq, AmlRegionSpace rs); + +#endif From patchwork Fri Jul 26 10:45:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 169799 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12863486ilk; Fri, 26 Jul 2019 03:47:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYbyyeR52T+r94UVFYF8bxIeeVEzqrHY5Enfw4/+YujUBCzj0wKu9vjtyDo9VFvBm6eEfR X-Received: by 2002:a17:906:19c6:: with SMTP id h6mr71821908ejd.262.1564138055163; Fri, 26 Jul 2019 03:47:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564138055; cv=none; d=google.com; s=arc-20160816; b=w/wyvIw2OUg0iw1MBuWpMY2J4vQy73HAbavlQT87c9T45vB5ZdhQ1g3FL1Sk2w/15+ Ltm4eGbhYiVtTp2m0nT/ntBGMV7Ra5//8a6MdKYtuTnBk3ZOfA+7aJmVfhwUSC3A/gPO r3YpBtnXOXWVNRo6sT7Dt9I9IdAdAfWdfQGPzihtnbNdtIU4Gf4d5OES6eTyetPBA/Vt SEjBv6Lykm2iNt1bSKfnmqYeWOG4AdqdZYKJvnTj8Y1XRTFoNJ+8XnvIfr9+kVoF6ras VyjUUcdrmEkfhX6CCs/VevogJhCNDLZIcRGOBFi6sJQ18RoZwH2uHML0/mRwKzUCYf7T QIow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=/wo8DDRADzvw/6OPeu1j8CqnKUax3HRhZWNahwETadg=; b=f+zrSsH7S6UO7R7tD0F5DLD3xEbkQN/xk3ivv41erGrJU+MM1ciSj1ip+Jqb3lSxLp PNgVotSJJKX045z46zbo4uk84wj2dztnDnNO4QAJSyfxa1mDagw6PAyBSNisOpEEbEXX i4VpQFSQAQdpdKQzmnE/c7jYbM2kMg5ia1wnXldvEG9WpDpV9YIRjKUj5ef4TvtI+wYz 5zwvvIKa38G0E0KUIRkvoQvS9wFU7e14V5Q3M1oKYii7Cbbi+I4aVkBrnRjHix/vHQuJ mSqjKsxGbHfLcZlNO/gio9ji93WZodxyFnsrjGNsW82xu9zWSWqALhuQ+pfG0LQk09IM Nddg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c55si12324195edc.323.2019.07.26.03.47.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jul 2019 03:47:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:38272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxl5-0000BQ-Io for patch@linaro.org; Fri, 26 Jul 2019 06:47:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43361) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxkh-0007yE-25 for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:47:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqxkK-0006lb-Ta for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:46:51 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:36846 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hqxkB-0005bY-2h; Fri, 26 Jul 2019 06:46:35 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 0E3C997E6DD18FC292D3; Fri, 26 Jul 2019 18:46:26 +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:19 +0800 From: Shameer Kolothum To: , , , Date: Fri, 26 Jul 2019 11:45:14 +0100 Message-ID: <20190726104519.23812-5-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.35 Subject: [Qemu-devel] [PATCH-for-4.2 v8 4/9] hw/arm/virt: Add memory hotplug framework 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Peter Maydell Reviewed-by: Igor Mammedov --- hw/arm/Kconfig | 2 ++ hw/arm/virt.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index ab65ecd216..84961c17ab 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -20,6 +20,8 @@ config ARM_VIRT select SMBIOS select VIRTIO_MMIO select ACPI_PCI + select MEM_DEVICE + select DIMM config CHEETAH bool diff --git a/hw/arm/virt.c b/hw/arm/virt.c index d9496c9363..907fb64bb9 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -64,6 +64,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" #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -1871,6 +1873,40 @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) return ms->possible_cpus; } +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 = 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) { @@ -1882,12 +1918,23 @@ static void virt_machine_device_plug_cb(HotplugHandler *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))); } static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, 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); } @@ -1951,7 +1998,9 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) mc->kvm_type = virt_kvm_type; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler = virt_machine_get_hotplug_handler; + hc->pre_plug = virt_machine_device_pre_plug_cb; hc->plug = virt_machine_device_plug_cb; + hc->unplug_request = virt_machine_device_unplug_request_cb; mc->numa_mem_supported = true; } From patchwork Fri Jul 26 10:45:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 169803 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12864405ilk; Fri, 26 Jul 2019 03:48:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIZEQtcgSZMrjx9N+S2AfhO3qS3iiLLrs0wVOBevjKNB+Fm4KW2YOII04AZ8ziS/RwwSFw X-Received: by 2002:a17:906:4048:: with SMTP id y8mr73800592ejj.35.1564138113939; Fri, 26 Jul 2019 03:48:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564138113; cv=none; d=google.com; s=arc-20160816; b=TBOEMm4RRVh+x0bRpkF40VelanN9AlWzpw61k5t1GsWoy43XPvjjzrW+/piG8/GcWf 3rLTrOgyBVNrYT13tW4f10NeM05agJHcx+m0uhGpGaf3TrqKgcYIKrr1CZTkH+SZpBn0 SZ1jvsU5dgoJOZOo2Wo78ofMALXdj3id2/70ZfOUME57ubFVPxcehzl0gyCiFHqbev+F K3sRNVTK2bBCDjXBclF9BPG8CNuDQt+TJrzbKeiP+vnZebONfapSeUziLFz8ZdUMx6DJ PMhWG2VT9PYVyy5cD2A1q1W3Y++h/DQMz8cVSfwG8B+VUZTMLX5IPHB8yQ8CROdOnF3a N3JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=cI6f50WHa+eaTbgxxDqMu50UaQxwXyBaVmb6pRoQU3I=; b=nwwpvbciE3t0iypDwdcDRQXjBq/KEheH/CAduVSftmpCiE7QI+vcc/k6alc/a2MToB 8uTR58uz+/+SCJVKv+iQCSzPsVr/6/uT6gMmDfMfRNllaPzpjoTEyVYHt3w1e2qu3xI5 LyqODxP+B+Rn/meIdyKe2BwE0L59pui01ktZCrasoVEcF0BFJkev4uBpOTlF2wPQWBWQ LfZV+lYqvXlFTXkAzdXMTn3ekBjBstb4Soegkn9JYQMbhXh2tECOU+X2WxvgRmNNfNnU rtDhdKGZ/Y5CGxal1/iovwsFRvqhRa7PPwJriKgCvUQ8KEa80TU16mZi1f7qpza691/W 6w0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q3si11936384eju.389.2019.07.26.03.48.33 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jul 2019 03:48:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:38302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxm2-0003Zg-FH for patch@linaro.org; Fri, 26 Jul 2019 06:48:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43323) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxkZ-0007cy-7I for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:47:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqxkK-0006lc-TS for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:46:51 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:51650 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hqxkF-0005uE-6k; Fri, 26 Jul 2019 06:46:39 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 16BE47F54068DBC17FAD; Fri, 26 Jul 2019 18:46:31 +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:22 +0800 From: Shameer Kolothum To: , , , Date: Fri, 26 Jul 2019 11:45:15 +0100 Message-ID: <20190726104519.23812-6-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.32 Subject: [Qemu-devel] [PATCH-for-4.2 v8 5/9] hw/arm/virt: Add 4.2 machine type 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is in preparation to create ACPI GED device as we need to disable it for <4.2 for migration to work. Signed-off-by: Shameer Kolothum Reviewed-by: Igor Mammedov --- hw/arm/virt.c | 9 ++++++++- hw/core/machine.c | 3 +++ include/hw/boards.h | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 907fb64bb9..bbe156dc35 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2095,10 +2095,17 @@ static void machvirt_machine_init(void) } type_init(machvirt_machine_init); +static void virt_machine_4_2_options(MachineClass *mc) +{ +} +DEFINE_VIRT_MACHINE_AS_LATEST(4, 2) + static void virt_machine_4_1_options(MachineClass *mc) { + virt_machine_4_2_options(mc); + compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len); } -DEFINE_VIRT_MACHINE_AS_LATEST(4, 1) +DEFINE_VIRT_MACHINE(4, 1) static void virt_machine_4_0_options(MachineClass *mc) { diff --git a/hw/core/machine.c b/hw/core/machine.c index c58a8e594e..a79d4ad740 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -27,6 +27,9 @@ #include "hw/pci/pci.h" #include "hw/mem/nvdimm.h" +GlobalProperty hw_compat_4_1[] = {}; +const size_t hw_compat_4_1_len = G_N_ELEMENTS(hw_compat_4_1); + GlobalProperty hw_compat_4_0[] = { { "VGA", "edid", "false" }, { "secondary-vga", "edid", "false" }, diff --git a/include/hw/boards.h b/include/hw/boards.h index a71d1a53a5..d9ec37d807 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -317,6 +317,9 @@ struct MachineState { } \ type_init(machine_initfn##_register_types) +extern GlobalProperty hw_compat_4_1[]; +extern const size_t hw_compat_4_1_len; + extern GlobalProperty hw_compat_4_0[]; extern const size_t hw_compat_4_0_len; From patchwork Fri Jul 26 10:45:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 169801 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12863794ilk; Fri, 26 Jul 2019 03:47:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxuHPPoIUCJcWNiMAMjl/2BE9IJMl52ScHnD0NNTXqYtnKe6bO0t7gk6I2bHdX67XyWhcUn X-Received: by 2002:a50:974b:: with SMTP id d11mr81583417edb.24.1564138075596; Fri, 26 Jul 2019 03:47:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564138075; cv=none; d=google.com; s=arc-20160816; b=P5xPnTaV6drUF9YOhez0lp3efWuzsepapeUmB31WAaOSufzPiiCI6vyHQ6/oLb7uDJ O+6virikyxFOO5KXdIdgXpBCFUXKo3+HQFPSjEH5flIJG8LWz/LBc4p2kcZIvZqDmSyA P7VvRdkmgq1+iiocf2JT/pVB2jTVl3j4LMyj1BfIQOXNnAS8yAa/jQ8NRDPZ/pyV45zq sIM3bSZEDYQW4BhrhOisDh0jsnEJoSoen5RLcR7I7akkXO2JTGwo8vqdmUkclLNG8b5p YQduR3HNEcxhYO5r2zMLVQy70xOK4d8/xYtrseck9A4NsXwYW/0NLT+iYAkRESE0kH9h z7+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=vjLcWRo8lCe2wB4ZgGBcjedaKi9MqWxUbYdA6TRZ+5U=; b=ZZYOUCj83OezDM7dW9WAeWx5g+hRlACJjZNtiARPnXNtGpuzlbTiGkMmbsHC73F7ZO QNVdNsLTD52ctaQyeS0ckAlS8mHnjHr3L9vpvtJjH9b5xbsTJLxNAnLg25mnnFC6RuGd U17Qdb6ShlaDD27HNqYMhtO4d7c4B9gt7g/QA3eInX+/Zj8lLbEUAaxYe5i2Ero7aEGz 2ElH6ZEb33YEURx/a5cBftsWgXpWdxnc4N6LKJ/BuaHmkCTZxFpiITIpABoe0sc9/c40 6BoJp+QoOb6n0Ga6wGIDNgaytTjsefRKwLtbMxyM6xO1Jm38Da5O1qv6yeSgisQroZ3/ 6c6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x46si11511147eda.54.2019.07.26.03.47.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jul 2019 03:47:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:38288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxlR-0001Tk-9R for patch@linaro.org; Fri, 26 Jul 2019 06:47:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43367) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxkj-0007yV-1N for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:47:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqxkY-0006wj-24 for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:47:02 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2180 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hqxkH-0006G7-2z; Fri, 26 Jul 2019 06:46:41 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 31EB8C7323097E830689; Fri, 26 Jul 2019 18:46:36 +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:26 +0800 From: Shameer Kolothum To: , , , Date: Fri, 26 Jul 2019 11:45:16 +0100 Message-ID: <20190726104519.23812-7-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.190 Subject: [Qemu-devel] [PATCH-for-4.2 v8 6/9] hw/arm/virt: Enable device memory cold/hot plug with ACPI boot 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- -Changed no_acpi_dev to no_ged. -Fixed 'dev' reference leak by object_new(). -Updated bios-tables-test-allowed-diff.h to avoid "make check" failure. --- hw/arm/Kconfig | 2 + hw/arm/virt-acpi-build.c | 14 +++++++ hw/arm/virt.c | 54 +++++++++++++++++++++++---- include/hw/arm/virt.h | 4 ++ tests/bios-tables-test-allowed-diff.h | 1 + 5 files changed, 68 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 84961c17ab..ad7f7c089b 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -22,6 +22,8 @@ config ARM_VIRT select ACPI_PCI select MEM_DEVICE select DIMM + select ACPI_MEMORY_HOTPLUG + select ACPI_HW_REDUCED config CHEETAH bool diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 0afb372769..018b1e326d 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -40,6 +40,8 @@ #include "hw/acpi/aml-build.h" #include "hw/acpi/utils.h" #include "hw/acpi/pci.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" @@ -705,6 +707,7 @@ static void build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { Aml *scope, *dsdt; + MachineState *ms = MACHINE(vms); const MemMapEntry *memmap = vms->memmap; const int *irqmap = vms->irqmap; @@ -729,6 +732,17 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *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_MEMORY); + } + + 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); aml_append(dsdt, scope); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index bbe156dc35..41386a6eb7 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -66,6 +66,7 @@ #include "target/arm/internals.h" #include "hw/mem/pc-dimm.h" #include "hw/mem/nvdimm.h" +#include "hw/acpi/generic_event_device.h" #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -136,6 +137,8 @@ static const MemMapEntry base_memmap[] = { [VIRT_GPIO] = { 0x09030000, 0x00001000 }, [VIRT_SECURE_UART] = { 0x09040000, 0x00001000 }, [VIRT_SMMU] = { 0x09050000, 0x00020000 }, + [VIRT_PCDIMM_ACPI] = { 0x09070000, MEMORY_HOTPLUG_IO_LEN }, + [VIRT_ACPI_GED] = { 0x09080000, ACPI_GED_EVT_SEL_LEN }, [VIRT_MMIO] = { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 }, @@ -171,6 +174,7 @@ static const int a15irqmap[] = { [VIRT_PCIE] = 3, /* ... to 6 */ [VIRT_GPIO] = 7, [VIRT_SECURE_UART] = 8, + [VIRT_ACPI_GED] = 9, [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */ [VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */ [VIRT_SMMU] = 74, /* ...to 74 + NUM_SMMU_IRQS - 1 */ @@ -520,6 +524,27 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) } } +static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq *pic) +{ + DeviceState *dev; + int irq = vms->irqmap[VIRT_ACPI_GED]; + uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT; + + dev = 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]); + + object_unref(OBJECT(dev)); + + return dev; +} + static void create_its(VirtMachineState *vms, DeviceState *gicdev) { const char *itsclass = its_class_name(); @@ -1483,6 +1508,7 @@ static void machvirt_init(MachineState *machine) MemoryRegion *ram = g_new(MemoryRegion, 1); bool firmware_loaded; bool aarch64 = true; + bool has_ged = !vmc->no_ged; unsigned int smp_cpus = machine->smp.cpus; unsigned int max_cpus = machine->smp.max_cpus; @@ -1697,6 +1723,10 @@ static void machvirt_init(MachineState *machine) create_gpio(vms, pic); + if (has_ged && aarch64 && firmware_loaded && acpi_enabled) { + vms->acpi_dev = 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. @@ -1876,27 +1906,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 = VIRT_MACHINE(hotplug_dev); + const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); - /* - * 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; } + if (!vms->acpi_dev) { + error_setg(errp, "memory hotplug is not enabled: missing acpi device"); + return; + } + + hotplug_handler_pre_plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, errp); + pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), NULL, errp); } static void virt_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { + HotplugHandlerClass *hhc; VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), NULL); + hhc = HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev); + hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, NULL); } static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, @@ -2102,8 +2139,11 @@ DEFINE_VIRT_MACHINE_AS_LATEST(4, 2) static void virt_machine_4_1_options(MachineClass *mc) { + VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); + virt_machine_4_2_options(mc); compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len); + vmc->no_ged = true; } DEFINE_VIRT_MACHINE(4, 1) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index a72094204e..577ee49b4b 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -77,6 +77,8 @@ enum { VIRT_GPIO, VIRT_SECURE_UART, VIRT_SECURE_MEM, + VIRT_PCDIMM_ACPI, + VIRT_ACPI_GED, VIRT_LOWMEMMAP_LAST, }; @@ -106,6 +108,7 @@ typedef struct { bool claim_edge_triggered_timers; bool smbios_old_sys_ver; bool no_highmem_ecam; + bool no_ged; /* Machines < 4.2 has no support for ACPI GED device */ } VirtMachineClass; typedef struct { @@ -133,6 +136,7 @@ typedef struct { uint32_t iommu_phandle; int psci_conduit; hwaddr highest_gpa; + DeviceState *acpi_dev; } VirtMachineState; #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) diff --git a/tests/bios-tables-test-allowed-diff.h b/tests/bios-tables-test-allowed-diff.h index dfb8523c8b..7b4adbc822 100644 --- a/tests/bios-tables-test-allowed-diff.h +++ b/tests/bios-tables-test-allowed-diff.h @@ -1 +1,2 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/virt/DSDT", From patchwork Fri Jul 26 10:45:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 169806 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12865384ilk; Fri, 26 Jul 2019 03:49:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLumJs4bB+L4bIhpPVo9YylX1o84crehZquy4omXmhIBAVe643xjGIk+kce0z1EDL18DDY X-Received: by 2002:a05:6402:78c:: with SMTP id d12mr82339349edy.160.1564138173019; Fri, 26 Jul 2019 03:49:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564138173; cv=none; d=google.com; s=arc-20160816; b=ddLf3KgjETx7ILRWwcKhmiDW4zVSSdLLxwI6G36vD5rMYGSBa0gY5QyouABcLaBk1x 9IInt9Zcu1nM7/g5eLu5AnWPCbeg/uWOafkTiWKfBhTRgVBXCzHG5jNH8crrUTbWL6Y2 1/I1SXILoaFDR9eLN/SiQX1aXqvwj1ReX9y9PWSvzVVGzfEF/3vGm9thXuJcN/HulAm0 f8KDL49rSfhqDl6su1eBor+NPzQqtYMMF9AuQoLWVofLS6kYVRzLOEqKgP5t/Iw3p/iY BU9rdr0Qt+Fzwbpq/5dR+lucTwOCZ61tLE/wBauZzjXHAp49iRAodD3GQADvrs5hhkmO n9gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=h5S8+dP6dn6AN3oDOkpD+x4k3Vk71kjG5fWUcwADDpg=; b=QFNQbFRnoFplw11JMrLtL+FPDyCRnOBZhCCHmYjzFSySQCK9VIZiNexysDI09GX9AA fZqzon4H9n+V0AqEASNH3fo0vqntpYTbGjSx58LdRn0lbdsYd8IHdmQmdi1BKbNeByBJ 7v+mNL8EzUkdN0syVRJ6VLdoEN8TTomvBcg0kts+scTnNEfrcoKYUHk7d+ALCw4VJQI5 rTSUTp4LZz/e6TyD92aclYG+XLHAKrpMgxVKPzkkuzgHjC9H+eoHOb3CKJ7Ub85XP9cK wpseevPU8mrpHHOw4cMbow1UyqKoKx1PTT/96bpilPPBUaMJsaI4ATF7MDURaimSLT2r qdPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c22si12868055edc.378.2019.07.26.03.49.32 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jul 2019 03:49:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:38336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxn0-0007uI-U8 for patch@linaro.org; Fri, 26 Jul 2019 06:49:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43432) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxkl-0008LI-LR for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:47:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqxkg-00073a-4i for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:47:08 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2179 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hqxkJ-0006Fv-V7; Fri, 26 Jul 2019 06:46:44 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 2B978ED77BC9CF22929E; Fri, 26 Jul 2019 18:46:36 +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:29 +0800 From: Shameer Kolothum To: , , , Date: Fri, 26 Jul 2019 11:45:17 +0100 Message-ID: <20190726104519.23812-8-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.190 Subject: [Qemu-devel] [PATCH-for-4.2 v8 7/9] hw/arm/virt-acpi-build: Add PC-DIMM in SRAT 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Generate Memory Affinity Structures for PC-DIMM ranges. Signed-off-by: Shameer Kolothum Signed-off-by: Eric Auger Reviewed-by: Igor Mammedov --- hw/arm/virt-acpi-build.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.17.1 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 018b1e326d..75657caa36 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, VirtMachineState *vms) int i, srat_start; uint64_t mem_base; MachineClass *mc = MACHINE_GET_CLASS(vms); + MachineState *ms = MACHINE(vms); const CPUArchIdList *cpu_list = mc->possible_cpu_arch_ids(MACHINE(vms)); srat_start = table_data->len; @@ -543,6 +544,14 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) } } + if (ms->device_memory) { + numamem = 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_start), "SRAT", table_data->len - srat_start, 3, NULL, NULL); } From patchwork Fri Jul 26 10:45:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 169802 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12864256ilk; Fri, 26 Jul 2019 03:48:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfR+4hbDXE2DB2BLPJ1/nxBWPIQVLUsgb3/iqxLOAIx1c+cCV0kaErR/snLbu/x4dw07+7 X-Received: by 2002:a50:ec0e:: with SMTP id g14mr42776492edr.210.1564138103351; Fri, 26 Jul 2019 03:48:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564138103; cv=none; d=google.com; s=arc-20160816; b=AbseadrKBuxgTOwZ4cP7M+/i7BZvUKUhs7Dz/ZY/kXA71OrcM0hp5d1CRzEa9jjNtb LCMy/ry4juBU8ApADCUnIJK38VLMDJVPnvs6Vsuw3DToDkPGXBtaIsrbg/uQ6dzzZlN6 VRS5FHvjgUNZl/Lk7u/t73BlmsF2R5WlNIPYLivqKdEMJ1J4pSdHga83mtYK8DSXe+TE qgiU6TuCQoSwJOmqqZMA7zATb2cZj5NLpUCUnBw5b3wK8xo/cVsCx5lq8IrxDGNBglyO 0UeVBsYD7i90w7I8EB9WMBDalBWWynWtNu5hi26tJnJnwM9B6URW+Nr8+9nMNPJl4Y/q H0BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=KYKHig3bT+0ct+qSXmJq7X0oyoeXzuw4p8rB5lfTPu4=; b=vXOhWWJ5w3OBzKPVTQrgAmjXxToaaaeHcPwrDcVIcmHfRc3BHJ3gN2vf75Cgolscrr Rwby9pjVck611sJnA5NcF6qF8M8hoUdpIw4nhDAKN8nL/vumCAP7P9NZOb5qvbLDrSks nq5/wJuzLu5xJ+MRNl9ooptqzOnXRrWy8b1iCmlLCjb6KL0cESIRtVfCed5uLPLh9RKv l+iLWI9qeaxBm8V5nSUAlbQrcCKL/hKHo8g4fhSk59zVIFxJYF24sI+4w2j6+HkRn8g2 niBveMSXOssOECRVMA5bxREJMVl9z35ji0x2d1dI8X2swmzjnbGkVSHNgEKPJmow9no8 M2KQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id sd23si10925924ejb.182.2019.07.26.03.48.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jul 2019 03:48:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:38298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxlr-0002wu-0Z for patch@linaro.org; Fri, 26 Jul 2019 06:48:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43463) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxkm-0008U6-SH for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:47:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqxkk-00078n-Lf for qemu-devel@nongnu.org; Fri, 26 Jul 2019 06:47:12 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:37100 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hqxkO-0006b4-Uc; Fri, 26 Jul 2019 06:46:53 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 3F6F065647E06F766090; Fri, 26 Jul 2019 18:46:41 +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:33 +0800 From: Shameer Kolothum To: , , , Date: Fri, 26 Jul 2019 11:45:18 +0100 Message-ID: <20190726104519.23812-9-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.35 Subject: [Qemu-devel] [PATCH-for-4.2 v8 8/9] 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 | 6 ++++++ include/hw/acpi/generic_event_device.h | 3 +++ 2 files changed, 9 insertions(+) -- 2.17.1 diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 7902e9d706..0b3214eff4 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -19,6 +19,7 @@ static const uint32_t ged_supported_events[] = { ACPI_GED_MEM_HOTPLUG_EVT, + ACPI_GED_PWR_DOWN_EVT, }; /* @@ -103,6 +104,11 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *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[] diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h index f0152b0018..63104f1344 100644 --- a/include/hw/acpi/generic_event_device.h +++ b/include/hw/acpi/generic_event_device.h @@ -61,6 +61,8 @@ #include "hw/acpi/memory_hotplug.h" +#define ACPI_POWER_BUTTON_DEVICE "PWRB" + #define TYPE_ACPI_GED "acpi-ged" #define ACPI_GED(obj) \ OBJECT_CHECK(AcpiGedState, (obj), TYPE_ACPI_GED) @@ -78,6 +80,7 @@ * through GED. */ #define ACPI_GED_MEM_HOTPLUG_EVT 0x1 +#define ACPI_GED_PWR_DOWN_EVT 0x2 typedef struct GEDState { MemoryRegion io; From patchwork Fri Jul 26 10:45:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 169804 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12864747ilk; Fri, 26 Jul 2019 03:48:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQqd1mL0q8U5iargTUtzncpr9CwqUfBnWRUUcNJjuUms/n6Zx74w+UF6kBCUqU1hBbECGR X-Received: by 2002:a50:fd91:: with SMTP id o17mr46729896edt.86.1564138134422; Fri, 26 Jul 2019 03:48:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564138134; cv=none; d=google.com; s=arc-20160816; b=E1fNfhX0+0QA1OlGv/Z17XtxeC6n1fGyK7kuMcKJdVsqIlocVH/M58k4aZfPwfjTi2 R6CZxjLvUTFIgR4O7QVS+BEDmkLP7WqpgaAgsyubCw1TB9AU0rpJbhQgq4iB48S7G3v/ qanGrEnc3vC0ok00Cl/mbB67am5zCYPPVuISXld2HoC6FUZB2dgoIn7SBxa216H6inu0 pewiSlIaLePVg4XGDCOVNgqBp+gsqFaUlsCMJOUvrsNPow09a9CajaPqD4xiXFfgmXRM ewR1o5J2f/UwdS4y+984WfGMnCRJP9GxUa3dLz7lxPkNMGDafsg5Jf+kY5cEcxdZohin lz9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=a3WcM1zWIiZpcOkCenZL1JNKr5ezn59ob7s9u8kx38s=; b=TEXlqJIEM+UGmAdKc4qBx1vB2Jbu52I0DUdUeHwxDL9SOHo16kG2LpJruuKwauMVed 3918CzFWPfczC1CEgRfaDhDbXWhSQ74raEGuxe71yVqF6aK+Bl2eQXNtKBnWkAHV2Yio i3jempGFqmbu7cROYARQ9QgUVsbDOOMG2xZoghGHTjGYBGM4FIiJDuxAr9R7670X4M+D 6oluQlgI3uQahNOzBO0PiHiBZ7rNiY01bg0J8fMe5meHBXPXVbR3c450kxikd6y0maIA jr5fPeJoAMXSR4/9S0Cd6OsdyPGbzdSWW/EgUYtmvdAdgPBKbZGPE2GEK1v2dKT3Gwru 9JFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g18si12155220ejw.180.2019.07.26.03.48.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jul 2019 03:48:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:38318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqxmM-0005Xi-F2 for patch@linaro.org; Fri, 26 Jul 2019 06:48:50 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.1 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, AcpiEventStatusBits ev) if (ev & ACPI_MEMORY_HOTPLUG_STATUS) { sel = ACPI_GED_MEM_HOTPLUG_EVT; + } else if (ev & ACPI_POWER_DOWN_STATUS) { + sel = 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" #define ARM_SPI_BASE 32 -#define ACPI_POWER_BUTTON_DEVICE "PWRB" static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) { @@ -739,12 +738,13 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS); 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_MEMORY); + } else { + acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], + (irqmap[VIRT_GPIO] + ARM_SPI_BASE)); } 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(VirtMachineState *vms, qemu_irq *pic) { DeviceState *dev; int irq = vms->irqmap[VIRT_ACPI_GED]; - uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT; + uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT | ACPI_GED_PWR_DOWN_EVT; dev = DEVICE(object_new(TYPE_ACPI_GED)); qdev_prop_set_uint64(dev, "memhp-base", @@ -784,13 +784,15 @@ static void create_rtc(const VirtMachineState *vms, qemu_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 = container_of(n, VirtMachineState, powerdown_notifier); -static Notifier virt_system_powerdown_notifier = { - .notify = 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); + } +} static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) { @@ -833,9 +835,6 @@ static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) qemu_fdt_setprop_cells(vms->fdt, "/gpio-keys/poweroff", "gpios", phandle, 3, 0); - /* connect powerdown request */ - qemu_register_powerdown_notifier(&virt_system_powerdown_notifier); - g_free(nodename); } @@ -1721,12 +1720,18 @@ static void machvirt_init(MachineState *machine) create_pcie(vms, pic); - create_gpio(vms, pic); if (has_ged && aarch64 && firmware_loaded && acpi_enabled) { vms->acpi_dev = create_acpi_ged(vms, pic); + } else { + create_gpio(vms, pic); } + /* connect powerdown request */ + vms->powerdown_notifier.notify = 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_dev_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 = 8, ACPI_NVDIMM_HOTPLUG_STATUS = 16, ACPI_VMGENID_CHANGE_STATUS = 32, + ACPI_POWER_DOWN_STATUS = 64, } AcpiEventStatusBits; #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; #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)