From patchwork Thu Jan 22 14:50:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 431884 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A81A814012F for ; Fri, 23 Jan 2015 02:19:03 +1100 (AEDT) Received: from localhost ([::1]:54048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJXB-0000E4-JV for incoming@patchwork.ozlabs.org; Thu, 22 Jan 2015 10:19:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48743) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJ6m-0003rf-SR for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEJ6g-0003k5-FI for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48415) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJ6g-0003jX-8h for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:38 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0MEpX1A018124 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Jan 2015 09:51:33 -0500 Received: from dell-pet610-01.lab.eng.brq.redhat.com (dell-pet610-01.lab.eng.brq.redhat.com [10.34.42.20]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0MEoYe2030524; Thu, 22 Jan 2015 09:51:32 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 22 Jan 2015 14:50:21 +0000 Message-Id: <1421938231-25698-38-git-send-email-imammedo@redhat.com> In-Reply-To: <1421938231-25698-1-git-send-email-imammedo@redhat.com> References: <1421938231-25698-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, drjones@redhat.com, marcel.a@redhat.com, claudio.fontana@huawei.com, mst@redhat.com Subject: [Qemu-devel] [PATCH v2 37/47] pc: acpi-build: create memory hotplug IO region dynamically X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org it replaces a static complied in DSDT MMIO region for memory hotplug with one created at runtime leaving only truly static memory hotplug related ASL bits in DSDT. And replaces template patching of MEMORY_SLOTS_NUMBER value with ASL API created named value. Later it also would make easier to reuse current ACPI memory hotplug on other targets. Also later it would be possible to move remaining memory hotplug ASL methods into build_ssdt() and add all memory hotplug related AML into SSDT only when memory hotplug is enabled, further reducing ACPI tables blob if memory hotplug isn't used. Signed-off-by: Igor Mammedov --- hw/i386/acpi-build.c | 57 ++++++++++++++++++++++++++++++++++++--- hw/i386/acpi-dsdt-mem-hotplug.dsl | 36 +++++++------------------ hw/i386/ssdt-misc.dsl | 2 -- 3 files changed, 64 insertions(+), 31 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 5e20193..b26bc6d 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -103,6 +103,8 @@ typedef struct AcpiPmInfo { uint32_t io_base; uint16_t cpu_hp_io_base; uint16_t cpu_hp_io_len; + uint16_t mem_hp_io_base; + uint16_t mem_hp_io_len; } AcpiPmInfo; typedef struct AcpiMiscInfo { @@ -188,6 +190,9 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) assert(obj); pm->cpu_hp_io_len = ACPI_GPE_PROC_LEN; + pm->mem_hp_io_base = ACPI_MEMORY_HOTPLUG_BASE; + pm->mem_hp_io_len = ACPI_MEMORY_HOTPLUG_IO_LEN; + /* Fill in optional s3/s4 related properties */ o = object_property_get_qobject(obj, ACPI_PM_PROP_S3_DISABLED, NULL); if (o) { @@ -695,9 +700,6 @@ build_ssdt(GArray *table_data, GArray *linker, patch_pci_windows(pci, ssdt_ptr, sizeof(ssdp_misc_aml)); - ACPI_BUILD_SET_LE(ssdt_ptr, sizeof(ssdp_misc_aml), - ssdt_mctrl_nr_slots[0], 32, nr_mem); - /* create S3_ / S4_ / S5_ packages if necessary */ scope = acpi_scope("\\"); if (!pm->s3_disabled) { @@ -835,6 +837,55 @@ build_ssdt(GArray *table_data, GArray *linker, /* build memory devices */ assert(nr_mem <= ACPI_MAX_RAM_SLOTS); + scope = acpi_scope("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE)); + aml_append(&scope, + acpi_name_decl(stringify(MEMORY_SLOTS_NUMBER), acpi_int(nr_mem)) + ); + + crs = acpi_resource_template(); + aml_append(&crs, + acpi_io(acpi_decode16, pm->mem_hp_io_base, pm->mem_hp_io_base, + 0, pm->mem_hp_io_len) + ); + aml_append(&scope, acpi_name_decl("_CRS", crs)); + + aml_append(&scope, acpi_operation_region( + stringify(MEMORY_HOTPLUG_IO_REGION), acpi_system_io, + pm->mem_hp_io_base, pm->mem_hp_io_len) + ); + + field = acpi_field(stringify(MEMORY_HOTPLUG_IO_REGION), acpi_dword_acc); + aml_append(&field, /* read only */ + acpi_named_field(stringify(MEMORY_SLOT_ADDR_LOW), 32)); + aml_append(&field, /* read only */ + acpi_named_field(stringify(MEMORY_SLOT_ADDR_HIGH), 32)); + aml_append(&field, /* read only */ + acpi_named_field(stringify(MEMORY_SLOT_SIZE_LOW), 32)); + aml_append(&field, /* read only */ + acpi_named_field(stringify(MEMORY_SLOT_SIZE_HIGH), 32)); + aml_append(&field, /* read only */ + acpi_named_field(stringify(MEMORY_SLOT_PROXIMITY), 32)); + aml_append(&scope, field); + + field = acpi_field(stringify(MEMORY_HOTPLUG_IO_REGION), acpi_byte_acc); + aml_append(&field, acpi_reserved_field(160 /* Offset(20) */)); + aml_append(&field, /* 1 if enabled, read only */ + acpi_named_field(stringify(MEMORY_SLOT_ENABLED), 1)); + aml_append(&field, + /*(read) 1 if has a insert event. (write) 1 to clear event */ + acpi_named_field(stringify(MEMORY_SLOT_INSERT_EVENT), 1)); + aml_append(&scope, field); + + field = acpi_field(stringify(MEMORY_HOTPLUG_IO_REGION), acpi_dword_acc); + aml_append(&field, /* DIMM selector, write only */ + acpi_named_field(stringify(MEMORY_SLOT_SLECTOR), 32)); + aml_append(&field, /* _OST event code, write only */ + acpi_named_field(stringify(MEMORY_SLOT_OST_EVENT), 32)); + aml_append(&field, /* _OST status code, write only */ + acpi_named_field(stringify(MEMORY_SLOT_OST_STATUS), 32)); + aml_append(&scope, field); + + aml_append(&sb_scope, scope); for (i = 0; i < nr_mem; i++) { #define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "." diff --git a/hw/i386/acpi-dsdt-mem-hotplug.dsl b/hw/i386/acpi-dsdt-mem-hotplug.dsl index 2a36c47..1e9ec39 100644 --- a/hw/i386/acpi-dsdt-mem-hotplug.dsl +++ b/hw/i386/acpi-dsdt-mem-hotplug.dsl @@ -22,14 +22,16 @@ External(MEMORY_SLOTS_NUMBER, IntObj) /* Memory hotplug IO registers */ - OperationRegion(MEMORY_HOTPLUG_IO_REGION, SystemIO, - ACPI_MEMORY_HOTPLUG_BASE, - ACPI_MEMORY_HOTPLUG_IO_LEN) - - Name(_CRS, ResourceTemplate() { - IO(Decode16, ACPI_MEMORY_HOTPLUG_BASE, ACPI_MEMORY_HOTPLUG_BASE, - 0, ACPI_MEMORY_HOTPLUG_IO_LEN, IO) - }) + External(MEMORY_SLOT_ADDR_LOW, FieldUnitObj) // read only + External(MEMORY_SLOT_ADDR_HIGH, FieldUnitObj) // read only + External(MEMORY_SLOT_SIZE_LOW, FieldUnitObj) // read only + External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only + External(MEMORY_SLOT_PROXIMITY, FieldUnitObj) // read only + External(MEMORY_SLOT_ENABLED, FieldUnitObj) // 1 if enabled, read only + External(MEMORY_SLOT_INSERT_EVENT, FieldUnitObj) // (read) 1 if has a insert event. (write) 1 to clear event + External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only + External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only + External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only Method(_STA, 0) { If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { @@ -39,25 +41,7 @@ Return(0xB) } - Field(MEMORY_HOTPLUG_IO_REGION, DWordAcc, NoLock, Preserve) { - MEMORY_SLOT_ADDR_LOW, 32, // read only - MEMORY_SLOT_ADDR_HIGH, 32, // read only - MEMORY_SLOT_SIZE_LOW, 32, // read only - MEMORY_SLOT_SIZE_HIGH, 32, // read only - MEMORY_SLOT_PROXIMITY, 32, // read only - } - Field(MEMORY_HOTPLUG_IO_REGION, ByteAcc, NoLock, Preserve) { - Offset(20), - MEMORY_SLOT_ENABLED, 1, // 1 if enabled, read only - MEMORY_SLOT_INSERT_EVENT, 1, // (read) 1 if has a insert event. (write) 1 to clear event - } - Mutex (MEMORY_SLOT_LOCK, 0) - Field (MEMORY_HOTPLUG_IO_REGION, DWordAcc, NoLock, Preserve) { - MEMORY_SLOT_SLECTOR, 32, // DIMM selector, write only - MEMORY_SLOT_OST_EVENT, 32, // _OST event code, write only - MEMORY_SLOT_OST_STATUS, 32, // _OST status code, write only - } Method(MEMORY_SLOT_SCAN_METHOD, 0) { If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) { diff --git a/hw/i386/ssdt-misc.dsl b/hw/i386/ssdt-misc.dsl index 81be858..2588e30 100644 --- a/hw/i386/ssdt-misc.dsl +++ b/hw/i386/ssdt-misc.dsl @@ -36,7 +36,5 @@ DefinitionBlock ("ssdt-misc.aml", "SSDT", 0x01, "BXPC", "BXSSDTSUSP", 0x1) Name(P1E, Buffer() { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }) ACPI_EXTRACT_NAME_BUFFER8 acpi_pci64_length Name(P1L, Buffer() { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }) - ACPI_EXTRACT_NAME_DWORD_CONST ssdt_mctrl_nr_slots - Name(MEMORY_SLOTS_NUMBER, 0x12345678) } }