From patchwork Thu Mar 21 10:47:36 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: 160771 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp647566jan; Thu, 21 Mar 2019 03:57:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzEsM3TPxdFdTgIqZG8TSgHHUx5rrWwUTVS9majR438DktEsEu7SZsvL+hG18ksTdsY21kF X-Received: by 2002:adf:cd83:: with SMTP id q3mr1986879wrj.228.1553165869508; Thu, 21 Mar 2019 03:57:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553165869; cv=none; d=google.com; s=arc-20160816; b=E/J5JJPWPLxP0NNClRcfbNlHdSwopvdJKA/bpFzQzF554/8RhG0R0nK4y8KrDeZBEd FIs/Z/ZifuYNlrm1JcXnKiGIK9w0v2CTzBJR3buwQSDAHBBLGKCXZ0/eIcRwEbBiIHP7 P8XKV3FPRjmQDP1jAg508cHIL33O5A0Qcy0fKe20lOXe0pgfcLdfgsmbHY+KiucRJIIb 9Fz5sZCVMhDjSuTo4dwzTpC3AveCcuQcx554AQz2AFSwojV+yyK+oeIsWrt6vdbJUCYp hMiHnqcZEfeN1FwE3FZTu+EVEW6muUduEGVtnlmZ3u323laWXi+6aC/bV4sRhuDihAsi 1FzA== 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=tEK9bS9tHTGBV9g1TG77QS4bCq8uVvpsgMIlK4O5iqA=; b=IdEA6bXDAVSCCAoD81OvilVT6c7VYNjCucgVZe/h5Uy1OhgMUVLo8Wj8Dx+hitu7D6 iNxpw+m7zlgyxUfTDyQupoT7DNFwXd8CYNacuyyxYfV6v+x5n+BYHuHYJsOU8twU6vNr 8Pll+oNoofgS6pAVhT5QHy3bWz8hJ/W035JAESeJKH8TzsklmPaXb9ddMX6xnG4Xwpk3 GojHmEHZH0L18WcMT1eBljOPPlZvAjhGRnv4LT+MOZ8HDFFL7Anl6uhSkUatbNjWJzNh ZYycoijTR4QU4PCQ0PlkVcrIcj7isAUOwyjhjjrp3gADOKSC7OsCAu2S2CdEWqmAJsRJ XPqw== 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 l14si3026033wrm.251.2019.03.21.03.57.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Mar 2019 03:57:49 -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 ([127.0.0.1]:34812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vOO-0001i3-DE for patch@linaro.org; Thu, 21 Mar 2019 06:57:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vHk-0004XC-RK for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:50:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6vFr-0001Rs-Jc for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:49:00 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:56144 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6vFp-0000Ml-7n; Thu, 21 Mar 2019 06:48:57 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 79103E5E8DB4E55B6534; Thu, 21 Mar 2019 18:48:47 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Thu, 21 Mar 2019 18:48:40 +0800 From: Shameer Kolothum To: , , , , , , , Date: Thu, 21 Mar 2019 10:47:36 +0000 Message-ID: <20190321104745.28068-2-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190321104745.28068-1-shameerali.kolothum.thodi@huawei.com> References: <20190321104745.28068-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 v3 01/10] 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. Also move the MEMORY_SLOT_SCAN_METHOD/MEMORY_DEVICES_CONTAINER 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 aml code. Signed-off-by: Shameer Kolothum Reviewed-by: Eric Auger --- hw/acpi/memory_hotplug.c | 24 ++++++++++++++---------- hw/i386/acpi-build.c | 3 ++- include/hw/acpi/memory_hotplug.h | 8 ++++++-- 3 files changed, 22 insertions(+), 13 deletions(-) -- 2.7.4 Reviewed-by: Igor Mammedov diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 297812d..80e25f0 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -29,12 +29,10 @@ #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 +207,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 +340,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 +364,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 416da31..6d6de44 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 77c6576..f95aa1f 100644 --- a/include/hw/acpi/memory_hotplug.h +++ b/include/hw/acpi/memory_hotplug.h @@ -5,6 +5,9 @@ #include "hw/acpi/acpi.h" #include "hw/acpi/aml-build.h" +#define MEMORY_SLOT_SCAN_METHOD "MSCN" +#define MEMORY_DEVICES_CONTAINER "\\_SB.MHPC" + /** * MemStatus: * @is_removing: the memory device in slot has been requested to be ejected. @@ -29,7 +32,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 +51,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 Thu Mar 21 10:47:37 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: 160770 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp647048jan; Thu, 21 Mar 2019 03:57:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyyKfUXfKO94pd1Z+SyjYY3EzXzP7W31ksC19QWG6SOu8uQoUMp7kEhTTXa6n2qrmm5NXO X-Received: by 2002:a05:6000:1292:: with SMTP id f18mr2137438wrx.115.1553165827627; Thu, 21 Mar 2019 03:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553165827; cv=none; d=google.com; s=arc-20160816; b=llqlPY++lSGMeff7XOkIL82x62zAJqWwpdAzNfkyZJzGvaX9nIhtc8DrvZtWsgAUw0 3EbxTyv8S2ZY+5Ryt/zFWL3lo90OeH7myj10aTfiiU+4c2RuF1GdG82brirpqWfHbbFY Pp35lagG4LrFMt34LKH5JDPSWYFATDvPY5cIpUYX19o4EiFdlXMljOaybKxSgZ/aM+lk WLWq1DJyBo1aA6jAiUdUzyjViQJNLyfOC6aR+1cLLvK5SNP1k8WqYO9my2yRIsREudAm g50qqUivgx2eDb+sk2vfIO+YPlK7AeU6mAIrXo8z9tbhGdpo6f3mP+58THGSr+YSGd77 Ymeg== 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=fKctV7GUD3Uo7WpHZwl71IY0iimmutABw+rl8Ebg4u4=; b=nxqh4DfH5IgxYha2C+L9h+oprQqjbsVNY6iLX546imG83vr1LFnkgexmgGg0aNtKUe Qhy72dopLqtSAEznETa2hLqCc6YuypV+pu1hTgtqIShLJEzXK1TMTENw789SKuD0NcHw 3cOlj5Siw4bYObZCsExEJ2Cx/20B2pbJn3Jp/O0yLJskSFwa9iSNuqNDuYfKh+krncPq 6GPYi4ZK4k/IhzGDySyLfh5KIQ6Gt8bZ1STo3DlGiA48PtbQBLEBaeeiAqPKVBoZ4/G6 1D+LBDAsSI1+LpHr+YXDBYZAy0Cb+pmDVGQLv/nD9YZtZ9hI7f78/QWui83oUTbclqpQ 886g== 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 b14si2869431wrj.358.2019.03.21.03.57.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Mar 2019 03:57:07 -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 ([127.0.0.1]:34800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vNi-00018W-9q for patch@linaro.org; Thu, 21 Mar 2019 06:57:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vHm-0004XC-9l for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:50:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6vFq-0001M1-TW for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:48:59 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2196 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6vFp-0000pF-85; Thu, 21 Mar 2019 06:48:57 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 86CEB75FF1BB59E97E57; Thu, 21 Mar 2019 18:48:52 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Thu, 21 Mar 2019 18:48:44 +0800 From: Shameer Kolothum To: , , , , , , , Date: Thu, 21 Mar 2019 10:47:37 +0000 Message-ID: <20190321104745.28068-3-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190321104745.28068-1-shameerali.kolothum.thodi@huawei.com> References: <20190321104745.28068-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 v3 02/10] 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 Reviewed-by: Eric Auger diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 80e25f0..98407e3 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -720,10 +720,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 Thu Mar 21 10:47:38 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: 160773 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp650058jan; Thu, 21 Mar 2019 04:00:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHSIT8NPvetu09/oB9qJ/f3tq/IYJioNopQMnBC+LFoJBezOYn+zfK8g5AgixXG2nyh1I+ X-Received: by 2002:adf:cd90:: with SMTP id q16mr2045626wrj.75.1553166039602; Thu, 21 Mar 2019 04:00:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553166039; cv=none; d=google.com; s=arc-20160816; b=Y0KvKURPVVycthnkcOT/Ruv7wYbkdzNsxUwy9Xt7JJ5cszzKdor+FY3WQu+0PvU+sR uDUzUYLAkvqGsv/DICcJe7X2pY1t7r+xPLx4j6sF1Eu6HRQDJ8k0btCJgid0mmKIoDjZ oThK+DrDJ+mHy/PJTIIAd3EbEzkAoZVNWXICe0kRqZqtK8ZjASZUgWnjMyefiwIr6vkZ SOK9iWLtJyVJzHa57nW5A8a7D5xfib/dQVxU8dsD7fGZIdIjeO7zZawjJRWoD6i1AAFW iBwyXqXyaXQJj6aS2+RZkTFOY6JGm4duzXEaCZhNbmyudoHRnzYUV4otXDI9D8Zt92/D CudA== 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=tzEirkFiIAa1w8M9qNxPys02O4zaC7AnaVmr44qHbXw=; b=ZkpuywGeINi1+1cSNZWWSV28bkcx1WfEGbUxnq6a6reSGNcxAKorhr7tQCTY60wp0I d07oTPUDrK0VbxxlSbLxGN8XyBPNmxs1/Od7Ng9D8+Ur0rMWVVXT70ykR5EYb+C+spYS Ij8duKpffU3Bt+YmbV+tRuoKeCyvRD8uY3cP91Mp+fL5Cu7h8A/VJuiIy0MrnLw025+G mTNsPB0JGRpTMDJse/lLe+S8HyMGNkODEcPFSDJWG+WkgjIZ/0cOJtG+vwylaID/o1Ow 9dnP7+aOO5LUYkaWa/52+Y/kVEEaT/NfVOBB5vBOvj+OEAy6EVrrKFGxPo1JL9Ulj4s/ xQwQ== 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 k9si3167619wmj.38.2019.03.21.04.00.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Mar 2019 04:00:39 -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 ([127.0.0.1]:34854 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vR8-0003Zu-I4 for patch@linaro.org; Thu, 21 Mar 2019 07:00:38 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vHf-0004Og-O3 for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:50:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6vFu-0001pL-Kw for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:49:04 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:56392 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6vFs-0001H6-2p; Thu, 21 Mar 2019 06:49:00 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 9E29957B498EFBCAD080; Thu, 21 Mar 2019 18:48:57 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Thu, 21 Mar 2019 18:48:47 +0800 From: Shameer Kolothum To: , , , , , , , Date: Thu, 21 Mar 2019 10:47:38 +0000 Message-ID: <20190321104745.28068-4-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190321104745.28068-1-shameerali.kolothum.thodi@huawei.com> References: <20190321104745.28068-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 v3 03/10] 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 adds the skeleton to support an acpi device interface for HW-reduced acpi platforms via ACPI GED - Generic Event Device (ACPI v6.1 5.6.9). This will be used by Arm/Virt to add hotplug support. Signed-off-by: Samuel Ortiz Signed-off-by: Shameer Kolothum --- hw/acpi/Kconfig | 4 ++ hw/acpi/Makefile.objs | 1 + hw/acpi/generic_event_device.c | 72 ++++++++++++++++++++++++++++++++++ include/hw/acpi/generic_event_device.h | 29 ++++++++++++++ 4 files changed, 106 insertions(+) create mode 100644 hw/acpi/generic_event_device.c create mode 100644 include/hw/acpi/generic_event_device.h -- 2.7.4 diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig index eca3bee..01a8b41 100644 --- a/hw/acpi/Kconfig +++ b/hw/acpi/Kconfig @@ -27,3 +27,7 @@ config ACPI_VMGENID bool default y depends on PC + +config ACPI_HW_REDUCED + bool + depends on ACPI diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs index 2d46e37..b753232 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 0000000..b21a551 --- /dev/null +++ b/hw/acpi/generic_event_device.c @@ -0,0 +1,72 @@ +/* + * + * 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 "hw/sysbus.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/generic_event_device.h" + +static void virt_device_plug_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) +{ +} + +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->props = virt_acpi_properties; + dc->realize = virt_device_realize; + + hc->plug = virt_device_plug_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/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h new file mode 100644 index 0000000..f314515 --- /dev/null +++ b/include/hw/acpi/generic_event_device.h @@ -0,0 +1,29 @@ +/* + * + * 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 + +#define TYPE_VIRT_ACPI "virt-acpi" +#define VIRT_ACPI(obj) \ + OBJECT_CHECK(VirtAcpiState, (obj), TYPE_VIRT_ACPI) + +typedef struct VirtAcpiState { + SysBusDevice parent_obj; +} VirtAcpiState; + +#endif From patchwork Thu Mar 21 10:47:39 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: 160775 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp654864jan; Thu, 21 Mar 2019 04:04:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsBoDR2YOxHDGGU+CNTD0iKKOkKz5JbRQjApBhUuagWKjrECJUxjLspN1LV89N/HkuYK2D X-Received: by 2002:a1c:f718:: with SMTP id v24mr1131339wmh.1.1553166270382; Thu, 21 Mar 2019 04:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553166270; cv=none; d=google.com; s=arc-20160816; b=YGrwW72cJp46ODDGa+fPxnLPxPXmU7Cd7+mtGkEVRtjtTvgizJImAujPjbvYtNW0Oa 2i7rp5zb+2xEYR7hfEPrucBtfzYD8uzvUbAiEL1Sq/TqATzDzBTVEAs6cyYvt1nEXNTo 0Ckf6esinIfKPlVr1cTC3AhLV5wpsJJLDR9DTYq8pq1JJdpmBeoWPYH44bPoesFtGySl dxpo4O1Mf4oMWNzFZ0ZaFgYERhFsMhuycSrr4lRNN2fjV3rHrkn4/QZYo/7oFh1yc9AX FL5WoLj4Qi+4gR290ywtywTEkkv71O0Xde/ZRWcCAw4Vbgkg6/Vc6acMuCM970TI8rU1 3y5A== 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=hHe1yv32FSB+KApKUMYSU/k3QsGmmIshgFGk3KhIvYY=; b=LotpbpUJw8jdZHmt/ok5HN7YJoWrW65W0CPNWY9KSD50QnI2RgZYwxHHlfdeXGdXj8 g8v+nQJYVI+vDQLvgk/AeFUYIP9BqeUySfX1mQRvqHKywYd8+7PK3xNEYXy1JVWkCjbW 5cKMNPY+AuDgPOC0pB4LRgmNz+tZJ+0NugyBQkR4resLD1aUnA7rlkf69PhTXrEG2aJn z9vBCMSwtyQSavco0d2eqT6g2mj7p8DGekWbLPZdF9W78/97/rw2WsDEwdPjBOzdt4ri HGPGWYVqJAOOHAlnMbv8eiUkLWWVb4Qm07ytYxDDJOeSgMbBU0Z6Q0biCujKkRXvYt5x wNCg== 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 d63si3177083wmf.30.2019.03.21.04.04.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Mar 2019 04:04:30 -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 ([127.0.0.1]:34907 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vUr-00063K-FB for patch@linaro.org; Thu, 21 Mar 2019 07:04:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vHh-0004Td-Pj for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:50:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6vFu-0001mi-4Y for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:49:03 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:56388 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6vFs-0001GN-04; Thu, 21 Mar 2019 06:49:00 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 97DC26E198EBD0991C00; Thu, 21 Mar 2019 18:48:57 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Thu, 21 Mar 2019 18:48:50 +0800 From: Shameer Kolothum To: , , , , , , , Date: Thu, 21 Mar 2019 10:47:39 +0000 Message-ID: <20190321104745.28068-5-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190321104745.28068-1-shameerali.kolothum.thodi@huawei.com> References: <20190321104745.28068-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 v3 04/10] 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 device memory is not yet reported to guest. Signed-off-by: Eric Auger Signed-off-by: Kwangwoo Lee Signed-off-by: Shameer Kolothum --- default-configs/arm-softmmu.mak | 3 +++ hw/arm/virt.c | 53 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak index 2a7efc1..795cb89 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -159,3 +159,6 @@ CONFIG_MUSICPAL=y # for realview and versatilepb CONFIG_LSI_SCSI_PCI=y + +CONFIG_MEM_DEVICE=y +CONFIG_DIMM=y diff --git a/hw/arm/virt.c b/hw/arm/virt.c index ce2664a..d0ff20d 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, \ @@ -1806,6 +1808,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) { @@ -1817,12 +1855,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); } @@ -1886,7 +1935,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 Thu Mar 21 10:47:40 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: 160769 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp645308jan; Thu, 21 Mar 2019 03:54:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWysY8xEUQ82wsrw04556wrfLRpnyENWzRLwm55R4xk2ZNbjQ1ukxo7xy+ESMs8lNV3tXM X-Received: by 2002:a5d:4a8a:: with SMTP id o10mr2073700wrq.189.1553165689934; Thu, 21 Mar 2019 03:54:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553165689; cv=none; d=google.com; s=arc-20160816; b=ZdpA+VnGoPRBTp4JJujW8gmGGHn+Fh0jlQPWCE+oAPyAestPkGv8PMNr2aeoHwB90W xGN12sbXoBqoKp/sXZZrPmcxLfS5+MV8JwRNj4yp2Rcuzi1qp6dJq7NuZWPUDhvI1A4M 9uM+S+ymfixgvBWVdHGv8oiXnGlkpGsU24UMqIUbpk/2+Izrdf0hWlZHUk5sDJD4LXLK Hw2kmGvm88Hpj2Ip9btYjJ9V/J/j9bQNi83Btv2RqjKgjZHGw7Z9OpNaEYL0YZtP964m ZqKNiY//+I/OuU7xgzwSSCEqM+kx1RTpAbeIdTaszJj3JKsIOCBDCAy5v5KatugBH18J QZvA== 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=rNaKglMkcF4skH1kUzQ5t1KWZGao2MePD68QU3jXw6A=; b=LScW2mfeO59lD4ruMNdb5LvSCg3VgDmztGtNBXk8ayfrXIEM5t5zp12r+GLv45iWT3 EnBeLjjIFOAOkjAV9H4Xo2axdZrwLwGkAXvWCCZo7faiMGq6PCnAOjGvyf9MyFy0lpbh NjpR8RfdNEW+jjUnxfhu19AKQ/sVXrRaS1o5/3VHE8yrmVCnwDBx301S3je/OndzG/3m uwnHRMDo98ArD04mFsBn/tyqV8H9gV+fo7drjSBEjK4J6jMjvAYrgjIJ1gt4xoMSx55I XLm45k6oMuOsO5FBGS6OfPmYexeeSi8yGYBJeWKD5P5JH3lKIChA2swjYbkWl8zeYNd0 7COQ== 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 a6si2994784wrt.316.2019.03.21.03.54.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Mar 2019 03:54:49 -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 ([127.0.0.1]:34739 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vLU-0007Qv-Or for patch@linaro.org; Thu, 21 Mar 2019 06:54:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vHd-0004Td-KL for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:50:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6vG0-0002Ro-8D for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:49:09 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:51940 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6vFx-0001um-QZ; Thu, 21 Mar 2019 06:49:06 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id A9C4A21494CB64D25712; Thu, 21 Mar 2019 18:49:02 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Thu, 21 Mar 2019 18:48:53 +0800 From: Shameer Kolothum To: , , , , , , , Date: Thu, 21 Mar 2019 10:47:40 +0000 Message-ID: <20190321104745.28068-6-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190321104745.28068-1-shameerali.kolothum.thodi@huawei.com> References: <20190321104745.28068-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 v3 05/10] 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(ACPI boot) can see the cold-plugged device memory. Memory cold plug support with DT boot is not yet enabled. Signed-off-by: Shameer Kolothum --- default-configs/arm-softmmu.mak | 2 ++ hw/acpi/generic_event_device.c | 23 +++++++++++++++++++++++ hw/arm/virt-acpi-build.c | 9 +++++++++ hw/arm/virt.c | 23 +++++++++++++++++++++++ include/hw/acpi/generic_event_device.h | 5 +++++ include/hw/arm/virt.h | 2 ++ 6 files changed, 64 insertions(+) -- 2.7.4 diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak index 795cb89..6db444e 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -162,3 +162,5 @@ CONFIG_LSI_SCSI_PCI=y CONFIG_MEM_DEVICE=y CONFIG_DIMM=y +CONFIG_ACPI_MEMORY_HOTPLUG=y +CONFIG_ACPI_HW_REDUCED=y diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index b21a551..0b32fc9 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -16,13 +16,26 @@ */ #include "qemu/osdep.h" +#include "qapi/error.h" +#include "exec/address-spaces.h" #include "hw/sysbus.h" #include "hw/acpi/acpi.h" #include "hw/acpi/generic_event_device.h" +#include "hw/mem/pc-dimm.h" 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_send_ged(AcpiDeviceIf *adev, AcpiEventStatusBits ev) @@ -31,9 +44,19 @@ static void virt_send_ged(AcpiDeviceIf *adev, AcpiEventStatusBits ev) static void virt_device_realize(DeviceState *dev, Error **errp) { + VirtAcpiState *s = VIRT_ACPI(dev); + + if (s->memhp_state.is_enabled) { + acpi_memory_hotplug_init(get_system_memory(), OBJECT(dev), + &s->memhp_state, + s->memhp_base); + } } static Property virt_acpi_properties[] = { + DEFINE_PROP_UINT64("memhp_base", VirtAcpiState, memhp_base, 0), + DEFINE_PROP_BOOL("memory-hotplug-support", VirtAcpiState, + memhp_state.is_enabled, true), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index bf9c0bc..20d3c83 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.c b/hw/arm/virt.c index d0ff20d..13db0e9 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 }, @@ -516,6 +517,18 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) } } +static DeviceState *create_virt_acpi(VirtMachineState *vms) +{ + DeviceState *dev; + + dev = qdev_create(NULL, "virt-acpi"); + qdev_prop_set_uint64(dev, "memhp_base", + vms->memmap[VIRT_PCDIMM_ACPI].base); + qdev_init_nofail(dev); + + return dev; +} + static void create_its(VirtMachineState *vms, DeviceState *gicdev) { const char *itsclass = its_class_name(); @@ -1644,6 +1657,8 @@ static void machvirt_init(MachineState *machine) create_platform_bus(vms, pic); + vms->acpi = create_virt_acpi(vms); + vms->bootinfo.ram_size = machine->ram_size; vms->bootinfo.kernel_filename = machine->kernel_filename; vms->bootinfo.kernel_cmdline = machine->kernel_cmdline; @@ -1828,11 +1843,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/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h index f314515..262ca7d 100644 --- a/include/hw/acpi/generic_event_device.h +++ b/include/hw/acpi/generic_event_device.h @@ -18,12 +18,17 @@ #ifndef HW_ACPI_GED_H #define HW_ACPI_GED_H +#include "hw/acpi/memory_hotplug.h" + #define TYPE_VIRT_ACPI "virt-acpi" #define VIRT_ACPI(obj) \ OBJECT_CHECK(VirtAcpiState, (obj), TYPE_VIRT_ACPI) typedef struct VirtAcpiState { SysBusDevice parent_obj; + MemHotplugState memhp_state; + hwaddr memhp_base; } VirtAcpiState; + #endif diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 507517c..c5e4c96 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 Thu Mar 21 10:47:41 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: 160768 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp643137jan; Thu, 21 Mar 2019 03:51:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjlR2agZv6M2xSV8cWGsRrh1sqhjGELRIz42gZINfMxJ/xe8IbgIa0/dxiXq+N2d8qnAXH X-Received: by 2002:adf:dc8e:: with SMTP id r14mr2144188wrj.118.1553165515657; Thu, 21 Mar 2019 03:51:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553165515; cv=none; d=google.com; s=arc-20160816; b=E6cBaA5a0h/SQXq3o6YEwnn4WbP8QV64ayD2kg+/7Qz9OfL6bHV/2NGHRjOHnRrQhf T9tRlZPqoFs8YVsqbEKhrbTqbcVjTrCYItYMM0b9wgYUYXD4v29ulwNz/Eietc9gQe9z S/fV4J3iGJ8Ti3Vmt8zXviCD72c55FQYEMfgTDFhFHLhtZ0jcfQSz12geNU2L5Qoed7E 3h5JIo9Yj/Xz6oj4cGEwTlRLpDHgKj6YmMHTcmPGUkXPdDMoSqpd37lWkgz2BJJkXhQf rzbnS7UQYS5/w+n9UI82R3Yd6jRM7DGzKKeTeHBbChT+bCdRVAHTgnNH1lZl1VaJYBzp silw== 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=BUpar81XegT9q5HTKgn8Nk9+FAXyapYKOQ1g/IS0udE=; b=tuBzvGfwJnIOSsFKdhBzD9n/SciX1qjFRW/+JO+UsE0o250IOJbiZCQeu3ZuXKpAPD MjYIbSa+t0SF7kW3lkwOobfABAZEDGdaIOkLrH/FH6pivRZi7+m27V8/2DhR/NXFbCzH JC1Oh/K/N5Db+NcoNR1/ySaQvmeCbt8ZWMWbKY+Wp4rKCpl2dnbKdmN67+PlgsY7VImR 7wasG9EDR1l8u0ochKCJsLKNEj/SvU3M0f5Wz6s3gNZZTpJm/OUl1mBdTDYJD5rgggtZ R4ta/mNmbHJPcmdftalWr52v+M3SdEnI2koSybB/3bozKD4gPRn+VGp0U9EGWDVlcxZi pKYw== 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 n127si816421wme.66.2019.03.21.03.51.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Mar 2019 03:51:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:34710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vIg-00051z-Hn for patch@linaro.org; Thu, 21 Mar 2019 06:51:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vHa-0004Og-CM for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:50:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6vG4-0002r1-2R for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:49:12 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:56518 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6vG2-0002VP-Cd; Thu, 21 Mar 2019 06:49:10 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id F07CBD773E7A054068D5; Thu, 21 Mar 2019 18:49:07 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Thu, 21 Mar 2019 18:48:56 +0800 From: Shameer Kolothum To: , , , , , , , Date: Thu, 21 Mar 2019 10:47:41 +0000 Message-ID: <20190321104745.28068-7-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190321104745.28068-1-shameerali.kolothum.thodi@huawei.com> References: <20190321104745.28068-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 v3 06/10] 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 20d3c83..1887531 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 Thu Mar 21 10:47:42 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: 160772 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp648022jan; Thu, 21 Mar 2019 03:58:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqyiRwSRKJcok7emV2lfHOTz+86VjWxHScvvNIfNOFj13SEVmBbV70g/K6klLdzzZcuIK9k2 X-Received: by 2002:a1c:a186:: with SMTP id k128mr2019281wme.54.1553165905440; Thu, 21 Mar 2019 03:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553165905; cv=none; d=google.com; s=arc-20160816; b=KXKR0e6wyqcTIvMr9vdMbL3vKdOrq7VxYZ9JYXjg6v/Dy98agUcMYvUItNQvHeZ0Xy Ph8H7L+OWE4JXUUWKa2gmDZwhFF/tVArpXnoe6LUJRx1SlicPl/Gw+y3pSiHhr26XwYq 2/i7DBYHj5ojc4MiUNksVrM3+RWDVtnL3cMERusXdx4IkE6WRoCKQ1VH04jYQwBM2d/E fVGKll/CY7fYjpTaUV/U2B5u8XiYDQo1z0eYPvaXsxbMB0SlhyFiBuHuSjeBC2BwUqeX uGO5YQS8jhatK+7zh6ZG/hZTdVtFcZctxVcaG5l+Cqdxwp9ukttomKPN1DsN0vbHmWyB Jf8A== 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=qsFGORQU4mJrDD2jEpvrVXk44zuv5QGQVutbHG5usa8=; b=Jv78NCCq9GZ9Ymto9tIKOOdb+Zr25Rw0YuK2mADzGmWGMV1gs67/SDmZAWBnkGAAU1 iVTBRJl+lXtaeao/DaL9PW7Zzi4DeL4EC2+wdAqEw75V61TNRYRj3VHFmTNA/M06RWFp n293xFhH1tNRk16s4upoqCUfWoEZANT2JNpEpF8KUJl0jzVqzK4f7d0jiUsoDDgp9sgg 4VHbz8n9ONFlu99eFA0oUvbWr8jKk7FWhbsvptxN2mJbxz8zb4v8EoYfzTw3RKVzbi4z PrGEis43ef4tNbLAQapNDUQGwedy3P5Bnz8L2fQcCwMRq5zV/zAxsTeGcjp+hgLAQOcV Ywjg== 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 f5si3070501wre.261.2019.03.21.03.58.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Mar 2019 03:58:25 -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 ([127.0.0.1]:34816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vOy-0001qk-CN for patch@linaro.org; Thu, 21 Mar 2019 06:58:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vHb-0004Og-R3 for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:50:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6vG3-0002ov-R4 for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:49:12 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2252 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6vG2-0002Tl-2J; Thu, 21 Mar 2019 06:49:10 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id BC46D422EBD4C3B27C3A; Thu, 21 Mar 2019 18:49:07 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Thu, 21 Mar 2019 18:48:59 +0800 From: Shameer Kolothum To: , , , , , , , Date: Thu, 21 Mar 2019 10:47:42 +0000 Message-ID: <20190321104745.28068-8-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190321104745.28068-1-shameerali.kolothum.thodi@huawei.com> References: <20190321104745.28068-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 v3 07/10] hw/arm/virt: Introduce opt-in feature "fdt" 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 to disable/enable populating DT nodes in case any conflict with acpi tables. The default is "off". This will be used in subsequent patch where cold plug device-memory support is added for DT boot. If DT memory node support is added for cold-plugged device memory, those memory will be visible to Guest kernel via UEFI GetMemoryMap() and gets treated as early boot memory. Hence memory becomes non hot-un-unpluggable even if Guest is booted in ACPI mode. Signed-off-by: Shameer Kolothum --- hw/arm/virt.c | 23 +++++++++++++++++++++++ include/hw/arm/virt.h | 1 + 2 files changed, 24 insertions(+) -- 2.7.4 diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 13db0e9..b602151 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1717,6 +1717,20 @@ static void virt_set_highmem(Object *obj, bool value, Error **errp) vms->highmem = value; } +static bool virt_get_fdt(Object *obj, Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + return vms->use_fdt; +} + +static void virt_set_fdt(Object *obj, bool value, Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + vms->use_fdt = value; +} + static bool virt_get_its(Object *obj, Error **errp) { VirtMachineState *vms = VIRT_MACHINE(obj); @@ -2005,6 +2019,15 @@ static void virt_instance_init(Object *obj) object_property_set_description(obj, "gic-version", "Set GIC version. " "Valid values are 2, 3 and host", NULL); + /* fdt is disabled by default */ + vms->use_fdt = false; + object_property_add_bool(obj, "fdt", virt_get_fdt, + virt_set_fdt, NULL); + object_property_set_description(obj, "fdt", + "Set on/off to enable/disable device tree " + "nodes in case any conflict with ACPI" + "(eg: device memory node)", + NULL); vms->highmem_ecam = !vmc->no_highmem_ecam; diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index c5e4c96..14b2e0a 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -119,6 +119,7 @@ typedef struct { bool highmem_ecam; bool its; bool virt; + bool use_fdt; int32_t gic_version; VirtIOMMUType iommu; struct arm_boot_info bootinfo; From patchwork Thu Mar 21 10:47:43 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: 160765 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp642655jan; Thu, 21 Mar 2019 03:51:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFTHL/y/GgsK1gh4h//2cLPWjy/XnO/b3qBZNAmBARCmusQFT6Aep05t+1D+umxGVjDe9/ X-Received: by 2002:adf:f48d:: with SMTP id l13mr2247531wro.2.1553165478569; Thu, 21 Mar 2019 03:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553165478; cv=none; d=google.com; s=arc-20160816; b=yY5ZFZarwDkq6se9eO3qJp8getNnB+LhrEMnbb5huLpP52bAC3f0pyyxI9AXXiA9Ks 3XNYXB/pnK/LVUX4wMwhyMOJCAnwzp2w29iHZXlvQwA8hBQtT5km5F6bE26rVX/qdnFl QAWh7p6h1nrVa6pmy2yV8rUlYuran1yWjC/Wst7smVfIuZ9p276B1KwcxosND6zuyim1 kV1L9xLF+JmERQ8PQO186RWR2BfooJpPOVXH8g5DkRGqqfIusDHG37ObXRO97klvMaYD TkNz+UegbRw3Qk1gWbG/ZtukzLZaBC7GG1CQx3VksT9cWBdAhjYVNUdptje1I5PjU0LH h+VA== 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=fA3zYJegmny2VbWNybrNR5q3ICUNxSl0RPBG8H8xrZg=; b=zvgFHxDdiTcVRExHtJhli/sbvXFsGQvbwrCjSxVry7W0pYnBcSekV8dJU+0fJfltuI GFjKWU7vP10or3MHIakAsTdh+LdyCW1vX1Rpjt2+xEVdJ6N+DCxTma26cmYo4/2YGlqA QWnQaHADqOFheIc5HMSdkWX4sHoKuh/W3UpP30eo4Sks3rpJcffBvtyhOZ70s5yi7Mr6 jK9KORUPRyIeY0ZyMpkuXgieeOF6NN/epts5sJWLdpB4dY+GMzJqwcvfVH7CxqHKJBMn p4RPm0YG0vE6DoWh6xVDXGkbkLXjC06nQumj2O8AbGatqOLiHkkh9o2VUiINV3MBxsUM HGcw== 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 j18si3091468wrs.420.2019.03.21.03.51.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Mar 2019 03:51: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 ([127.0.0.1]:34697 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vI2-0004Tc-Nq for patch@linaro.org; Thu, 21 Mar 2019 06:51:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vHX-0004Og-Vn for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:50:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6vG8-0003Lq-QK for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:49:17 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2253 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6vG7-000322-3F; Thu, 21 Mar 2019 06:49:15 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C864B518F006BC5AD6DD; Thu, 21 Mar 2019 18:49:12 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Thu, 21 Mar 2019 18:49:03 +0800 From: Shameer Kolothum To: , , , , , , , Date: Thu, 21 Mar 2019 10:47:43 +0000 Message-ID: <20190321104745.28068-9-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190321104745.28068-1-shameerali.kolothum.thodi@huawei.com> References: <20190321104745.28068-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 v3 08/10] 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. This is an opt-in feature and needs to be enabled("fdt=on") when Guest is booted with DT. 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 Signed-off-by: Shameer Kolothum --- hw/arm/boot.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) -- 2.7.4 diff --git a/hw/arm/boot.c b/hw/arm/boot.c index a830655..5b9a994 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,14 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, } } + if (object_property_get_bool(OBJECT(qdev_get_machine()), "fdt", NULL)) { + 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 Thu Mar 21 10:47:44 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: 160766 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp642656jan; Thu, 21 Mar 2019 03:51:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBuaZyvbIKVDy16n2I1Mgb7x8TljMpA9NfUsuJ7QZlJdKr+q02Wx0vAdy/DX2BhA0QuW02 X-Received: by 2002:a7b:c4d5:: with SMTP id g21mr1830272wmk.133.1553165478714; Thu, 21 Mar 2019 03:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553165478; cv=none; d=google.com; s=arc-20160816; b=YMFrrIrSVwG8CKn1GDMNmEA1OhSjZeEsitLZZigFkwF9tDSxCi7DeILEWj1aQ3Id0/ ebtYb145UZxkcMM+iW0+7gCKIZBUNDlTIoYD+Wvi2cyRzAiUgyJ0y4G6e53IVBto1yqR 4mG2DpQVQZYlLxtwap8K7+t6eebYNuVDciENtZeNW13xW6THQXoVTJFvaObqRxulvSJh j2kMBI1XqBfwX1oa/YT6sS0NxwapptvHDw1jVmB7cwBoMeW84O9S9VpBASOUgcpo65Nu jCE2UkuKyfdpG6czXuRU1y/Z93tyIy5xWo0iltyeveiBOib8jRDHZ+8Onnq4y+7/pGWR O1lg== 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=JrTBzc9RmoGclKGvuo614QjQAENvax9yzHS6UlB/Ok8=; b=Bt9kqkQqJCu7U9XoKGXz2TOlTlW7zna6bZdSSUs31/INs9+2cwvnB8Ep1hovjwPtYM GKDIutqUMPURm2c+sHoc4n5bZ4xYNJa+VXc1pxpcziHPFPsfWnbiBCIy7xaHmjemZOdb o2bpecaYIDzo0zDieC5W6FSiq0pdSDnXPH08gq6PyTaFgaiUS7UkKt/GLXN5mNcvaahu MLEWYRdwJ9wNz2PT4HfXd6y23UbzVAmGXF0OpNzSLQbJZAW1L8QKT1Ol5ArPCrGPVHjt s4EB4UJKf/N/3/GlAqmW5qnedZR1Vyap9IbsiXg6hhWWzbqyzd3xj4NkP4QwqI2XP6er 5GFw== 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 u11si2994277wrn.298.2019.03.21.03.51.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Mar 2019 03:51: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 ([127.0.0.1]:34686 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vHr-0004Oy-BE for patch@linaro.org; Thu, 21 Mar 2019 06:51:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vHP-0004Og-ES for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:50:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6vGE-0003ck-RV for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:49:24 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2197 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6vGC-0003RC-AB; Thu, 21 Mar 2019 06:49:20 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id E6F44237696FE3E62ADE; Thu, 21 Mar 2019 18:49:17 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Thu, 21 Mar 2019 18:49:07 +0800 From: Shameer Kolothum To: , , , , , , , Date: Thu, 21 Mar 2019 10:47:44 +0000 Message-ID: <20190321104745.28068-10-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190321104745.28068-1-shameerali.kolothum.thodi@huawei.com> References: <20190321104745.28068-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 v3 09/10] 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 generates 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. 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 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/generic_event_device.c | 200 +++++++++++++++++++++++++++++++++ include/hw/acpi/generic_event_device.h | 34 ++++++ 2 files changed, 234 insertions(+) -- 2.7.4 diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 0b32fc9..9deaa33 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -23,6 +23,183 @@ #include "hw/acpi/generic_event_device.h" #include "hw/mem/pc-dimm.h" +static hwaddr ged_io_base; +static GedEvent *ged_events; +static uint32_t ged_events_size; + +static Aml *ged_event_aml(const 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(MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD); + default: + break; + } + + return NULL; +} + +/* + * 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 + * GedEvent array 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, uint32_t ged_irq, + AmlRegionSpace rs) +{ + Aml *crs = aml_resource_template(); + Aml *evt, *field; + 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 || !ged_events || !ged_events_size) { + 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 < ged_events_size; i++) { + ged_aml = ged_event_aml(&ged_events[i]); + if (!ged_aml) { + continue; + } + + /* If ((Local1 == irq))*/ + if_ctx = aml_if(aml_equal(aml_and(irq_sel, aml_int(ged_events[i].selector), NULL), aml_int(ged_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", aml_string(GED_DEVICE))); + 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); +} + +/* 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_IRQ_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(GEDState *ged_st, 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(ged_st->gsi[ged_st->irq]); +} + static void virt_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -40,6 +217,21 @@ static void virt_device_plug_cb(HotplugHandler *hotplug_dev, static void virt_send_ged(AcpiDeviceIf *adev, AcpiEventStatusBits ev) { + VirtAcpiState *s = VIRT_ACPI(adev); + uint32_t sel; + + 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, sel); } static void virt_device_realize(DeviceState *dev, Error **errp) @@ -57,6 +249,11 @@ static Property virt_acpi_properties[] = { DEFINE_PROP_UINT64("memhp_base", VirtAcpiState, memhp_base, 0), DEFINE_PROP_BOOL("memory-hotplug-support", VirtAcpiState, memhp_state.is_enabled, true), + DEFINE_PROP_PTR("gsi", VirtAcpiState, gsi), + DEFINE_PROP_UINT64("ged_base", VirtAcpiState, ged_base, 0), + DEFINE_PROP_UINT32("ged_irq", VirtAcpiState, ged_irq, 0), + DEFINE_PROP_PTR("ged_events", VirtAcpiState, ged_events), + DEFINE_PROP_UINT32("ged_events_size", VirtAcpiState, ged_events_size, 0), DEFINE_PROP_END_OF_LIST(), }; @@ -70,6 +267,9 @@ static void virt_acpi_class_init(ObjectClass *class, void *data) dc->props = virt_acpi_properties; dc->realize = virt_device_realize; + /* Reason: pointer properties "gsi" and "gde_events" */ + dc->user_creatable = false; + hc->plug = virt_device_plug_cb; adevc->send_event = virt_send_ged; diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h index 262ca7d..7f130f3 100644 --- a/include/hw/acpi/generic_event_device.h +++ b/include/hw/acpi/generic_event_device.h @@ -24,11 +24,45 @@ #define VIRT_ACPI(obj) \ OBJECT_CHECK(VirtAcpiState, (obj), TYPE_VIRT_ACPI) +#define ACPI_GED_IRQ_SEL_OFFSET 0x0 +#define ACPI_GED_IRQ_SEL_LEN 0x4 +#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 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; + qemu_irq *gsi; + QemuMutex lock; +} GEDState; + typedef struct VirtAcpiState { SysBusDevice parent_obj; MemHotplugState memhp_state; hwaddr memhp_base; + void *gsi; + hwaddr ged_base; + GEDState ged_state; + uint32_t ged_irq; + void *ged_events; + uint32_t ged_events_size; } VirtAcpiState; +void build_ged_aml(Aml *table, const char* name, uint32_t ged_irq, + AmlRegionSpace rs); #endif From patchwork Thu Mar 21 10:47:45 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: 160767 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp642659jan; Thu, 21 Mar 2019 03:51:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4lfHZTQN3LOnmKLC/8afyJi56T8oqsAfviH7z9yLvjj0pu4hPNi0yz9hrHR20yqZcGpse X-Received: by 2002:a7b:c044:: with SMTP id u4mr2129349wmc.88.1553165478733; Thu, 21 Mar 2019 03:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553165478; cv=none; d=google.com; s=arc-20160816; b=odriIMzS/F7FPNUhKt9IEGRqq+nMo50oTEeLSVEvTNqt2J6JZ6+GMyv0COMxJJEVGb TLYZ36LQWjQ41OJEwNpNz20jfJBSji2aDoVrnJLSTpXrx9oD70L/rYcvO7gQTcvakprG 8aLpanVV8NWiEm5/LbmJAAn/Fz46wk5y6xPeIIfHPdCBekHVis1QkMvc7hn+97TJFpth nF+Ewky+UwxqnEKdfs9smgxsA/X144UonKh0uZ3vcTp0O928cPTuKm11JwrP73rECKRt ODYXIR1ZtrlBxQIVZd2+OFRZkU6pDpyXcncsZLqx2YCwEqokE/ybrGN1SwTYJ5BuJLBK BIMg== 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=T/Q6MmbhocyMMOA5IHbrtSV35RsnEDOVPA5pXAO8Kxg=; b=J72v9YSWdbIrpBfXdVinHMnMaLIghW8QixjFGdjvWKKPSF4AYCjMSY4GLJ0Ml6qLhz Kwpm/Z75X/YTKy4mMBVvYz3eeQINfRBl4dORvVP8M3RdcrgZzqc766MX2I/AcJI4tgrY EE2+gU55bUmUM0nFo1rmJTK4LHesgCmKumZLYBQCoLJFzxiI0phmuhacMbDZmFfvubMd IuPlIECliUJq9ZGHfnZxwdgProhJopQehHUxgwxfhF8FOq0mr1tM0/ngUs3y4GnteI3k AXTLOl8eiWzahxlUGUVy/4jaWt3ydrYMQyH2dDY5Xflg/91oNvNexNRVenqvi2FqrkfG GPWA== 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 j9si514825wrs.321.2019.03.21.03.51.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Mar 2019 03:51: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 ([127.0.0.1]:34691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vHu-0004Pz-8Z for patch@linaro.org; Thu, 21 Mar 2019 06:51:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6vHR-0004Og-Dr for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:50:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6vGE-0003cV-Q9 for qemu-devel@nongnu.org; Thu, 21 Mar 2019 06:49:24 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2198 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6vGC-0003RE-9s; Thu, 21 Mar 2019 06:49:21 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id DF16CF2C21D2748F327F; Thu, 21 Mar 2019 18:49:17 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Thu, 21 Mar 2019 18:49:10 +0800 From: Shameer Kolothum To: , , , , , , , Date: Thu, 21 Mar 2019 10:47:45 +0000 Message-ID: <20190321104745.28068-11-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190321104745.28068-1-shameerali.kolothum.thodi@huawei.com> References: <20190321104745.28068-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 v3 10/10] hw/arm/virt: Init GED device 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" This initializes the GED device with base memory and irq, configures ged memory hotplug event and builds the corresponding aml code. GED irq routing to Guest is also enabled. Memory hotplug should now work. Signed-off-by: Shameer Kolothum --- hw/acpi/generic_event_device.c | 18 ++++++++++++++++++ hw/arm/virt-acpi-build.c | 9 +++++++++ hw/arm/virt.c | 30 +++++++++++++++++++++++++----- include/hw/arm/virt.h | 2 ++ 4 files changed, 54 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 9deaa33..02d5e66 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -200,6 +200,23 @@ static void acpi_ged_event(GEDState *ged_st, uint32_t ged_irq_sel) qemu_irq_pulse(ged_st->gsi[ged_st->irq]); } +static void acpi_ged_init(MemoryRegion *as, DeviceState *dev, GEDState *ged_st) +{ + VirtAcpiState *s = VIRT_ACPI(dev); + + assert(!ged_io_base && !ged_events && !ged_events_size); + + ged_io_base = s->ged_base; + ged_events = s->ged_events; + ged_events_size = s->ged_events_size; + ged_st->irq = s->ged_irq; + ged_st->gsi = s->gsi; + qemu_mutex_init(&ged_st->lock); + memory_region_init_io(&ged_st->io, OBJECT(dev), &ged_ops, ged_st, + "acpi-ged-event", ACPI_GED_REG_LEN); + memory_region_add_subregion(as, ged_io_base, &ged_st->io); +} + static void virt_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -242,6 +259,7 @@ static void virt_device_realize(DeviceState *dev, Error **errp) 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); } } diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 1887531..116e9c9 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -41,6 +41,7 @@ #include "hw/hw.h" #include "hw/acpi/aml-build.h" #include "hw/acpi/memory_hotplug.h" +#include "hw/acpi/generic_event_device.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/arm/virt.h" @@ -50,6 +51,13 @@ #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; + + build_ged_aml(scope, "\\_SB."GED_DEVICE, irq, AML_SYSTEM_MEMORY); +} + static void acpi_dsdt_add_memory_hotplug(Aml *scope, MachineState *ms) { uint32_t nr_mem = ms->ram_slots; @@ -758,6 +766,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.c b/hw/arm/virt.c index b602151..e3f8aa7 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -63,6 +63,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, \ @@ -134,6 +135,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 +171,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 +187,13 @@ static const char *valid_cpus[] = { ARM_CPU_TYPE_NAME("max"), }; +static GedEvent ged_events[] = { + { + .selector = ACPI_GED_IRQ_SEL_MEM, + .event = GED_MEMORY_HOTPLUG, + }, +}; + static bool cpu_type_valid(const char *cpu) { int i; @@ -524,6 +534,11 @@ static DeviceState *create_virt_acpi(VirtMachineState *vms) dev = qdev_create(NULL, "virt-acpi"); qdev_prop_set_uint64(dev, "memhp_base", vms->memmap[VIRT_PCDIMM_ACPI].base); + qdev_prop_set_ptr(dev, "gsi", vms->gsi); + qdev_prop_set_uint64(dev, "ged_base", vms->memmap[VIRT_ACPI_GED].base); + qdev_prop_set_uint32(dev, "ged_irq", vms->irqmap[VIRT_ACPI_GED]); + qdev_prop_set_ptr(dev, "ged_events", ged_events); + qdev_prop_set_uint32(dev, "ged_events_size", ARRAY_SIZE(ged_events)); qdev_init_nofail(dev); return dev; @@ -568,6 +583,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 */ @@ -683,6 +704,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) { @@ -1431,7 +1454,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; @@ -1627,6 +1650,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); @@ -1842,10 +1866,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 14b2e0a..850296a 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -78,6 +78,7 @@ enum { VIRT_SECURE_UART, VIRT_SECURE_MEM, VIRT_PCDIMM_ACPI, + VIRT_ACPI_GED, VIRT_LOWMEMMAP_LAST, }; @@ -135,6 +136,7 @@ typedef struct { int psci_conduit; hwaddr highest_gpa; DeviceState *acpi; + qemu_irq *gsi; } VirtMachineState; #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)