From patchwork Fri Mar 8 11:42:08 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: 159971 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp8612594jad; Fri, 8 Mar 2019 03:51:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxEzKUcu2A/aueS7SMiEwgmnV+ynbnp+V6eX3xh56DC3ApLoIH2oYXC2HYJlYc/Q+mnE3Ap X-Received: by 2002:a25:56d4:: with SMTP id k203mr15276273ybb.475.1552045871272; Fri, 08 Mar 2019 03:51:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552045871; cv=none; d=google.com; s=arc-20160816; b=zChhb6P4jVR2xEYH/5h0k8jaQjWmUtCc3Zfjtk5XCozOlzeS2VuG/GSuCYo/NHzeYe HuqOxr82vdHEwoAJqu7Iy2YC32oJ2yk57fTXJ9g91WH+WsDlP6Kt3KdQKsMb4g72lmxt MDR9FK7bMQlALe92mOLLlvmDyfTwu7rXyeqvvBqEIuzN+vx+y4mp8TU8HhPC1IHM1q6p YGWRFF3hdn7W9QWTAQhFeX+fh98Py9gnl88/P2xQRtBFPXgypXd1SZFoSKuIFL/9GZ1f aTtte1iIeShGP2afLRK5d5XM9xD/N6o6I2OpFfETPjyRQ75aqlSxwt540zhQPZypfCbj 8DaA== 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=pkHvbKwiU4EqPm9mQdr/8i5WsI7eNKc9PxspeAgBYRI=; b=WeRbWTdGm6yWGl/t/d0sYbuEvCi9H0lDe7ncEfR00EJMJfpYC3tZCyLUanoutdn2dX W8nWsph8QrUsMtd6s331c/eeZYkavFTnIWQOYzf+gIzXM/yYeLW4kSa691/7e1Oya9YD iCoMUIx3FWm5HLWbzBxWVwrP9JqZzjN343fgsq8XU29RECACywwJhPxrzlZ0eka9PAQV onpy1lF88niBfrDZP0+FGftYlJvDwSUOWZ1eMMIhco+47nuI3q694NREOvFaXPZAhZ0j pk0K03zwxU/1+2WNYh3/tj5EsEP2iH0v0Wbl6lRO/no8IbDwDdYcOFQPdexLWQOmDZW5 v3ww== 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 a187si812113ywg.202.2019.03.08.03.51.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Mar 2019 03:51:11 -0800 (PST) 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 ([127.0.0.1]:41578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2E1b-0003db-7i for patch@linaro.org; Fri, 08 Mar 2019 06:50:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2DvX-00088Z-Qw for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2DvT-0005FN-Sx for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:34 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2244 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2DvO-0004JS-J9; Fri, 08 Mar 2019 06:44:26 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 12D7CAAC261A0EB052F2; Fri, 8 Mar 2019 19:44:18 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.408.0; Fri, 8 Mar 2019 19:44:08 +0800 From: Shameer Kolothum To: , , , , , , , Date: Fri, 8 Mar 2019 11:42:08 +0000 Message-ID: <20190308114218.26692-2-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190308114218.26692-1-shameerali.kolothum.thodi@huawei.com> References: <20190308114218.26692-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 v2 01/11] hw/acpi: Move constant definitions to header files X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxarm@huawei.com, xuwei5@hisilicon.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Sebastien Boeuf By moving the definition of memory hotplug related constants used by ACPI for both CPU and memory, this commits allows those to be used from other parts of the code. Signed-off-by: Sebastien Boeuf Signed-off-by: Shameer Kolothum --- hw/acpi/memory_hotplug.c | 26 -------------------------- include/hw/acpi/memory_hotplug.h | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 26 deletions(-) -- 2.7.4 diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 921cad2..a6beb10 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -8,32 +8,6 @@ #include "qapi/error.h" #include "qapi/qapi-events-misc.h" -#define MEMORY_SLOTS_NUMBER "MDNR" -#define MEMORY_HOTPLUG_IO_REGION "HPMR" -#define MEMORY_SLOT_ADDR_LOW "MRBL" -#define MEMORY_SLOT_ADDR_HIGH "MRBH" -#define MEMORY_SLOT_SIZE_LOW "MRLL" -#define MEMORY_SLOT_SIZE_HIGH "MRLH" -#define MEMORY_SLOT_PROXIMITY "MPX" -#define MEMORY_SLOT_ENABLED "MES" -#define MEMORY_SLOT_INSERT_EVENT "MINS" -#define MEMORY_SLOT_REMOVE_EVENT "MRMV" -#define MEMORY_SLOT_EJECT "MEJ" -#define MEMORY_SLOT_SLECTOR "MSEL" -#define MEMORY_SLOT_OST_EVENT "MOEV" -#define MEMORY_SLOT_OST_STATUS "MOSC" -#define MEMORY_SLOT_LOCK "MLCK" -#define MEMORY_SLOT_STATUS_METHOD "MRST" -#define MEMORY_SLOT_CRS_METHOD "MCRS" -#define MEMORY_SLOT_OST_METHOD "MOST" -#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 ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev) diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h index 77c6576..fbfcbe6 100644 --- a/include/hw/acpi/memory_hotplug.h +++ b/include/hw/acpi/memory_hotplug.h @@ -5,6 +5,32 @@ #include "hw/acpi/acpi.h" #include "hw/acpi/aml-build.h" +#define MEMORY_SLOTS_NUMBER "MDNR" +#define MEMORY_HOTPLUG_IO_REGION "HPMR" +#define MEMORY_SLOT_ADDR_LOW "MRBL" +#define MEMORY_SLOT_ADDR_HIGH "MRBH" +#define MEMORY_SLOT_SIZE_LOW "MRLL" +#define MEMORY_SLOT_SIZE_HIGH "MRLH" +#define MEMORY_SLOT_PROXIMITY "MPX" +#define MEMORY_SLOT_ENABLED "MES" +#define MEMORY_SLOT_INSERT_EVENT "MINS" +#define MEMORY_SLOT_REMOVE_EVENT "MRMV" +#define MEMORY_SLOT_EJECT "MEJ" +#define MEMORY_SLOT_SLECTOR "MSEL" +#define MEMORY_SLOT_OST_EVENT "MOEV" +#define MEMORY_SLOT_OST_STATUS "MOSC" +#define MEMORY_SLOT_LOCK "MLCK" +#define MEMORY_SLOT_STATUS_METHOD "MRST" +#define MEMORY_SLOT_CRS_METHOD "MCRS" +#define MEMORY_SLOT_OST_METHOD "MOST" +#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" + /** * MemStatus: * @is_removing: the memory device in slot has been requested to be ejected. From patchwork Fri Mar 8 11:42:09 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: 159967 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp8608178jad; Fri, 8 Mar 2019 03:45:52 -0800 (PST) X-Google-Smtp-Source: APXvYqzkuO4AtuFQghROKkowmtoR49wZ3T8UTfumQzCj3Rqv9P8cVu+U4ReU5eZjRUnJ1TqrVS2F X-Received: by 2002:a0d:e1d3:: with SMTP id k202mr14042822ywe.198.1552045552909; Fri, 08 Mar 2019 03:45:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552045552; cv=none; d=google.com; s=arc-20160816; b=tynLDsyivivUMNoqLbCNk3gwK2bDSmimp+30DEA/dgTLUO+w1b4FLvda5iXB/LmsiD DDHxQoJLrKAJR2Q/DIby7ihG8P+JMbVCtGtAwW6T1iO+zr1fIhhcIKuE2dzhYmSY/59I CyjLfT8JLfmCwbYFU3tvjWyuFAsD9X3myWcBk3hcTMi+3eha/PCq1YlegrGi7wLbHzg3 z6HARl2rpHCx9iherxeCXT/fzvpmfZcf5JL0uz60YiQcYeHqmRv5159XpNLHh5rSVEvo 0uiaf3A6mCrExQ008Y4B2TyQnb63hR3hppRz6gxuta+3CEvZfayoFiQJADqnN2JxTxZR b4nQ== 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=FYK0N6GXElhUstF5fgcT2GwenM3736rX4wdmEvliaVw=; b=mjb6UTqlY6O2ZEVuXE2ezCQG7w0dNOyZDIbXkIJbgvP2KLr5XsCvwEewuNW/qF4g6v kwBmN9HvizJcHpuN9cPw6/TW52hqm5P5vG6erscZy2Xg+PDGz0Ee+x4L1PBROypTGksZ frhJrD6B4m39lLjwHTNMk3PyGPEfbSugpOw4iCgPjZSbg4CUtKiaP8taZwuSm6hGPTnr 3YpitnmHayzaYdkx4dk8XQX+IQfRHh2rcAInjTiDsjXnoQ8oST0ERPPkyc5E5j/7QRZr naVKunl82B9LHbLsUnvWsVbyGi9H7YRb2mEo9oLGonVlUy7icXqMMVyTBcfWT3mXNNJQ H55w== 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 n205si4397599ywb.42.2019.03.08.03.45.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Mar 2019 03:45:52 -0800 (PST) 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 ([127.0.0.1]:41534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Dwl-0000Yi-CQ for patch@linaro.org; Fri, 08 Mar 2019 06:45:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2DvV-00086G-HE for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2DvR-00054L-Iy for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:32 -0500 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 1h2DvN-0004Hy-6i; Fri, 08 Mar 2019 06:44:25 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0795CE6C5AD45850E88E; Fri, 8 Mar 2019 19:44:18 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.408.0; Fri, 8 Mar 2019 19:44:11 +0800 From: Shameer Kolothum To: , , , , , , , Date: Fri, 8 Mar 2019 11:42:09 +0000 Message-ID: <20190308114218.26692-3-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190308114218.26692-1-shameerali.kolothum.thodi@huawei.com> References: <20190308114218.26692-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 v2 02/11] hw/acpi: Make ACPI IO address space configurable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxarm@huawei.com, xuwei5@hisilicon.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. Signed-off-by: Shameer Kolothum --- hw/acpi/memory_hotplug.c | 22 ++++++++++++++-------- hw/i386/acpi-build.c | 3 ++- include/hw/acpi/memory_hotplug.h | 5 +++-- 3 files changed, 19 insertions(+), 11 deletions(-) -- 2.7.4 Reviewed-by: Eric Auger diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index a6beb10..77ff0af 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -8,7 +8,7 @@ #include "qapi/error.h" #include "qapi/qapi-events-misc.h" -static uint16_t memhp_io_base; +static hwaddr memhp_io_base; static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev) { @@ -182,7 +182,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()); @@ -315,7 +315,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; @@ -338,14 +339,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 622ccb9..d9b554f 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1852,7 +1852,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 fbfcbe6..52f9027 100644 --- a/include/hw/acpi/memory_hotplug.h +++ b/include/hw/acpi/memory_hotplug.h @@ -55,7 +55,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); @@ -74,5 +74,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 Mar 8 11:42:10 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: 159969 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp8609873jad; Fri, 8 Mar 2019 03:47:54 -0800 (PST) X-Google-Smtp-Source: APXvYqxkU35t6RtEvIU8qEPZhH3ImR2yvHynAeGAOAwq7Lig0s8AwuCLI0LBhnlgHCTNfsdhOSOn X-Received: by 2002:a81:3b56:: with SMTP id i83mr14358420ywa.508.1552045674665; Fri, 08 Mar 2019 03:47:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552045674; cv=none; d=google.com; s=arc-20160816; b=qtZcAtc492Ep5MiHd6xi0+WL8v5oIybYcT+YW14fsyCMhC4SYd0iH4rFeHr4+2Kpqq ouzTFngdB/AELCn/vhlBTzY4wqP+PAM3GymYaSFLo6QUrgIGok1ycgtbesQlYTuIhg0H yr22lJlVUVfWKQSfY7M3Ppu+BAZbsoYVRmMeu1Q2ZUjNF4l9mkq1dhoSvU9a1tJQQW2K zX5frYbDPovR+iG16JguhXqyqkSS9FqZWdk8/sUOAlk/pfMitBSzj9JqCWbFfiBjkUST rmKlk3/7gXJ4v/uefBBQlG3BJvSFcBBoTNjNCiq1UX9Ns+nVAhhDk78V6b297kh4r5O1 1rZw== 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=XqdpuubfZOx9kPn17mfDNAqHMU4Y0N6bN887XjNCnD8=; b=izynjuno6hl5j6977o/0KzDBUkTI6HIlOtITXw62G385VWDMmIsbDyaVS/Aq3UTcj9 owMoqKb4HIujJ1lXJHezKwV1BnakgcdylOxhVdxVZA/4RdyhNt2+lHohgpbanP2xFy/T Dvu3hOhM2K0cibKRX/pCCxH6hoYPZAFx3MgDtsjXm48SZGY5TwugH+4e7dXqvpvZ6hJg 3NL5WZw4h8maOdM3R8VKuShhRXFLf4RjYT3G6CLpFixaSjJhmbJycqXARQgDUyI2Ibia vB2RiARCUxUxHzqVGXubW1Z5HIF+TZv27V2qVZcFQTlhonziDwhrSaHUlM7VgYJkaxzH VQLg== 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 i69si4269331yba.88.2019.03.08.03.47.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Mar 2019 03:47:54 -0800 (PST) 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 ([127.0.0.1]:41548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Dyf-0001Jv-6L for patch@linaro.org; Fri, 08 Mar 2019 06:47:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2DvW-000873-HQ for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2DvU-0005KZ-Pc for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:34 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2188 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2DvP-0004eh-Qt; Fri, 08 Mar 2019 06:44:28 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 16FE1672FD91F0642A08; Fri, 8 Mar 2019 19:44:23 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.408.0; Fri, 8 Mar 2019 19:44:14 +0800 From: Shameer Kolothum To: , , , , , , , Date: Fri, 8 Mar 2019 11:42:10 +0000 Message-ID: <20190308114218.26692-4-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190308114218.26692-1-shameerali.kolothum.thodi@huawei.com> References: <20190308114218.26692-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 v2 03/11] hw/acpi: Do not create memory hotplug method when handler is not defined X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxarm@huawei.com, xuwei5@hisilicon.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 --- hw/acpi/memory_hotplug.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 77ff0af..b138bef 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -695,10 +695,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 Mar 8 11:42: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: 159973 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp8613065jad; Fri, 8 Mar 2019 03:51:46 -0800 (PST) X-Google-Smtp-Source: APXvYqyXHqgLtPEV87LfLQQ2KnriprZNTvotG2wG9q1ovpPRD6B4si4DPZ9j7Z+A5r8QLv3ouOWw X-Received: by 2002:a81:7c05:: with SMTP id x5mr1181091ywc.168.1552045906301; Fri, 08 Mar 2019 03:51:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552045906; cv=none; d=google.com; s=arc-20160816; b=CJw0EwVEDfjEpmsgxG3o6fagWtv1SjCVR1XZqQkU4ipVyaTGlYuyP6DcpbW/2/i8n0 E8rQGPGF/+ajWZ/rr+w/d/71U8j1Guq8rjeqm7QfM5mnn6haiV53VK5HMP0MtcCtk1VY i0CK7j4WDYZ59zB5bdH9bVrNGBEzwL7XLGKTRLWAE9Zr787V3A07eTNZd5tHgEvo/pV6 1K4XUN2A2w4NzWl9J9VXPEyE6i2Jv9qXS0UjxyF1FvZ1/DBYsbeaOkTAQG+BKXAYy+SL HmaAi6e2HBulX+0UJhpWmgLgiFdSn/2mrN5Slor7ZNfNm/hRkvnnJ8R4zak/dKFobrSe nKjw== 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=qUFxfLue9kPDLmQXqjTNvy7+EG4wwjc7T8u3YWDLtyg=; b=AFek+Q/o56MxkAr4sdHPoCdriWewG89h/gnKPvMEENEo6cVPUDBAFwvzMZQgHFg+lk yH6o+0MMxwg46R7yj6NX88C/hcgyimV+1m3hsHha8miwEcuiR67kBCLYEMRpE6ZGW9PV pCJ9sJIbrTWpMzu4qXDxNiUKKtjG5uh/FJNgfaa8tATNapDlv0gh52RnrtQBfyXGRecm bWdLJEmsjPaDU/OyDoqqjkq5sK2ew5anFLZ6lVXNQeS2jlqzgsFIU+ZcCdpJs6+X80rk HOSA31AGeO1jxbBTUcu1kqEA7KOdF7synhrelHX2IIeeIC1qNtNM+kikW9RQSlxsMVZ5 38XA== 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 s130si4169800ybb.107.2019.03.08.03.51.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Mar 2019 03:51:46 -0800 (PST) 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 ([127.0.0.1]:41591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2E2Q-0004K3-M5 for patch@linaro.org; Fri, 08 Mar 2019 06:51:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2DvZ-0008Bk-4o for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2DvX-0005Xf-EH for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:37 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:43388 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2DvU-00051I-3q; Fri, 08 Mar 2019 06:44:32 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 281A5CF44E85DC7BA650; Fri, 8 Mar 2019 19:44:28 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.408.0; Fri, 8 Mar 2019 19:44:17 +0800 From: Shameer Kolothum To: , , , , , , , Date: Fri, 8 Mar 2019 11:42:11 +0000 Message-ID: <20190308114218.26692-5-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190308114218.26692-1-shameerali.kolothum.thodi@huawei.com> References: <20190308114218.26692-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 v2 04/11] hw/arm/virt: Add virtual ACPI device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxarm@huawei.com, xuwei5@hisilicon.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Samuel Ortiz This is to provide an acpi device interface for Arm/virt. This will be used by Arm/Virt to add hotplug support via ACPI GED device. Signed-off-by: Samuel Ortiz Signed-off-by: Shameer Kolothum --- hw/arm/Makefile.objs | 2 +- hw/arm/virt-acpi.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/arm/virt.h | 1 + 3 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 hw/arm/virt-acpi.c -- 2.7.4 diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs index fa57c7c..e0db3cd 100644 --- a/hw/arm/Makefile.objs +++ b/hw/arm/Makefile.objs @@ -1,6 +1,6 @@ obj-y += boot.o sysbus-fdt.o obj-$(CONFIG_ARM_VIRT) += virt.o -obj-$(CONFIG_ACPI) += virt-acpi-build.o +obj-$(CONFIG_ACPI) += virt-acpi-build.o virt-acpi.o obj-$(CONFIG_DIGIC) += digic_boards.o obj-$(CONFIG_EXYNOS4) += exynos4_boards.o obj-$(CONFIG_HIGHBANK) += highbank.o diff --git a/hw/arm/virt-acpi.c b/hw/arm/virt-acpi.c new file mode 100644 index 0000000..df8a02b --- /dev/null +++ b/hw/arm/virt-acpi.c @@ -0,0 +1,111 @@ +/* + * + * Copyright (c) 2018 Intel Corporation + * + * 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. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include "qemu/osdep.h" +#include "qemu/range.h" +#include "qapi/error.h" +#include "exec/address-spaces.h" + +#include "hw/hw.h" +#include "hw/hotplug.h" +#include "hw/sysbus.h" +#include "hw/arm/virt.h" + +#include "hw/acpi/acpi.h" + +typedef struct VirtAcpiState { + SysBusDevice parent_obj; +} VirtAcpiState; + +#define TYPE_VIRT_ACPI "virt-acpi" +#define VIRT_ACPI(obj) \ + OBJECT_CHECK(VirtAcpiState, (obj), TYPE_VIRT_ACPI) + +static const VMStateDescription vmstate_acpi = { + .name = "virt_acpi", + .version_id = 1, + .minimum_version_id = 1, +}; + +static void virt_device_plug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ +} + +static void virt_device_unplug_request_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ +} + +static void virt_device_unplug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ +} + +static void virt_send_ged(AcpiDeviceIf *adev, AcpiEventStatusBits ev) +{ +} + +static void virt_device_realize(DeviceState *dev, Error **errp) +{ +} + +DeviceState *virt_acpi_init(void) +{ + return sysbus_create_simple(TYPE_VIRT_ACPI, -1, NULL); +} + +static Property virt_acpi_properties[] = { + DEFINE_PROP_END_OF_LIST(), +}; + +static void virt_acpi_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"; + dc->vmsd = &vmstate_acpi; + dc->props = virt_acpi_properties; + dc->realize = virt_device_realize; + + hc->plug = virt_device_plug_cb; + hc->unplug_request = virt_device_unplug_request_cb; + hc->unplug = virt_device_unplug_cb; + + adevc->send_event = virt_send_ged; +} + +static const TypeInfo virt_acpi_info = { + .name = TYPE_VIRT_ACPI, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(VirtAcpiState), + .class_init = virt_acpi_class_init, + .interfaces = (InterfaceInfo[]) { + { TYPE_HOTPLUG_HANDLER }, + { TYPE_ACPI_DEVICE_IF }, + { } + } +}; + +static void virt_acpi_register_types(void) +{ + type_register_static(&virt_acpi_info); +} + +type_init(virt_acpi_register_types) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 507517c..6076167 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -145,6 +145,7 @@ typedef struct { OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE) void virt_acpi_setup(VirtMachineState *vms); +DeviceState *virt_acpi_init(void); /* Return the number of used redistributor regions */ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms) From patchwork Fri Mar 8 11:42: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: 159970 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp8609928jad; Fri, 8 Mar 2019 03:47:58 -0800 (PST) X-Google-Smtp-Source: APXvYqzAj7WK9o5snfWEebcXTTaInpEGc6Q5mJNa2+umFC0SLEDZ0xIeuCOu0B5OclYC7brTJHf4 X-Received: by 2002:a25:3507:: with SMTP id c7mr15736993yba.390.1552045678375; Fri, 08 Mar 2019 03:47:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552045678; cv=none; d=google.com; s=arc-20160816; b=pr7k38jXHthLxyK+yUGMTRhkyL8wjb5AWILk6GgS0APb0wG3hGDJcyDGqhjf8t1JDu NkuR7LON/bO4FTPLJETwepraW38lJ/ONc/f86zLUNk6OkNqJt07LR9ZC4ClAwMzzCxGL 0URJ/pRp0z/pNwhWNbEvJGxtwXAM3+FTGRfaJQAnmuBFDXIf4VzZqQq/tAyKFx/rlarD AiunH8zK8N/0obXHmSDkseEmrwo/CbSRxvHZhU0fny+BJRF5P8H/9C7XdsdmbOxVAgSd pDzzxhgw4e+Huz4IuZ38EyjwgfKKKYLXf1FuPK8jZa2ZdloetJ0skkNr1RsSNOqzIgHb sGBQ== 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=AW/XNXd8L+l+qdYaJ3YotPaB8UTWXSAh2/HKPQGK5jA=; b=sSqS6uWoogN/+SzWV3SAjolGTBejxgHwM/MtVOzpFsqoGrLlir14o5N4RwC7PU95ZM hMzcYccqAuCWbc8mzrAqPJ7xLbO3bF3Tzr908WWKxPk13xXMwsTEcfKJCxNK2u14w3Ov NJh64T1Ox3nIwfeIF5T8qnOiZwv8JccC6kC+zgEyDC8YjGZkc2Tx5xZb7um6yjCSluNo 3oFkrz57M0FvXY7jzrG+gQ7p/8heDKMl44GFlNciyN77l2f8X4QdJTNy6Ax765XJeRsb 6x5Pde0Y8lNFhMRDGqdRH1FRNr7qX1C2ogOS8CnEu0x24VKf9kpWsWgVgYldq28ZfLHa xIxg== 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 j195si4486764ybj.369.2019.03.08.03.47.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Mar 2019 03:47:58 -0800 (PST) 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 ([127.0.0.1]:41550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Dym-0001L3-Rk for patch@linaro.org; Fri, 08 Mar 2019 06:47:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Dvc-0008FT-PB for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2Dva-0005sE-RG for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:40 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:43392 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2DvU-00051M-Bf; Fri, 08 Mar 2019 06:44:32 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 2E250EBD6B6C4DB095A4; Fri, 8 Mar 2019 19:44:28 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.408.0; Fri, 8 Mar 2019 19:44:20 +0800 From: Shameer Kolothum To: , , , , , , , Date: Fri, 8 Mar 2019 11:42:12 +0000 Message-ID: <20190308114218.26692-6-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190308114218.26692-1-shameerali.kolothum.thodi@huawei.com> References: <20190308114218.26692-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 v2 05/11] hw/arm/virt: Add memory hotplug framework X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxarm@huawei.com, xuwei5@hisilicon.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Eric Auger This patch adds the the memory hot-plug/hot-unplug infrastructure in machvirt. It is still not enabled as no device memory is allocated. Signed-off-by: Eric Auger Signed-off-by: Kwangwoo Lee Signed-off-by: Shameer Kolothum --- default-configs/arm-softmmu.mak | 2 ++ hw/arm/virt.c | 53 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak index bd6943b..fbc4564 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -165,3 +165,5 @@ CONFIG_PCI_EXPRESS_DESIGNWARE=y CONFIG_STRONGARM=y CONFIG_HIGHBANK=y CONFIG_MUSICPAL=y +CONFIG_MEM_DEVICE=y +CONFIG_DIMM=y diff --git a/hw/arm/virt.c b/hw/arm/virt.c index c7fb534..40a1273 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -61,6 +61,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, \ @@ -1810,6 +1812,42 @@ 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) +{ + const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); + + if (dev->hotplugged) { + error_setg(errp, "memory hotplug is not supported"); + } + + if (is_nvdimm) { + error_setg(errp, "nvdimm 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); + Error *local_err = NULL; + + pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err); + + error_propagate(errp, local_err); +} + +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) { @@ -1821,12 +1859,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); } @@ -1890,7 +1939,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 Fri Mar 8 11:42: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: 159974 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp8615231jad; Fri, 8 Mar 2019 03:54:21 -0800 (PST) X-Google-Smtp-Source: APXvYqxp+okz48dE9r3fT9twpG4/4ZDzLoto2QSGR360IbQjzF3oWeK6uiBbLXp+DUU+B2yUmixX X-Received: by 2002:a25:dd2:: with SMTP id 201mr16027268ybn.31.1552046061039; Fri, 08 Mar 2019 03:54:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552046061; cv=none; d=google.com; s=arc-20160816; b=pWakWjlwisWt6LWedJCKmLAkGxLwFVJ9+UTP6kB3V2mKBfL3/wVv8a3nbzZsyoc7mL wlZ/YUZUAXNgqW/i/HvN4Y8wd+eEQokdRpZZ6LKPLmNXcbx6IW7Jva6NRddHnuE9bgvr 8sMiRUaahnyHnZSX4qr+Xd/bgNsTtxisgHYLjSDNO2rSqDVp0fY3Yq3tA3d9AbNwo5Iu LDYpj/xv1oLgoAYFQjIY4KcnJSIL8OiVz1dWhjKAwtNdbc3Wxc/u9bxC2ni9YqIMOO8i 7rbu2zSNs1XRKsj/0ZxD2aBlT2ChoaFJeZokAg9PksAwn7HoPozYknE8W/5Onu5Wb88z n4WQ== 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=DXrWh5PMUqSTXTZKraLbC3wLy1APb2RLXFBR2sOIuW4=; b=gtmArl800SdHM/4KLnVJmrnImUls0urSksA8KbWK7INgI3Y9g0kR5F6BqBOth2PguU jkdHSCaU88vb56TA1pR3VRTbWSdxX7yj3iBByetG1A7r3u5Lwj9xddwLFDEZPM7GiCDp 2QeKcNT4PGCaKwv9E8LrJkcToI01+uyWANLWKV+im5orv5oX271SxkxxjGTcNI+xp1gY U6u5qvEyGohGw6pk1oI84Zur2LdQeDN0chObWSOvevUCMOjjXwf14aADTUuY3gnM5m9b pOpyyWhqjLxQVXPhy8viCMnIfmMNS+GEPi6dBl0Tw/djjZWnFJy7m3WuzPbv5Ra5JyqY sQPw== 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 c206si4282791ybb.484.2019.03.08.03.54.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Mar 2019 03:54:21 -0800 (PST) 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 ([127.0.0.1]:41656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2E4v-0006Qv-FF for patch@linaro.org; Fri, 08 Mar 2019 06:54:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40543) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Dvj-0008Ij-Jg for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2Dvc-00061E-D1 for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:44 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:43510 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2DvX-0005Qp-Ib; Fri, 08 Mar 2019 06:44:35 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 3C91F3B6384287646624; Fri, 8 Mar 2019 19:44:33 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.408.0; Fri, 8 Mar 2019 19:44:23 +0800 From: Shameer Kolothum To: , , , , , , , Date: Fri, 8 Mar 2019 11:42:13 +0000 Message-ID: <20190308114218.26692-7-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190308114218.26692-1-shameerali.kolothum.thodi@huawei.com> References: <20190308114218.26692-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 v2 06/11] hw/arm/virt: Add ACPI support for device memory cold-plug X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxarm@huawei.com, xuwei5@hisilicon.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This adds support to build the aml code so that Guest can see the cold-plugged device memory. Signed-off-by: Shameer Kolothum --- default-configs/arm-softmmu.mak | 1 + hw/arm/virt-acpi-build.c | 9 +++++++++ hw/arm/virt-acpi.c | 23 +++++++++++++++++++++++ hw/arm/virt.c | 11 +++++++++++ include/hw/arm/virt.h | 2 ++ 5 files changed, 46 insertions(+) -- 2.7.4 diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak index fbc4564..b3bac25 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -167,3 +167,4 @@ CONFIG_HIGHBANK=y CONFIG_MUSICPAL=y CONFIG_MEM_DEVICE=y CONFIG_DIMM=y +CONFIG_ACPI_MEMORY_HOTPLUG=y diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index d7e2e48..87d66da 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -40,6 +40,7 @@ #include "hw/loader.h" #include "hw/hw.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/memory_hotplug.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/arm/virt.h" @@ -49,6 +50,13 @@ #define ARM_SPI_BASE 32 #define ACPI_POWER_BUTTON_DEVICE "PWRB" +static void acpi_dsdt_add_memory_hotplug(Aml *scope, MachineState *ms) +{ + uint32_t nr_mem = ms->ram_slots; + + build_memory_hotplug_aml(scope, nr_mem, "\\_SB", NULL, AML_SYSTEM_MEMORY); +} + static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) { uint16_t i; @@ -740,6 +748,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) * the RTC ACPI device at all when using UEFI. */ scope = aml_scope("\\_SB"); + acpi_dsdt_add_memory_hotplug(scope, MACHINE(vms)); acpi_dsdt_add_cpus(scope, vms->smp_cpus); acpi_dsdt_add_uart(scope, &memmap[VIRT_UART], (irqmap[VIRT_UART] + ARM_SPI_BASE)); diff --git a/hw/arm/virt-acpi.c b/hw/arm/virt-acpi.c index df8a02b..18ebe94 100644 --- a/hw/arm/virt-acpi.c +++ b/hw/arm/virt-acpi.c @@ -26,9 +26,11 @@ #include "hw/arm/virt.h" #include "hw/acpi/acpi.h" +#include "hw/acpi/memory_hotplug.h" typedef struct VirtAcpiState { SysBusDevice parent_obj; + MemHotplugState memhp_state; } VirtAcpiState; #define TYPE_VIRT_ACPI "virt-acpi" @@ -44,6 +46,16 @@ static const VMStateDescription vmstate_acpi = { static void virt_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { + VirtAcpiState *s = VIRT_ACPI(hotplug_dev); + + if (s->memhp_state.is_enabled && + object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, + dev, errp); + } else { + error_setg(errp, "virt: device plug request for unsupported device" + " type: %s", object_get_typename(OBJECT(dev))); + } } static void virt_device_unplug_request_cb(HotplugHandler *hotplug_dev, @@ -62,6 +74,15 @@ static void virt_send_ged(AcpiDeviceIf *adev, AcpiEventStatusBits ev) static void virt_device_realize(DeviceState *dev, Error **errp) { + VirtMachineState *vms = VIRT_MACHINE(qdev_get_machine()); + const MemMapEntry *memmap = vms->memmap; + VirtAcpiState *s = VIRT_ACPI(dev); + + if (s->memhp_state.is_enabled) { + acpi_memory_hotplug_init(get_system_memory(), OBJECT(dev), + &s->memhp_state, + memmap[VIRT_PCDIMM_ACPI].base); + } } DeviceState *virt_acpi_init(void) @@ -70,6 +91,8 @@ DeviceState *virt_acpi_init(void) } static Property virt_acpi_properties[] = { + DEFINE_PROP_BOOL("memory-hotplug-support", VirtAcpiState, + memhp_state.is_enabled, true), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 40a1273..9427f4f 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -133,6 +133,7 @@ static const MemMapEntry base_memmap[] = { [VIRT_GPIO] = { 0x09030000, 0x00001000 }, [VIRT_SECURE_UART] = { 0x09040000, 0x00001000 }, [VIRT_SMMU] = { 0x09050000, 0x00020000 }, + [VIRT_PCDIMM_ACPI] = { 0x09070000, 0x00010000 }, [VIRT_MMIO] = { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 }, @@ -1648,6 +1649,8 @@ static void machvirt_init(MachineState *machine) create_platform_bus(vms, pic); + vms->acpi = virt_acpi_init(); + vms->bootinfo.ram_size = machine->ram_size; vms->bootinfo.kernel_filename = machine->kernel_filename; vms->bootinfo.kernel_cmdline = machine->kernel_cmdline; @@ -1832,11 +1835,19 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, static void virt_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { + HotplugHandlerClass *hhc; VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); Error *local_err = NULL; pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err); + if (local_err) { + goto out; + } + + hhc = HOTPLUG_HANDLER_GET_CLASS(vms->acpi); + hhc->plug(HOTPLUG_HANDLER(vms->acpi), dev, &error_abort); +out: error_propagate(errp, local_err); } diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 6076167..e46a051 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -77,6 +77,7 @@ enum { VIRT_GPIO, VIRT_SECURE_UART, VIRT_SECURE_MEM, + VIRT_PCDIMM_ACPI, VIRT_LOWMEMMAP_LAST, }; @@ -132,6 +133,7 @@ typedef struct { uint32_t iommu_phandle; int psci_conduit; hwaddr highest_gpa; + DeviceState *acpi; } VirtMachineState; #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) From patchwork Fri Mar 8 11:42: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: 159972 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp8612840jad; Fri, 8 Mar 2019 03:51:29 -0800 (PST) X-Google-Smtp-Source: APXvYqxyZkXjdpzGaqE8ADsBxmpPQi31byfk6Dft9Pv0oIlmCr17feUEHxU2z6IqjX+aTgAMnIEY X-Received: by 2002:a81:7446:: with SMTP id p67mr14048288ywc.233.1552045889929; Fri, 08 Mar 2019 03:51:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552045889; cv=none; d=google.com; s=arc-20160816; b=xqU4Zl/ewfhJL2wu9RcQDVQU1hm0cxvBKUV5k87kx3a0UD6KxYpNl14tktBVoku6C3 tRwijAn3NyaumnCpi+K6QgmEXCcD27zYx5w2v97hFiq+dlJzaDDI35CSyAsn1NDBZu5I JCWsHVMmlWpGEkoh4dVa4AJAP8kF4e8nfbfV93PqNKxRrHdQJJTSZvCkwbWfWPLatEyh lwOqCqaLYA4Q+5g3pvtLQMrHGZORpkFbcvOm29u1Q0oeTg3sE7qhgA2F7K/y8s+0dRZw iaZxVZ+7+Ng6yOSB3oJAK7WC4u8wFXnx61oZ1oGbS6GRmbeLIJzJmUZGTvGDnq6yaOpO AirQ== 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=aCck2UPev7bgF/laZsoHvm9hwObwhxYpSbzZFmnDg0g=; b=PN2D/fxFmnuwRCEslAWK0yKJzFXbg4JLohZozdBZoB3UKZLiTDtkQOJpqKxa2NGFWC d0dgSbzmPY4BicBLZALLGIwRo/Zok01aXdJ2KCI58oQaV1NMKPKvZ3+/ak/pOkVV+YcI iPw7FNM2Do52WyorXoWJmYSSgB+qhaVs+B6BAPM1373qmoiWv0OEQOShrmiOGbgIWc4D nYAP8T4px2Ne8mFmOXEIpG5kpgcbK41UIlV8bjFXldnE+8amtnO//RgPvFjleFRUxMdp 7Fpti9uYCDtVMEgcOBWMdQG8FwdvTAgIAlmPzDSjP0+UuDeQIkMgQ7vAD8Uonp79LlAs YqTA== 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 l16si4251400ybm.34.2019.03.08.03.51.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Mar 2019 03:51:29 -0800 (PST) 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 ([127.0.0.1]:41582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2E2A-00046m-GC for patch@linaro.org; Fri, 08 Mar 2019 06:51:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Dvh-0008Id-Fy for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2Dvf-0006ID-LK for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:44 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:43516 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2Dvb-0005Qq-KM; Fri, 08 Mar 2019 06:44:39 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 4272DF07CC17982C5FAE; Fri, 8 Mar 2019 19:44:33 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.408.0; Fri, 8 Mar 2019 19:44:26 +0800 From: Shameer Kolothum To: , , , , , , , Date: Fri, 8 Mar 2019 11:42:14 +0000 Message-ID: <20190308114218.26692-8-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190308114218.26692-1-shameerali.kolothum.thodi@huawei.com> References: <20190308114218.26692-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 v2 07/11] hw/arm/virt-acpi-build: Add PC-DIMM in SRAT X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxarm@huawei.com, xuwei5@hisilicon.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.7.4 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 87d66da..6cb7263 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -524,6 +524,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; @@ -549,6 +550,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 Mar 8 11:42: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: 159976 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp8617415jad; Fri, 8 Mar 2019 03:56:56 -0800 (PST) X-Google-Smtp-Source: APXvYqwscwW4O7EQVfign3aVlH+PYQSx+xcgyxXGDyUextbwMBMF90qloW8oAkAw5OlnrHu2fBMi X-Received: by 2002:a25:e601:: with SMTP id d1mr15535802ybh.415.1552046216767; Fri, 08 Mar 2019 03:56:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552046216; cv=none; d=google.com; s=arc-20160816; b=iF6MnmmS6htLe36bf7WaVQ8N1Ju77UcWyG25NjyZVoBla5iZPeIXZoP+MKgGPU/E6L tHHjOj8vD/W6gywOQA2jG0S50cXzZH+beMrbzKOn9gQIhiqV3lMjnOAXKk5ouSQshuNN KKXHQJLzoIBTmdB6h9znZmtWbym0oZl0Q/O5mm0kmnFVlU1dgr+OorhCHeLPZDKBEXB9 U/Q5/abZBXWfm3ojb1rwQEc42+vyK87YmscHZLslXY1UcKmgD9STxpLPIGdA8Ij4gdRh 6p2lfcSKZ7+EzDqNPY8IkijiEorZDKUsvwPvyGjLBLlubykj7+L0B7yoXUPXh/5ZeHqQ uuAQ== 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=0g5Jc0+LPt2qXzCI4n3PV6Fo26B0T6c2hXYYSPtswjE=; b=A9LmutQ2tD+wktB/Xl44w8Mw8O6AOCtpNQcsPPYmaPqNd1nIlnjVIuj4NaT08Odu6/ Gps9HmZFK1IFEqk4RyBDJz0HNS+8nvhFbPnzxsTw1+D9nrNWyq8BjU9wDmsk/9YbxA+l eNoQCSA4xZcT8Yj+CAZPKZYGwd+AyMcLJE9/67ievD6OKJGpmsM/JWw2bR1C3Hiwuts8 0jIshOVSXOoF3Sjt3fSlnlcOXwbQQ3589grBZ3As6yDqghMGLbkIJeP6LY0w5vYCYeZp hd+K2KuI6O54jnQj7h1siURYNkh3KwqmAedOMUHPazSPUf6Tt0ByGWAMd+SshujwJpf7 snPw== 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 p123si4410887ywp.110.2019.03.08.03.56.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Mar 2019 03:56:56 -0800 (PST) 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 ([127.0.0.1]:41733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2E7S-0000p2-DN for patch@linaro.org; Fri, 08 Mar 2019 06:56:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Dvn-0008Op-JQ for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2Dvl-0006pR-T0 for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:51 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:59546 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2Dvg-0005td-SZ; Fri, 08 Mar 2019 06:44:45 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 4E59FE940061C88A2065; Fri, 8 Mar 2019 19:44:38 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.408.0; Fri, 8 Mar 2019 19:44:30 +0800 From: Shameer Kolothum To: , , , , , , , Date: Fri, 8 Mar 2019 11:42:15 +0000 Message-ID: <20190308114218.26692-9-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190308114218.26692-1-shameerali.kolothum.thodi@huawei.com> References: <20190308114218.26692-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 v2 08/11] hw/arm/boot: Expose the PC-DIMM nodes in the DT X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxarm@huawei.com, xuwei5@hisilicon.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This patch adds memory nodes corresponding to PC-DIMM regions. NVDIMM and ACPI_NVDIMM configs are not yet set for ARM so we don't need to care about NVDIMM at this stage. Signed-off-by: Shameer Kolothum Signed-off-by: Eric Auger --- hw/arm/boot.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) -- 2.7.4 diff --git a/hw/arm/boot.c b/hw/arm/boot.c index a830655..4caaf91 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -19,6 +19,7 @@ #include "sysemu/numa.h" #include "hw/boards.h" #include "hw/loader.h" +#include "hw/mem/memory-device.h" #include "elf.h" #include "sysemu/device_tree.h" #include "qemu/config-file.h" @@ -522,6 +523,41 @@ static void fdt_add_psci_node(void *fdt) qemu_fdt_setprop_cell(fdt, "/psci", "migrate", migrate_fn); } +static int fdt_add_hotpluggable_memory_nodes(void *fdt, + uint32_t acells, uint32_t scells) { + MemoryDeviceInfoList *info, *info_list = qmp_memory_device_list(); + MemoryDeviceInfo *mi; + int ret = 0; + + for (info = info_list; info != NULL; info = info->next) { + mi = info->value; + switch (mi->type) { + case MEMORY_DEVICE_INFO_KIND_DIMM: + { + PCDIMMDeviceInfo *di = mi->u.dimm.data; + + ret = fdt_add_memory_node(fdt, acells, di->addr, + scells, di->size, di->node); + if (ret) { + fprintf(stderr, + "couldn't add PCDIMM /memory@%"PRIx64" node\n", + di->addr); + goto out; + } + break; + } + default: + fprintf(stderr, "%s memory nodes are not yet supported\n", + MemoryDeviceInfoKind_str(mi->type)); + ret = -ENOENT; + goto out; + } + } +out: + qapi_free_MemoryDeviceInfoList(info_list); + return ret; +} + int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, hwaddr addr_limit, AddressSpace *as) { @@ -621,6 +657,12 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, } } + rc = fdt_add_hotpluggable_memory_nodes(fdt, acells, scells); + if (rc < 0) { + fprintf(stderr, "couldn't add hotpluggable memory nodes\n"); + goto fail; + } + rc = fdt_path_offset(fdt, "/chosen"); if (rc < 0) { qemu_fdt_add_subnode(fdt, "/chosen"); From patchwork Fri Mar 8 11:42: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: 159978 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp8618776jad; Fri, 8 Mar 2019 03:58:33 -0800 (PST) X-Google-Smtp-Source: APXvYqyWBCJ/0msKkaOIGaNVxcOEmo6wO6Mvh42tQyewlmvMtRj9brxX6uC5GhRuQcUJv9pfI1J7 X-Received: by 2002:a0d:c342:: with SMTP id f63mr1328080ywd.427.1552046313611; Fri, 08 Mar 2019 03:58:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552046313; cv=none; d=google.com; s=arc-20160816; b=dqmvVNkA1iAqLitpntqdDlIbXDfinCrYaQs/oyvPuqgvKxRP2c+yodVYyOxe/fnd7v lzjh/WX4vKlZQdlbOp0tajsKr447guBCmBw4lGkYWzH7oOnVRPcSWjvmQBMjVaYZ0Slb G/5FCREnHEvVE7SyGKHtHwhSjHSdqQmUEuv6LqRJOmEI0K2nSMAnNfgXt/Dnu+EWbitg ULuG87YegV5qVsz4F88kw9h5L/IcuWyEhchLMPLNz0aciS1LYbei1r4GfmbO7KoN64df Wb8is3s9ehtdVdzLbsNy6pG5SRmCRDQeglbTqgKjZRsPrEtHZfhW9NqDayPHtPOU82ka ozDg== 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=0NNwfoZyS1SbAu+cQcmgHzKuXlyIqBvp5WKa7Oal7es=; b=CUFIKE+MPf+0PKaXSW5VPQDzbaRjAu/fDtWGNAaKkaSDOfBitHIoorVGQmifsgHlDF f8ifG24EGJW3OpuizeAnL7sshBFllWD4YnEH23gMpZCE7XagMouSju3V4TooiPmgnXrh fryCGsd/UfvUyEwSTVtorGdGR7Zp80v5Yl7wqRxxE+OB7MpNvS1+fZC7Co7Jer5dl9Z+ 9QRLo0KCtKkoScQZz48vzpzhAaQabUNsKYk/GpiGfqw8ptRkcmHV1v4IGEc+C5UYN09a fuM2lpPTWASRbXu1DNq0VOv1b36t67p+MQb4XydkfQaRpaLtIwxD6T1qAnHBDvEa4BOn lJ9Q== 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 192si4377931ybm.103.2019.03.08.03.58.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Mar 2019 03:58:33 -0800 (PST) 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 ([127.0.0.1]:41837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2E90-00023R-QX for patch@linaro.org; Fri, 08 Mar 2019 06:58:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Dvx-00007V-2U for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:45:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2Dvt-0007RQ-9a for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:59 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:43874 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2Dvl-0006Lx-Ui; Fri, 08 Mar 2019 06:44:50 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 5FF69E29E76A163E24C8; Fri, 8 Mar 2019 19:44:43 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.408.0; Fri, 8 Mar 2019 19:44:33 +0800 From: Shameer Kolothum To: , , , , , , , Date: Fri, 8 Mar 2019 11:42:16 +0000 Message-ID: <20190308114218.26692-10-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190308114218.26692-1-shameerali.kolothum.thodi@huawei.com> References: <20190308114218.26692-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 v2 09/11] hw/acpi: Add ACPI Generic Event Device Support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxarm@huawei.com, xuwei5@hisilicon.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 that handles all platform events, including the hotplug ones. This patch generate the AML code that defines GEDs. Platforms need to specify their own GedEvent array to describe what kind of events they want to support through GED. The build_ged_aml routine takes a GedEvent array that maps a specific GED event to an IRQ number. Then we use that array to build both the _CRS and the _EVT section of the GED device. This is in preparation for making use of GED for ARM/virt platform and for now supports only memory hotplug. Signed-off-by: Samuel Ortiz Signed-off-by: Sebastien Boeuf Signed-off-by: Shameer Kolothum --- hw/acpi/Makefile.objs | 1 + hw/acpi/ged.c | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/acpi/ged.h | 61 ++++++++++++++++ 3 files changed, 260 insertions(+) create mode 100644 hw/acpi/ged.c create mode 100644 include/hw/acpi/ged.h -- 2.7.4 diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs index 2d46e37..6cf572b 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) += ged.o common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o common-obj-y += acpi_interface.o diff --git a/hw/acpi/ged.c b/hw/acpi/ged.c new file mode 100644 index 0000000..5076fbc --- /dev/null +++ b/hw/acpi/ged.c @@ -0,0 +1,198 @@ +/* + * + * Copyright (c) 2018 Intel Corporation + * + * 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. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include "hw/acpi/ged.h" + +static hwaddr ged_io_base; + +static uint64_t ged_read(void *opaque, hwaddr addr, unsigned size) +{ + uint64_t val = 0; + GEDState *ged_st = opaque; + + switch (addr) { + case ACPI_GED_IRQ_SEL_OFFSET: + /* Read the selector value and reset it */ + qemu_mutex_lock(&ged_st->lock); + val = ged_st->sel; + ged_st->sel = ACPI_GED_IRQ_SEL_INIT; + 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, + }, +}; + +void acpi_ged_init(MemoryRegion *as, Object *owner, GEDState *ged_st, + hwaddr base_addr, uint32_t ged_irq) +{ + + assert(!ged_io_base); + + ged_io_base = base_addr; + ged_st->irq = ged_irq; + qemu_mutex_init(&ged_st->lock); + memory_region_init_io(&ged_st->io, owner, &ged_ops, ged_st, + "acpi-ged-event", ACPI_GED_REG_LEN); + memory_region_add_subregion(as, base_addr, &ged_st->io); +} + +void acpi_ged_event(GEDState *ged_st, qemu_irq *irq, uint32_t ged_irq_sel) +{ + /* + * 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 |= ged_irq_sel; + qemu_mutex_unlock(&ged_st->lock); + + /* Trigger the event by sending an interrupt to the guest. */ + qemu_irq_pulse(irq[ged_st->irq]); +} + +static Aml *ged_event_aml(GedEvent *event) +{ + + if (!event) { + return NULL; + } + + switch (event->event) { + case GED_MEMORY_HOTPLUG: + /* We run a complete memory SCAN when getting a memory hotplug event */ + return aml_call0("\\_SB.MHPC." MEMORY_SLOT_SCAN_METHOD); + default: + break; + } + + return NULL; +} + +void build_ged_aml(Aml *table, const char *name, uint32_t ged_irq, + GedEvent *events, uint32_t events_size, + AmlRegionSpace rs) +{ + Aml *crs = aml_resource_template(); + Aml *evt, *field; + Aml *zero = aml_int(0); + Aml *dev = aml_device("%s", name); + Aml *irq_sel = aml_local(0); + Aml *isel = aml_name(AML_GED_IRQ_SEL); + uint32_t i; + + if (!ged_io_base) { + return; + } + + /* _CRS interrupt */ + aml_append(crs, aml_interrupt(AML_CONSUMER, AML_EDGE, AML_ACTIVE_HIGH, + AML_EXCLUSIVE, &ged_irq, 1)); + /* + * For each GED event we: + * - Add an interrupt to the CRS section. + * - Add a conditional block for each event, inside a while loop. + * This is semantically equivalent to a switch/case implementation. + */ + evt = aml_method("_EVT", 1, AML_SERIALIZED); + { + Aml *ged_aml; + Aml *if_ctx; + + /* Local0 = ISEL */ + aml_append(evt, aml_store(isel, irq_sel)); + + /* + * Here we want to call a method for each supported GED event type. + * The resulting ASL code looks like: + * + * Local0 = ISEL + * If ((Local0 & irq0) == irq0) + * { + * MethodEvent0() + * } + * + * If ((Local0 & irq1) == irq1) + * { + * MethodEvent1() + * } + * + * If ((Local0 & irq2) == irq2) + * { + * MethodEvent2() + * } + */ + + for (i = 0; i < events_size; i++) { + ged_aml = ged_event_aml(&events[i]); + if (!ged_aml) { + continue; + } + + /* If ((Local1 == irq))*/ + if_ctx = aml_if(aml_equal(aml_and(irq_sel, aml_int(events[i].selector), NULL), aml_int(events[i].selector))); + { + /* AML for this specific type of event */ + aml_append(if_ctx, ged_aml); + } + + /* + * We append the first if to the while context. + * Other ifs will be elseifs. + */ + aml_append(evt, if_ctx); + } + } + + aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0013"))); + aml_append(dev, aml_name_decl("_UID", zero)); + aml_append(dev, aml_name_decl("_CRS", crs)); + + /* Append IO region */ + aml_append(dev, aml_operation_region(AML_GED_IRQ_REG, rs, + aml_int(ged_io_base + ACPI_GED_IRQ_SEL_OFFSET), + ACPI_GED_IRQ_SEL_LEN)); + field = aml_field(AML_GED_IRQ_REG, AML_DWORD_ACC, AML_NOLOCK, + AML_WRITE_AS_ZEROS); + aml_append(field, aml_named_field(AML_GED_IRQ_SEL, + ACPI_GED_IRQ_SEL_LEN * 8)); + aml_append(dev, field); + + /* Append _EVT method */ + aml_append(dev, evt); + + aml_append(table, dev); +} diff --git a/include/hw/acpi/ged.h b/include/hw/acpi/ged.h new file mode 100644 index 0000000..60689b0 --- /dev/null +++ b/include/hw/acpi/ged.h @@ -0,0 +1,61 @@ +/* + * + * Copyright (c) 2018 Intel Corporation + * + * 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. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#ifndef HW_ACPI_GED_H +#define HW_ACPI_GED_H + +#include "qemu/osdep.h" +#include "exec/memory.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/memory_hotplug.h" + +#define ACPI_GED_IRQ_SEL_OFFSET 0x0 +#define ACPI_GED_IRQ_SEL_LEN 0x4 +#define ACPI_GED_IRQ_SEL_INIT 0x0 +#define ACPI_GED_IRQ_SEL_MEM 0x1 +#define ACPI_GED_REG_LEN 0x4 + +#define GED_DEVICE "GED" +#define AML_GED_IRQ_REG "IREG" +#define AML_GED_IRQ_SEL "ISEL" + +typedef struct Aml Aml; + +typedef enum { + GED_MEMORY_HOTPLUG = 1, +} GedEventType; + +typedef struct GedEvent { + uint32_t selector; + GedEventType event; +} GedEvent; + +typedef struct GEDState { + MemoryRegion io; + uint32_t sel; + uint32_t irq; + QemuMutex lock; +} GEDState; + +void acpi_ged_init(MemoryRegion *as, Object *owner, GEDState *ged_st, + hwaddr base_addr, uint32_t ged_irq); +void acpi_ged_event(GEDState *ged_st, qemu_irq *irq, uint32_t ged_irq_sel); +void build_ged_aml(Aml *table, const char* name, uint32_t ged_irq, + GedEvent *events, uint32_t events_size, + AmlRegionSpace rs); + +#endif From patchwork Fri Mar 8 11:42: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: 159977 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp8618550jad; Fri, 8 Mar 2019 03:58:17 -0800 (PST) X-Google-Smtp-Source: APXvYqz/jg6nImKM7l4rEaaUWQMr8ysBsk83Us+67u0iA9k2L8wkdPkuztrI1ueFXO/fbnI4ee+S X-Received: by 2002:a81:446:: with SMTP id 67mr13475469ywe.310.1552046297151; Fri, 08 Mar 2019 03:58:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552046297; cv=none; d=google.com; s=arc-20160816; b=mbJTTCn5RZXWVZw7JCo/Kk3BI782PIpTeCvNvorzgY91LAUErluLzIudDdCi0J4mFG +Zx7HYVgVnVNnzZraauEXux0hVE1xa6K/HeX/i8RhTWrrkHQPpJUdiPf8M4tRcl6UoT9 J7qFLIfG9xDuPLW2VL1k7TNyJtHr/KniOuBPOzemK8U/l1y4z83Lo38YuX3eJVXDnS8r HSEknNg0tRr+KdAloATXR28xG+L82DlDZ9MzlYIIzdRjWIGduT1XMl2Kd6GF7hIjLQG+ lo6QNRcEbxzN3zESDxyl9NHBtzOo5WugAiUQ3r90rA4sBtKd9XM0yGcUPBaGt0n7PrIk fpKg== 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=hv+iqiyS3uoxqJAmcplN19skS6J2mMqMen+o0Dp4TJU=; b=ngPenKYK3ux0zhoW38InQ14C3V3L9C7I9o+TO/WycEuAy4OzzYHFKOMs3zljdMDf5F 9h69xey89k4zUO+W7Hq8IQxE0f8pip0gQKruLG6QGEqecHYMg/NYoVbX05hdT1To+GJT NN3boxJtbYnFX9ONd9J0KSfbPqAbHGQrRDQS/0V8E8HNTHCfCJlz6eRUul02QyJncYme iyQsRZJvLcs1FwTueybdZJVD3IjxqGT3KRtew8WG2WCmVn4nWE/RustvovsKr4pHBhpN tjvinN+yGCEvvSeTrH3jtI46g/t7pADbIZypGs71zkjnD6ShN2lB4VkkfQTxrHhuHT9v Stuw== 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 e2si151816ywe.125.2019.03.08.03.58.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Mar 2019 03:58:17 -0800 (PST) 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 ([127.0.0.1]:41825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2E8j-0001g2-Pp for patch@linaro.org; Fri, 08 Mar 2019 06:58:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Dvv-0008WM-AK for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:45:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2Dvq-0007Eo-R3 for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:44:57 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:43868 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2Dvk-0006Ly-2E; Fri, 08 Mar 2019 06:44:48 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 59352DBA3A4E39A5D7AB; Fri, 8 Mar 2019 19:44:43 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.408.0; Fri, 8 Mar 2019 19:44:36 +0800 From: Shameer Kolothum To: , , , , , , , Date: Fri, 8 Mar 2019 11:42:17 +0000 Message-ID: <20190308114218.26692-11-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190308114218.26692-1-shameerali.kolothum.thodi@huawei.com> References: <20190308114218.26692-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 v2 10/11] hw/arm/virt: Add GED device configuration and build aml X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxarm@huawei.com, xuwei5@hisilicon.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This initializes the GED device with base memory and irq. It also configures ged memory hotplug event and builds the corresponding aml code. But ged irq routing to Guest is not enabled and thus hotplug is not yet supported. Signed-off-by: Shameer Kolothum --- default-configs/arm-softmmu.mak | 1 + hw/arm/virt-acpi-build.c | 13 +++++++++++++ hw/arm/virt-acpi.c | 4 ++++ hw/arm/virt.c | 22 ++++++++++++++++++++++ include/hw/arm/virt.h | 4 ++++ 5 files changed, 44 insertions(+) -- 2.7.4 diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak index b3bac25..7c442fd 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -168,3 +168,4 @@ CONFIG_MUSICPAL=y CONFIG_MEM_DEVICE=y CONFIG_DIMM=y CONFIG_ACPI_MEMORY_HOTPLUG=y +CONFIG_ACPI_HW_REDUCED=y diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 6cb7263..86f25ad 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -50,6 +50,18 @@ #define ARM_SPI_BASE 32 #define ACPI_POWER_BUTTON_DEVICE "PWRB" +static void acpi_dsdt_add_ged(Aml *scope, VirtMachineState *vms) +{ + int irq = vms->irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE; + + if (!vms->ged_events || !vms->ged_events_size) { + return; + } + + build_ged_aml(scope, "\\_SB."GED_DEVICE, irq, vms->ged_events, + vms->ged_events_size, AML_SYSTEM_MEMORY); +} + static void acpi_dsdt_add_memory_hotplug(Aml *scope, MachineState *ms) { uint32_t nr_mem = ms->ram_slots; @@ -758,6 +770,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) */ scope = aml_scope("\\_SB"); acpi_dsdt_add_memory_hotplug(scope, MACHINE(vms)); + acpi_dsdt_add_ged(scope, vms); acpi_dsdt_add_cpus(scope, vms->smp_cpus); acpi_dsdt_add_uart(scope, &memmap[VIRT_UART], (irqmap[VIRT_UART] + ARM_SPI_BASE)); diff --git a/hw/arm/virt-acpi.c b/hw/arm/virt-acpi.c index 18ebe94..3b55c63 100644 --- a/hw/arm/virt-acpi.c +++ b/hw/arm/virt-acpi.c @@ -31,6 +31,7 @@ typedef struct VirtAcpiState { SysBusDevice parent_obj; MemHotplugState memhp_state; + GEDState ged_state; } VirtAcpiState; #define TYPE_VIRT_ACPI "virt-acpi" @@ -76,12 +77,15 @@ static void virt_device_realize(DeviceState *dev, Error **errp) { VirtMachineState *vms = VIRT_MACHINE(qdev_get_machine()); const MemMapEntry *memmap = vms->memmap; + const int *irqmap = vms->irqmap; VirtAcpiState *s = VIRT_ACPI(dev); if (s->memhp_state.is_enabled) { acpi_memory_hotplug_init(get_system_memory(), OBJECT(dev), &s->memhp_state, memmap[VIRT_PCDIMM_ACPI].base); + acpi_ged_init(get_system_memory(), OBJECT(dev), &s->ged_state, + memmap[VIRT_ACPI_GED].base, irqmap[VIRT_ACPI_GED]); } } diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 9427f4f..352dbb1 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -134,6 +134,7 @@ static const MemMapEntry base_memmap[] = { [VIRT_SECURE_UART] = { 0x09040000, 0x00001000 }, [VIRT_SMMU] = { 0x09050000, 0x00020000 }, [VIRT_PCDIMM_ACPI] = { 0x09070000, 0x00010000 }, + [VIRT_ACPI_GED] = { 0x09080000, 0x00010000 }, [VIRT_MMIO] = { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 }, @@ -169,6 +170,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 */ @@ -184,6 +186,25 @@ static const char *valid_cpus[] = { ARM_CPU_TYPE_NAME("max"), }; +static void virt_acpi_ged_conf(VirtMachineState *vms) +{ + uint8_t events_size; + + /* GED events */ + GedEvent events[] = { + { + .selector = ACPI_GED_IRQ_SEL_MEM, + .event = GED_MEMORY_HOTPLUG, + }, + }; + + events_size = ARRAY_SIZE(events); + + vms->ged_events = g_malloc0(events_size * sizeof(GedEvent)); + memcpy(vms->ged_events, events, events_size * sizeof(GedEvent)); + vms->ged_events_size = events_size; +} + static bool cpu_type_valid(const char *cpu) { int i; @@ -1650,6 +1671,7 @@ static void machvirt_init(MachineState *machine) create_platform_bus(vms, pic); vms->acpi = virt_acpi_init(); + virt_acpi_ged_conf(vms); vms->bootinfo.ram_size = machine->ram_size; vms->bootinfo.kernel_filename = machine->kernel_filename; diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index e46a051..49fda81 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -37,6 +37,7 @@ #include "hw/arm/arm.h" #include "sysemu/kvm.h" #include "hw/intc/arm_gicv3_common.h" +#include "hw/acpi/ged.h" #define NUM_GICV2M_SPIS 64 #define NUM_VIRTIO_TRANSPORTS 32 @@ -78,6 +79,7 @@ enum { VIRT_SECURE_UART, VIRT_SECURE_MEM, VIRT_PCDIMM_ACPI, + VIRT_ACPI_GED, VIRT_LOWMEMMAP_LAST, }; @@ -134,6 +136,8 @@ typedef struct { int psci_conduit; hwaddr highest_gpa; DeviceState *acpi; + GedEvent *ged_events; + uint32_t ged_events_size; } VirtMachineState; #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) From patchwork Fri Mar 8 11:42: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: 159975 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp8615372jad; Fri, 8 Mar 2019 03:54:32 -0800 (PST) X-Google-Smtp-Source: APXvYqzgvyXfE34XDCmP1ctZvsMxRoEkkhgsaUCEWLUDsC1fx7FJVX4FRVFjnS6af37eU66svUmS X-Received: by 2002:a0d:e1d3:: with SMTP id k202mr14063269ywe.198.1552046072335; Fri, 08 Mar 2019 03:54:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552046072; cv=none; d=google.com; s=arc-20160816; b=0fZaegX0UNnSWbVIxBpEAqqC8GPTNkAw8EI3i73dPkh4GMu5WuA3TTcspCAgNki0m6 PdNk7XV91s9COLO3Wi86T0PIIe9zdzH3FJeUqm2uavIH/jbxMw2mbqrBmMSyK3E+3mLy iaaFJqk0zimsehs+BDLvVBkqwNWNrppKfVC4E7xj/1Yk6g/VTk1SbJEBBKtLfjGT4Q1I 8VZ2Or7o91Y7O5hgZ/Qo/iejP/XiJeIv8cQ7fABHfUf9mbDmxWhQ5VZdgBE/igAa27gq mj8E7iluj1PIz7HlVL3km7q3vsdMlUcZP18T/XZK1JqtEr6PGgqBaSTUo2oQYiFDj1T9 2CFQ== 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=8dAZh6ardznfCQ5M2tkxm3YaTQKmKl9t7SYpkC9mBe4=; b=XpegRxVLOukmB33mOR0UMwS0S4rXbWvMSgkEDVK4GQbuneGYzjG4+pHqIX75wgVC7/ Gf85dUKzJrLIAwkAmMrxFbGj9e9353gt4mTq/makkLYh+7ve9g5DGUm3G0hHZFALfNra JiFiiXAC8WoftM4OpLGnl/dj28P674DfnxNft11IzKwbZ35P1nvAFfeCHINr4r+6WoFK AOH6JPnDvz+OuN3qp3E9POzJMKtc4NcWE55Sr57/y2nKGExYRobM/bSCNFw5jHKNi2Ek /jym8iZgZrEftMC+82ht5UmUqyAtFqIZ6Wo/zC5VxV2fGyx3pz/bgl3rWTFbDmbn1/ye 7BCQ== 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 x15si2629036ybk.423.2019.03.08.03.54.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Mar 2019 03:54:32 -0800 (PST) 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 ([127.0.0.1]:41658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2E57-0006bD-Ta for patch@linaro.org; Fri, 08 Mar 2019 06:54:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Dw0-0000Bi-Hv for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:45:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2Dvx-0007lq-9U for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:45:03 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2189 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2Dvo-0006m5-IH; Fri, 08 Mar 2019 06:44:52 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 6D4E06C0D5FC7E7957FB; Fri, 8 Mar 2019 19:44:48 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.408.0; Fri, 8 Mar 2019 19:44:39 +0800 From: Shameer Kolothum To: , , , , , , , Date: Fri, 8 Mar 2019 11:42:18 +0000 Message-ID: <20190308114218.26692-12-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190308114218.26692-1-shameerali.kolothum.thodi@huawei.com> References: <20190308114218.26692-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 v2 11/11] hw/arm/virt: Add GED irq routing and Enable memory hotplug X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxarm@huawei.com, xuwei5@hisilicon.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Adds GED irq routing to guest and enables memory hotplug. Signed-off-by: Shameer Kolothum --- hw/arm/virt-acpi.c | 27 +++++++++++++++++++++++++-- hw/arm/virt.c | 17 +++++++++++------ include/hw/arm/virt.h | 3 ++- 3 files changed, 38 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/hw/arm/virt-acpi.c b/hw/arm/virt-acpi.c index 3b55c63..c5a9311 100644 --- a/hw/arm/virt-acpi.c +++ b/hw/arm/virt-acpi.c @@ -32,6 +32,7 @@ typedef struct VirtAcpiState { SysBusDevice parent_obj; MemHotplugState memhp_state; GEDState ged_state; + qemu_irq *gsi; } VirtAcpiState; #define TYPE_VIRT_ACPI "virt-acpi" @@ -71,6 +72,21 @@ static void virt_device_unplug_cb(HotplugHandler *hotplug_dev, static void virt_send_ged(AcpiDeviceIf *adev, AcpiEventStatusBits ev) { + VirtAcpiState *s = VIRT_ACPI(adev); + uint32_t sel = ACPI_GED_IRQ_SEL_INIT; + + if (ev & ACPI_MEMORY_HOTPLUG_STATUS) { + sel = ACPI_GED_IRQ_SEL_MEM; + } else { + /* Unknown event. Return without generating interrupt. */ + return; + } + + /* + * We inject the hotplug interrupt. The IRQ selector will make + * the difference from the ACPI table. + */ + acpi_ged_event(&s->ged_state, s->gsi, sel); } static void virt_device_realize(DeviceState *dev, Error **errp) @@ -89,9 +105,16 @@ static void virt_device_realize(DeviceState *dev, Error **errp) } } -DeviceState *virt_acpi_init(void) +DeviceState *virt_acpi_init(qemu_irq *gsi) { - return sysbus_create_simple(TYPE_VIRT_ACPI, -1, NULL); + DeviceState *dev; + VirtAcpiState *s; + + dev = sysbus_create_simple(TYPE_VIRT_ACPI, -1, NULL); + s = VIRT_ACPI(dev); + s->gsi = gsi; + + return dev; } static Property virt_acpi_properties[] = { diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 352dbb1..fa352c5 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -577,6 +577,12 @@ static void create_v2m(VirtMachineState *vms, qemu_irq *pic) fdt_add_v2m_gic_node(vms); } +static void virt_gsi_handler(void *opaque, int n, int level) +{ + qemu_irq *gic_irq = opaque; + qemu_set_irq(gic_irq[n], level); +} + static void create_gic(VirtMachineState *vms, qemu_irq *pic) { /* We create a standalone GIC */ @@ -692,6 +698,8 @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic) pic[i] = qdev_get_gpio_in(gicdev, i); } + vms->gsi = qemu_allocate_irqs(virt_gsi_handler, pic, NUM_IRQS); + fdt_add_gic_node(vms); if (type == 3 && vms->its) { @@ -1444,7 +1452,7 @@ static void machvirt_init(MachineState *machine) VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(machine); MachineClass *mc = MACHINE_GET_CLASS(machine); const CPUArchIdList *possible_cpus; - qemu_irq pic[NUM_IRQS]; + qemu_irq *pic; MemoryRegion *sysmem = get_system_memory(); MemoryRegion *secure_sysmem = NULL; int n, virt_max_cpus; @@ -1640,6 +1648,7 @@ static void machvirt_init(MachineState *machine) create_flash(vms, sysmem, secure_sysmem ? secure_sysmem : sysmem); + pic = g_new0(qemu_irq, NUM_IRQS); create_gic(vms, pic); fdt_add_pmu_nodes(vms); @@ -1670,7 +1679,7 @@ static void machvirt_init(MachineState *machine) create_platform_bus(vms, pic); - vms->acpi = virt_acpi_init(); + vms->acpi = virt_acpi_init(vms->gsi); virt_acpi_ged_conf(vms); vms->bootinfo.ram_size = machine->ram_size; @@ -1842,10 +1851,6 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, { const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); - if (dev->hotplugged) { - error_setg(errp, "memory hotplug is not supported"); - } - if (is_nvdimm) { error_setg(errp, "nvdimm is not yet supported"); return; diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 49fda81..30ff460 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -136,6 +136,7 @@ typedef struct { int psci_conduit; hwaddr highest_gpa; DeviceState *acpi; + qemu_irq *gsi; GedEvent *ged_events; uint32_t ged_events_size; } VirtMachineState; @@ -151,7 +152,7 @@ typedef struct { OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE) void virt_acpi_setup(VirtMachineState *vms); -DeviceState *virt_acpi_init(void); +DeviceState *virt_acpi_init(qemu_irq *gsi); /* Return the number of used redistributor regions */ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms)