From patchwork Tue Jun 25 12:14: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: 167715 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp5486879ilk; Tue, 25 Jun 2019 05:25:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwimorw6fWcnYKI+tYXg0zr8S4KgxmRQFjImfycREJJ6vkceIDqYFjSt4HqJQ4wrwihoNQq X-Received: by 2002:a05:6402:12d2:: with SMTP id k18mr52665164edx.197.1561465534189; Tue, 25 Jun 2019 05:25:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561465534; cv=none; d=google.com; s=arc-20160816; b=f0YZS8eP/vNr1O+cdqGV3iPn74ASuMDYEQpe3nDVWZy/nZlVcBgRheHADENa/YzHK7 6TVrHzbYeaUcT5BY5euH3GQEcuTxQx2C3RZXynY+oeAt+FPuafSvLw6ZJJskMtXfdvQ4 0fhXzwRJrTObz/WnPSTBVYkI0npcU/us6m1a+z/tSy8SYBuenwL4gQTUdCRbhRWrmHue Sz33rmVHgAMDr8e/fiIcrDzmP1WJWN1wtKdN5t44rVufYlbbnKcCO7NQDqvWkdcA2anP 2IWgyBYDVV8jg1ZhRawVB5dxxFr7RyjzKaLBNPgyUUs0I96KrOlZEmDHfJlkF02ibdcs TyFA== 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=lu8b1Dn5v10TcN0a/KxSA6wZxrtkp2rhLjWDAlMiKHk=; b=lx26HJsDyPTPJaYl5lmKSyfk+9I8e0QHl3gRUsL3PEvV9/TaZSuT3CQN4QtKjmps0a lC6BgKiCLWW2ls5G3R10JZ2/zyp93aSJLgSW8t/1zCyXMk3KVsX4BzOGr2j6kf4jKMWm 7bNWGm100zLGtpAcLlugyH0Pp6KYBFi0ho7U65oFTz9BElZiBSnyGFmL2eIIrmQo2B4r rUPuWV2IwYaS5Ntv5g3Nd6lhmIWCNwIy+hrAo1/0fliq45ZyqHgb4d8iSTK+VGv2TICe wHzTMyYH+geAUIbZh818KelzZF1d1+bQpPA4wsqNU2iMrgQoCYAULhBZgnrz2P92h0u3 hnyA== 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 u2si223532ejk.197.2019.06.25.05.25.33 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jun 2019 05:25:34 -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]:59660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkVx-0004wh-3j for patch@linaro.org; Tue, 25 Jun 2019 08:25:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36275) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkMh-0007Bx-C7 for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:16:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfkMY-00048d-QX for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:15:54 -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 1hfkMS-00041H-JK; Tue, 25 Jun 2019 08:15:46 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 6AA48C108F77C277EE6C; Tue, 25 Jun 2019 20:15:39 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Tue, 25 Jun 2019 20:15:29 +0800 From: Shameer Kolothum To: , , , Date: Tue, 25 Jun 2019 13:14:14 +0100 Message-ID: <20190625121421.22280-2-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> References: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.190 Subject: [Qemu-devel] [PATCH v6 1/8] 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 31a1c1e3ad..6c7c33e47a 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1862,7 +1862,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 Tue Jun 25 12:14: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: 167721 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp5500125ilk; Tue, 25 Jun 2019 05:38:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlcAFVsDI95UjcyF413ST86pB17ZY9pBZ7SvncQiKuPgwf0FhbTNm7mhsdMjdjUxoCZxIh X-Received: by 2002:a17:906:b203:: with SMTP id p3mr5898870ejz.145.1561466315365; Tue, 25 Jun 2019 05:38:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561466315; cv=none; d=google.com; s=arc-20160816; b=KYon6Ba5PpJqBuv6on98cCw9Ur+yNUvpeYYIScsoQmEcuNC0aCT1BaSqaWW1MEdCNX lrYoPc2307kaGq4OosYqd9baw65Ug8chrMA9DYPT6jiyeODb0WOY7dzTXOx3b3hIdlV1 Gd3oLaJHW/9BYI0ZhmQZJNNiPNXLow/YRPKtJKNsLQ9yqwDAAME/MMeVXJx4dwi53qVK /+27pe+/zFymRn/gFl44I7SQGCjwEOQV7LJr+fpFEr8j2tIIXOQHP5Fdc2W4VyoWsLIQ cj52Q/tm7cg+XOxdBNlxHNgElpPDSqg20KKUUni3Jo3dQ4Fywtanpu0EU4ZIHy/wg2M/ ocWA== 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=WHESVJlvr51j3zgRoRgC/7LTP5irpTY09pRQMoFOUah4v5Gi9lX/rEYteCvJCMT3W6 LZAowdObPxXNm3xoj4QXAC//oFlP8UH0qxWifkSt0CJdMpjj0/7g9DhUJuhNC18xDce8 ckZ64fdHD4V/MftxYRcOo8daq+AgPRdV8A9IDcZf8r9YKIwquLOLaqSuAPCJGwrA4D3D snKN4dHdATTyq6aukZpr5PDPVVS6xY1UNnEUZKoq8AlUK7fx2XETZvQNGSCLkbMcjdOd 47SmvCm02L20kmkIeEaI+L4FfVeKLoNvOA+1oG5hbp3ZfJZLVmM4JD4pYuAdelejx9QI a2yw== 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 pv1si265566ejb.259.2019.06.25.05.38.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jun 2019 05:38: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]:59732 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkiY-0005bI-Ai for patch@linaro.org; Tue, 25 Jun 2019 08:38:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36274) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkMh-0007Bw-C7 for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:16:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfkMY-00048L-Nr for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:15:54 -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 1hfkMT-00040C-1W; Tue, 25 Jun 2019 08:15:46 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 64560D0D11A5D8470602; Tue, 25 Jun 2019 20:15:39 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Tue, 25 Jun 2019 20:15:32 +0800 From: Shameer Kolothum To: , , , Date: Tue, 25 Jun 2019 13:14:15 +0100 Message-ID: <20190625121421.22280-3-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> References: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.190 Subject: [Qemu-devel] [PATCH v6 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.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 Tue Jun 25 12:14: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: 167716 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp5492174ilk; Tue, 25 Jun 2019 05:31:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwZHRdHMXMeo3RT6vYo/GyJ+x8nAEO/U9ic5aQhMyIvzAzODwywKSGqBv5CMcVZ/wd2Asd X-Received: by 2002:a50:94b1:: with SMTP id s46mr70923366eda.188.1561465865980; Tue, 25 Jun 2019 05:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561465865; cv=none; d=google.com; s=arc-20160816; b=Njtrr/rkWv8HXVGZd6qfl5RWyhTJbMF1el6HOZZ1Ot6+qhj1Bv+CclhzYQka6X5wiM xQ4i8B+S2xhEJXzkhyNSH/n+fAKwD/vwKmfuGScKPuIaoX3sM8nDSC8TV1X/SlcIHfXh rJ6ScQM0eDj8K16+aLl2NEIMlDH+b/Hc+0bdN8TF2oyzrrL1WhfQyLAeYPxsrBVEyqnq GnJ1pE3+oL6Y1gPfk+AYLTJsa1h3CELwQiVlKQAq1F30pUkqn078T4qJsA5BjT+EFyso 7JeWTUYUUcQ3X1llknKkUrtr9EUOf9X5q8k40O/829x9af2Zp+k8Szw1v43ZrU4sQtUU vrbA== 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=wPK/034HCG+sEwHhRM0qg+XrJTnXYp3Rg+NjMbkil5s=; b=gw8o+zGuC+vW1jL1L1JsawWX4sW8uKpBzwPTuOhQxxjVp2FFfRJrQRz46a4kwUqSO+ gRZxtq1FNpcjSp4lqzuMoJ8dQ5lebUfgjm5+AmLr9M9pz8WFG9sLx4WF8OJRmLT7D1FY mA3ROnqxOxr5lWJ430ZuNh0cR+A5F0S7gUoI813w1XZ15Ro/Moi7L/dRs3pqhbLTIZN1 5iKMaBnSKsq9RXyL7kEtMu2uGNOt7tVOv+lz4qK+BCo3YEmBhYWBpk95lC10f39ke/zS reC91tZK1aR+3y0qYU8lqoDMDB5ZmE3BaXINBLsQdUqZKxiz7LHo74fdXi/sKb9uqTnt yw3A== 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 b33si330494eda.75.2019.06.25.05.31.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jun 2019 05:31:05 -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]:59698 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkbI-0000kS-Nj for patch@linaro.org; Tue, 25 Jun 2019 08:31:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36355) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkMw-0007El-NS for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:16:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfkMm-0004Gn-Bq for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:16:08 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2247 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hfkMW-000453-OD; Tue, 25 Jun 2019 08:15:50 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 6CDC1307F09D6D18EFA0; Tue, 25 Jun 2019 20:15:44 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Tue, 25 Jun 2019 20:15:36 +0800 From: Shameer Kolothum To: , , , Date: Tue, 25 Jun 2019 13:14:16 +0100 Message-ID: <20190625121421.22280-4-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> References: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.191 Subject: [Qemu-devel] [PATCH v6 3/8] 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 --- v5-->v6 -Added !s->memhp_state.is_enabled case handling. -Addressed other comments on v5 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 | 336 +++++++++++++++++++++++++ include/hw/acpi/generic_event_device.h | 102 ++++++++ 4 files changed, 443 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..2a83d68e82 --- /dev/null +++ b/hw/acpi/generic_event_device.c @@ -0,0 +1,336 @@ +/* + * + * 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 */ + qemu_mutex_lock(&ged_st->lock); + val = ged_st->sel; + ged_st->sel = 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 = { + .read = ged_read, + .write = ged_write, + .endianness = DEVICE_LITTLE_ENDIAN, + .valid = { + .min_access_size = 4, + .max_access_size = 4, + }, +}; + +static void acpi_ged_event(AcpiGedState *s, uint32_t sel) +{ + GEDState *ged_st = &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 |= 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 *ged_st) +{ + AcpiGedState *s = 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 = 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); + 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; + } + + /* + * 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 = 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[] = { + /* + * 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..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 = 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 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_dev, + uint32_t ged_irq, AmlRegionSpace rs); + +#endif From patchwork Tue Jun 25 12:14: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: 167724 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp5504500ilk; Tue, 25 Jun 2019 05:43:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVN0dBk/RX9pVjPyk1QZ6QfOR9pD+fjTHfIj/M/AdVOD4WNUwEF+5H/kNACgWflYAeNHlu X-Received: by 2002:a17:906:2a94:: with SMTP id l20mr50382703eje.131.1561466596778; Tue, 25 Jun 2019 05:43:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561466596; cv=none; d=google.com; s=arc-20160816; b=IIwB66B0gV/YTnK1UDe1FTJR2tEcCqF45f3+6dXKsmdMSpqdPaXTs14uikqC/yELOI E6s9ssooicpIK8DUNo5rwnlTHp/it6/R15KVEUzdToYEZp84jV5s0CZOfeBCWvlQO3XP oWdzBz3z2EQPf/x9/2FjEuNW3vPww7rUulNFGz3p5TkJacpo89V+xIxmkGivfoGyVGhK /MH4OpnHhnYDrbMObdf7S5191FWlPWJriNxmqYUkXjKXRLaZT8Kl+W57gabirEtJYyi8 XvRzWO1fDe/JMUaq/tUQpgry9j6ItPrzsu9i8amkH4GnAZdox4zlnUC5MQx8q700bjPE wVHQ== 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=04hoOnsdKXcUXnLQLgyioSOSVaHVJ9i+uOtXmY1Z81k=; b=FFbk95xZjg7R4EAvLNcVePpTZGAmXKLc66T7TDLYkKkFHU6aoulrmw9pM45lfYPm+H XqQU0Gssw7p0Bn//6+CSMKSccVYj9RHtfmZZVQuAdAZ+as+Ma94naQfKw/pNsPAEK01x At/ww4bYLWY5w8iP9eknaIXBSxNhXootqAn39Tej9uGmYjGP+EMxSZ3gZP0xN0XwoXzP m6lcKNiBIaBlyWoCflvUqiwa2zKVmJSUEPG+LsoIs2vqTB/qM68m2aDykhRDZiwHvQdK ncUXdBg0WhfL0451xJe6811/hqPkZ4g/2dQ67egr6aHsp8YFPriqPAFJudIkFe8AQ7yo QujA== 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 o21si347079edc.65.2019.06.25.05.43.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jun 2019 05:43:16 -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]:59784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkn5-0002Be-Mh for patch@linaro.org; Tue, 25 Jun 2019 08:43:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36498) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkN7-0007IU-IG for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:16:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfkN5-0004VM-ET for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:16:25 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2248 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hfkMs-00048v-AO; Tue, 25 Jun 2019 08:16:13 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 813CFE68FF18170E2E9B; Tue, 25 Jun 2019 20:15:49 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Tue, 25 Jun 2019 20:15:40 +0800 From: Shameer Kolothum To: , , , Date: Tue, 25 Jun 2019 13:14:17 +0100 Message-ID: <20190625121421.22280-5-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> References: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.191 Subject: [Qemu-devel] [PATCH v6 4/8] 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 --- v5-->v6 -Resolved a conflict with latest master branch. --- hw/arm/Kconfig | 2 ++ hw/arm/virt.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Peter Maydell diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 9aced9d54d..05c329f1e9 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 431e2900fd..d216c7f892 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, \ @@ -1864,6 +1866,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) { @@ -1875,12 +1911,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); } @@ -1944,7 +1991,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; } static void virt_instance_init(Object *obj) From patchwork Tue Jun 25 12:14: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: 167722 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp5500629ilk; Tue, 25 Jun 2019 05:39:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxV1Fq1hPu9MEQcEVhwicyrXE9pVUXxtywvUToeqN85ZhDTN3scj6GChcd5/awkZjGFYhtn X-Received: by 2002:a17:906:7f0f:: with SMTP id d15mr13319986ejr.39.1561466346734; Tue, 25 Jun 2019 05:39:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561466346; cv=none; d=google.com; s=arc-20160816; b=donqOUzfi92Ckx1+hLNoEoeLjcdjbKzKOqaWFlsPXAAwEFixTfBuqEz/dBWNSYzRGz Huppk1dFEKFq8EC65oLeGp06LRi5z4blPxfpJhJQ6Fl9vbWxya0ZkFMXGXxRvgkv7EgW z4bCaXqdFlBwJqKA2HyqpKo1QqkIxy1AYnAYeWVgv18Wsi8QzprflliLivvw1nd/tea4 BZghGi62keBIbC8ZD3bxrTphafzDX/bKa3JKLL/FVwpAKaTlN8jvEbl9c7Lw4cnbqO7H uI7d/CFj+ouC7qzcU5EsYThFKKCevWDO9pBsiZfc9+9PlttMcZC5BfHOfyvfAozWWpc2 0yOg== 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=fS4qSUBuRXwbMmlPGc07hjPIO/T3LbvBELJ2zcq2zMQ=; b=HXemP0l9CSrPJFE4eTM2ufgaOLLgEcFLGwjoKd96j9ztpNxHz+dL66E3XoE5pCXmIz yFd46LWC5OPaJGRCJwBuCFTFwm8Q9kGrlchSki7wMCl8I+tKAVx50m1wSSuJiyMSpFYk RirL/5LWKStM9ZWi3yygFrikgU+9KLAf1XEH+Q06CkGMBz9Te4aKVfqHDOEIvNyGE5tX Q7LK4biksMQhErsNDh2p8iFVVhxEkbRJUvsb6F3E3U06uD0YVQpOGThTcbrEbzigrB9g P8SoNA3ygh0OEqiC0JaCzH/27jF/azlCekipvCwQW9FfLXQq0JsdepnX+Sz49GoWFrWA fk1Q== 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 s43si357192eda.175.2019.06.25.05.39.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jun 2019 05:39:06 -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]:59744 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkj3-0005zC-MZ for patch@linaro.org; Tue, 25 Jun 2019 08:39:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36649) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkNL-0007Q7-VW for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:16:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfkNJ-0004if-ON for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:16:39 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2249 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hfkN7-0004BD-FG; Tue, 25 Jun 2019 08:16:27 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 9202664FF45EAE144F10; Tue, 25 Jun 2019 20:15:54 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Tue, 25 Jun 2019 20:15:43 +0800 From: Shameer Kolothum To: , , , Date: Tue, 25 Jun 2019 13:14:18 +0100 Message-ID: <20190625121421.22280-6-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> References: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.191 Subject: [Qemu-devel] [PATCH v6 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.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 --- 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(-) -- 2.17.1 diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 05c329f1e9..d75634c4ef 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 d216c7f892..51173f6ce1 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_REG_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 */ @@ -519,6 +523,25 @@ 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]); + + return dev; +} + static void create_its(VirtMachineState *vms, DeviceState *gicdev) { const char *itsclass = its_class_name(); @@ -1691,6 +1714,10 @@ static void machvirt_init(MachineState *machine) create_gpio(vms, pic); + if (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. @@ -1869,27 +1896,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, diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index a72094204e..d5a7d299b9 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, }; @@ -133,6 +135,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) From patchwork Tue Jun 25 12:14: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: 167725 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp5504548ilk; Tue, 25 Jun 2019 05:43:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSpKi8GD6kE3CJKIXGUdOOXCNHon9D68e/m4svxwLr8fIu9/GIhjWfRu6zBfJ0SySUte90 X-Received: by 2002:a17:906:4ed8:: with SMTP id i24mr87369632ejv.118.1561466598622; Tue, 25 Jun 2019 05:43:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561466598; cv=none; d=google.com; s=arc-20160816; b=paEQyika8BPyT3g2vJ/gLbCvYJPS2yBujVBkYj/3v2/wBARJViupF2Qz4u3wNoIoJ9 gEFGcgV7rn7x9PL+6+vui5DNUCQ5JF7cGxewrGumFWKgflETmO8iyRMVZxDvjLMTTmaG WjS/58HHaxovJiV2HqJynla16UcnVnqbUJQD0PvJrrkEuWtzLXXQPs69YIErWoocAGkg VOB9SoNmYWe3NU0aIfsYv36SxCdx+Rxw/eAo+PzW7EFfzplN6yjHUKFa3GK0oCx9/Wvo wcse94J3Yrfm1p3SYbtyKTN202ugFDqyVGM8MzvpaCr6dqNRwS1fhB++k/XYMgBfeOTz TeuA== 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=UDFJOH0NVdPjV1XjutOQirkmwl4VNC4nxwFdzOvEd5WK47INOvIzXmBR95/SYnV5mU PsfWiAaA39J3d1EjFiLK7SAaYarJ0c5yxILABtlgQCH4hcaDsKT4dGnUFoNruO1uYhn6 7T6xycltqJf91KPXaLNTOVen3m3bFA9WhuUjM03rkHtuEUo3cW8SmIEHOzJdEqUqjeyu oed6aqSChqu+Ju+A0dLKoBm3QMK5YWGlHvemXOOC0UbgHl1Nnfozn2vo9BFp8CCJvcNA 6Tc6dOV5hM1MPJE7Q3nxi8ty561HYZqVjpom2mC7r/qYeV/8NcmatPbyoQ0ggEA6xwK7 j31Q== 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 c22si381077eda.76.2019.06.25.05.43.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jun 2019 05:43:18 -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]:59786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkn7-0002FA-GK for patch@linaro.org; Tue, 25 Jun 2019 08:43:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36526) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkN8-0007KT-N0 for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:16:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfkN7-0004XF-Dj for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:16:26 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2250 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hfkMx-0004BE-99; Tue, 25 Jun 2019 08:16:15 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 8BB81555095E07A8943E; Tue, 25 Jun 2019 20:15:54 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Tue, 25 Jun 2019 20:15:47 +0800 From: Shameer Kolothum To: , , , Date: Tue, 25 Jun 2019 13:14:19 +0100 Message-ID: <20190625121421.22280-7-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> References: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.191 Subject: [Qemu-devel] [PATCH v6 6/8] 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 Tue Jun 25 12:14:20 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: 167723 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp5500770ilk; Tue, 25 Jun 2019 05:39:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlIIZqLlQXu5nEzhMaP3Lqtfrq0+ujVUPOoUFQkC0jvzqoyUqs5BWlMsRf1FjL6c1yhdjp X-Received: by 2002:a17:906:cccd:: with SMTP id ot13mr85502088ejb.37.1561466353283; Tue, 25 Jun 2019 05:39:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561466353; cv=none; d=google.com; s=arc-20160816; b=wrIe5IByGMfDZQidSkVdKtSq4NyyTth/t2Zm6DDgfkijVrYA9XIzpIw4gjBjU0zEY3 7g/imCPMrdQxXJafL/Qh3xwF2eAMz1o4IfeyBPPy9RuqxI/1Gu/IFgbzOxR/TDCX276k v73ZX1RYuee9we1idcvhpNGmpGqrPo3DOI3A5lgnTfQhrOO9Hyt0/grI7bhuTR/8m6iX QFXHCZ1Q3/7HK1aZBTywy/LHGfH4qQF35GMrjmRHNJR8WsY4ZNSBw3KADo8Ci/esQUcU VvimIOe+hOmI0m/gYhEBiMdcBoq48qvdfcNkpKilD2cXUaGOjwyYJIXZ6Kuo5iw9CmjW N4+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=jRLuuv3sLKJ4MMZy9mT+7kth4Pq48ndqHe9l3GxCZLw=; b=lLdaza5BErsPPcbjzQG3JYvRRFVuqRihITnomaKpPYlcw5XcvtsuB6s694Isbi1Si3 gfgox9QpuKXMdA92UslRWR2804jHGCAEwexelvqTfmtNE2l8zikWESwCOLN+UkKY8cu7 LtMG/nMZEIIbrwN03pZCZOmMK2tFcdfdmqcpRloVkAYJiY+MTGTzIj692hanOxn0fozK dYextjY4EIxyQIBOCL9bBTxBSdC9ISjWWZfOdXPz5rN/JiJMdbnkHUjakU9umTTLjKxX uca2eebMUsCbsEMV/aWhTOtgLxghiem6n9ZTK12x79WAbr64mkZLuQabKkuDO+9Ka1Xw +Skw== 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 i12si311102edq.333.2019.06.25.05.39.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jun 2019 05:39:13 -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]:59740 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkjA-0005lu-9P for patch@linaro.org; Tue, 25 Jun 2019 08:39:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36607) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkNE-0007OM-4y for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:16:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfkNC-0004cr-2H for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:16:31 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:54734 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hfkN3-0004Ex-J5; Tue, 25 Jun 2019 08:16:23 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 99F7B2D2E6848C930D19; Tue, 25 Jun 2019 20:15:59 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Tue, 25 Jun 2019 20:15:50 +0800 From: Shameer Kolothum To: , , , Date: Tue, 25 Jun 2019 13:14:20 +0100 Message-ID: <20190625121421.22280-8-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> References: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.35 Subject: [Qemu-devel] [PATCH v6 7/8] hw/acpi: Add system power down support to GED X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+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 | 16 ++++++++++++++++ include/hw/acpi/generic_event_device.h | 4 ++++ 2 files changed, 20 insertions(+) -- 2.17.1 diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 2a83d68e82..2bd786b7ab 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -19,6 +19,7 @@ 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[] @@ -232,6 +238,13 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev) acpi_ged_event(s, sel); } +static void acpi_ged_pm_powerdown_req(Notifier *n, void *opaque) +{ + AcpiGedState *s = 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 = ACPI_GED(dev); @@ -243,6 +256,9 @@ static void acpi_ged_device_realize(DeviceState *dev, Error **errp) } acpi_ged_init(get_system_memory(), dev, &s->ged_state); + + s->powerdown_notifier.notify = acpi_ged_pm_powerdown_req; + qemu_register_powerdown_notifier(&s->powerdown_notifier); } static Property acpi_ged_properties[] = { diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_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 @@ #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) @@ -79,6 +81,7 @@ * through GED. */ #define ACPI_GED_MEM_HOTPLUG_EVT 0x1 +#define ACPI_GED_PWR_DOWN_EVT 0x2 typedef struct GEDState { MemoryRegion io; @@ -88,6 +91,7 @@ typedef struct GEDState { typedef struct AcpiGedState { DeviceClass parent_obj; + Notifier powerdown_notifier; MemHotplugState memhp_state; hwaddr memhp_base; hwaddr ged_base; From patchwork Tue Jun 25 12:14:21 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: 167718 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp5494430ilk; Tue, 25 Jun 2019 05:33:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqypFa3+/JMuwxUVON8Trs2+CxcAuecjN+kWy9+DgCNSCxFWbCk8nv+3fl0Tcn82s1qko9mt X-Received: by 2002:a50:90af:: with SMTP id c44mr142593235eda.126.1561465986582; Tue, 25 Jun 2019 05:33:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561465986; cv=none; d=google.com; s=arc-20160816; b=XpXF/NK3hdvfyJ+pmjh1ZMNqtNubwPhG91IYmWKfa/mc5dbi2E3bFQM1FWCNBwp3JA eEAy9irsZDu8RVfTM5D/Zo3x/IIx/qtgVj2YczSI/4r8MetIcmtatjG7utNU93NvTwCI Mc/LwxlWvFo9UoL7fPQHxjV7pgQvQbSVWsA3NZlhO5V+wgGDruauesDMHrsxWl1CrwPO idIZGO93Y/ZBmI23UaeVX8BquQdIxH0eraR0SQjf9UoyeFNCSFND2lnLs6xw2iRJ75eA iCajBpkXuuaEVRG8UIYxOSePecJHdeZMoWmYGR1iv9XjsQq/qVIei2Yp9C1ArsriA61z ZXkw== 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=yJh2nFGCz2iJoTItFxl3oPL2kP+Pn4Js3ltYfd0rJNw=; b=0fdmx3JysZXUMaox/GNJu2BgTp4uYmiXddESnSwqAQ4fDguA0oG+mr7/hdxxxHCIMu cgVl+6rwaZFj4WDUt9/+AvWfIpUgbxBXBjw2imkkLcT1VzdVFPDHsPzBygq2J2eD0R7N w0ETUM78LO9Pp7xljL8yzYT39k9ktLnPOISI8/WsEGseUWuTnQYvEkqHQqlhFFR7f8x4 wzDW5j21GBdyBQB9Mdak9rLOuejw30wUjXwZoFOce5lksYvaaTAk1+5Y4odk4woi6Zj3 q37JIWk2YFORML6k9XIrA+tOKvdUbJdn/x6vdfHs5V0rijAGwSA77kvLDX91xrSu1Okh XNiA== 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 k25si339290ede.169.2019.06.25.05.33.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jun 2019 05:33:06 -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]:59712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkdF-0001LQ-HY for patch@linaro.org; Tue, 25 Jun 2019 08:33:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36551) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfkN9-0007Lz-Ce for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:16:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfkN7-0004Xv-K2 for qemu-devel@nongnu.org; Tue, 25 Jun 2019 08:16:27 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:54892 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hfkMx-0004IO-DC; Tue, 25 Jun 2019 08:16:19 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id B4A38590451BDC308A82; Tue, 25 Jun 2019 20:16:04 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Tue, 25 Jun 2019 20:15:53 +0800 From: Shameer Kolothum To: , , , Date: Tue, 25 Jun 2019 13:14:21 +0100 Message-ID: <20190625121421.22280-9-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> References: <20190625121421.22280-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.35 Subject: [Qemu-devel] [PATCH v6 8/8] 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" 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 --- hw/arm/virt-acpi-build.c | 37 +------------------------------------ hw/arm/virt.c | 7 +++---- 2 files changed, 4 insertions(+), 40 deletions(-) -- 2.17.1 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 75657caa36..9178ca8e40 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) { @@ -328,37 +327,6 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, aml_append(scope, dev); } -static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap, - uint32_t gpio_irq) -{ - Aml *dev = 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 = aml_resource_template(); - aml_append(crs, aml_memory32_fixed(gpio_memmap->base, gpio_memmap->size, - 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 = aml_resource_template(); - /* Pin 3 for power button */ - const uint32_t pin_list[1] = {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 = 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 = aml_device(ACPI_POWER_BUTTON_DEVICE); @@ -739,9 +707,8 @@ 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) { + 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_MEMORY); @@ -752,8 +719,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) AML_SYSTEM_MEMORY); } - acpi_dsdt_add_power_button(scope); - aml_append(dsdt, scope); /* copy AML table into ACPI tables blob and patch header there */ diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 51173f6ce1..e6cef1e536 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -527,7 +527,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", @@ -1712,12 +1712,11 @@ static void machvirt_init(MachineState *machine) create_pcie(vms, pic); - create_gpio(vms, pic); - if (aarch64 && firmware_loaded && acpi_enabled) { vms->acpi_dev = 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.