From patchwork Tue Aug 13 21:05:28 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: 171211 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1396814ily; Tue, 13 Aug 2019 14:08:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0fy5wT5bvTW/+C2xzghO+G/j7qUqa1LC3J/Z5WedUh8AKza/eU6FDwnFHvN1sD+SdBwU9 X-Received: by 2002:a50:9999:: with SMTP id m25mr44669090edb.183.1565730524743; Tue, 13 Aug 2019 14:08:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565730524; cv=none; d=google.com; s=arc-20160816; b=0oZ1KQuPrn0Nb+EX1cSyvq0R2Sy9fZZGSy05fXDVyH+XG2HMEB2wSkWKxfUhp7Bm41 KZcapv8SBTp/2ORCSZoQsqTEHNtFYpTmoCnPXshGIQLxvQuSXHC6pRk5IPa2RGZjmYz3 tV8RmYoSSOBdYXFnnKogiyUzO9yKWMGrRP21sDrW13vR2dE2IL5sO9qhHbvv+V8M5Bcf I1tZgr8We0MkhYTofhxicdCrkdD+sYgMV/N2roCx9jCDJLNTi9dqy/dthXznXKz8KsfT mDWbORXkIuyTMQQF2XbIfpzueOlYzjCsNaBa9w6U3FJKHg5WKzmy7rJXsnryo/ej+74k a2Ug== 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=KOaBbheiXegr9n05bHIw34hEbIwBv9xvZKRMYUeQ0UA=; b=AfAQv70cLLGH7aV3Rx62XiIOQ81F7101WbuF9CHxVBHfYvS3KYbev0ATRpeouBdahj sOt7x39PVCLNpp8sYogQlDzdCWTptLypV6Z3kNNNj1xI/xjiYbXt/Oe54/YcXZdjh0vc toww7Z3VGGE3e51YKc29ZG434fSglRG8P9d9j3+dP5Slt4C/2PU2l6ROPNdzWJ+LnzBr gdUcSSYGZX8c73a7hU8DhG9wS6hk6TWQU/KlM+iwaClEILNSZutV+JzwI/swE2k2lBnr ROu02h3mtDG/glO98WKzhf/6NeJpmK7R1O1nkiUML+dLZgawj2GnHVRb8FxJJqsdo3+B uW0A== 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 f11si5887638ejt.373.2019.08.13.14.08.44 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2019 14:08:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:55458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe27-0004gK-Oo for patch@linaro.org; Tue, 13 Aug 2019 17:08:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41623) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe0q-0004c5-Op for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe0p-00012c-F6 for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:24 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2251 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe0l-0000tW-Mh; Tue, 13 Aug 2019 17:07:20 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id CFB2BDBBB1A785A531F5; Wed, 14 Aug 2019 05:07:16 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:06 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:28 +0100 Message-ID: <20190813210539.31164-2-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.191 Subject: [Qemu-devel] [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space configurable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is in preparation for adding support for ARM64 platforms where it doesn't use port mapped IO for ACPI IO space. We are making changes so that MMIO region can be accommodated and board can pass the base address into the aml build function. Also move few MEMORY_* definitions to header so that other memory hotplug event signalling mechanisms (eg. Generic Event Device on HW-reduced acpi platforms) can use the same from their respective event handler code. Signed-off-by: Shameer Kolothum --- v8 --> v9 -base address is an input into build_memory_hotplug_aml() -Removed R-by tags from Igor and Eric for now. --- hw/acpi/memory_hotplug.c | 29 ++++++++++++++--------------- hw/i386/acpi-build.c | 4 +++- hw/i386/pc.c | 3 +++ include/hw/acpi/memory_hotplug.h | 9 +++++++-- include/hw/i386/pc.h | 3 +++ 5 files changed, 30 insertions(+), 18 deletions(-) -- 2.17.1 Reviewed-by: Eric Auger diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 297812d5f7..1734d4b44f 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -29,12 +29,7 @@ #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) { @@ -209,7 +204,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()); @@ -218,12 +213,10 @@ void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, return; } - assert(!memhp_io_base); - memhp_io_base = io_base; state->devs = g_malloc0(sizeof(*state->devs) * state->dev_count); memory_region_init_io(&state->io, owner, &acpi_memory_hotplug_ops, state, "acpi-mem-hotplug", MEMORY_HOTPLUG_IO_LEN); - memory_region_add_subregion(as, memhp_io_base, &state->io); + memory_region_add_subregion(as, io_base, &state->io); } /** @@ -342,7 +335,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, hwaddr memhp_io_base) { int i; Aml *ifctx; @@ -365,14 +359,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 f3fdfefcd5..e76d6631ea 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1871,7 +1871,9 @@ 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, + pcms->memhp_io_base); scope = aml_scope("_GPE"); { diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 549c437050..be973cea99 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1936,6 +1936,9 @@ void pc_memory_init(PCMachineState *pcms, /* Init default IOAPIC address space */ pcms->ioapic_as = &address_space_memory; + + /* Init ACPI memory hotplug IO base address */ + pcms->memhp_io_base = ACPI_MEMORY_HOTPLUG_BASE; } /* diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h index 77c65765d6..dfe9cf3fde 100644 --- a/include/hw/acpi/memory_hotplug.h +++ b/include/hw/acpi/memory_hotplug.h @@ -5,6 +5,10 @@ #include "hw/acpi/acpi.h" #include "hw/acpi/aml-build.h" +#define MEMORY_SLOT_SCAN_METHOD "MSCN" +#define MEMORY_DEVICES_CONTAINER "\\_SB.MHPC" +#define MEMORY_HOTPLUG_IO_LEN 24 + /** * MemStatus: * @is_removing: the memory device in slot has been requested to be ejected. @@ -29,7 +33,7 @@ typedef struct MemHotplugState { } MemHotplugState; void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, - MemHotplugState *state, uint16_t io_base); + MemHotplugState *state, hwaddr io_base); void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st, DeviceState *dev, Error **errp); @@ -48,5 +52,6 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list); void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, const char *res_root, - const char *event_handler_method); + const char *event_handler_method, + AmlRegionSpace rs, hwaddr memhp_io_base); #endif diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 859b64c51d..49b47535cf 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -69,6 +69,9 @@ struct PCMachineState { /* Address space used by IOAPIC device. All IOAPIC interrupts * will be translated to MSI messages in the address space. */ AddressSpace *ioapic_as; + + /* ACPI Memory hotplug IO base address */ + hwaddr memhp_io_base; }; #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device" From patchwork Tue Aug 13 21:05:29 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: 171212 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1396985ily; Tue, 13 Aug 2019 14:08:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZSClV9CjHui2NwZHmiDOHgpi48pucjtBZXjqKpk4Fd2RBc26B3qYoAdtI+I672qU1B5GR X-Received: by 2002:a17:906:158c:: with SMTP id k12mr38048645ejd.83.1565730535823; Tue, 13 Aug 2019 14:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565730535; cv=none; d=google.com; s=arc-20160816; b=DX0pOjSaDrtITjadPNxxRWheenmV8lMeHpCzk5rwu7zl/SZ8BUQtJQp2Ut/8HqYjWt VGxCmhO43eLiSaAnsl3D+5IPth0IfQjWU/2X9qQUD5vinP9EySJuUruWPSzvSbowdoJl 9WtTYXgiFiVHuoU729/VgZXkcxqQzOfdU05tv+qY4NXpvwbMDCn21FKNtNW7IxogdqKC OIy5FbxMGoVVYLA6dqkf6bnSA59XzB1PciNY7W3NiF+npltbHGCbY1UXmzcxYmMLjv0V 6+Mbh+ygpzxnxlen7SlcMvzQ8m3vYr78TaofVEa20jw9DrYZTnz/P23oXUe2Z6/+U1zI u+0Q== 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=Mr1ezuKYoxi9xD3uOq/jX8oVxNnNpcd1PW9SAOmoapY=; b=oxsdnB12sK3Yh4EIQZAKpU6dq/KaAL3Ouqz1rdlrsKCHMNl2WpOAg4OYHyuZnqQrgL fttVycuXH0DeJG6Qx8RLTcWEXR9Y/Fs3o84wmwICkXjM2XwjMvQLOMi6idXzEPr6XvFu OZfRr9F2p9iqhdrxPOQT1uWAs6Qu5rTCIcVgAUPwOwgF6/Y0Z2lc1ZhP1xZjt2VElAbT bf0iwxUYZL479vav1XYMJjh8M2pDZJiuOsgkfInSHmCsAzDSepzQ58wioRSEb+lcjm1j tthvuNxRoPOPgmTLDZDZ3GsDKZC01l+KrTfKTfzDwZx5Vg+V3OgEjfl/kVuLV3A9sFWw oNzQ== 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 c30si4526742ejj.214.2019.08.13.14.08.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2019 14:08:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:55468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe2I-0005PS-R9 for patch@linaro.org; Tue, 13 Aug 2019 17:08:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41602) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe0o-0004Zd-P8 for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe0n-00010e-TY for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:22 -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 1hxe0l-0000tZ-Fm; Tue, 13 Aug 2019 17:07:19 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id D986516219B64C76B000; Wed, 14 Aug 2019 05:07:16 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:10 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:29 +0100 Message-ID: <20190813210539.31164-3-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.191 Subject: [Qemu-devel] [PATCH-for-4.2 v9 02/12] hw/acpi: Do not create memory hotplug method when handler is not defined X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Samuel Ortiz With Hardware-reduced ACPI, the GED device will manage ACPI hotplug entirely. As a consequence, make the memory specific events AML generation optional. The code will only be added when the method name is not NULL. Signed-off-by: Samuel Ortiz Signed-off-by: Shameer Kolothum Reviewed-by: Eric Auger Reviewed-by: Igor Mammedov --- hw/acpi/memory_hotplug.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 1734d4b44f..552f60a716 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -715,10 +715,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, } aml_append(table, dev_container); - method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED); - aml_append(method, - aml_call0(MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD)); - aml_append(table, method); + if (event_handler_method) { + method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED); + aml_append(method, aml_call0(MEMORY_DEVICES_CONTAINER "." + MEMORY_SLOT_SCAN_METHOD)); + aml_append(table, method); + } g_free(mhp_res_path); } From patchwork Tue Aug 13 21:05:30 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: 171215 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1399253ily; Tue, 13 Aug 2019 14:11:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqi/ocZo5ka9pCc42CkbbXVvLX5LIwtRVdawuIPesRjHVy2eNPVC9mTyZDUGrK/vA65HOY X-Received: by 2002:a05:620a:7cc:: with SMTP id 12mr14037053qkb.64.1565730679383; Tue, 13 Aug 2019 14:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565730679; cv=none; d=google.com; s=arc-20160816; b=jionFmLj46BuOG5dZ539927ju0P7G1OeWFRSnu5R0YmlhGV1SR45wM7DKLArK0c4aa yA8D1LDXCb6n5J5Nth9vwvrhUEHOq3Ugpr1whqxLxQeWaUhjbrYDcU3ZGn7lLPEb93pV mAajed47LNQSwC2V4Dxv4BpmTh/+CwuyjVcDkG9kjzd/939jS9QjM0xthiLjfXMa3hxz pmevmgHmyYnRpjS/3WG8cOMObrXUcHChwiyJVg7r32vETLPNKUfMnuEbCT4Ku4+GnGie tlTW3oL51DsA9NW97s8jNjpc3wXK0yrfaXp4j4rlAWm9cdku9vv/GzFT9OyChKic7daX riyw== 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=OMZxs+LbxpFFds/GUwN2lu/gGYfT8nBRCsDJhMLjD/E=; b=n6Qd7cbfeI7HrRbM//PkKgjSuRoaX2vxvAvaWGHp8laGIZ9DtRGs531x13JcksXoPC CrGDcCEyGvSgE3H8zGdS8amrR9xF7lwoVvGmLKN0NObUP8oDYLos5cVV+y4h8PaG9TVU Y9Cvq9xKLmAqba4+6rinTXkZYWbKGuoa/yNafWyO6p1bQfjyaL9nRVOV9l0JkuzngBSY XKFyPzNQLzdxWFlduaCKH5wyzwQi2ikWchgD/z7BnQ5aAEb33dp4G7gjVCllE/1o0hzO +KF1COtaKvQe6x7GucMgkpWEs4zNaGsOzBmnBCmZCnqtx9ANbiXWCbRr8TIuJSmyscqX tm4A== 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 o13si66596213qve.145.2019.08.13.14.11.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2019 14:11:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:55488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe4c-000058-UF for patch@linaro.org; Tue, 13 Aug 2019 17:11:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41671) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe0x-0004s4-PZ for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe0v-0001A6-KV for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:31 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33344 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe0q-00010y-O9; Tue, 13 Aug 2019 17:07:25 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 8E539D6B25135C5F72ED; Wed, 14 Aug 2019 05:07:21 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:13 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:30 +0100 Message-ID: <20190813210539.31164-4-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH-for-4.2 v9 03/12] hw/acpi: Add ACPI Generic Event Device Support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Samuel Ortiz The ACPI Generic Event Device (GED) is a hardware-reduced specific device[ACPI v6.1 Section 5.6.9] that handles all platform events, including the hotplug ones. This patch generates the AML code that defines GEDs. Platforms need to specify their own GED Event bitmap to describe what kind of events they want to support through GED. Also this uses a a single interrupt for the GED device, relying on IO memory region to communicate the type of device affected by the interrupt. This way, we can support up to 32 events with a unique interrupt. This supports only memory hotplug for now. Signed-off-by: Samuel Ortiz Signed-off-by: Sebastien Boeuf Signed-off-by: Shameer Kolothum --- v8 --> v9 -Changes related to GED being a TYPE_SYS_BUS_DEVICE now. -Removed Eric's R-by tag for now. v7 --> v8. -Removed qemu_mutex_lock() across the ged state selector access. -Rephrased comments section in acpi_ged_send_event(). -Moved acpi_ged_event() code into acpi_ged_send_event(). -Added check for memhp_base and ged_base in realize(). --- hw/acpi/Kconfig | 4 + hw/acpi/Makefile.objs | 1 + hw/acpi/generic_event_device.c | 316 +++++++++++++++++++++++++ include/hw/acpi/generic_event_device.h | 100 ++++++++ 4 files changed, 421 insertions(+) create mode 100644 hw/acpi/generic_event_device.c create mode 100644 include/hw/acpi/generic_event_device.h -- 2.17.1 Reviewed-by: Eric Auger diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig index 7c59cf900b..12e3f1e86e 100644 --- a/hw/acpi/Kconfig +++ b/hw/acpi/Kconfig @@ -31,3 +31,7 @@ config ACPI_VMGENID bool default y depends on PC + +config ACPI_HW_REDUCED + bool + depends on ACPI diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs index 9bb2101e3b..655a9c1973 100644 --- a/hw/acpi/Makefile.objs +++ b/hw/acpi/Makefile.objs @@ -6,6 +6,7 @@ common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu.o common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o common-obj-$(CONFIG_ACPI_VMGENID) += vmgenid.o +common-obj-$(CONFIG_ACPI_HW_REDUCED) += generic_event_device.o common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o common-obj-y += acpi_interface.o diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c new file mode 100644 index 0000000000..f4c23470c2 --- /dev/null +++ b/hw/acpi/generic_event_device.c @@ -0,0 +1,316 @@ +/* + * + * Copyright (c) 2018 Intel Corporation + * Copyright (c) 2019 Huawei Technologies R & D (UK) Ltd + * Written by Samuel Ortiz, Shameer Kolothum + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "exec/address-spaces.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/generic_event_device.h" +#include "hw/mem/pc-dimm.h" +#include "qemu/error-report.h" + +static const uint32_t ged_supported_events[] = { + ACPI_GED_MEM_HOTPLUG_EVT, +}; + +/* + * The ACPI Generic Event Device (GED) is a hardware-reduced specific + * device[ACPI v6.1 Section 5.6.9] that handles all platform events, + * including the hotplug ones. Platforms need to specify their own + * GED Event bitmap to describe what kind of events they want to support + * through GED. This routine uses a single interrupt for the GED device, + * relying on IO memory region to communicate the type of device + * affected by the interrupt. This way, we can support up to 32 events + * with a unique interrupt. + */ +void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev, + uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base) +{ + AcpiGedState *s = ACPI_GED(hotplug_dev); + Aml *crs = aml_resource_template(); + Aml *evt, *field; + Aml *dev = aml_device("%s", name); + Aml *evt_sel = aml_local(0); + Aml *esel = aml_name(AML_GED_EVT_SEL); + + assert(ged_base); + + /* _CRS interrupt */ + aml_append(crs, aml_interrupt(AML_CONSUMER, AML_EDGE, AML_ACTIVE_HIGH, + AML_EXCLUSIVE, &ged_irq, 1)); + + aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0013"))); + aml_append(dev, aml_name_decl("_UID", aml_string(GED_DEVICE))); + aml_append(dev, aml_name_decl("_CRS", crs)); + + /* Append IO region */ + aml_append(dev, aml_operation_region(AML_GED_EVT_REG, rs, + aml_int(ged_base + ACPI_GED_EVT_SEL_OFFSET), + ACPI_GED_EVT_SEL_LEN)); + field = aml_field(AML_GED_EVT_REG, AML_DWORD_ACC, AML_NOLOCK, + AML_WRITE_AS_ZEROS); + aml_append(field, aml_named_field(AML_GED_EVT_SEL, + ACPI_GED_EVT_SEL_LEN * BITS_PER_BYTE)); + aml_append(dev, field); + + /* + * For each GED event we: + * - Add a conditional block for each event, inside a loop. + * - Call a method for each supported GED event type. + * + * The resulting ASL code looks like: + * + * Local0 = ESEL + * If ((Local0 & One) == One) + * { + * MethodEvent0() + * } + * + * If ((Local0 & 0x2) == 0x2) + * { + * MethodEvent1() + * } + * ... + */ + evt = aml_method("_EVT", 1, AML_SERIALIZED); + { + Aml *if_ctx; + uint32_t i; + uint32_t ged_events = ctpop32(s->ged_event_bitmap); + + /* Local0 = ESEL */ + aml_append(evt, aml_store(esel, evt_sel)); + + for (i = 0; i < ARRAY_SIZE(ged_supported_events) && ged_events; i++) { + uint32_t event = s->ged_event_bitmap & ged_supported_events[i]; + + if (!event) { + continue; + } + + if_ctx = aml_if(aml_equal(aml_and(evt_sel, aml_int(event), NULL), + aml_int(event))); + switch (event) { + case ACPI_GED_MEM_HOTPLUG_EVT: + aml_append(if_ctx, aml_call0(MEMORY_DEVICES_CONTAINER "." + MEMORY_SLOT_SCAN_METHOD)); + break; + default: + /* + * Please make sure all the events in ged_supported_events[] + * are handled above. + */ + g_assert_not_reached(); + } + + aml_append(evt, if_ctx); + ged_events--; + } + + if (ged_events) { + error_report("Unsupported events specified"); + abort(); + } + } + + /* Append _EVT method */ + aml_append(dev, evt); + + aml_append(table, dev); +} + +/* Memory read by the GED _EVT AML dynamic method */ +static uint64_t ged_read(void *opaque, hwaddr addr, unsigned size) +{ + uint64_t val = 0; + GEDState *ged_st = opaque; + + switch (addr) { + case ACPI_GED_EVT_SEL_OFFSET: + /* Read the selector value and reset it */ + val = ged_st->sel; + ged_st->sel = 0; + break; + default: + break; + } + + return val; +} + +/* Nothing is expected to be written to the GED memory region */ +static void ged_write(void *opaque, hwaddr addr, uint64_t data, + unsigned int size) +{ +} + +static const MemoryRegionOps ged_ops = { + .read = ged_read, + .write = ged_write, + .endianness = DEVICE_LITTLE_ENDIAN, + .valid = { + .min_access_size = 4, + .max_access_size = 4, + }, +}; + +static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + AcpiGedState *s = ACPI_GED(hotplug_dev); + + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + if (s->memhp_state.is_enabled) { + acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp); + } else { + error_setg(errp, + "memory hotplug is not enabled: %s.memory-hotplug-support " + "is not set", object_get_typename(OBJECT(s))); + } + } else { + error_setg(errp, "virt: device plug request for unsupported device" + " type: %s", object_get_typename(OBJECT(dev))); + } +} + +static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev) +{ + AcpiGedState *s = ACPI_GED(adev); + GEDState *ged_st = &s->ged_state; + uint32_t sel; + + if (ev & ACPI_MEMORY_HOTPLUG_STATUS) { + sel = ACPI_GED_MEM_HOTPLUG_EVT; + } else { + /* Unknown event. Return without generating interrupt. */ + warn_report("GED: Unsupported event %d. No irq injected", ev); + return; + } + + /* + * Set the GED selector field to communicate the event type. + * This will be read by GED aml code to select the appropriate + * event method. + */ + ged_st->sel |= sel; + + /* Trigger the event by sending an interrupt to the guest. */ + qemu_irq_pulse(s->irq); +} + +static void acpi_ged_device_realize(DeviceState *dev, Error **errp) +{ + AcpiGedState *s = ACPI_GED(dev); + GEDState *ged_st = &s->ged_state; + + memory_region_init_io(&ged_st->io, OBJECT(dev), &ged_ops, ged_st, + TYPE_ACPI_GED, ACPI_GED_EVT_SEL_LEN); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &ged_st->io); + + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); + + if (s->memhp_state.is_enabled) { + /* + * GED handles memory hotplug event and acpi-mem-hotplug + * memory region gets initialized here. Create an exclusive + * container for memory hotplug IO and expose it as GED sysbus + * MMIO so that boards can map it separately. + */ + memory_region_init(&s->container_memhp, OBJECT(dev), "container", + MEMORY_HOTPLUG_IO_LEN); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->container_memhp); + acpi_memory_hotplug_init(&s->container_memhp, OBJECT(dev), + &s->memhp_state, 0); + } +} + +static Property acpi_ged_properties[] = { + DEFINE_PROP_BOOL("memory-hotplug-support", AcpiGedState, + memhp_state.is_enabled, true), + DEFINE_PROP_UINT32("ged-event", AcpiGedState, ged_event_bitmap, 0), + DEFINE_PROP_END_OF_LIST(), +}; + +static bool vmstate_test_use_memhp(void *opaque) +{ + AcpiGedState *s = opaque; + return s->memhp_state.is_enabled; +} + +static const VMStateDescription vmstate_memhp_state = { + .name = "acpi-ged/memhp", + .version_id = 1, + .minimum_version_id = 1, + .needed = vmstate_test_use_memhp, + .fields = (VMStateField[]) { + VMSTATE_MEMORY_HOTPLUG(memhp_state, AcpiGedState), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_ged_state = { + .name = "acpi-ged-state", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT32(sel, GEDState), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_acpi_ged = { + .name = "acpi-ged", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_STRUCT(ged_state, AcpiGedState, 1, vmstate_ged_state, GEDState), + VMSTATE_END_OF_LIST(), + }, + .subsections = (const VMStateDescription * []) { + &vmstate_memhp_state, + NULL + } +}; + +static void acpi_ged_class_init(ObjectClass *class, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(class); + HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(class); + AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_CLASS(class); + + dc->desc = "ACPI Generic Event Device"; + dc->props = acpi_ged_properties; + dc->realize = acpi_ged_device_realize; + dc->vmsd = &vmstate_acpi_ged; + + hc->plug = acpi_ged_device_plug_cb; + + adevc->send_event = acpi_ged_send_event; +} + +static const TypeInfo acpi_ged_info = { + .name = TYPE_ACPI_GED, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(AcpiGedState), + .class_init = acpi_ged_class_init, + .interfaces = (InterfaceInfo[]) { + { TYPE_HOTPLUG_HANDLER }, + { TYPE_ACPI_DEVICE_IF }, + { } + } +}; + +static void acpi_ged_register_types(void) +{ + type_register_static(&acpi_ged_info); +} + +type_init(acpi_ged_register_types) diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h new file mode 100644 index 0000000000..2049e8d873 --- /dev/null +++ b/include/hw/acpi/generic_event_device.h @@ -0,0 +1,100 @@ +/* + * + * Copyright (c) 2018 Intel Corporation + * Copyright (c) 2019 Huawei Technologies R & D (UK) Ltd + * Written by Samuel Ortiz, Shameer Kolothum + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * The ACPI Generic Event Device (GED) is a hardware-reduced specific + * device[ACPI v6.1 Section 5.6.9] that handles all platform events, + * including the hotplug ones. Generic Event Device allows platforms + * to handle interrupts in ACPI ASL statements. It follows a very + * similar approach like the _EVT method from GPIO events. All + * interrupts are listed in _CRS and the handler is written in _EVT + * method. Here, we use a single interrupt for the GED device, relying + * on IO memory region to communicate the type of device affected by + * the interrupt. This way, we can support up to 32 events with a + * unique interrupt. + * + * Here is an example. + * + * Device (\_SB.GED) + * { + * Name (_HID, "ACPI0013") + * Name (_UID, Zero) + * Name (_CRS, ResourceTemplate () + * { + * Interrupt (ResourceConsumer, Edge, ActiveHigh, Exclusive, ,, ) + * { + * 0x00000029, + * } + * }) + * OperationRegion (EREG, SystemMemory, 0x09080000, 0x04) + * Field (EREG, DWordAcc, NoLock, WriteAsZeros) + * { + * ESEL, 32 + * } + * + * Method (_EVT, 1, Serialized) // _EVT: Event + * { + * Local0 = ESEL // ESEL = IO memory region which specifies the + * // device type. + * If (((Local0 & One) == One)) + * { + * MethodEvent1() + * } + * If ((Local0 & 0x2) == 0x2) + * { + * MethodEvent2() + * } + * ... + * } + * } + * + */ + +#ifndef HW_ACPI_GED_H +#define HW_ACPI_GED_H + +#include "hw/sysbus.h" +#include "hw/acpi/memory_hotplug.h" + +#define TYPE_ACPI_GED "acpi-ged" +#define ACPI_GED(obj) \ + OBJECT_CHECK(AcpiGedState, (obj), TYPE_ACPI_GED) + +#define ACPI_GED_EVT_SEL_OFFSET 0x0 +#define ACPI_GED_EVT_SEL_LEN 0x4 + +#define GED_DEVICE "GED" +#define AML_GED_EVT_REG "EREG" +#define AML_GED_EVT_SEL "ESEL" + +/* + * Platforms need to specify the GED event bitmap + * to describe what kind of events they want to support + * through GED. + */ +#define ACPI_GED_MEM_HOTPLUG_EVT 0x1 + +typedef struct GEDState { + MemoryRegion io; + uint32_t sel; +} GEDState; + +typedef struct AcpiGedState { + SysBusDevice parent_obj; + MemHotplugState memhp_state; + MemoryRegion container_memhp; + GEDState ged_state; + uint32_t ged_event_bitmap; + qemu_irq irq; +} AcpiGedState; + +void build_ged_aml(Aml *table, const char* name, HotplugHandler *hotplug_dev, + uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base); + +#endif From patchwork Tue Aug 13 21:05:31 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: 171210 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1396615ily; Tue, 13 Aug 2019 14:08:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0gRN74fkcRh8/a5/kmoy9F/Tg/wSS3CJJYUB2BfrorXexo7kU2pScE/3ryQ6y1hoTwW6V X-Received: by 2002:a17:906:bcf5:: with SMTP id op21mr23319454ejb.190.1565730512775; Tue, 13 Aug 2019 14:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565730512; cv=none; d=google.com; s=arc-20160816; b=xel8GmQnhTSEz2EtzW2CIvEXcGdb0or0uMKRWUcMqp/QsyMUQCG9VMG2MK23rI9sNc XnbIXgB5s1XQPJLCSiPY6IPKKLbi7eQF6XF3k2vtdyYGkYsNmxkkqmxHsqWT2git1ouh cmsA2jregLULKYWKzv5wUgMW8Z8Oox+PIkIjWbwdQ0x3Q7hMj9m2IhIO4zuuCu4Ok4Qz etbELPLXPF4Hvn3eTTKVdx/ThX95OkKltS7PrdY73IEOBNEz3X52X2/92ics8X7h6OyP jMwTI/3gEV0J7lhe5SyPnHphOpfAMS3xkdFUFlQkzOgAMdWKYWg11kzeIGfqoOKg/o+o eAfg== 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=X2YPILbyafHd6ejeqAe7nqDLxe78CklcYHCBmUkx44o=; b=mpGwWqwijA7gtkH2nT0qt2jwe3jEPsQmT9FnEBIhsuhXyhO+Y1NgVobTeOlXbuk2ZH OkJ/QqworpAMxkMgouhREpGcZO+50h0DDs7aGjmqxQTK4lt0KezbPSbdJN0CjCuU+fro XJYxQPEOJhue9Tewds5tr4P6IurC/Z+wVnr0zUwdzCFoUcbLyfm8ADiWZtW/lnAJCxXt wqfihUCZgS31nXMRhbULpZucf/w53Vx8io0M32TtWYMkgROuropjoVFJ1dlnyq0RRlho ays187xIse6v11SMf013uVobwigKBvKz70Eth+pg/dUvi9yFHZbAU36/phvgWZ8jQuFb Wg9g== 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 w26si3124344ejb.334.2019.08.13.14.08.32 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2019 14:08:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:55466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe1v-0004vN-Os for patch@linaro.org; Tue, 13 Aug 2019 17:08:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41678) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe0z-0004t4-63 for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe0x-0001Bn-On for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:32 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2186 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe0u-00016N-Nf; Tue, 13 Aug 2019 17:07:29 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D6296777F7D2255294D1; Wed, 14 Aug 2019 05:07:26 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:17 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:31 +0100 Message-ID: <20190813210539.31164-5-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.190 Subject: [Qemu-devel] [PATCH-for-4.2 v9 04/12] hw/arm/virt: Add memory hotplug framework X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Eric Auger This patch adds the memory hot-plug/hot-unplug infrastructure in machvirt. The device memory is not yet exposed to the Guest either through DT or ACPI and hence both cold/hot plug of memory is explicitly disabled for now. Signed-off-by: Eric Auger Signed-off-by: Kwangwoo Lee Signed-off-by: Shameer Kolothum Reviewed-by: Peter Maydell Reviewed-by: Igor Mammedov --- v8 --> v9 -Added error propagation. --- hw/arm/Kconfig | 2 ++ hw/arm/virt.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index ab65ecd216..84961c17ab 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -20,6 +20,8 @@ config ARM_VIRT select SMBIOS select VIRTIO_MMIO select ACPI_PCI + select MEM_DEVICE + select DIMM config CHEETAH bool diff --git a/hw/arm/virt.c b/hw/arm/virt.c index d9496c9363..72cde9deba 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -64,6 +64,8 @@ #include "hw/arm/smmuv3.h" #include "hw/acpi/acpi.h" #include "target/arm/internals.h" +#include "hw/mem/pc-dimm.h" +#include "hw/mem/nvdimm.h" #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -1871,6 +1873,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) +{ + + /* + * The device memory is not yet exposed to the Guest either through + * DT or ACPI and hence both cold/hot plug of memory is explicitly + * disabled for now. + */ + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + error_setg(errp, "memory cold/hot plug is not yet supported"); + return; + } + + pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), NULL, errp); +} + +static void virt_memory_plug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); + 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) { @@ -1882,12 +1920,23 @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, SYS_BUS_DEVICE(dev)); } } + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + virt_memory_plug(hotplug_dev, dev, errp); + } +} + +static void virt_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + error_setg(errp, "device unplug request for unsupported device" + " type: %s", object_get_typename(OBJECT(dev))); } static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, DeviceState *dev) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE) || + (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) { return HOTPLUG_HANDLER(machine); } @@ -1951,7 +2000,9 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) mc->kvm_type = virt_kvm_type; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler = virt_machine_get_hotplug_handler; + hc->pre_plug = virt_machine_device_pre_plug_cb; hc->plug = virt_machine_device_plug_cb; + hc->unplug_request = virt_machine_device_unplug_request_cb; mc->numa_mem_supported = true; } From patchwork Tue Aug 13 21:05:32 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: 171220 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1400723ily; Tue, 13 Aug 2019 14:12:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6g8N/SoTFheElteOnrwnQIPZchMot5ztYin9rjv6vfUxsu1ieI+r5iZ061YhQLH5rIHL9 X-Received: by 2002:ac8:2f84:: with SMTP id l4mr35993323qta.55.1565730776813; Tue, 13 Aug 2019 14:12:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565730776; cv=none; d=google.com; s=arc-20160816; b=rxzian9YWqnGoRqiTr9/pZnps2Y0QSSG0EBwLWNOZz+h2uHudT7f3QiRgtXdoi+EQ2 9sH0ytGZI5g9lW14B2tBUR8G9K/4L62qzOZ86gbFATYtzHSH1jGCHyyd2aNsSBFSfs4m PgfBIIbxl3i8kA6Uk2KViUmKXKJJXCIFcMBLcaAPKHha3/RqTrlPdlTwcE6qFnIigqJ2 F+1ar41Wlr+wQBU2Mwy3ovWGBAyNdIsgx25I6Evig/xIYN9e4r52X+0GgpsjlaerbWML HbAVShUF7E2zKIW3MDSnQEcklLgd/LIWpiqznTk3p/QZwsIJupUL1fBnKKOeYs+vkR2V /3zg== 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=902FfrCE18fMMDnbH1AbjewyJewJhlr780PGsmnk3K4=; b=K0OuRLoM+7cAXPlojDjkFSxlW+bqhEzEu6MMndvhBnLuiJscP52UJottiupAMspfvZ FxisAoqbPVoZD++EsMluGuJ9iXTHxDpVU3eSLeK33uQygWYy63nUlDWVDOQKdfttiitf z70eqSXaQmhHI5rSQJZogMTt6FIRx8w9PwhGFZp+iSqIo+bxDW5cCU3KGWidCM4DhI9I kCdnj7rbk9iBRd4NDJb2N+VfEGD9J9xNJoc+dY0OQE2F3DBP1uKlUohPvK1aPO8fjYrD D1EqVqzPS7RoUOOhoZuSwjsrPusqKZDww3njt4LhdXnRSOxxIy/fgj0bwH536yD9Z1TN 3zFw== 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 h50si67495118qvh.86.2019.08.13.14.12.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2019 14:12:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:55524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe6C-0003yz-DW for patch@linaro.org; Tue, 13 Aug 2019 17:12:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41726) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe19-0004vQ-W3 for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe17-0001Kr-Vs for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:43 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33576 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe0z-0001CJ-Lm; Tue, 13 Aug 2019 17:07:34 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B3D2A16FBA25251D182D; Wed, 14 Aug 2019 05:07:31 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:21 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:32 +0100 Message-ID: <20190813210539.31164-6-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH-for-4.2 v9 05/12] hw/arm/virt: Add 4.2 machine type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is in preparation to create ACPI GED device as we need to disable it for <4.2 for migration to work. Signed-off-by: Shameer Kolothum Reviewed-by: Igor Mammedov --- hw/arm/virt.c | 9 ++++++++- hw/core/machine.c | 3 +++ include/hw/boards.h | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 72cde9deba..ef65e721d2 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2097,10 +2097,17 @@ static void machvirt_machine_init(void) } type_init(machvirt_machine_init); +static void virt_machine_4_2_options(MachineClass *mc) +{ +} +DEFINE_VIRT_MACHINE_AS_LATEST(4, 2) + static void virt_machine_4_1_options(MachineClass *mc) { + virt_machine_4_2_options(mc); + compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len); } -DEFINE_VIRT_MACHINE_AS_LATEST(4, 1) +DEFINE_VIRT_MACHINE(4, 1) static void virt_machine_4_0_options(MachineClass *mc) { diff --git a/hw/core/machine.c b/hw/core/machine.c index 32d1ca9abc..83cd1bfeec 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -27,6 +27,9 @@ #include "hw/pci/pci.h" #include "hw/mem/nvdimm.h" +GlobalProperty hw_compat_4_1[] = {}; +const size_t hw_compat_4_1_len = G_N_ELEMENTS(hw_compat_4_1); + GlobalProperty hw_compat_4_0[] = { { "VGA", "edid", "false" }, { "secondary-vga", "edid", "false" }, diff --git a/include/hw/boards.h b/include/hw/boards.h index a71d1a53a5..d9ec37d807 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -317,6 +317,9 @@ struct MachineState { } \ type_init(machine_initfn##_register_types) +extern GlobalProperty hw_compat_4_1[]; +extern const size_t hw_compat_4_1_len; + extern GlobalProperty hw_compat_4_0[]; extern const size_t hw_compat_4_0_len; From patchwork Tue Aug 13 21:05:33 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: 171213 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1397957ily; Tue, 13 Aug 2019 14:09:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxzlRzrNX5r+NDiE4BZNzQOgUw68b9gjQ7RO6CsqvgZpIszYs4TCZ9g5+auOgeFobXmWy6K X-Received: by 2002:a17:906:48da:: with SMTP id d26mr23713478ejt.106.1565730598810; Tue, 13 Aug 2019 14:09:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565730598; cv=none; d=google.com; s=arc-20160816; b=R+ZRsN5Iu9sWudkkexavk7Kj+7y417Q7Z7cRKkaiKb9H3AGjjiONEGljk7CwtWWuG5 ppLnWQwFPN1w2BgX6UKSbUX5rnQWm7HoFOE8QOd5rm0oZ12LeCUQlVVh4YgnEDqbM+R+ UyDSrR0okPesGpZGxZDnmI5qVw5pDzVd/r/+8P7OjNnrQa/toVcu2R6Qfxc7odKW+w5i IGVgb60iS9k8Y34TD2fTOMlT8VVPPFi+oGrsfoM33CxxxS4W7PrWBmTo23Ox0DtBzhvj Lec29sVutQxI9iGpqJ9JQ11fYUyMJ1XAujpsqsLJomcQt0tyU5Bz+9xUvQ9IRid8G8hB ORKw== 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=lDC5wxKEnbG+QmevK2jhJk5KcxHOOiburnLjAoG0e4s=; b=E2VYvPdmOP3qPejFEmM2yXe587WwgxO9w+Yf90RduFc3MPdcPnnxd+8RO3CP1swq73 AHzVsf63lY1AWl6eq1+atCzLCjkr4wtYqx/AQb8DJJbQzuatHNkoWpSg2jMP4nF7/oM+ Cw8y5d4zvX3IXrSrvzUK6Mhutci2CHHTIMLE6YyAc/8ivrauLn/43RihoCX1yITQL+wx Breev3QPi7z39g+4UJoLtOTVWzz4XjCvw4EhK4shFM8y4vR/ulaOXkxUcdepnVefws+R pXOj3LgS8zVNfDN/NzduXWfIBfDfcdcKAAKNNz3o8ptGq7Th1R87LN5u9F2ichCXGD0k uKUw== 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 w5si38789843ejj.399.2019.08.13.14.09.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2019 14:09:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:55474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe3J-0005uP-ML for patch@linaro.org; Tue, 13 Aug 2019 17:09:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41780) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe1C-0004xe-0a for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe1A-0001ND-Bm for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:45 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33570 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe0z-0001CL-PG; Tue, 13 Aug 2019 17:07:34 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id ABD28ED78EFA60630CCB; Wed, 14 Aug 2019 05:07:31 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:25 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:33 +0100 Message-ID: <20190813210539.31164-7-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH-for-4.2 v9 06/12] hw/arm/virt: Enable device memory cold/hot plug with ACPI boot X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This initializes the GED device with base memory and irq, configures ged memory hotplug event and builds the corresponding aml code. With this, both hot and cold plug of device memory is enabled now for Guest with ACPI boot. Memory cold plug support with Guest DT boot is not yet supported. Signed-off-by: Shameer Kolothum --- v8 --> v9 -Changes related to GED being a TYPE_SYS_BUS_DEVICE now. -Error propagation to _plug() handler. -Removed R-by by Eric for now. v7 --> v8 -Changed no_acpi_dev to no_ged. -Fixed 'dev' reference leak by object_new(). -Updated bios-tables-test-allowed-diff.h to avoid "make check" failure. --- hw/arm/Kconfig | 2 + hw/arm/virt-acpi-build.c | 16 +++++++ hw/arm/virt.c | 62 ++++++++++++++++++++++++--- include/hw/arm/virt.h | 4 ++ tests/bios-tables-test-allowed-diff.h | 1 + 5 files changed, 78 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 84961c17ab..ad7f7c089b 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -22,6 +22,8 @@ config ARM_VIRT select ACPI_PCI select MEM_DEVICE select DIMM + select ACPI_MEMORY_HOTPLUG + select ACPI_HW_REDUCED config CHEETAH bool diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 0afb372769..63fa845076 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -40,6 +40,8 @@ #include "hw/acpi/aml-build.h" #include "hw/acpi/utils.h" #include "hw/acpi/pci.h" +#include "hw/acpi/memory_hotplug.h" +#include "hw/acpi/generic_event_device.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/arm/virt.h" @@ -705,6 +707,7 @@ static void build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { Aml *scope, *dsdt; + MachineState *ms = MACHINE(vms); const MemMapEntry *memmap = vms->memmap; const int *irqmap = vms->irqmap; @@ -729,6 +732,19 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) vms->highmem, vms->highmem_ecam); acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], (irqmap[VIRT_GPIO] + ARM_SPI_BASE)); + if (vms->acpi_dev) { + build_ged_aml(scope, "\\_SB."GED_DEVICE, + HOTPLUG_HANDLER(vms->acpi_dev), + irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE, AML_SYSTEM_MEMORY, + memmap[VIRT_ACPI_GED].base); + } + + if (vms->acpi_dev && ms->ram_slots) { + build_memory_hotplug_aml(scope, ms->ram_slots, "\\_SB", NULL, + AML_SYSTEM_MEMORY, + memmap[VIRT_PCDIMM_ACPI].base); + } + acpi_dsdt_add_power_button(scope); aml_append(dsdt, scope); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index ef65e721d2..0949a227a9 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -66,6 +66,7 @@ #include "target/arm/internals.h" #include "hw/mem/pc-dimm.h" #include "hw/mem/nvdimm.h" +#include "hw/acpi/generic_event_device.h" #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -136,6 +137,8 @@ static const MemMapEntry base_memmap[] = { [VIRT_GPIO] = { 0x09030000, 0x00001000 }, [VIRT_SECURE_UART] = { 0x09040000, 0x00001000 }, [VIRT_SMMU] = { 0x09050000, 0x00020000 }, + [VIRT_PCDIMM_ACPI] = { 0x09070000, MEMORY_HOTPLUG_IO_LEN }, + [VIRT_ACPI_GED] = { 0x09080000, ACPI_GED_EVT_SEL_LEN }, [VIRT_MMIO] = { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 }, @@ -171,6 +174,7 @@ static const int a15irqmap[] = { [VIRT_PCIE] = 3, /* ... to 6 */ [VIRT_GPIO] = 7, [VIRT_SECURE_UART] = 8, + [VIRT_ACPI_GED] = 9, [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */ [VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */ [VIRT_SMMU] = 74, /* ...to 74 + NUM_SMMU_IRQS - 1 */ @@ -520,6 +524,26 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) } } +static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq *pic) +{ + DeviceState *dev; + int irq = vms->irqmap[VIRT_ACPI_GED]; + uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT; + + dev = qdev_create(NULL, TYPE_ACPI_GED); + qdev_prop_set_uint32(dev, "ged-event", event); + object_property_add_child(qdev_get_machine(), "acpi-ged", + OBJECT(dev), NULL); + qdev_init_nofail(dev); + + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_ACPI_GED].base); + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, vms->memmap[VIRT_PCDIMM_ACPI].base); + + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irq]); + + return dev; +} + static void create_its(VirtMachineState *vms, DeviceState *gicdev) { const char *itsclass = its_class_name(); @@ -1483,6 +1507,7 @@ static void machvirt_init(MachineState *machine) MemoryRegion *ram = g_new(MemoryRegion, 1); bool firmware_loaded; bool aarch64 = true; + bool has_ged = !vmc->no_ged; unsigned int smp_cpus = machine->smp.cpus; unsigned int max_cpus = machine->smp.max_cpus; @@ -1697,6 +1722,10 @@ static void machvirt_init(MachineState *machine) create_gpio(vms, pic); + if (has_ged && aarch64 && firmware_loaded && acpi_enabled) { + vms->acpi_dev = create_acpi_ged(vms, pic); + } + /* Create mmio transports, so the user can create virtio backends * (which will be automatically plugged in to the transports). If * no backend is created the transport will just sit harmlessly idle. @@ -1876,14 +1905,23 @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { + VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); + const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); + Error *local_err = NULL; - /* - * The device memory is not yet exposed to the Guest either through - * DT or ACPI and hence both cold/hot plug of memory is explicitly - * disabled for now. - */ - if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { - error_setg(errp, "memory cold/hot plug is not yet supported"); + if (is_nvdimm) { + error_setg(errp, "nvdimm is not yet supported"); + return; + } + + if (!vms->acpi_dev) { + error_setg(errp, "memory hotplug is not enabled: missing acpi device"); + return; + } + + hotplug_handler_pre_plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); return; } @@ -1893,11 +1931,18 @@ 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_dev); + hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err); +out: error_propagate(errp, local_err); } @@ -2104,8 +2149,11 @@ DEFINE_VIRT_MACHINE_AS_LATEST(4, 2) static void virt_machine_4_1_options(MachineClass *mc) { + VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); + virt_machine_4_2_options(mc); compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len); + vmc->no_ged = true; } DEFINE_VIRT_MACHINE(4, 1) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index a72094204e..577ee49b4b 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -77,6 +77,8 @@ enum { VIRT_GPIO, VIRT_SECURE_UART, VIRT_SECURE_MEM, + VIRT_PCDIMM_ACPI, + VIRT_ACPI_GED, VIRT_LOWMEMMAP_LAST, }; @@ -106,6 +108,7 @@ typedef struct { bool claim_edge_triggered_timers; bool smbios_old_sys_ver; bool no_highmem_ecam; + bool no_ged; /* Machines < 4.2 has no support for ACPI GED device */ } VirtMachineClass; typedef struct { @@ -133,6 +136,7 @@ typedef struct { uint32_t iommu_phandle; int psci_conduit; hwaddr highest_gpa; + DeviceState *acpi_dev; } VirtMachineState; #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) diff --git a/tests/bios-tables-test-allowed-diff.h b/tests/bios-tables-test-allowed-diff.h index dfb8523c8b..7b4adbc822 100644 --- a/tests/bios-tables-test-allowed-diff.h +++ b/tests/bios-tables-test-allowed-diff.h @@ -1 +1,2 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/virt/DSDT", From patchwork Tue Aug 13 21:05:34 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: 171221 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1401827ily; Tue, 13 Aug 2019 14:14:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxYMcxtIN46S07JaW2GN+LSPMKqGwx13o3DDQsCJpyVAMivi8Ef5VeH/kNr4wXVAkjH34uB X-Received: by 2002:a05:620a:7c8:: with SMTP id 8mr11899946qkb.424.1565730843486; Tue, 13 Aug 2019 14:14:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565730843; cv=none; d=google.com; s=arc-20160816; b=oh4GPLe6D6qbwKLMe9Ogmq/iK3T4tZHU1eCyn8Tau3ZGv2kRRYhuyyvQKYhms2Bmr+ kHdm3/LZahKrbFdaXEg9Pbl+KqlWyUuffsdLRlS0yTH9d+SHnt0v8YCh+/kERI3zjBJQ knE1hrpp/zKdMPGp2i+wWMKJMTcY3iulkTX+BSr/2YtIZDnsm1GyljrCn2LubtozcHUQ MrAFU1SgssxltLRGcdX/NYCYHgflAy0y/LJYeS3Kw7kAtpVvLPMyj1dDNo25zr9iV3qB Df/7pEHAGlr/oyzpI/9SUOaxTPRFYcJqCtk8+gC1mMv1Li9OQsijoHZQZrtKgeVko+a9 jsRA== 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=4AA/f4hAnUvuMcxTGXjpVMnrEDmO5xa+XaS0cP7GV3g=; b=NaqIzIfvXg0L+yfQMkE2jRJpohByLOuZGP/PZPzUHv4114OfnOlwTXwS/WGJdAE9Is xi9CEc4fLoUwQ4dtqxTGpxqdVfqWEhyZyfwx01nQcC349z97elQA6ex1j9j1fi8T3ONb iS9QBc/QleOpvQZZhhaN+18Dr0s2kxfrsyaEytUud0islpJtZPQs/gklb3FmYb698zVH DrDFuR06cyulqAuu8OQEufFyB71/FR2NZuMm+G95Xqn1eG+K9aUO/0G0LGitzEbDyHdQ 1tYeAafZ9R+Zp1a2WsHCzza5l7YNGKEYcPufzkeh3wwNIDJA+fo3hGdOLcm6b5GqoEQv H8eA== 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 b23si8273741qkl.26.2019.08.13.14.14.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2019 14:14:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:55560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe7H-0007CR-20 for patch@linaro.org; Tue, 13 Aug 2019 17:14:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41898) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe1J-00053B-Ix for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe1I-0001YA-FX for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:53 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:60828 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe1A-0001H0-K9; Tue, 13 Aug 2019 17:07:45 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id BEB44CF41561ABA8969A; Wed, 14 Aug 2019 05:07:36 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:28 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:34 +0100 Message-ID: <20190813210539.31164-8-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.35 Subject: [Qemu-devel] [PATCH-for-4.2 v9 07/12] hw/arm/virt-acpi-build: Add PC-DIMM in SRAT X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Generate Memory Affinity Structures for PC-DIMM ranges. Also, Linux and Windows need ACPI SRAT table to make memory hotplug work properly, however currently QEMU doesn't create SRAT table if numa options aren't present on CLI. Hence add support(>=4.2) to create numa node automatically (auto_enable_numa_with_memhp) when QEMU is started with memory hotplug enabled but without '-numa' options on CLI. Signed-off-by: Shameer Kolothum Signed-off-by: Eric Auger Reviewed-by: Igor Mammedov --- v8 --> v9 - Added auto_enable_numa_with_memhp support. --- hw/arm/virt-acpi-build.c | 9 +++++++++ hw/arm/virt.c | 2 ++ 2 files changed, 11 insertions(+) -- 2.17.1 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 63fa845076..6d697af2df 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -518,6 +518,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) int i, srat_start; uint64_t mem_base; MachineClass *mc = MACHINE_GET_CLASS(vms); + MachineState *ms = MACHINE(vms); const CPUArchIdList *cpu_list = mc->possible_cpu_arch_ids(MACHINE(vms)); srat_start = table_data->len; @@ -543,6 +544,14 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) } } + if (ms->device_memory) { + numamem = acpi_data_push(table_data, sizeof *numamem); + build_srat_memory(numamem, ms->device_memory->base, + memory_region_size(&ms->device_memory->mr), + nb_numa_nodes - 1, + MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED); + } + build_header(linker, table_data, (void *)(table_data->data + srat_start), "SRAT", table_data->len - srat_start, 3, NULL, NULL); } diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 0949a227a9..56d64fc0a9 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2049,6 +2049,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) hc->plug = virt_machine_device_plug_cb; hc->unplug_request = virt_machine_device_unplug_request_cb; mc->numa_mem_supported = true; + mc->auto_enable_numa_with_memhp = true; } static void virt_instance_init(Object *obj) @@ -2154,6 +2155,7 @@ static void virt_machine_4_1_options(MachineClass *mc) virt_machine_4_2_options(mc); compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len); vmc->no_ged = true; + mc->auto_enable_numa_with_memhp = false; } DEFINE_VIRT_MACHINE(4, 1) From patchwork Tue Aug 13 21:05:35 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: 171217 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1399759ily; Tue, 13 Aug 2019 14:11:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDS83cSPq2sWmseg6P5Vip0ZGK8IIN1u9Pn8NGHEAdGKXywU9KCU277uBXHQaq4sxhiZw9 X-Received: by 2002:a05:620a:6cf:: with SMTP id 15mr33472318qky.98.1565730712202; Tue, 13 Aug 2019 14:11:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565730712; cv=none; d=google.com; s=arc-20160816; b=UaPUJvU5Jmch9IVNYWXTV8wyKqBxjRs59Xd/UrHIu1Wk5Xc5/s654vSV9Vh6IZLj7L GyMnyZzNZ+dgysHn6i1aV4hjLrGIVYjCW7SF/eWt4c7TEP6QcjYvNCreiprQazwkOmhp mcaeB8sDsyuIyiH7o/ZlmrGp39DThgUvIX0ttoTsVRfNVtzU17hP/QOgtctXQrMTp/bK s9XGECrB7mrq5s+CFSFFMENqR8soGucm8NSmj/bznjThX7CqSON5ZMs+DJVrxUmv+SdI uaI3lOorkwjulCcZLu781jzRkTFU7N1wEo6iOjYVtAniUZF2fnlA2+nA6KUjUnCTdq4T uKXA== 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=FsLpo8JpdiLXdKuXzSpP/A/dAc8J0CbYIS3Cl6WOb28=; b=gnpKFxaCPOdqh/JWezEkO2neoQc2bSM9xTozj8Qb73GWdTeNtojODKG29KMUrWDLo+ lPzkOrG9Bn9zd7wtDd3zGgQU9/6VOf2/i3+l/u+bOa9AowAEYpNsGjohKdhpbZZpPBZW 1xOONJriP2a+uhBsSCQ5lW/lyjSsGDqh6pwq7P7qaDtknyeg5dp3H8BjuX0yoqXhNRX6 BAXe0211Pn/Pv6F9CuWccH+MP0hJ1CRrn2YW95jxDoHtA/X9YLFhe3GJBsJUlRM7qdRN lj6RobKjRfbRHHntrLDP9ykZYHUY5/JjXO5Hn4NC18ZCzjGFEZYvvcumdaZNV41agt8C C3HQ== 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 j5si5713547qte.76.2019.08.13.14.11.52 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2019 14:11:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:55498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe59-0000eQ-PR for patch@linaro.org; Tue, 13 Aug 2019 17:11:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41899) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe1J-00053C-JA for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe1I-0001YF-Fh for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:53 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33788 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe1A-0001LH-Kq; Tue, 13 Aug 2019 17:07:44 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id CF7AED25FCFDA0750D96; Wed, 14 Aug 2019 05:07:41 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:32 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:35 +0100 Message-ID: <20190813210539.31164-9-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH-for-4.2 v9 08/12] hw/arm: Factor out powerdown notifier from GPIO X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is in preparation of using GED device for system_powerdown event. Make the powerdown notifier registration independent of create_gpio() fn. Signed-off-by: Shameer Kolothum --- hw/arm/virt.c | 12 ++++-------- include/hw/arm/virt.h | 1 + 2 files changed, 5 insertions(+), 8 deletions(-) -- 2.17.1 Reviewed-by: Eric Auger diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 56d64fc0a9..0e75213b44 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -787,10 +787,6 @@ static void virt_powerdown_req(Notifier *n, void *opaque) qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1); } -static Notifier virt_system_powerdown_notifier = { - .notify = virt_powerdown_req -}; - static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) { char *nodename; @@ -831,10 +827,6 @@ static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) KEY_POWER); qemu_fdt_setprop_cells(vms->fdt, "/gpio-keys/poweroff", "gpios", phandle, 3, 0); - - /* connect powerdown request */ - qemu_register_powerdown_notifier(&virt_system_powerdown_notifier); - g_free(nodename); } @@ -1726,6 +1718,10 @@ static void machvirt_init(MachineState *machine) vms->acpi_dev = create_acpi_ged(vms, pic); } + /* connect powerdown request */ + vms->powerdown_notifier.notify = virt_powerdown_req; + qemu_register_powerdown_notifier(&vms->powerdown_notifier); + /* Create mmio transports, so the user can create virtio backends * (which will be automatically plugged in to the transports). If * no backend is created the transport will just sit harmlessly idle. diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 577ee49b4b..0b41083e9d 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -137,6 +137,7 @@ typedef struct { int psci_conduit; hwaddr highest_gpa; DeviceState *acpi_dev; + Notifier powerdown_notifier; } VirtMachineState; #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) From patchwork Tue Aug 13 21:05: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: 171219 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1400612ily; Tue, 13 Aug 2019 14:12:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6ZPcnGi/cClAEjnh0C2hJXQb+hbTLPTRZuWRfQ1dgQbzLb8V0ehA6d578Br1ATSNNIhQ4 X-Received: by 2002:a37:a5d1:: with SMTP id o200mr36124254qke.93.1565730771301; Tue, 13 Aug 2019 14:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565730771; cv=none; d=google.com; s=arc-20160816; b=BVotQvIzgQXkP/WroHkrcTkB04k9yHXiMSrS4AR03kYD0S5VxBfhQzhn9dQIt5DYzL 8Ph4Nk0aWicbMOEds959c9Q6iyG7VRqagiDIQjLP3n4ECCW6/EHaWJ3jdQfuc7CM9cse Ql28VmyuQveFarBugwtcju7OGPAzTvEBb7Aiyhn9EaZhLybe+wz7FrvGwN+Tccw4oePD BHhVxHn2GvG7AJ382SjBfktU0iZ8lskYpT2nsbg5/QSoC3XnmtkPD27zv5iAzGtpvS/i q+NdnCR/sEYNB78mSoNQUCsisKb2fN0TStZN9Mk/GX6YxNjraf4v2ixmsq+w5hf/Wxia /qjQ== 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=hKHHY1cJw7n5+GwvXCIspcDe8BTV9o7Z2jROMlC41XQ=; b=0IhjdcINimV8jSIGrUUpcrUJQEt2SLb10ptpprUXdCb0yPnYmo2qOcVxRwXt/ZfT8s T1d/IjS3smCYd9FzmxumIoOllVa6VvrqRsWE8rCJY4GX+3qRQQdNou4CZjqYZ2+ZwPq9 2e8c8qusyb4Pt1WLn7pwFjzR4Dl1Z4RW5BkIiqK/N292/yxWemL8TrAsPnBcg984XnyN gZoQ6Y9qHx+7QF4EhnS/Ekj6iLu4jPHivlvbLQZJbIQLygZG37U4d7XyKio63FPtgfyA XfmccGU9Si5vIE+bxhocakT7v0JX8eIOZth4QUw0t2+6cA784ILBZLmQUMlfruUJ8080 T4kA== 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 g33si67886444qtb.145.2019.08.13.14.12.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2019 14:12:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:55530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe66-0004eC-Up for patch@linaro.org; Tue, 13 Aug 2019 17:12:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41905) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe1J-00053u-Tg for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe1I-0001YX-HF for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:53 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33914 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe1F-0001RE-0b; Tue, 13 Aug 2019 17:07:49 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id E8FD7FB4E9428B21955B; Wed, 14 Aug 2019 05:07:46 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:36 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:36 +0100 Message-ID: <20190813210539.31164-10-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH-for-4.2 v9 09/12] hw/arm: Use GED for system_powerdown event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For machines 4.2 or higher with ACPI boot use GED for system_powerdown event instead of GPIO. Guest boot with DT still uses GPIO. Signed-off-by: Shameer Kolothum --- v8 --> v9 -Re-arranged patches 8 & 9 from v8 based on Igor's comments. v7 --> v8 -Retained gpio based system_powerdown support for machines < 4.2. -Reuse of virt_powerdown_req() for ACPI GED use. -Dropped Eric's R-by for now because of above. --- hw/acpi/generic_event_device.c | 8 ++++++++ hw/arm/virt-acpi-build.c | 6 +++--- hw/arm/virt.c | 16 +++++++++++----- include/hw/acpi/acpi_dev_interface.h | 1 + include/hw/acpi/generic_event_device.h | 3 +++ 5 files changed, 26 insertions(+), 8 deletions(-) -- 2.17.1 Reviewed-by: Eric Auger diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index f4c23470c2..d6d7b28cfd 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -19,6 +19,7 @@ static const uint32_t ged_supported_events[] = { ACPI_GED_MEM_HOTPLUG_EVT, + ACPI_GED_PWR_DOWN_EVT, }; /* @@ -103,6 +104,11 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev, aml_append(if_ctx, aml_call0(MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD)); break; + case ACPI_GED_PWR_DOWN_EVT: + aml_append(if_ctx, + aml_notify(aml_name(ACPI_POWER_BUTTON_DEVICE), + aml_int(0x80))); + break; default: /* * Please make sure all the events in ged_supported_events[] @@ -189,6 +195,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev) if (ev & ACPI_MEMORY_HOTPLUG_STATUS) { sel = ACPI_GED_MEM_HOTPLUG_EVT; + } else if (ev & ACPI_POWER_DOWN_STATUS) { + sel = ACPI_GED_PWR_DOWN_EVT; } else { /* Unknown event. Return without generating interrupt. */ warn_report("GED: Unsupported event %d. No irq injected", ev); diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 6d697af2df..61b399dc58 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -49,7 +49,6 @@ #include "kvm_arm.h" #define ARM_SPI_BASE 32 -#define ACPI_POWER_BUTTON_DEVICE "PWRB" static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) { @@ -739,13 +738,14 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS); acpi_dsdt_add_pci(scope, memmap, (irqmap[VIRT_PCIE] + ARM_SPI_BASE), vms->highmem, vms->highmem_ecam); - acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], - (irqmap[VIRT_GPIO] + ARM_SPI_BASE)); if (vms->acpi_dev) { build_ged_aml(scope, "\\_SB."GED_DEVICE, HOTPLUG_HANDLER(vms->acpi_dev), irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE, AML_SYSTEM_MEMORY, memmap[VIRT_ACPI_GED].base); + } else { + acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], + (irqmap[VIRT_GPIO] + ARM_SPI_BASE)); } if (vms->acpi_dev && ms->ram_slots) { diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 0e75213b44..d49e1a583c 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -528,7 +528,7 @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq *pic) { DeviceState *dev; int irq = vms->irqmap[VIRT_ACPI_GED]; - uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT; + uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT | ACPI_GED_PWR_DOWN_EVT; dev = qdev_create(NULL, TYPE_ACPI_GED); qdev_prop_set_uint32(dev, "ged-event", event); @@ -783,8 +783,14 @@ static void create_rtc(const VirtMachineState *vms, qemu_irq *pic) static DeviceState *gpio_key_dev; static void virt_powerdown_req(Notifier *n, void *opaque) { - /* use gpio Pin 3 for power button event */ - qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1); + VirtMachineState *s = container_of(n, VirtMachineState, powerdown_notifier); + + if (s->acpi_dev) { + acpi_send_event(s->acpi_dev, ACPI_POWER_DOWN_STATUS); + } else { + /* use gpio Pin 3 for power button event */ + qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1); + } } static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) @@ -1712,10 +1718,10 @@ static void machvirt_init(MachineState *machine) create_pcie(vms, pic); - create_gpio(vms, pic); - if (has_ged && aarch64 && firmware_loaded && acpi_enabled) { vms->acpi_dev = create_acpi_ged(vms, pic); + } else { + create_gpio(vms, pic); } /* connect powerdown request */ diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h index 43ff119179..adcb3a816c 100644 --- a/include/hw/acpi/acpi_dev_interface.h +++ b/include/hw/acpi/acpi_dev_interface.h @@ -11,6 +11,7 @@ typedef enum { ACPI_MEMORY_HOTPLUG_STATUS = 8, ACPI_NVDIMM_HOTPLUG_STATUS = 16, ACPI_VMGENID_CHANGE_STATUS = 32, + ACPI_POWER_DOWN_STATUS = 64, } AcpiEventStatusBits; #define TYPE_ACPI_DEVICE_IF "acpi-device-interface" diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h index 2049e8d873..d157eac088 100644 --- a/include/hw/acpi/generic_event_device.h +++ b/include/hw/acpi/generic_event_device.h @@ -62,6 +62,8 @@ #include "hw/sysbus.h" #include "hw/acpi/memory_hotplug.h" +#define ACPI_POWER_BUTTON_DEVICE "PWRB" + #define TYPE_ACPI_GED "acpi-ged" #define ACPI_GED(obj) \ OBJECT_CHECK(AcpiGedState, (obj), TYPE_ACPI_GED) @@ -79,6 +81,7 @@ * through GED. */ #define ACPI_GED_MEM_HOTPLUG_EVT 0x1 +#define ACPI_GED_PWR_DOWN_EVT 0x2 typedef struct GEDState { MemoryRegion io; From patchwork Tue Aug 13 21:05: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: 171216 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1399560ily; Tue, 13 Aug 2019 14:11:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLEg69dLjO3BVzAqR8GJ3TzMSHlQEtlMs7Bl4xRAPXTOlPCfU9NQsgpGNx7AxlaiFdO6h5 X-Received: by 2002:ac8:2652:: with SMTP id v18mr3148234qtv.40.1565730699550; Tue, 13 Aug 2019 14:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565730699; cv=none; d=google.com; s=arc-20160816; b=Oi+RpU1sFtzjj8lL02zcVVd0e3pVzobgi+Zalg0vJOxE5mR6caIRWgqYm+y2UbbLGe ZvS5r1969lGB795BgzT2f4x5tCyt14LMiFgZjAxbjrxj+vR5HNIpAeQh6zhTIMF/MPls /ix0ArDAhhfKkQ5+/Y/IECzEeBvTFhMMDHFib9oD6qa06B+Av2MzSV3j8qfr4f4j+QVl EdgeyxagJ0Rhn4TwjrXUetZF5bq1vJaWIjKi6B9elWcE2SvC92P+OMgkexP1/nISqyYN r3jEPq10pdzcoD4kxGGUpsVSAYG27Shoo7oh3PBO3p0MKtP5crI8y+CkJ5JnVU+iLSKJ S+og== 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=2A77xDkBGjIvIFXCxAe1nFVvDQrOJVTqECfZ2tujOXE=; b=0GR1IhcD2P1Iwuxjc2zlgLjadvxs1bPdGfHZL9gd/ASX/k/GbhVoGetHOFMPSPMwoL nYTVEb/4THRCeGCCeVR2fCoaYf2SjXm65EPin8HS+gUI3ltLW1f1CLk4nvu4t0jg4Npu VJElQFG1ZEejSjUGXHykdp3k4Nski4S17I2nkQHQtryQbeeHB7PBGt+GSWZkXCNj0rZq aqWO2Q4hCagjcPGwMZpsHjIt7p/yxFwizXdK3Dq9UZafQVkEMhP+XabB0y8doVjTQ/eT pe/kuSeGcIEOjLwF5kJW5u/awbo+gwkdiPGRS+Kv1kR0QHEDsX8/GM6l8yaR50BVERRL 6vNA== 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 m18si11393761qta.74.2019.08.13.14.11.39 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2019 14:11: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 ([::1]:55505 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe4x-0001OS-5u for patch@linaro.org; Tue, 13 Aug 2019 17:11:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41903) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe1J-00053t-Rq for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe1I-0001Yc-Ht for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:53 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33900 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe1E-0001RA-Tp; Tue, 13 Aug 2019 17:07:49 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id E23D4E12C927C458684F; Wed, 14 Aug 2019 05:07:46 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:40 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:37 +0100 Message-ID: <20190813210539.31164-11-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH-for-4.2 v9 10/12] docs/specs: Add ACPI GED documentation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Documents basic concepts of ACPI Generic Event device(GED) and interface between QEMU and the ACPI BIOS. Signed-off-by: Shameer Kolothum --- docs/specs/acpi_hw_reduced_hotplug.txt | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 docs/specs/acpi_hw_reduced_hotplug.txt -- 2.17.1 Reviewed-by: Eric Auger diff --git a/docs/specs/acpi_hw_reduced_hotplug.txt b/docs/specs/acpi_hw_reduced_hotplug.txt new file mode 100644 index 0000000000..46839be5ff --- /dev/null +++ b/docs/specs/acpi_hw_reduced_hotplug.txt @@ -0,0 +1,60 @@ +QEMU<->ACPI BIOS Generic Event Device interface + +The ACPI Generic Event Device (GED) is a HW reduced platform +specific device introduced in ACPI v6.1 that handles all platform +events, including the hotplug ones. GED is modelled as a device +in the namespace with a _HID defined to be ACPI0013. This document +describes the interface between QEMU and the ACPI BIOS. + +GED allows HW reduced platforms to handle interrupts in ACPI ASL +statements. It follows a very similar approach like the _EVT method +from GPIO events. All interrupts are listed in _CRS and the handler +is written in _EVT method. However, Qemu implementation 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. + +Here is an example. + +Device (\_SB.GED) +{ + Name (_HID, "ACPI0013") + Name (_UID, Zero) + Name (_CRS, ResourceTemplate () + { + Interrupt (ResourceConsumer, Edge, ActiveHigh, Exclusive, ,, ) + { + 0x00000029, + } + }) + OperationRegion (EREG, SystemMemory, 0x09080000, 0x04) + Field (EREG, DWordAcc, NoLock, WriteAsZeros) + { + ESEL, 32 + } + Method (_EVT, 1, Serialized) + { + Local0 = ESEL // ESEL = IO memory region which specifies the + // device type. + If (((Local0 & One) == One)) + { + MethodEvent1() + } + If ((Local0 & 0x2) == 0x2) + { + MethodEvent2() + } + ... + } +} + +GED IO interface (4 byte access): +read access: + [0x0-0x3] Event selector bit field(32 bit) set by Qemu. + bits: + 1: Memory hotplug event + 2: System power down event + 3-31: Reserved + +write_access: + Nothing is expected to be written into GED IO memory From patchwork Tue Aug 13 21:05: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: 171218 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1400451ily; Tue, 13 Aug 2019 14:12:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyo+MPJIxjH4Jmgq7yTdnmC7P4xzvGdEWKHxJDF2Y5TgryUTrsrPgKdLF7+eMGD7UolQRep X-Received: by 2002:a05:6214:1447:: with SMTP id b7mr202104qvy.89.1565730760958; Tue, 13 Aug 2019 14:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565730760; cv=none; d=google.com; s=arc-20160816; b=cGtp64Ltx1sq9xHo5Pug5PF0EEY+0KyZdX/4OQOmvfWmSx4wsFP2kCuaUUYcGHyIlO SvBZnA8w/v/C6cEnyK2GJZXDnpA9yQJoJwARurhIkOwvO6JsLv9eCbrUti0M65RJIlkm /94H9SlPVD6MUZIsOuTu6Nh2LaunsDqvPbIuUuHH7PURJPzbYWAwCDsOgXH0C4LCnPsp YJTf4R/MWum1+WwluQe0wiFT0GHfnc8gaVv7i/8e/vVD04sNbEKIVFrXknVzUbhChJGz Tllka0tVYZYi5dxxi16RU+NAtMN8RCpkT0SvGlWTwzOZcqzhqDJpWVIitABbM0YdNxy2 chiw== 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=uftxv5ZWfB4oXgjJMG+CxRkuwojbJUaZfZoxhvhXDsw=; b=UMABjAJK7I5NgPPGISB65IrBdFUaDDfNBSblXpDOc70C9rbM3PyFzpE/bgt1t8v6xU CkvGKTAUVY8qlA+l6Ec4xTLWiAMhVn8dMw+4SUZMIziyUDTvd4T2nvN3SU8TfGz8KAgM I3EpV6lKoHzfDVnFZtE/VOtqpm+dpWPiE4tF94wSJYIW0zcgfCqHmTOl0JHDc/yTelvK gBM/KosZDdgBS3PNK5I6MzuFYs9vl3z3J9AAo9EwNAEPObnokSe+2/cZJhUiVCgdmWWV FIyeK/4wVZYIEClT3WS/afGhH+OH/p4Nl0NfODK6UzxlsUm08XXC/kMstufPPuP9Ptk1 ACFw== 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 f33si8891925qvd.65.2019.08.13.14.12.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2019 14:12:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:55526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe5w-00043g-Ey for patch@linaro.org; Tue, 13 Aug 2019 17:12:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42107) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe1X-0005Ia-Dc for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:08:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe1V-0001oO-Db for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:08:06 -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 1hxe1P-0001dE-37; Tue, 13 Aug 2019 17:08:00 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 0E3FEE996CB23ADEC89A; Wed, 14 Aug 2019 05:07:57 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:47 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:39 +0100 Message-ID: <20190813210539.31164-13-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.191 Subject: [Qemu-devel] [PATCH-for-4.2 v9 12/12] tests: Add bios tests to arm/virt X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This adds numamem and memhp tests for arm/virt platform Signed-off-by: Shameer Kolothum --- tests/bios-tables-test-allowed-diff.h | 1 + tests/bios-tables-test.c | 49 +++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) -- 2.17.1 diff --git a/tests/bios-tables-test-allowed-diff.h b/tests/bios-tables-test-allowed-diff.h index 7b4adbc822..d181a4da4a 100644 --- a/tests/bios-tables-test-allowed-diff.h +++ b/tests/bios-tables-test-allowed-diff.h @@ -1,2 +1,3 @@ /* List of comma-separated changed AML files to ignore */ "tests/data/acpi/virt/DSDT", +"tests/data/acpi/virt/SRAT", diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index a356ac3489..1d6f330d53 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -871,6 +871,53 @@ static void test_acpi_piix4_tcg_dimm_pxm(void) test_acpi_tcg_dimm_pxm(MACHINE_PC); } +static void test_acpi_virt_tcg_memhp(void) +{ + test_data data = { + .machine = "virt", + .accel = "tcg", + .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", + .uefi_fl2 = "pc-bios/edk2-arm-vars.fd", + .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2", + .ram_start = 0x40000000ULL, + .scan_len = 256ULL * 1024 * 1024, + }; + + data.variant = ".memhp"; + test_acpi_one(" -cpu cortex-a57" + " -m 256M,slots=3,maxmem=1G" + " -object memory-backend-ram,id=ram0,size=128M" + " -object memory-backend-ram,id=ram1,size=128M" + " -numa node,memdev=ram0 -numa node,memdev=ram1" + " -numa dist,src=0,dst=1,val=21", + &data); + + free_test_data(&data); + +} + +static void test_acpi_virt_tcg_numamem(void) +{ + test_data data = { + .machine = "virt", + .accel = "tcg", + .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", + .uefi_fl2 = "pc-bios/edk2-arm-vars.fd", + .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2", + .ram_start = 0x40000000ULL, + .scan_len = 128ULL * 1024 * 1024, + }; + + data.variant = ".numamem"; + test_acpi_one(" -cpu cortex-a57" + " -object memory-backend-ram,id=ram0,size=128M" + " -numa node,memdev=ram0", + &data); + + free_test_data(&data); + +} + static void test_acpi_virt_tcg(void) { test_data data = { @@ -917,6 +964,8 @@ int main(int argc, char *argv[]) qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm); } else if (strcmp(arch, "aarch64") == 0) { qtest_add_func("acpi/virt", test_acpi_virt_tcg); + qtest_add_func("acpi/virt/numamem", test_acpi_virt_tcg_numamem); + qtest_add_func("acpi/virt/memhp", test_acpi_virt_tcg_memhp); } ret = g_test_run(); boot_sector_cleanup(disk);