pc: acpi: memory hotplug cleanup/consolidation
cover pc: acpi: memory hotplug cleanup/consolidation
Series cleanups and consolidates scattered memory hotplug code so it could be easily reused by ARM target later.
As result:
* added memory hotplug variant to bios tables test
* all ACPI related parts of memory hotplug are consolidated within memory_hotplug.c
* DSDT table size is reduced ~900 bytes when memory hotplug is not enabled (by not generating not used AML)
* DSDT table size is reduced on 12 bytes per slot
(i.e. up to ~3000 bytes savings for 256 DIMMs) with memory hotplug enabled due AML reorganization that makes calls to common functions smaller as devices and common functions are now within the same scope.
Tested with following guests:
- RHEL7.3, WS2008DC, WS2008R2DC, WS2012R2DC, WS2016TP5 - no regressions found
- XP3 and WS2003 - boots fine even if memhotplug is enabled (but otherwise it never worked as memhp is not supported there)
Git tree for testing:
https://github.com/imammedo/qemu.git memhp_consolidate_v1
viewing:
https://github.com/imammedo/qemu/commits/memhp_consolidate_v1
Note to maintaner:
* blobs patch 2/10 should be merged to patch 1/10
* ACPI tables should be regenarated and applied after series is merged as DSDT will cange for all tests cases due removal of inactive memory hotplug code.
Igor Mammedov (10):
tests: pc: add memory hotplug acpi tables tests
tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant
memhp: move build_memory_hotplug_aml() into memory_hotplug.c
memhp: move build_memory_devices() into memory_hotplug.c
memhp: consolidate scattered MHPD device declaration
memhp: merge build_memory_devices() into build_memory_hotplug_aml()
memhp: move GPE handler_E03 into build_memory_hotplug_aml()
memhp: move memory hotplug only defines to memory_hotplug.c
memhp: don't generate memory hotplug AML if it's not enabled/supported
memhp: move DIMM devices into dedicated scope with related common
methods
include/hw/acpi/memory_hotplug.h | 12 +- include/hw/acpi/pc-hotplug.h | 23 -- hw/acpi/Makefile.objs | 2 +- hw/acpi/ich9.c | 3 +- hw/acpi/memory_hotplug.c | 420 +++++++++++++++++++++++++++++++++++- hw/acpi/memory_hotplug_acpi_table.c | 262 ---------------------- hw/acpi/piix4.c | 3 +- hw/i386/acpi-build.c | 197 +++-------------- tests/acpi-test-data/pc/DSDT.memhp | Bin 0 -> 6613 bytes tests/acpi-test-data/pc/SRAT.memhp | Bin 0 -> 224 bytes tests/acpi-test-data/q35/DSDT.memhp | Bin 0 -> 9375 bytes tests/acpi-test-data/q35/SRAT.memhp | Bin 0 -> 224 bytes tests/bios-tables-test.c | 24 +++ 13 files changed, 479 insertions(+), 467 deletions(-) delete mode 100644 hw/acpi/memory_hotplug_acpi_table.c create mode 100644 tests/acpi-test-data/pc/DSDT.memhp create mode 100644 tests/acpi-test-data/pc/SRAT.memhp create mode 100644 tests/acpi-test-data/q35/DSDT.memhp create mode 100644 tests/acpi-test-data/q35/SRAT.memhp
Signature · 1 line
2.7.4
PATCH 1/10 tests: pc: add memory hotplug acpi tables tests
--- tests/bios-tables-test.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
tests/bios-tables-test.c +24 -0
@@ -867,6 +867,28 @@ static void test_acpi_piix4_tcg_ipmi(void)free_test_data (&data); } +static void test_acpi_q35_tcg_memhp (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_Q35 ; + data.variant =".memhp" ; +test_acpi_one (" -m 128,slots=3,maxmem=1G -numa node" , &data); +free_test_data (&data); +} + +static void test_acpi_piix4_tcg_memhp (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_PC ; + data.variant =".memhp" ; +test_acpi_one (" -m 128,slots=3,maxmem=1G -numa node" , &data); +free_test_data (&data); +} +int main (int argc,char *argv[]) {const char *arch =qtest_get_arch ();
@@ -887,6 +909,8 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/q35/ipmi" , test_acpi_q35_tcg_ipmi);qtest_add_func ("acpi/piix4/cpuhp" , test_acpi_piix4_tcg_cphp);qtest_add_func ("acpi/q35/cpuhp" , test_acpi_q35_tcg_cphp); +qtest_add_func ("acpi/piix4/memhp" , test_acpi_piix4_tcg_memhp); +qtest_add_func ("acpi/q35/memhp" , test_acpi_q35_tcg_memhp); } ret =g_test_run ();boot_sector_cleanup (disk);
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH for-2.9 01/10] tests: pc: add memory hotplug acpi tables tests
tests/bios-tables-test.c static void test_acpi_piix4_tcg_ipmi(void) · line 869
Quoted 13 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- tests/bios-tables-test.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)tests/bios-tables-test.c +0
-0@@ -867,6 +867,28 @@ static void test_acpi_piix4_tcg_ipmi(void)free_test_data (&data); }
Hi Igor,
tests/bios-tables-test.c static void test_acpi_piix4_tcg_ipmi(void) · line 877
Quoted 8 lines
tests/bios-tables-test.c +8
-0+static void test_acpi_q35_tcg_memhp (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_Q35 ; + data.variant =".memhp" ; +test_acpi_one (" -m 128,slots=3,maxmem=1G -numa node" , &data);
Why do we need the "-numa node" ? (I am sure you put it there for a reason, but I don't know it :))
Thanks,
Marcel
Quoted 27 lines
tests/bios-tables-test.c +16
-0+free_test_data (&data); +} + +static void test_acpi_piix4_tcg_memhp (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_PC ; + data.variant =".memhp" ; +test_acpi_one (" -m 128,slots=3,maxmem=1G -numa node" , &data); +free_test_data (&data); +} +int main (int argc,char *argv[]) {const char *arch =qtest_get_arch ();@@ -887,6 +909,8 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/q35/ipmi" , test_acpi_q35_tcg_ipmi);qtest_add_func ("acpi/piix4/cpuhp" , test_acpi_piix4_tcg_cphp);qtest_add_func ("acpi/q35/cpuhp" , test_acpi_q35_tcg_cphp); +qtest_add_func ("acpi/piix4/memhp" , test_acpi_piix4_tcg_memhp); +qtest_add_func ("acpi/q35/memhp" , test_acpi_q35_tcg_memhp); } ret =g_test_run ();boot_sector_cleanup (disk);
Re: [Qemu-devel] [PATCH for-2.9 01/10] tests: pc: add memory hotplug acpi tables tests
Quoted 18 lines · On Tue, 20 Dec 2016 12:40:21 +0200 Marcel Apfelbaum <[email protected]> wrote:
tests/bios-tables-test.c static void test_acpi_piix4_tcg_ipmi(void) · line 869
Quoted 13 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- tests/bios-tables-test.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)tests/bios-tables-test.c +0
-0@@ -867,6 +867,28 @@ static void test_acpi_piix4_tcg_ipmi(void)free_test_data (&data); }Hi Igor,
Quoted 10 lines
tests/bios-tables-test.c static void test_acpi_piix4_tcg_ipmi(void) · line 877
Quoted 8 lines
tests/bios-tables-test.c +8
-0+static void test_acpi_q35_tcg_memhp (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_Q35 ; + data.variant =".memhp" ; +test_acpi_one (" -m 128,slots=3,maxmem=1G -numa node" , &data);Why do we need the "-numa node" ? (I am sure you put it there for a reason, but I don't know it :))
I added it to expose SRAT table to guest
so we could detect unexpected changes caused by memory hotplug changes
Quoted 31 lines
Thanks,
MarcelQuoted 27 lines
tests/bios-tables-test.c +16
-0+free_test_data (&data); +} + +static void test_acpi_piix4_tcg_memhp (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_PC ; + data.variant =".memhp" ; +test_acpi_one (" -m 128,slots=3,maxmem=1G -numa node" , &data); +free_test_data (&data); +} +int main (int argc,char *argv[]) {const char *arch =qtest_get_arch ();@@ -887,6 +909,8 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/q35/ipmi" , test_acpi_q35_tcg_ipmi);qtest_add_func ("acpi/piix4/cpuhp" , test_acpi_piix4_tcg_cphp);qtest_add_func ("acpi/q35/cpuhp" , test_acpi_q35_tcg_cphp); +qtest_add_func ("acpi/piix4/memhp" , test_acpi_piix4_tcg_memhp); +qtest_add_func ("acpi/q35/memhp" , test_acpi_q35_tcg_memhp); } ret =g_test_run ();boot_sector_cleanup (disk);
Marcel Apfelbaum
Reviewed-byRe: [Qemu-devel] [PATCH for-2.9 01/10] tests: pc: add memory hotplug acpi tables tests
Quoted 31 lines · Igor Mammedov
Quoted 18 lines · On Tue, 20 Dec 2016 12:40:21 +0200 Marcel Apfelbaum <[email protected]> wrote:
tests/bios-tables-test.c static void test_acpi_piix4_tcg_ipmi(void) · line 869
Quoted 13 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- tests/bios-tables-test.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)tests/bios-tables-test.c +0
-0@@ -867,6 +867,28 @@ static void test_acpi_piix4_tcg_ipmi(void)free_test_data (&data); }Hi Igor,
Quoted 10 lines
tests/bios-tables-test.c static void test_acpi_piix4_tcg_ipmi(void) · line 877
Quoted 8 lines
tests/bios-tables-test.c +8
-0+static void test_acpi_q35_tcg_memhp (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_Q35 ; + data.variant =".memhp" ; +test_acpi_one (" -m 128,slots=3,maxmem=1G -numa node" , &data);Why do we need the "-numa node" ? (I am sure you put it there for a reason, but I don't know it :))
Quoted 3 lines
I added it to expose SRAT table to guest
so we could detect unexpected changes caused by memory hotplug changes
Thanks
Quoted 32 lines
Quoted 31 lines
Thanks,
MarcelQuoted 27 lines
tests/bios-tables-test.c +16
-0+free_test_data (&data); +} + +static void test_acpi_piix4_tcg_memhp (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_PC ; + data.variant =".memhp" ; +test_acpi_one (" -m 128,slots=3,maxmem=1G -numa node" , &data); +free_test_data (&data); +} +int main (int argc,char *argv[]) {const char *arch =qtest_get_arch ();@@ -887,6 +909,8 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/q35/ipmi" , test_acpi_q35_tcg_ipmi);qtest_add_func ("acpi/piix4/cpuhp" , test_acpi_piix4_tcg_cphp);qtest_add_func ("acpi/q35/cpuhp" , test_acpi_q35_tcg_cphp); +qtest_add_func ("acpi/piix4/memhp" , test_acpi_piix4_tcg_memhp); +qtest_add_func ("acpi/q35/memhp" , test_acpi_q35_tcg_memhp); } ret =g_test_run ();boot_sector_cleanup (disk);
PATCH 2/10 tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant
In reply to Igor Mammedov---
PS: note to maintainer
when applied, this patch should be merged with previous patch
"tests: pc: add memory hotplug acpi tables tests"
to avoid 'make check" failure during bisect
--- tests/acpi-test-data/pc/DSDT.memhp | Bin 0 -> 6613 bytes tests/acpi-test-data/pc/SRAT.memhp | Bin 0 -> 224 bytes tests/acpi-test-data/q35/DSDT.memhp | Bin 0 -> 9375 bytes tests/acpi-test-data/q35/SRAT.memhp | Bin 0 -> 224 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/acpi-test-data/pc/DSDT.memhp create mode 100644 tests/acpi-test-data/pc/SRAT.memhp create mode 100644 tests/acpi-test-data/q35/DSDT.memhp create mode 100644 tests/acpi-test-data/q35/SRAT.memhp
tests/acpi-test-data/pc/DSDT.memhp new file binary +0 -0
tests/acpi-test-data/pc/SRAT.memhp new file binary +0 -0
tests/acpi-test-data/q35/DSDT.memhp new file binary +0 -0
tests/acpi-test-data/q35/SRAT.memhp new file binary +0 -0
Signature · 1 line
2.7.4
PATCH 3/10 memhp: move build_memory_hotplug_aml() into memory_hotplug.c
In reply to Igor Mammedov--- hw/acpi/Makefile.objs | 2 +- hw/acpi/memory_hotplug.c | 247 +++++++++++++++++++++++++++++++++ hw/acpi/memory_hotplug_acpi_table.c | 262 ------------------------------------ 3 files changed, 248 insertions(+), 263 deletions(-) delete mode 100644 hw/acpi/memory_hotplug_acpi_table.c
hw/acpi/Makefile.objs +1 -1
@@ -1,7 +1,7 @@ common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o +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) += acpi_interface.o
hw/acpi/memory_hotplug.c +247 -0
250 lines not on this page · raw message
hw/acpi/memory_hotplug_acpi_table.c deleted +0 -262
262 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH for-2.9 03/10] memhp: move build_memory_hotplug_aml() into memory_hotplug.c
Quoted 535 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/Makefile.objs | 2 +- hw/acpi/memory_hotplug.c | 247 +++++++++++++++++++++++++++++++++ hw/acpi/memory_hotplug_acpi_table.c | 262 ------------------------------------ 3 files changed, 248 insertions(+), 263 deletions(-) delete mode 100644 hw/acpi/memory_hotplug_acpi_table.chw/acpi/Makefile.objs +1
-1@@ -1,7 +1,7 @@ common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o +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) += acpi_interface.ohw/acpi/memory_hotplug.c +247
-0@@ -306,3 +306,250 @@ const VMStateDescription vmstate_memory_hotplug = { VMSTATE_END_OF_LIST() } }; + +void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +uint16_t io_base,uint16_t io_len) +{ +Aml *ifctx; +Aml *method; +Aml *pci_scope; +Aml *mem_ctrl_dev; + +/* scope for memory hotplug controller device node */ + pci_scope =aml_scope ("_SB.PCI0" ); + mem_ctrl_dev =aml_device (MEMORY_HOTPLUG_DEVICE ); + { +Aml *one =aml_int (1 ); +Aml *zero =aml_int (0 ); +Aml *ret_val =aml_local (0 ); +Aml *slot_arg0 =aml_arg (0 ); +Aml *slots_nr =aml_name (MEMORY_SLOTS_NUMBER ); +Aml *ctrl_lock =aml_name (MEMORY_SLOT_LOCK ); +Aml *slot_selector =aml_name (MEMORY_SLOT_SLECTOR ); + +aml_append (mem_ctrl_dev,aml_name_decl ("_HID" ,aml_string ("PNP0A06" ))); +aml_append (mem_ctrl_dev, +aml_name_decl ("_UID" ,aml_string ("Memory hotplug resources" ))); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + ifctx =aml_if (aml_equal (slots_nr, zero)); + { +aml_append (ifctx,aml_return (zero)); + } +aml_append (method, ifctx); +/* present, functioning, decoding, not shown in UI */ +aml_append (method,aml_return (aml_int (0xB ))); +aml_append (mem_ctrl_dev, method); + +aml_append (mem_ctrl_dev,aml_mutex (MEMORY_SLOT_LOCK ,0 )); + + method =aml_method (MEMORY_SLOT_SCAN_METHOD ,0 ,AML_NOTSERIALIZED ); + { +Aml *else_ctx; +Aml *while_ctx; +Aml *idx =aml_local (0 ); +Aml *eject_req =aml_int (3 ); +Aml *dev_chk =aml_int (1 ); + + ifctx =aml_if (aml_equal (slots_nr, zero)); + { +aml_append (ifctx,aml_return (zero)); + } +aml_append (method, ifctx); + +aml_append (method,aml_store (zero, idx)); +aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); +/* build AML that: +* loops over all slots and Notifies DIMMs with +* Device Check or Eject Request notifications if +* slot has corresponding status bit set and clears +* slot status. +*/ + while_ctx =aml_while (aml_lless (idx, slots_nr)); + { +Aml *ins_evt =aml_name (MEMORY_SLOT_INSERT_EVENT ); +Aml *rm_evt =aml_name (MEMORY_SLOT_REMOVE_EVENT ); + +aml_append (while_ctx,aml_store (idx, slot_selector)); + ifctx =aml_if (aml_equal (ins_evt, one)); + { +aml_append (ifctx, +aml_call2 (MEMORY_SLOT_NOTIFY_METHOD , + idx, dev_chk)); +aml_append (ifctx,aml_store (one, ins_evt)); + } +aml_append (while_ctx, ifctx); + + else_ctx =aml_else (); + ifctx =aml_if (aml_equal (rm_evt, one)); + { +aml_append (ifctx, +aml_call2 (MEMORY_SLOT_NOTIFY_METHOD , + idx, eject_req)); +aml_append (ifctx,aml_store (one, rm_evt)); + } +aml_append (else_ctx, ifctx); +aml_append (while_ctx, else_ctx); + +aml_append (while_ctx,aml_add (idx, one, idx)); + } +aml_append (method, while_ctx); +aml_append (method,aml_release (ctrl_lock)); +aml_append (method,aml_return (one)); + } +aml_append (mem_ctrl_dev, method); + + method =aml_method (MEMORY_SLOT_STATUS_METHOD ,1 ,AML_NOTSERIALIZED ); + { +Aml *slot_enabled =aml_name (MEMORY_SLOT_ENABLED ); + +aml_append (method,aml_store (zero, ret_val)); +aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); +aml_append (method, +aml_store (aml_to_integer (slot_arg0), slot_selector)); + + ifctx =aml_if (aml_equal (slot_enabled, one)); + { +aml_append (ifctx,aml_store (aml_int (0xF ), ret_val)); + } +aml_append (method, ifctx); + +aml_append (method,aml_release (ctrl_lock)); +aml_append (method,aml_return (ret_val)); + } +aml_append (mem_ctrl_dev, method); + + method =aml_method (MEMORY_SLOT_CRS_METHOD ,1 ,AML_SERIALIZED ); + { +Aml *mr64 =aml_name ("MR64" ); +Aml *mr32 =aml_name ("MR32" ); +Aml *crs_tmpl =aml_resource_template (); +Aml *minl =aml_name ("MINL" ); +Aml *minh =aml_name ("MINH" ); +Aml *maxl =aml_name ("MAXL" ); +Aml *maxh =aml_name ("MAXH" ); +Aml *lenl =aml_name ("LENL" ); +Aml *lenh =aml_name ("LENH" ); + +aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); +aml_append (method,aml_store (aml_to_integer (slot_arg0), + slot_selector)); + +aml_append (crs_tmpl, +aml_qword_memory (AML_POS_DECODE ,AML_MIN_FIXED ,AML_MAX_FIXED , +AML_CACHEABLE ,AML_READ_WRITE , +0 ,0x0 ,0xFFFFFFFFFFFFFFFEULL ,0 , +0xFFFFFFFFFFFFFFFFULL )); +aml_append (method,aml_name_decl ("MR64" , crs_tmpl)); +aml_append (method, +aml_create_dword_field (mr64,aml_int (14 ),"MINL" )); +aml_append (method, +aml_create_dword_field (mr64,aml_int (18 ),"MINH" )); +aml_append (method, +aml_create_dword_field (mr64,aml_int (38 ),"LENL" )); +aml_append (method, +aml_create_dword_field (mr64,aml_int (42 ),"LENH" )); +aml_append (method, +aml_create_dword_field (mr64,aml_int (22 ),"MAXL" )); +aml_append (method, +aml_create_dword_field (mr64,aml_int (26 ),"MAXH" )); + +aml_append (method, +aml_store (aml_name (MEMORY_SLOT_ADDR_HIGH ), minh)); +aml_append (method, +aml_store (aml_name (MEMORY_SLOT_ADDR_LOW ), minl)); +aml_append (method, +aml_store (aml_name (MEMORY_SLOT_SIZE_HIGH ), lenh)); +aml_append (method, +aml_store (aml_name (MEMORY_SLOT_SIZE_LOW ), lenl)); + +/* 64-bit math: MAX = MIN + LEN - 1 */ +aml_append (method,aml_add (minl, lenl, maxl)); +aml_append (method,aml_add (minh, lenh, maxh)); + ifctx =aml_if (aml_lless (maxl, minl)); + { +aml_append (ifctx,aml_add (maxh, one, maxh)); + } +aml_append (method, ifctx); + ifctx =aml_if (aml_lless (maxl, one)); + { +aml_append (ifctx,aml_subtract (maxh, one, maxh)); + } +aml_append (method, ifctx); +aml_append (method,aml_subtract (maxl, one, maxl)); + +/* return 32-bit _CRS if addr/size is in low mem */ +/* TODO: remove it since all hotplugged DIMMs are in high mem */ + ifctx =aml_if (aml_equal (maxh, zero)); + { + crs_tmpl =aml_resource_template (); +aml_append (crs_tmpl, +aml_dword_memory (AML_POS_DECODE ,AML_MIN_FIXED , +AML_MAX_FIXED ,AML_CACHEABLE , +AML_READ_WRITE , +0 ,0x0 ,0xFFFFFFFE ,0 , +0xFFFFFFFF )); +aml_append (ifctx,aml_name_decl ("MR32" , crs_tmpl)); +aml_append (ifctx, +aml_create_dword_field (mr32,aml_int (10 ),"MIN" )); +aml_append (ifctx, +aml_create_dword_field (mr32,aml_int (14 ),"MAX" )); +aml_append (ifctx, +aml_create_dword_field (mr32,aml_int (22 ),"LEN" )); +aml_append (ifctx,aml_store (minl,aml_name ("MIN" ))); +aml_append (ifctx,aml_store (maxl,aml_name ("MAX" ))); +aml_append (ifctx,aml_store (lenl,aml_name ("LEN" ))); + +aml_append (ifctx,aml_release (ctrl_lock)); +aml_append (ifctx,aml_return (mr32)); + } +aml_append (method, ifctx); + +aml_append (method,aml_release (ctrl_lock)); +aml_append (method,aml_return (mr64)); + } +aml_append (mem_ctrl_dev, method); + + method =aml_method (MEMORY_SLOT_PROXIMITY_METHOD ,1 , +AML_NOTSERIALIZED ); + { +Aml *proximity =aml_name (MEMORY_SLOT_PROXIMITY ); + +aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); +aml_append (method,aml_store (aml_to_integer (slot_arg0), + slot_selector)); +aml_append (method,aml_store (proximity, ret_val)); +aml_append (method,aml_release (ctrl_lock)); +aml_append (method,aml_return (ret_val)); + } +aml_append (mem_ctrl_dev, method); + + method =aml_method (MEMORY_SLOT_OST_METHOD ,4 ,AML_NOTSERIALIZED ); + { +Aml *ost_evt =aml_name (MEMORY_SLOT_OST_EVENT ); +Aml *ost_status =aml_name (MEMORY_SLOT_OST_STATUS ); + +aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); +aml_append (method,aml_store (aml_to_integer (slot_arg0), + slot_selector)); +aml_append (method,aml_store (aml_arg (1 ), ost_evt)); +aml_append (method,aml_store (aml_arg (2 ), ost_status)); +aml_append (method,aml_release (ctrl_lock)); + } +aml_append (mem_ctrl_dev, method); + + method =aml_method (MEMORY_SLOT_EJECT_METHOD ,2 ,AML_NOTSERIALIZED ); + { +Aml *eject =aml_name (MEMORY_SLOT_EJECT ); + +aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); +aml_append (method,aml_store (aml_to_integer (slot_arg0), + slot_selector)); +aml_append (method,aml_store (one, eject)); +aml_append (method,aml_release (ctrl_lock)); + } +aml_append (mem_ctrl_dev, method); + } +aml_append (pci_scope, mem_ctrl_dev); +aml_append (ctx, pci_scope); +}hw/acpi/memory_hotplug_acpi_table.c deleted +0
-252@@ -1,262 +0,0 @@ -/* -* Memory hotplug AML code of DSDT ACPI table -* -* Copyright (C) 2015 Red Hat Inc -* -* Author: Igor Mammedov <[email protected]> -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -*/ - -#include "qemu/osdep.h" -#include "hw/acpi/memory_hotplug.h" -#include "include/hw/acpi/pc-hotplug.h" -#include "hw/boards.h" - -void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, -uint16_t io_base,uint16_t io_len) -{ -Aml *ifctx; -Aml *method; -Aml *pci_scope; -Aml *mem_ctrl_dev; - -/* scope for memory hotplug controller device node */ - pci_scope =aml_scope ("_SB.PCI0" ); - mem_ctrl_dev =aml_device (MEMORY_HOTPLUG_DEVICE ); - { -Aml *one =aml_int (1 ); -Aml *zero =aml_int (0 ); -Aml *ret_val =aml_local (0 ); -Aml *slot_arg0 =aml_arg (0 ); -Aml *slots_nr =aml_name (MEMORY_SLOTS_NUMBER ); -Aml *ctrl_lock =aml_name (MEMORY_SLOT_LOCK ); -Aml *slot_selector =aml_name (MEMORY_SLOT_SLECTOR ); - -aml_append (mem_ctrl_dev,aml_name_decl ("_HID" ,aml_string ("PNP0A06" ))); -aml_append (mem_ctrl_dev, -aml_name_decl ("_UID" ,aml_string ("Memory hotplug resources" ))); - - method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); - ifctx =aml_if (aml_equal (slots_nr, zero)); - { -aml_append (ifctx,aml_return (zero)); - } -aml_append (method, ifctx); -/* present, functioning, decoding, not shown in UI */ -aml_append (method,aml_return (aml_int (0xB ))); -aml_append (mem_ctrl_dev, method); - -aml_append (mem_ctrl_dev,aml_mutex (MEMORY_SLOT_LOCK ,0 )); - - method =aml_method (MEMORY_SLOT_SCAN_METHOD ,0 ,AML_NOTSERIALIZED ); - { -Aml *else_ctx; -Aml *while_ctx; -Aml *idx =aml_local (0 ); -Aml *eject_req =aml_int (3 ); -Aml *dev_chk =aml_int (1 ); - - ifctx =aml_if (aml_equal (slots_nr, zero)); - { -aml_append (ifctx,aml_return (zero)); - } -aml_append (method, ifctx); - -aml_append (method,aml_store (zero, idx)); -aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); -/* build AML that: -* loops over all slots and Notifies DIMMs with -* Device Check or Eject Request notifications if -* slot has corresponding status bit set and clears -* slot status. -*/ - while_ctx =aml_while (aml_lless (idx, slots_nr)); - { -Aml *ins_evt =aml_name (MEMORY_SLOT_INSERT_EVENT ); -Aml *rm_evt =aml_name (MEMORY_SLOT_REMOVE_EVENT ); - -aml_append (while_ctx,aml_store (idx, slot_selector)); - ifctx =aml_if (aml_equal (ins_evt, one)); - { -aml_append (ifctx, -aml_call2 (MEMORY_SLOT_NOTIFY_METHOD , - idx, dev_chk)); -aml_append (ifctx,aml_store (one, ins_evt)); - } -aml_append (while_ctx, ifctx); - - else_ctx =aml_else (); - ifctx =aml_if (aml_equal (rm_evt, one)); - { -aml_append (ifctx, -aml_call2 (MEMORY_SLOT_NOTIFY_METHOD , - idx, eject_req)); -aml_append (ifctx,aml_store (one, rm_evt)); - } -aml_append (else_ctx, ifctx); -aml_append (while_ctx, else_ctx); - -aml_append (while_ctx,aml_add (idx, one, idx)); - } -aml_append (method, while_ctx); -aml_append (method,aml_release (ctrl_lock)); -aml_append (method,aml_return (one)); - } -aml_append (mem_ctrl_dev, method); - - method =aml_method (MEMORY_SLOT_STATUS_METHOD ,1 ,AML_NOTSERIALIZED ); - { -Aml *slot_enabled =aml_name (MEMORY_SLOT_ENABLED ); - -aml_append (method,aml_store (zero, ret_val)); -aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); -aml_append (method, -aml_store (aml_to_integer (slot_arg0), slot_selector)); - - ifctx =aml_if (aml_equal (slot_enabled, one)); - { -aml_append (ifctx,aml_store (aml_int (0xF ), ret_val)); - } -aml_append (method, ifctx); - -aml_append (method,aml_release (ctrl_lock)); -aml_append (method,aml_return (ret_val)); - } -aml_append (mem_ctrl_dev, method); - - method =aml_method (MEMORY_SLOT_CRS_METHOD ,1 ,AML_SERIALIZED ); - { -Aml *mr64 =aml_name ("MR64" ); -Aml *mr32 =aml_name ("MR32" ); -Aml *crs_tmpl =aml_resource_template (); -Aml *minl =aml_name ("MINL" ); -Aml *minh =aml_name ("MINH" ); -Aml *maxl =aml_name ("MAXL" ); -Aml *maxh =aml_name ("MAXH" ); -Aml *lenl =aml_name ("LENL" ); -Aml *lenh =aml_name ("LENH" ); - -aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); -aml_append (method,aml_store (aml_to_integer (slot_arg0), - slot_selector)); - -aml_append (crs_tmpl, -aml_qword_memory (AML_POS_DECODE ,AML_MIN_FIXED ,AML_MAX_FIXED , -AML_CACHEABLE ,AML_READ_WRITE , -0 ,0x0 ,0xFFFFFFFFFFFFFFFEULL ,0 , -0xFFFFFFFFFFFFFFFFULL )); -aml_append (method,aml_name_decl ("MR64" , crs_tmpl)); -aml_append (method, -aml_create_dword_field (mr64,aml_int (14 ),"MINL" )); -aml_append (method, -aml_create_dword_field (mr64,aml_int (18 ),"MINH" )); -aml_append (method, -aml_create_dword_field (mr64,aml_int (38 ),"LENL" )); -aml_append (method, -aml_create_dword_field (mr64,aml_int (42 ),"LENH" )); -aml_append (method, -aml_create_dword_field (mr64,aml_int (22 ),"MAXL" )); -aml_append (method, -aml_create_dword_field (mr64,aml_int (26 ),"MAXH" )); - -aml_append (method, -aml_store (aml_name (MEMORY_SLOT_ADDR_HIGH ), minh)); -aml_append (method, -aml_store (aml_name (MEMORY_SLOT_ADDR_LOW ), minl)); -aml_append (method, -aml_store (aml_name (MEMORY_SLOT_SIZE_HIGH ), lenh)); -aml_append (method, -aml_store (aml_name (MEMORY_SLOT_SIZE_LOW ), lenl)); - -/* 64-bit math: MAX = MIN + LEN - 1 */ -aml_append (method,aml_add (minl, lenl, maxl)); -aml_append (method,aml_add (minh, lenh, maxh)); - ifctx =aml_if (aml_lless (maxl, minl)); - { -aml_append (ifctx,aml_add (maxh, one, maxh)); - } -aml_append (method, ifctx); - ifctx =aml_if (aml_lless (maxl, one)); - { -aml_append (ifctx,aml_subtract (maxh, one, maxh)); - } -aml_append (method, ifctx); -aml_append (method,aml_subtract (maxl, one, maxl)); - -/* return 32-bit _CRS if addr/size is in low mem */ -/* TODO: remove it since all hotplugged DIMMs are in high mem */ - ifctx =aml_if (aml_equal (maxh, zero)); - { - crs_tmpl =aml_resource_template (); -aml_append (crs_tmpl, -aml_dword_memory (AML_POS_DECODE ,AML_MIN_FIXED , -AML_MAX_FIXED ,AML_CACHEABLE , -AML_READ_WRITE , -0 ,0x0 ,0xFFFFFFFE ,0 , -0xFFFFFFFF )); -aml_append (ifctx,aml_name_decl ("MR32" , crs_tmpl)); -aml_append (ifctx, -aml_create_dword_field (mr32,aml_int (10 ),"MIN" )); -aml_append (ifctx, -aml_create_dword_field (mr32,aml_int (14 ),"MAX" )); -aml_append (ifctx, -aml_create_dword_field (mr32,aml_int (22 ),"LEN" )); -aml_append (ifctx,aml_store (minl,aml_name ("MIN" ))); -aml_append (ifctx,aml_store (maxl,aml_name ("MAX" ))); -aml_append (ifctx,aml_store (lenl,aml_name ("LEN" ))); - -aml_append (ifctx,aml_release (ctrl_lock)); -aml_append (ifctx,aml_return (mr32)); - } -aml_append (method, ifctx); - -aml_append (method,aml_release (ctrl_lock)); -aml_append (method,aml_return (mr64)); - } -aml_append (mem_ctrl_dev, method); - - method =aml_method (MEMORY_SLOT_PROXIMITY_METHOD ,1 , -AML_NOTSERIALIZED ); - { -Aml *proximity =aml_name (MEMORY_SLOT_PROXIMITY ); - -aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); -aml_append (method,aml_store (aml_to_integer (slot_arg0), - slot_selector)); -aml_append (method,aml_store (proximity, ret_val)); -aml_append (method,aml_release (ctrl_lock)); -aml_append (method,aml_return (ret_val)); - } -aml_append (mem_ctrl_dev, method); - - method =aml_method (MEMORY_SLOT_OST_METHOD ,4 ,AML_NOTSERIALIZED ); - { -Aml *ost_evt =aml_name (MEMORY_SLOT_OST_EVENT ); -Aml *ost_status =aml_name (MEMORY_SLOT_OST_STATUS ); - -aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); -aml_append (method,aml_store (aml_to_integer (slot_arg0), - slot_selector)); -aml_append (method,aml_store (aml_arg (1 ), ost_evt)); -aml_append (method,aml_store (aml_arg (2 ), ost_status)); -aml_append (method,aml_release (ctrl_lock)); - } -aml_append (mem_ctrl_dev, method); - - method =aml_method (MEMORY_SLOT_EJECT_METHOD ,2 ,AML_NOTSERIALIZED ); - { -Aml *eject =aml_name (MEMORY_SLOT_EJECT ); - -aml_append (method,aml_acquire (ctrl_lock,0xFFFF ));
hw/acpi/memory_hotplug_acpi_table.c line 262
Quoted 10 lines
hw/acpi/memory_hotplug_acpi_table.c deleted +0
-10-aml_append (method,aml_store (aml_to_integer (slot_arg0), - slot_selector)); -aml_append (method,aml_store (one, eject)); -aml_append (method,aml_release (ctrl_lock)); - } -aml_append (mem_ctrl_dev, method); - } -aml_append (pci_scope, mem_ctrl_dev); -aml_append (ctx, pci_scope); -}
I suppose we don't need the extra file.
Thanks,
Marcel
PATCH 4/10 memhp: move build_memory_devices() into memory_hotplug.c
In reply to Igor Mammedov--- include/hw/acpi/memory_hotplug.h | 2 + hw/acpi/memory_hotplug.c | 124 +++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 124 --------------------------------------- 3 files changed, 126 insertions(+), 124 deletions(-)
include/hw/acpi/memory_hotplug.h +2 -0
@@ -54,4 +54,6 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem,uint16_t io_base,uint16_t io_len); +void build_memory_devices (Aml *sb_scope,int nr_mem, +uint16_t io_base,uint16_t io_len);#endif
hw/acpi/memory_hotplug.c +124 -0
127 lines not on this page · raw message
hw/i386/acpi-build.c +0 -124
130 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH for-2.9 04/10] memhp: move build_memory_devices() into memory_hotplug.c
Quoted 12 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/memory_hotplug.h | 2 + hw/acpi/memory_hotplug.c | 124 +++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 124 --------------------------------------- 3 files changed, 126 insertions(+), 124 deletions(-)include/hw/acpi/memory_hotplug.h +0
-0
include/hw/acpi/memory_hotplug.h void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list); · line 58
Quoted 5 lines
include/hw/acpi/memory_hotplug.h +2
-0@@ -54,4 +54,6 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem,uint16_t io_base,uint16_t io_len); +void build_memory_devices (Aml *sb_scope,int nr_mem, +uint16_t io_base,uint16_t io_len);
We add an extra function to the header file, but if it can be used by the ARM machines is worth it.
Thanks,
Marcel
Quoted 269 lines
include/hw/acpi/memory_hotplug.h +0
-0#endif hw/acpi/memory_hotplug.c +124
-0@@ -553,3 +553,127 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (pci_scope, mem_ctrl_dev);aml_append (ctx, pci_scope); } + +void build_memory_devices (Aml *sb_scope,int nr_mem, +uint16_t io_base,uint16_t io_len) +{ +int i; +Aml *scope; +Aml *crs; +Aml *field; +Aml *dev; +Aml *method; +Aml *ifctx; + +/* build memory devices */ +assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); + scope =aml_scope ("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE ); +aml_append (scope, +aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) + ); + + crs =aml_resource_template (); +aml_append (crs, +aml_io (AML_DECODE16 , io_base, io_base,0 , io_len) + ); +aml_append (scope,aml_name_decl ("_CRS" , crs)); + +aml_append (scope,aml_operation_region ( +MEMORY_HOTPLUG_IO_REGION ,AML_SYSTEM_IO , +aml_int (io_base), io_len) + ); + + field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , +AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_ADDR_LOW ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_ADDR_HIGH ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_SIZE_LOW ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_SIZE_HIGH ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_PROXIMITY ,32 )); +aml_append (scope, field); + + field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_BYTE_ACC , +AML_NOLOCK ,AML_WRITE_AS_ZEROS ); +aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); +aml_append (field,/* 1 if enabled, read only */ +aml_named_field (MEMORY_SLOT_ENABLED ,1 )); +aml_append (field, +/*(read) 1 if has a insert event. (write) 1 to clear event */ +aml_named_field (MEMORY_SLOT_INSERT_EVENT ,1 )); +aml_append (field, +/* (read) 1 if has a remove event. (write) 1 to clear event */ +aml_named_field (MEMORY_SLOT_REMOVE_EVENT ,1 )); +aml_append (field, +/* initiates device eject, write only */ +aml_named_field (MEMORY_SLOT_EJECT ,1 )); +aml_append (scope, field); + + field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , +AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,/* DIMM selector, write only */ +aml_named_field (MEMORY_SLOT_SLECTOR ,32 )); +aml_append (field,/* _OST event code, write only */ +aml_named_field (MEMORY_SLOT_OST_EVENT ,32 )); +aml_append (field,/* _OST status code, write only */ +aml_named_field (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." MEMORY_HOTPLUG_DEVICE "." +const char *s; + + dev =aml_device ("MP%02X" , i); +aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); + + method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); + s = BASEPATH MEMORY_SLOT_CRS_METHOD; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + s = BASEPATH MEMORY_SLOT_STATUS_METHOD; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); + s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); + s = BASEPATH MEMORY_SLOT_OST_METHOD; + +aml_append (method,aml_return (aml_call4 ( + s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) + ))); +aml_append (dev, method); + + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); + s = BASEPATH MEMORY_SLOT_EJECT_METHOD; +aml_append (method,aml_return (aml_call2 ( + s,aml_name ("_UID" ),aml_arg (0 )))); +aml_append (dev, method); + +aml_append (sb_scope, dev); + } + +/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { +* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } +*/ + method =aml_method (MEMORY_SLOT_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); +for (i =0 ; i < nr_mem; i++) { + ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); +aml_append (ifctx, +aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) + ); +aml_append (method, ifctx); + } +aml_append (sb_scope, method); +}hw/i386/acpi-build.c +0
-124@@ -1038,130 +1038,6 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)return crs; } -static void build_memory_devices (Aml *sb_scope,int nr_mem, -uint16_t io_base,uint16_t io_len) -{ -int i; -Aml *scope; -Aml *crs; -Aml *field; -Aml *dev; -Aml *method; -Aml *ifctx; - -/* build memory devices */ -assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); - scope =aml_scope ("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE ); -aml_append (scope, -aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) - ); - - crs =aml_resource_template (); -aml_append (crs, -aml_io (AML_DECODE16 , io_base, io_base,0 , io_len) - ); -aml_append (scope,aml_name_decl ("_CRS" , crs)); - -aml_append (scope,aml_operation_region ( -MEMORY_HOTPLUG_IO_REGION ,AML_SYSTEM_IO , -aml_int (io_base), io_len) - ); - - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , -AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_ADDR_LOW ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_ADDR_HIGH ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_SIZE_LOW ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_SIZE_HIGH ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_PROXIMITY ,32 )); -aml_append (scope, field); - - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_BYTE_ACC , -AML_NOLOCK ,AML_WRITE_AS_ZEROS ); -aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); -aml_append (field,/* 1 if enabled, read only */ -aml_named_field (MEMORY_SLOT_ENABLED ,1 )); -aml_append (field, -/*(read) 1 if has a insert event. (write) 1 to clear event */ -aml_named_field (MEMORY_SLOT_INSERT_EVENT ,1 )); -aml_append (field, -/* (read) 1 if has a remove event. (write) 1 to clear event */ -aml_named_field (MEMORY_SLOT_REMOVE_EVENT ,1 )); -aml_append (field, -/* initiates device eject, write only */ -aml_named_field (MEMORY_SLOT_EJECT ,1 )); -aml_append (scope, field); - - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , -AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,/* DIMM selector, write only */ -aml_named_field (MEMORY_SLOT_SLECTOR ,32 )); -aml_append (field,/* _OST event code, write only */ -aml_named_field (MEMORY_SLOT_OST_EVENT ,32 )); -aml_append (field,/* _OST status code, write only */ -aml_named_field (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." MEMORY_HOTPLUG_DEVICE "." -const char *s; - - dev =aml_device ("MP%02X" , i); -aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); - - method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_CRS_METHOD; -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -aml_append (dev, method); - - method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_STATUS_METHOD; -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -aml_append (dev, method); - - method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD; -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -aml_append (dev, method); - - method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_OST_METHOD; - -aml_append (method,aml_return (aml_call4 ( - s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) - ))); -aml_append (dev, method); - - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_EJECT_METHOD; -aml_append (method,aml_return (aml_call2 ( - s,aml_name ("_UID" ),aml_arg (0 )))); -aml_append (dev, method); - -aml_append (sb_scope, dev); - } - -/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { -* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } -*/ - method =aml_method (MEMORY_SLOT_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); -for (i =0 ; i < nr_mem; i++) { - ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); -aml_append (ifctx, -aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) - ); -aml_append (method, ifctx); - } -aml_append (sb_scope, method); -} -static void build_hpet_aml (Aml *table) {Aml *crs;
Re: [Qemu-devel] [PATCH for-2.9 04/10] memhp: move build_memory_devices() into memory_hotplug.c
Quoted 14 lines · On Tue, 20 Dec 2016 12:44:22 +0200 Marcel Apfelbaum <[email protected]> wrote:
Quoted 13 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/memory_hotplug.h | 2 + hw/acpi/memory_hotplug.c | 124 +++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 124 --------------------------------------- 3 files changed, 126 insertions(+), 124 deletions(-)include/hw/acpi/memory_hotplug.h +0
-0@@ -54,4 +54,6 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
Quoted 8 lines
include/hw/acpi/memory_hotplug.h void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list); · line 58
Quoted 4 lines
include/hw/acpi/memory_hotplug.h +2
-0void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem,uint16_t io_base,uint16_t io_len); +void build_memory_devices (Aml *sb_scope,int nr_mem, +uint16_t io_base,uint16_t io_len);We add an extra function to the header file, but if it can be used by the ARM machines is worth it.
it's temporary for purpose of clean small/atocmic movement and it's removed in 6/10
Quoted 277 lines
Reviewed-by Marcel Apfelbaum <[email protected]>Thanks,
MarcelQuoted 269 lines
include/hw/acpi/memory_hotplug.h +0
-0#endif hw/acpi/memory_hotplug.c +124
-0@@ -553,3 +553,127 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (pci_scope, mem_ctrl_dev);aml_append (ctx, pci_scope); } + +void build_memory_devices (Aml *sb_scope,int nr_mem, +uint16_t io_base,uint16_t io_len) +{ +int i; +Aml *scope; +Aml *crs; +Aml *field; +Aml *dev; +Aml *method; +Aml *ifctx; + +/* build memory devices */ +assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); + scope =aml_scope ("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE ); +aml_append (scope, +aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) + ); + + crs =aml_resource_template (); +aml_append (crs, +aml_io (AML_DECODE16 , io_base, io_base,0 , io_len) + ); +aml_append (scope,aml_name_decl ("_CRS" , crs)); + +aml_append (scope,aml_operation_region ( +MEMORY_HOTPLUG_IO_REGION ,AML_SYSTEM_IO , +aml_int (io_base), io_len) + ); + + field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , +AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_ADDR_LOW ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_ADDR_HIGH ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_SIZE_LOW ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_SIZE_HIGH ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_PROXIMITY ,32 )); +aml_append (scope, field); + + field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_BYTE_ACC , +AML_NOLOCK ,AML_WRITE_AS_ZEROS ); +aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); +aml_append (field,/* 1 if enabled, read only */ +aml_named_field (MEMORY_SLOT_ENABLED ,1 )); +aml_append (field, +/*(read) 1 if has a insert event. (write) 1 to clear event */ +aml_named_field (MEMORY_SLOT_INSERT_EVENT ,1 )); +aml_append (field, +/* (read) 1 if has a remove event. (write) 1 to clear event */ +aml_named_field (MEMORY_SLOT_REMOVE_EVENT ,1 )); +aml_append (field, +/* initiates device eject, write only */ +aml_named_field (MEMORY_SLOT_EJECT ,1 )); +aml_append (scope, field); + + field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , +AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,/* DIMM selector, write only */ +aml_named_field (MEMORY_SLOT_SLECTOR ,32 )); +aml_append (field,/* _OST event code, write only */ +aml_named_field (MEMORY_SLOT_OST_EVENT ,32 )); +aml_append (field,/* _OST status code, write only */ +aml_named_field (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." MEMORY_HOTPLUG_DEVICE "." +const char *s; + + dev =aml_device ("MP%02X" , i); +aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); + + method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); + s = BASEPATH MEMORY_SLOT_CRS_METHOD; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + s = BASEPATH MEMORY_SLOT_STATUS_METHOD; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); + s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); + s = BASEPATH MEMORY_SLOT_OST_METHOD; + +aml_append (method,aml_return (aml_call4 ( + s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) + ))); +aml_append (dev, method); + + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); + s = BASEPATH MEMORY_SLOT_EJECT_METHOD; +aml_append (method,aml_return (aml_call2 ( + s,aml_name ("_UID" ),aml_arg (0 )))); +aml_append (dev, method); + +aml_append (sb_scope, dev); + } + +/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { +* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } +*/ + method =aml_method (MEMORY_SLOT_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); +for (i =0 ; i < nr_mem; i++) { + ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); +aml_append (ifctx, +aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) + ); +aml_append (method, ifctx); + } +aml_append (sb_scope, method); +}hw/i386/acpi-build.c +0
-124@@ -1038,130 +1038,6 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)return crs; } -static void build_memory_devices (Aml *sb_scope,int nr_mem, -uint16_t io_base,uint16_t io_len) -{ -int i; -Aml *scope; -Aml *crs; -Aml *field; -Aml *dev; -Aml *method; -Aml *ifctx; - -/* build memory devices */ -assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); - scope =aml_scope ("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE ); -aml_append (scope, -aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) - ); - - crs =aml_resource_template (); -aml_append (crs, -aml_io (AML_DECODE16 , io_base, io_base,0 , io_len) - ); -aml_append (scope,aml_name_decl ("_CRS" , crs)); - -aml_append (scope,aml_operation_region ( -MEMORY_HOTPLUG_IO_REGION ,AML_SYSTEM_IO , -aml_int (io_base), io_len) - ); - - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , -AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_ADDR_LOW ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_ADDR_HIGH ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_SIZE_LOW ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_SIZE_HIGH ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_PROXIMITY ,32 )); -aml_append (scope, field); - - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_BYTE_ACC , -AML_NOLOCK ,AML_WRITE_AS_ZEROS ); -aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); -aml_append (field,/* 1 if enabled, read only */ -aml_named_field (MEMORY_SLOT_ENABLED ,1 )); -aml_append (field, -/*(read) 1 if has a insert event. (write) 1 to clear event */ -aml_named_field (MEMORY_SLOT_INSERT_EVENT ,1 )); -aml_append (field, -/* (read) 1 if has a remove event. (write) 1 to clear event */ -aml_named_field (MEMORY_SLOT_REMOVE_EVENT ,1 )); -aml_append (field, -/* initiates device eject, write only */ -aml_named_field (MEMORY_SLOT_EJECT ,1 )); -aml_append (scope, field); - - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , -AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,/* DIMM selector, write only */ -aml_named_field (MEMORY_SLOT_SLECTOR ,32 )); -aml_append (field,/* _OST event code, write only */ -aml_named_field (MEMORY_SLOT_OST_EVENT ,32 )); -aml_append (field,/* _OST status code, write only */ -aml_named_field (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." MEMORY_HOTPLUG_DEVICE "." -const char *s; - - dev =aml_device ("MP%02X" , i); -aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); - - method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_CRS_METHOD; -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -aml_append (dev, method); - - method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_STATUS_METHOD; -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -aml_append (dev, method); - - method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD; -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -aml_append (dev, method); - - method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_OST_METHOD; - -aml_append (method,aml_return (aml_call4 ( - s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) - ))); -aml_append (dev, method); - - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_EJECT_METHOD; -aml_append (method,aml_return (aml_call2 ( - s,aml_name ("_UID" ),aml_arg (0 )))); -aml_append (dev, method); - -aml_append (sb_scope, dev); - } - -/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { -* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } -*/ - method =aml_method (MEMORY_SLOT_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); -for (i =0 ; i < nr_mem; i++) { - ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); -aml_append (ifctx, -aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) - ); -aml_append (method, ifctx); - } -aml_append (sb_scope, method); -} -static void build_hpet_aml (Aml *table) {Aml *crs;
PATCH 5/10 memhp: consolidate scattered MHPD device declaration
In reply to Igor Mammedovsince static and dynamic parts of memory MHPD device are now in the same table (DSDT), there is no point keeping them scattered across the table, so consolidate it in one place.
There aren't any functional change, only AML text movement from externally refferenced MHPD scope directly into MHPD device declaration.
--- include/hw/acpi/memory_hotplug.h | 2 +- hw/acpi/memory_hotplug.c | 123 +++++++++++++++++++-------------------- 2 files changed, 61 insertions(+), 64 deletions(-)
include/hw/acpi/memory_hotplug.h +1 -1
@@ -52,7 +52,7 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);#define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \ MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHOD -void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem,uint16_t io_base,uint16_t io_len);void build_memory_devices (Aml *sb_scope,int nr_mem,uint16_t io_base,uint16_t io_len);
hw/acpi/memory_hotplug.c +60 -63
158 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH for-2.9 05/10] memhp: consolidate scattered MHPD device declaration
Quoted 33 lines · Igor Mammedov
since static and dynamic parts of memory MHPD device are now in the same table (DSDT), there is no point keeping them scattered across the table, so consolidate it in one place.
There aren't any functional change, only AML text movement from externally refferenced MHPD scope directly into MHPD device declaration.
Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/memory_hotplug.h | 2 +- hw/acpi/memory_hotplug.c | 123 +++++++++++++++++++-------------------- 2 files changed, 61 insertions(+), 64 deletions(-)include/hw/acpi/memory_hotplug.h +1
-1@@ -52,7 +52,7 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);#define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \ MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHOD -void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem,uint16_t io_base,uint16_t io_len);void build_memory_devices (Aml *sb_scope,int nr_mem,uint16_t io_base,uint16_t io_len);hw/acpi/memory_hotplug.c +0
-0
hw/acpi/memory_hotplug.c const VMStateDescription vmstate_memory_hotplug = { · line 311
Quoted 6 lines
hw/acpi/memory_hotplug.c +1
-1@@ -307,7 +307,7 @@ const VMStateDescription vmstate_memory_hotplug = { } }; -void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem,uint16_t io_base,uint16_t io_len)
The signature of the function is changed, but I see no caller changes. Is this function used?
Quoted 75 lines
hw/acpi/memory_hotplug.c +58
-0{Aml *ifctx;@@ -319,6 +319,8 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, pci_scope =aml_scope ("_SB.PCI0" ); mem_ctrl_dev =aml_device (MEMORY_HOTPLUG_DEVICE ); { +Aml *crs; +Aml *field;Aml *one =aml_int (1 );Aml *zero =aml_int (0 );Aml *ret_val =aml_local (0 );@@ -331,6 +333,62 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (mem_ctrl_dev,aml_name_decl ("_UID" ,aml_string ("Memory hotplug resources" ))); +assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); +aml_append (mem_ctrl_dev, +aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) + ); + + crs =aml_resource_template (); +aml_append (crs, +aml_io (AML_DECODE16 , io_base, io_base,0 , io_len) + ); +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 , +aml_int (io_base), io_len) + ); + + field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , +AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_ADDR_LOW ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_ADDR_HIGH ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_SIZE_LOW ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_SIZE_HIGH ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_PROXIMITY ,32 )); +aml_append (mem_ctrl_dev, field); + + field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_BYTE_ACC , +AML_NOLOCK ,AML_WRITE_AS_ZEROS ); +aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); +aml_append (field,/* 1 if enabled, read only */ +aml_named_field (MEMORY_SLOT_ENABLED ,1 )); +aml_append (field, +/*(read) 1 if has a insert event. (write) 1 to clear event */ +aml_named_field (MEMORY_SLOT_INSERT_EVENT ,1 )); +aml_append (field, +/* (read) 1 if has a remove event. (write) 1 to clear event */ +aml_named_field (MEMORY_SLOT_REMOVE_EVENT ,1 )); +aml_append (field, +/* initiates device eject, write only */ +aml_named_field (MEMORY_SLOT_EJECT ,1 )); +aml_append (mem_ctrl_dev, field); + + field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , +AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,/* DIMM selector, write only */ +aml_named_field (MEMORY_SLOT_SLECTOR ,32 )); +aml_append (field,/* _OST event code, write only */ +aml_named_field (MEMORY_SLOT_OST_EVENT ,32 )); +aml_append (field,/* _OST status code, write only */ +aml_named_field (MEMORY_SLOT_OST_STATUS ,32 )); +aml_append (mem_ctrl_dev, field); + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); ifctx =aml_if (aml_equal (slots_nr, zero)); {
hw/acpi/memory_hotplug.c void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, · line 616
Quoted 9 lines
hw/acpi/memory_hotplug.c +1
-1@@ -551,79 +609,18 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (mem_ctrl_dev, method); }aml_append (pci_scope, mem_ctrl_dev); -aml_append (ctx, pci_scope); +aml_append (table, pci_scope); }void build_memory_devices (Aml *sb_scope,int nr_mem,uint16_t io_base,uint16_t io_len)
Do you still need the io_base/io_len parameters here?
Thanks,
Marcel
Quoted 72 lines
hw/acpi/memory_hotplug.c +0
-61{int i; -Aml *scope; -Aml *crs; -Aml *field;Aml *dev;Aml *method;Aml *ifctx;/* build memory devices */ -assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); - scope =aml_scope ("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE ); -aml_append (scope, -aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) - ); - - crs =aml_resource_template (); -aml_append (crs, -aml_io (AML_DECODE16 , io_base, io_base,0 , io_len) - ); -aml_append (scope,aml_name_decl ("_CRS" , crs)); - -aml_append (scope,aml_operation_region ( -MEMORY_HOTPLUG_IO_REGION ,AML_SYSTEM_IO , -aml_int (io_base), io_len) - ); - - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , -AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_ADDR_LOW ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_ADDR_HIGH ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_SIZE_LOW ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_SIZE_HIGH ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_PROXIMITY ,32 )); -aml_append (scope, field); - - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_BYTE_ACC , -AML_NOLOCK ,AML_WRITE_AS_ZEROS ); -aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); -aml_append (field,/* 1 if enabled, read only */ -aml_named_field (MEMORY_SLOT_ENABLED ,1 )); -aml_append (field, -/*(read) 1 if has a insert event. (write) 1 to clear event */ -aml_named_field (MEMORY_SLOT_INSERT_EVENT ,1 )); -aml_append (field, -/* (read) 1 if has a remove event. (write) 1 to clear event */ -aml_named_field (MEMORY_SLOT_REMOVE_EVENT ,1 )); -aml_append (field, -/* initiates device eject, write only */ -aml_named_field (MEMORY_SLOT_EJECT ,1 )); -aml_append (scope, field); - - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , -AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,/* DIMM selector, write only */ -aml_named_field (MEMORY_SLOT_SLECTOR ,32 )); -aml_append (field,/* _OST event code, write only */ -aml_named_field (MEMORY_SLOT_OST_EVENT ,32 )); -aml_append (field,/* _OST status code, write only */ -aml_named_field (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." MEMORY_HOTPLUG_DEVICE "."const char *s;
Re: [Qemu-devel] [PATCH for-2.9 05/10] memhp: consolidate scattered MHPD device declaration
Quoted 37 lines · On Tue, 20 Dec 2016 13:00:35 +0200 Marcel Apfelbaum <[email protected]> wrote:
Quoted 36 lines · Igor Mammedov
since static and dynamic parts of memory MHPD device are now in the same table (DSDT), there is no point keeping them scattered across the table, so consolidate it in one place.
There aren't any functional change, only AML text movement from externally refferenced MHPD scope directly into MHPD device declaration.
Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/memory_hotplug.h | 2 +- hw/acpi/memory_hotplug.c | 123 +++++++++++++++++++-------------------- 2 files changed, 61 insertions(+), 64 deletions(-)include/hw/acpi/memory_hotplug.h +1
-1@@ -52,7 +52,7 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);#define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \ MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHOD -void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem,uint16_t io_base,uint16_t io_len);void build_memory_devices (Aml *sb_scope,int nr_mem,uint16_t io_base,uint16_t io_len);hw/acpi/memory_hotplug.c +0
-0@@ -307,7 +307,7 @@ const VMStateDescription vmstate_memory_hotplug = { } };
Quoted 6 lines
hw/acpi/memory_hotplug.c const VMStateDescription vmstate_memory_hotplug = { · line 311
Quoted 3 lines
hw/acpi/memory_hotplug.c +1
-1-void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem,uint16_t io_base,uint16_t io_len)The signature of the function is changed, but I see no caller changes. Is this function used?
There is no need to change callers, it's in acpi-build.c, this change is here for better documenting what this argument means within build_memory_hotplug_aml(), see it at the end of patch.
Quoted 165 lines
Quoted 76 lines
hw/acpi/memory_hotplug.c +58
-0{Aml *ifctx;@@ -319,6 +319,8 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, pci_scope =aml_scope ("_SB.PCI0" ); mem_ctrl_dev =aml_device (MEMORY_HOTPLUG_DEVICE ); { +Aml *crs; +Aml *field;Aml *one =aml_int (1 );Aml *zero =aml_int (0 );Aml *ret_val =aml_local (0 );@@ -331,6 +333,62 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (mem_ctrl_dev,aml_name_decl ("_UID" ,aml_string ("Memory hotplug resources" ))); +assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); +aml_append (mem_ctrl_dev, +aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) + ); + + crs =aml_resource_template (); +aml_append (crs, +aml_io (AML_DECODE16 , io_base, io_base,0 , io_len) + ); +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 , +aml_int (io_base), io_len) + ); + + field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , +AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_ADDR_LOW ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_ADDR_HIGH ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_SIZE_LOW ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_SIZE_HIGH ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_PROXIMITY ,32 )); +aml_append (mem_ctrl_dev, field); + + field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_BYTE_ACC , +AML_NOLOCK ,AML_WRITE_AS_ZEROS ); +aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); +aml_append (field,/* 1 if enabled, read only */ +aml_named_field (MEMORY_SLOT_ENABLED ,1 )); +aml_append (field, +/*(read) 1 if has a insert event. (write) 1 to clear event */ +aml_named_field (MEMORY_SLOT_INSERT_EVENT ,1 )); +aml_append (field, +/* (read) 1 if has a remove event. (write) 1 to clear event */ +aml_named_field (MEMORY_SLOT_REMOVE_EVENT ,1 )); +aml_append (field, +/* initiates device eject, write only */ +aml_named_field (MEMORY_SLOT_EJECT ,1 )); +aml_append (mem_ctrl_dev, field); + + field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , +AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,/* DIMM selector, write only */ +aml_named_field (MEMORY_SLOT_SLECTOR ,32 )); +aml_append (field,/* _OST event code, write only */ +aml_named_field (MEMORY_SLOT_OST_EVENT ,32 )); +aml_append (field,/* _OST status code, write only */ +aml_named_field (MEMORY_SLOT_OST_STATUS ,32 )); +aml_append (mem_ctrl_dev, field); + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); ifctx =aml_if (aml_equal (slots_nr, zero)); {hw/acpi/memory_hotplug.c void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, · line 616
Quoted 9 lines
hw/acpi/memory_hotplug.c +1
-1@@ -551,79 +609,18 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (mem_ctrl_dev, method); }aml_append (pci_scope, mem_ctrl_dev); -aml_append (ctx, pci_scope); +aml_append (table, pci_scope); }void build_memory_devices (Aml *sb_scope,int nr_mem,uint16_t io_base,uint16_t io_len)Do you still need the io_base/io_len parameters here?
Thanks,
MarcelQuoted 72 lines
hw/acpi/memory_hotplug.c +0
-61{int i; -Aml *scope; -Aml *crs; -Aml *field;Aml *dev;Aml *method;Aml *ifctx;/* build memory devices */ -assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); - scope =aml_scope ("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE ); -aml_append (scope, -aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) - ); - - crs =aml_resource_template (); -aml_append (crs, -aml_io (AML_DECODE16 , io_base, io_base,0 , io_len) - ); -aml_append (scope,aml_name_decl ("_CRS" , crs)); - -aml_append (scope,aml_operation_region ( -MEMORY_HOTPLUG_IO_REGION ,AML_SYSTEM_IO , -aml_int (io_base), io_len) - ); - - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , -AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_ADDR_LOW ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_ADDR_HIGH ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_SIZE_LOW ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_SIZE_HIGH ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_PROXIMITY ,32 )); -aml_append (scope, field); - - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_BYTE_ACC , -AML_NOLOCK ,AML_WRITE_AS_ZEROS ); -aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); -aml_append (field,/* 1 if enabled, read only */ -aml_named_field (MEMORY_SLOT_ENABLED ,1 )); -aml_append (field, -/*(read) 1 if has a insert event. (write) 1 to clear event */ -aml_named_field (MEMORY_SLOT_INSERT_EVENT ,1 )); -aml_append (field, -/* (read) 1 if has a remove event. (write) 1 to clear event */ -aml_named_field (MEMORY_SLOT_REMOVE_EVENT ,1 )); -aml_append (field, -/* initiates device eject, write only */ -aml_named_field (MEMORY_SLOT_EJECT ,1 )); -aml_append (scope, field); - - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , -AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,/* DIMM selector, write only */ -aml_named_field (MEMORY_SLOT_SLECTOR ,32 )); -aml_append (field,/* _OST event code, write only */ -aml_named_field (MEMORY_SLOT_OST_EVENT ,32 )); -aml_append (field,/* _OST status code, write only */ -aml_named_field (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." MEMORY_HOTPLUG_DEVICE "."const char *s;
Marcel Apfelbaum
Reviewed-byRe: [Qemu-devel] [PATCH for-2.9 05/10] memhp: consolidate scattered MHPD device declaration
Quoted 46 lines · Igor Mammedov
Quoted 37 lines · On Tue, 20 Dec 2016 13:00:35 +0200 Marcel Apfelbaum <[email protected]> wrote:
Quoted 36 lines · Igor Mammedov
since static and dynamic parts of memory MHPD device are now in the same table (DSDT), there is no point keeping them scattered across the table, so consolidate it in one place.
There aren't any functional change, only AML text movement from externally refferenced MHPD scope directly into MHPD device declaration.
Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/memory_hotplug.h | 2 +- hw/acpi/memory_hotplug.c | 123 +++++++++++++++++++-------------------- 2 files changed, 61 insertions(+), 64 deletions(-)include/hw/acpi/memory_hotplug.h +1
-1@@ -52,7 +52,7 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);#define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \ MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHOD -void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem,uint16_t io_base,uint16_t io_len);void build_memory_devices (Aml *sb_scope,int nr_mem,uint16_t io_base,uint16_t io_len);hw/acpi/memory_hotplug.c +0
-0@@ -307,7 +307,7 @@ const VMStateDescription vmstate_memory_hotplug = { } };Quoted 6 lines
hw/acpi/memory_hotplug.c const VMStateDescription vmstate_memory_hotplug = { · line 311
Quoted 3 lines
hw/acpi/memory_hotplug.c +1
-1-void build_memory_hotplug_aml (Aml *ctx,uint32_t nr_mem, +void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem,uint16_t io_base,uint16_t io_len)The signature of the function is changed, but I see no caller changes. Is this function used?
Quoted 4 lines
There is no need to change callers, it's in
acpi-build.c, this change is here for better documenting what this argument means withinbuild_memory_hotplug_aml(), see it at the end of patch.
Sorry, the io_base and io_len parameters are not new.
Thanks,
Marcel
Quoted 166 lines
Quoted 165 lines
Quoted 76 lines
hw/acpi/memory_hotplug.c +58
-0{Aml *ifctx;@@ -319,6 +319,8 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, pci_scope =aml_scope ("_SB.PCI0" ); mem_ctrl_dev =aml_device (MEMORY_HOTPLUG_DEVICE ); { +Aml *crs; +Aml *field;Aml *one =aml_int (1 );Aml *zero =aml_int (0 );Aml *ret_val =aml_local (0 );@@ -331,6 +333,62 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (mem_ctrl_dev,aml_name_decl ("_UID" ,aml_string ("Memory hotplug resources" ))); +assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); +aml_append (mem_ctrl_dev, +aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) + ); + + crs =aml_resource_template (); +aml_append (crs, +aml_io (AML_DECODE16 , io_base, io_base,0 , io_len) + ); +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 , +aml_int (io_base), io_len) + ); + + field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , +AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_ADDR_LOW ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_ADDR_HIGH ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_SIZE_LOW ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_SIZE_HIGH ,32 )); +aml_append (field,/* read only */ +aml_named_field (MEMORY_SLOT_PROXIMITY ,32 )); +aml_append (mem_ctrl_dev, field); + + field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_BYTE_ACC , +AML_NOLOCK ,AML_WRITE_AS_ZEROS ); +aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); +aml_append (field,/* 1 if enabled, read only */ +aml_named_field (MEMORY_SLOT_ENABLED ,1 )); +aml_append (field, +/*(read) 1 if has a insert event. (write) 1 to clear event */ +aml_named_field (MEMORY_SLOT_INSERT_EVENT ,1 )); +aml_append (field, +/* (read) 1 if has a remove event. (write) 1 to clear event */ +aml_named_field (MEMORY_SLOT_REMOVE_EVENT ,1 )); +aml_append (field, +/* initiates device eject, write only */ +aml_named_field (MEMORY_SLOT_EJECT ,1 )); +aml_append (mem_ctrl_dev, field); + + field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , +AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,/* DIMM selector, write only */ +aml_named_field (MEMORY_SLOT_SLECTOR ,32 )); +aml_append (field,/* _OST event code, write only */ +aml_named_field (MEMORY_SLOT_OST_EVENT ,32 )); +aml_append (field,/* _OST status code, write only */ +aml_named_field (MEMORY_SLOT_OST_STATUS ,32 )); +aml_append (mem_ctrl_dev, field); + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); ifctx =aml_if (aml_equal (slots_nr, zero)); {hw/acpi/memory_hotplug.c void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, · line 616
Quoted 9 lines
hw/acpi/memory_hotplug.c +1
-1@@ -551,79 +609,18 @@ void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,aml_append (mem_ctrl_dev, method); }aml_append (pci_scope, mem_ctrl_dev); -aml_append (ctx, pci_scope); +aml_append (table, pci_scope); }void build_memory_devices (Aml *sb_scope,int nr_mem,uint16_t io_base,uint16_t io_len)Do you still need the io_base/io_len parameters here?
Thanks,
MarcelQuoted 72 lines
hw/acpi/memory_hotplug.c +0
-61{int i; -Aml *scope; -Aml *crs; -Aml *field;Aml *dev;Aml *method;Aml *ifctx;/* build memory devices */ -assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); - scope =aml_scope ("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE ); -aml_append (scope, -aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) - ); - - crs =aml_resource_template (); -aml_append (crs, -aml_io (AML_DECODE16 , io_base, io_base,0 , io_len) - ); -aml_append (scope,aml_name_decl ("_CRS" , crs)); - -aml_append (scope,aml_operation_region ( -MEMORY_HOTPLUG_IO_REGION ,AML_SYSTEM_IO , -aml_int (io_base), io_len) - ); - - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , -AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_ADDR_LOW ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_ADDR_HIGH ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_SIZE_LOW ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_SIZE_HIGH ,32 )); -aml_append (field,/* read only */ -aml_named_field (MEMORY_SLOT_PROXIMITY ,32 )); -aml_append (scope, field); - - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_BYTE_ACC , -AML_NOLOCK ,AML_WRITE_AS_ZEROS ); -aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); -aml_append (field,/* 1 if enabled, read only */ -aml_named_field (MEMORY_SLOT_ENABLED ,1 )); -aml_append (field, -/*(read) 1 if has a insert event. (write) 1 to clear event */ -aml_named_field (MEMORY_SLOT_INSERT_EVENT ,1 )); -aml_append (field, -/* (read) 1 if has a remove event. (write) 1 to clear event */ -aml_named_field (MEMORY_SLOT_REMOVE_EVENT ,1 )); -aml_append (field, -/* initiates device eject, write only */ -aml_named_field (MEMORY_SLOT_EJECT ,1 )); -aml_append (scope, field); - - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , -AML_NOLOCK ,AML_PRESERVE ); -aml_append (field,/* DIMM selector, write only */ -aml_named_field (MEMORY_SLOT_SLECTOR ,32 )); -aml_append (field,/* _OST event code, write only */ -aml_named_field (MEMORY_SLOT_OST_EVENT ,32 )); -aml_append (field,/* _OST status code, write only */ -aml_named_field (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." MEMORY_HOTPLUG_DEVICE "."const char *s;
PATCH 6/10 memhp: merge build_memory_devices() into build_memory_hotplug_aml()
In reply to Igor MammedovIt consolidates memory hotplug AML in one place within DSDT
--- include/hw/acpi/memory_hotplug.h | 2 -- hw/acpi/memory_hotplug.c | 14 ++++----- hw/i386/acpi-build.c | 61 ++++++++++++++++++---------------------- 3 files changed, 33 insertions(+), 44 deletions(-)
include/hw/acpi/memory_hotplug.h +0 -2
@@ -54,6 +54,4 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem,uint16_t io_base,uint16_t io_len); -void build_memory_devices (Aml *sb_scope,int nr_mem, -uint16_t io_base,uint16_t io_len);#endif
hw/acpi/memory_hotplug.c +5 -9
@@ -310,9 +310,11 @@ const VMStateDescription vmstate_memory_hotplug = {void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem,uint16_t io_base,uint16_t io_len) { +int i;Aml *ifctx;Aml *method;Aml *pci_scope; +Aml *sb_scope;Aml *mem_ctrl_dev;/* scope for memory hotplug controller device node */
@@ -610,19 +612,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, }aml_append (pci_scope, mem_ctrl_dev);aml_append (table, pci_scope); -} - -void build_memory_devices (Aml *sb_scope,int nr_mem, -uint16_t io_base,uint16_t io_len) -{ -int i; -Aml *dev; -Aml *method; -Aml *ifctx; + sb_scope =aml_scope ("_SB" );/* build memory devices */ for (i =0 ; i < nr_mem; i++) {#define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "." +Aml *dev;const char *s; dev =aml_device ("MP%02X" , i);
@@ -673,4 +668,5 @@ void build_memory_devices(Aml *sb_scope, int nr_mem,aml_append (method, ifctx); }aml_append (sb_scope, method); +aml_append (table, sb_scope); }
hw/i386/acpi-build.c +28 -33
73 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH for-2.9 06/10] memhp: merge build_memory_devices() into build_memory_hotplug_aml()
Quoted 41 lines · Igor Mammedov
It consolidates memory hotplug AML in one place within DSDT
Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/memory_hotplug.h | 2 -- hw/acpi/memory_hotplug.c | 14 ++++----- hw/i386/acpi-build.c | 61 ++++++++++++++++++---------------------- 3 files changed, 33 insertions(+), 44 deletions(-)include/hw/acpi/memory_hotplug.h +0
-2@@ -54,6 +54,4 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem,uint16_t io_base,uint16_t io_len); -void build_memory_devices (Aml *sb_scope,int nr_mem, -uint16_t io_base,uint16_t io_len);#endif hw/acpi/memory_hotplug.c +2
-1@@ -310,9 +310,11 @@ const VMStateDescription vmstate_memory_hotplug = {void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem,uint16_t io_base,uint16_t io_len) { +int i;Aml *ifctx;Aml *method;Aml *pci_scope; +Aml *sb_scope;Aml *mem_ctrl_dev;/* scope for memory hotplug controller device node */ @@ -610,19 +612,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, }aml_append (pci_scope, mem_ctrl_dev);aml_append (table, pci_scope); -}
hw/acpi/memory_hotplug.c void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, · line 616
Quoted 10 lines
hw/acpi/memory_hotplug.c +1
-8- -void build_memory_devices (Aml *sb_scope,int nr_mem, -uint16_t io_base,uint16_t io_len) -{ -int i; -Aml *dev; -Aml *method; -Aml *ifctx; + sb_scope =aml_scope ("_SB" );
One question here, before this patch the mem devices were added to \\_SB scope, now they are added to _SB.
I suppose is OK? Is there any change in the DSDT? Can we see a diff?
Thanks,
Marcel
Quoted 92 lines
hw/acpi/memory_hotplug.c +2
-0/* build memory devices */ for (i =0 ; i < nr_mem; i++) {#define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "." +Aml *dev;const char *s; dev =aml_device ("MP%02X" , i);@@ -673,4 +668,5 @@ void build_memory_devices(Aml *sb_scope, int nr_mem,aml_append (method, ifctx); }aml_append (sb_scope, method); +aml_append (table, sb_scope); }hw/i386/acpi-build.c +28
-33@@ -2197,45 +2197,40 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, sb_scope =aml_scope ("\\_SB" ); { -build_memory_devices (sb_scope, nr_mem, pm->mem_hp_io_base, - pm->mem_hp_io_len); +Object *pci_host; +PCIBus *bus =NULL ; - { -Object *pci_host; -PCIBus *bus =NULL ; + pci_host =acpi_get_i386_pci_host (); +if (pci_host) { + bus =PCI_HOST_BRIDGE (pci_host)->bus; + } - pci_host =acpi_get_i386_pci_host (); -if (pci_host) { - bus =PCI_HOST_BRIDGE (pci_host)->bus; +if (bus) { +Aml *scope =aml_scope ("PCI0" ); +/* Scan all PCI buses. Generate tables to support hotplug. */ +build_append_pci_bus_devices (scope, bus, pm->pcihp_bridge_en); + +if (misc->tpm_version !=TPM_VERSION_UNSPEC ) { + dev =aml_device ("ISA.TPM" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C31" ))); +aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xF ))); + crs =aml_resource_template (); +aml_append (crs,aml_memory32_fixed (TPM_TIS_ADDR_BASE , +TPM_TIS_ADDR_SIZE ,AML_READ_WRITE )); +/* +FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs, +Rewrite to take IRQ from TPM device model and +fix default IRQ value there to use some unused IRQ +*/ +/* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */ +aml_append (dev,aml_name_decl ("_CRS" , crs)); +aml_append (scope, dev); } -if (bus) { -Aml *scope =aml_scope ("PCI0" ); -/* Scan all PCI buses. Generate tables to support hotplug. */ -build_append_pci_bus_devices (scope, bus, pm->pcihp_bridge_en); - -if (misc->tpm_version !=TPM_VERSION_UNSPEC ) { - dev =aml_device ("ISA.TPM" ); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C31" ))); -aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xF ))); - crs =aml_resource_template (); -aml_append (crs,aml_memory32_fixed (TPM_TIS_ADDR_BASE , -TPM_TIS_ADDR_SIZE ,AML_READ_WRITE )); -/* -FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs, -Rewrite to take IRQ from TPM device model and -fix default IRQ value there to use some unused IRQ -*/ -/* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */ -aml_append (dev,aml_name_decl ("_CRS" , crs)); -aml_append (scope, dev); - } - -aml_append (sb_scope, scope); - } +aml_append (sb_scope, scope); } -aml_append (dsdt, sb_scope); } +aml_append (dsdt, sb_scope);/* copy AML table into ACPI tables blob and patch header there */ g_array_append_vals (table_data, dsdt->buf->data, dsdt->buf->len);
Re: [Qemu-devel] [PATCH for-2.9 06/10] memhp: merge build_memory_devices() into build_memory_hotplug_aml()
Quoted 51 lines · On Wed, 21 Dec 2016 14:10:33 +0200 Marcel Apfelbaum <[email protected]> wrote:
Quoted 50 lines · Igor Mammedov
It consolidates memory hotplug AML in one place within DSDT
Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/memory_hotplug.h | 2 -- hw/acpi/memory_hotplug.c | 14 ++++----- hw/i386/acpi-build.c | 61 ++++++++++++++++++---------------------- 3 files changed, 33 insertions(+), 44 deletions(-)include/hw/acpi/memory_hotplug.h +0
-2@@ -54,6 +54,4 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem,uint16_t io_base,uint16_t io_len); -void build_memory_devices (Aml *sb_scope,int nr_mem, -uint16_t io_base,uint16_t io_len);#endif hw/acpi/memory_hotplug.c +2
-9@@ -310,9 +310,11 @@ const VMStateDescription vmstate_memory_hotplug = {void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem,uint16_t io_base,uint16_t io_len) { +int i;Aml *ifctx;Aml *method;Aml *pci_scope; +Aml *sb_scope;Aml *mem_ctrl_dev;/* scope for memory hotplug controller device node */ @@ -610,19 +612,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, }aml_append (pci_scope, mem_ctrl_dev);aml_append (table, pci_scope); -} - -void build_memory_devices (Aml *sb_scope,int nr_mem, -uint16_t io_base,uint16_t io_len) -{ -int i; -Aml *dev; -Aml *method; -Aml *ifctx;
Quoted 7 lines
hw/acpi/memory_hotplug.c void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, · line 616
Quoted 1 line
hw/acpi/memory_hotplug.c +1
-0+ sb_scope =aml_scope ("_SB" );One question here, before this patch the mem devices were added to \\_SB scope, now they are added to
_SB.I suppose is OK? Is there any change in the DSDT? Can we see a diff?
It's ok as sb_scope is added to root context (i.e. table), below in this patch.
This patch doesn't change logic, it only gets rid of Scope (\_SB.PCI0.MHPD) by moving elements from it to preceding device declaration which above scope refers to:
Scope (_SB.PCI0) { Device (MHPD) { ... } }and places MTFY method right after this declaration.
In other words the patch does exactly what commit message says, "It consolidates memory hotplug AML in one place within DSDT"
here is diff at this point but it's not really useful as it doesn't capture enough context to see where AML is being moved. To get full tables to compare one need run:
make && make tests/bios-tables-test QTEST_QEMU_BINARY=./x86_64-softmmu/qemu-system-x86_64 V=1 tests/bios-tables-test
tmp/asl-ZSBJSY.dsl renamed from tmp/asl-EQAJSY.dsl +46 -46
@@ -5,13 +5,13 @@ * * Disassembling to symbolic ASL+ operators * - * Disassembly of tests/acpi-test-data/pc/DSDT.bridge, Wed Dec 21 13:34:30 2016 + * Disassembly of /tmp/aml-AKBJSY, Wed Dec 21 13:34:30 2016 * * Original Table Header: * Signature "DSDT" - * Length 0x00001EBB (7867) + * Length 0x00001EAF (7855) * Revision 0x01 **** 32-bit table (V1), no 64-bit math support - * Checksum 0x35 + * Checksum 0x44 * OEM ID "BOCHS " * OEM Table ID "BXPCDSDT" * OEM Revision 0x00000001 (1)
@@ -798,6 +798,42 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001) { Name (_HID, "PNP0A06" /* Generic Container Device */) // _HID: Hardware ID Name (_UID, "Memory hotplug resources") // _UID: Unique ID + Name (MDNR, Zero) + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings + { + IO (Decode16, + 0x0A00, // Range Minimum + 0x0A00, // Range Maximum + 0x00, // Alignment + 0x18, // Length + ) + }) + OperationRegion (HPMR, SystemIO, 0x0A00, 0x18) + Field (HPMR, DWordAcc, NoLock, Preserve) + { + MRBL, 32, + MRBH, 32, + MRLL, 32, + MRLH, 32, + MPX, 32 + } + + Field (HPMR, ByteAcc, NoLock, WriteAsZeros) + { + Offset (0x14), + MES, 1, + MINS, 1, + MRMV, 1, + MEJ, 1 + } + + Field (HPMR, DWordAcc, NoLock, Preserve) + { + MSEL, 32, + MOEV, 32, + MOSC, 32 + } + Method (_STA, 0, NotSerialized) // _STA: Status { If (MDNR == Zero)
@@ -944,6 +980,13 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001) } } + Scope (_SB) + { + Method (MTFY, 2, NotSerialized) + { + } + } + Scope (_GPE) { Name (_HID, "ACPI0006" /* GPE Block Device */) // _HID: Hardware ID
@@ -1084,49 +1127,6 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001) Scope (\_SB) { - Scope (\_SB.PCI0.MHPD) - { - Name (MDNR, Zero) - Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings - { - IO (Decode16, - 0x0A00, // Range Minimum - 0x0A00, // Range Maximum - 0x00, // Alignment - 0x18, // Length - ) - }) - OperationRegion (HPMR, SystemIO, 0x0A00, 0x18) - Field (HPMR, DWordAcc, NoLock, Preserve) - { - MRBL, 32, - MRBH, 32, - MRLL, 32, - MRLH, 32, - MPX, 32 - } - - Field (HPMR, ByteAcc, NoLock, WriteAsZeros) - { - Offset (0x14), - MES, 1, - MINS, 1, - MRMV, 1, - MEJ, 1 - } - - Field (HPMR, DWordAcc, NoLock, Preserve) - { - MSEL, 32, - MOEV, 32, - MOSC, 32 - } - } - - Method (MTFY, 2, NotSerialized) - { - } - Scope (PCI0) { Name (BSEL, Zero)
Quoted 97 lines
Thanks,
MarcelQuoted 92 lines
hw/acpi/memory_hotplug.c +2
-0/* build memory devices */ for (i =0 ; i < nr_mem; i++) {#define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "." +Aml *dev;const char *s; dev =aml_device ("MP%02X" , i);@@ -673,4 +668,5 @@ void build_memory_devices(Aml *sb_scope, int nr_mem,aml_append (method, ifctx); }aml_append (sb_scope, method); +aml_append (table, sb_scope); }hw/i386/acpi-build.c +28
-33@@ -2197,45 +2197,40 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, sb_scope =aml_scope ("\\_SB" ); { -build_memory_devices (sb_scope, nr_mem, pm->mem_hp_io_base, - pm->mem_hp_io_len); +Object *pci_host; +PCIBus *bus =NULL ; - { -Object *pci_host; -PCIBus *bus =NULL ; + pci_host =acpi_get_i386_pci_host (); +if (pci_host) { + bus =PCI_HOST_BRIDGE (pci_host)->bus; + } - pci_host =acpi_get_i386_pci_host (); -if (pci_host) { - bus =PCI_HOST_BRIDGE (pci_host)->bus; +if (bus) { +Aml *scope =aml_scope ("PCI0" ); +/* Scan all PCI buses. Generate tables to support hotplug. */ +build_append_pci_bus_devices (scope, bus, pm->pcihp_bridge_en); + +if (misc->tpm_version !=TPM_VERSION_UNSPEC ) { + dev =aml_device ("ISA.TPM" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C31" ))); +aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xF ))); + crs =aml_resource_template (); +aml_append (crs,aml_memory32_fixed (TPM_TIS_ADDR_BASE , +TPM_TIS_ADDR_SIZE ,AML_READ_WRITE )); +/* +FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs, +Rewrite to take IRQ from TPM device model and +fix default IRQ value there to use some unused IRQ +*/ +/* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */ +aml_append (dev,aml_name_decl ("_CRS" , crs)); +aml_append (scope, dev); } -if (bus) { -Aml *scope =aml_scope ("PCI0" ); -/* Scan all PCI buses. Generate tables to support hotplug. */ -build_append_pci_bus_devices (scope, bus, pm->pcihp_bridge_en); - -if (misc->tpm_version !=TPM_VERSION_UNSPEC ) { - dev =aml_device ("ISA.TPM" ); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C31" ))); -aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xF ))); - crs =aml_resource_template (); -aml_append (crs,aml_memory32_fixed (TPM_TIS_ADDR_BASE , -TPM_TIS_ADDR_SIZE ,AML_READ_WRITE )); -/* -FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs, -Rewrite to take IRQ from TPM device model and -fix default IRQ value there to use some unused IRQ -*/ -/* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */ -aml_append (dev,aml_name_decl ("_CRS" , crs)); -aml_append (scope, dev); - } - -aml_append (sb_scope, scope); - } +aml_append (sb_scope, scope); } -aml_append (dsdt, sb_scope); } +aml_append (dsdt, sb_scope);/* copy AML table into ACPI tables blob and patch header there */ g_array_append_vals (table_data, dsdt->buf->data, dsdt->buf->len);
PATCH 7/10 memhp: move GPE handler_E03 into build_memory_hotplug_aml()
In reply to Igor MammedovQuoted 1 line
From this patch all the memory hotplug related AML
bits are consolidated in one place within DSTD.
Follow up patches will utilize that to simplify
memory hotplug related C/AML code.
--- include/hw/acpi/memory_hotplug.h | 6 +++--- hw/acpi/memory_hotplug.c | 42 ++++++++++++++++++++++++++-------------- hw/i386/acpi-build.c | 7 ++----- 3 files changed, 32 insertions(+), 23 deletions(-)
include/hw/acpi/memory_hotplug.h +3 -3
@@ -49,9 +49,9 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);#define MEMORY_HOTPLUG_DEVICE "MHPD"#define MEMORY_SLOT_SCAN_METHOD "MSCN" -#define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \ - MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHODvoid build_memory_hotplug_aml (Aml *table,uint32_t nr_mem, -uint16_t io_base,uint16_t io_len); +uint16_t io_base,uint16_t io_len, +const char *res_root, +const char *event_handler_method);#endif
hw/acpi/memory_hotplug.c +27 -15
96 lines not on this page · raw message
hw/i386/acpi-build.c +2 -5
@@ -1926,7 +1926,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, "\\_SB.PCI0", "\\_GPE._E02"); }build_memory_hotplug_aml (dsdt, nr_mem, pm->mem_hp_io_base, - pm->mem_hp_io_len); + pm->mem_hp_io_len, +"\\_SB.PCI0" ,"\\_GPE._E03" ); scope =aml_scope ("_GPE" ); {
@@ -1941,10 +1942,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (scope, method); } - method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH )); -aml_append (scope, method); -if (pcms->acpi_nvdimm_state.is_enabled) { method =aml_method ("_E04" ,0 ,AML_NOTSERIALIZED ); aml_append(method, aml_notify(aml_name("\\_SB.NVDR"),
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH for-2.9 07/10] memhp: move GPE handler_E03 into build_memory_hotplug_aml()
Quoted 4 lines · Igor Mammedov
From this patch all the memory hotplug related AML bits are consolidated in one place within DSTD. Follow up patches will utilize that to simplify memory hotplug related C/AML code.
I didn't quite understand what you mean...
Quoted 41 lines
Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/memory_hotplug.h | 6 +++--- hw/acpi/memory_hotplug.c | 42 ++++++++++++++++++++++++++-------------- hw/i386/acpi-build.c | 7 ++----- 3 files changed, 32 insertions(+), 23 deletions(-)include/hw/acpi/memory_hotplug.h +3
-3@@ -49,9 +49,9 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);#define MEMORY_HOTPLUG_DEVICE "MHPD"#define MEMORY_SLOT_SCAN_METHOD "MSCN" -#define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \ - MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHODvoid build_memory_hotplug_aml (Aml *table,uint32_t nr_mem, -uint16_t io_base,uint16_t io_len); +uint16_t io_base,uint16_t io_len, +const char *res_root, +const char *event_handler_method);#endif hw/acpi/memory_hotplug.c +3
-1@@ -308,18 +308,19 @@ const VMStateDescription vmstate_memory_hotplug = { };void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem, -uint16_t io_base,uint16_t io_len) +uint16_t io_base,uint16_t io_len, +const char *res_root, +const char *event_handler_method) {int i;Aml *ifctx;Aml *method;
hw/acpi/memory_hotplug.c const VMStateDescription vmstate_memory_hotplug = { · line 323
Quoted 10 lines
hw/acpi/memory_hotplug.c +3
-4-Aml *pci_scope;Aml *sb_scope;Aml *mem_ctrl_dev; +char *scan_path; +char *mhp_res_path =g_strdup_printf ("%s." MEMORY_HOTPLUG_DEVICE , res_root); -/* scope for memory hotplug controller device node */ - pci_scope =aml_scope ("_SB.PCI0" ); - mem_ctrl_dev =aml_device (MEMORY_HOTPLUG_DEVICE ); + mem_ctrl_dev =aml_device ("%s" , mhp_res_path);
Will mem_ctrl_dev's name will have an extra "." suffix now?
Quoted 16 lines
hw/acpi/memory_hotplug.c +1
-3{Aml *crs;Aml *field;@@ -610,47 +611,50 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, }aml_append (mem_ctrl_dev, method); } -aml_append (pci_scope, mem_ctrl_dev); -aml_append (table, pci_scope); +aml_append (table, mem_ctrl_dev); sb_scope =aml_scope ("_SB" );/* build memory devices */ for (i =0 ; i < nr_mem; i++) { -#define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."Aml *dev;
hw/acpi/memory_hotplug.c void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, · line 627
Quoted 10 lines
hw/acpi/memory_hotplug.c +2
-2-const char *s; +char *s; dev =aml_device ("MP%02X" , i);aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i)));aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_CRS_METHOD; + s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_CRS_METHOD );
Same question here, do we get ".." in the path? Maybe is OK?
Thanks,
Marcel
Quoted 77 lines
hw/acpi/memory_hotplug.c +18
-5aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +g_free (s);aml_append (dev, method); method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_STATUS_METHOD; + s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_STATUS_METHOD );aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +g_free (s);aml_append (dev, method); method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD; + s =g_strdup_printf ("%s.%s" , mhp_res_path, +MEMORY_SLOT_PROXIMITY_METHOD );aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +g_free (s);aml_append (dev, method); method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_OST_METHOD; - + s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_OST_METHOD );aml_append (method,aml_return (aml_call4 ( s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) ))); +g_free (s);aml_append (dev, method); method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_EJECT_METHOD; + s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_EJECT_METHOD );aml_append (method,aml_return (aml_call2 ( s,aml_name ("_UID" ),aml_arg (0 )))); +g_free (s);aml_append (dev, method);aml_append (sb_scope, dev);@@ -669,4 +673,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, }aml_append (sb_scope, method);aml_append (table, sb_scope); + + method =aml_method (event_handler_method,0 ,AML_NOTSERIALIZED ); + scan_path =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_SCAN_METHOD ); +aml_append (method,aml_call0 (scan_path)); +g_free (scan_path); +aml_append (table, method); + +g_free (mhp_res_path); }hw/i386/acpi-build.c +2
-5@@ -1926,7 +1926,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, "\\_SB.PCI0", "\\_GPE._E02"); }build_memory_hotplug_aml (dsdt, nr_mem, pm->mem_hp_io_base, - pm->mem_hp_io_len); + pm->mem_hp_io_len, +"\\_SB.PCI0" ,"\\_GPE._E03" ); scope =aml_scope ("_GPE" ); {@@ -1941,10 +1942,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (scope, method); } - method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH )); -aml_append (scope, method); -if (pcms->acpi_nvdimm_state.is_enabled) { method =aml_method ("_E04" ,0 ,AML_NOTSERIALIZED ); aml_append(method, aml_notify(aml_name("\\_SB.NVDR"),
Re: [Qemu-devel] [PATCH for-2.9 07/10] memhp: move GPE handler_E03 into build_memory_hotplug_aml()
Quoted 8 lines · On Wed, 21 Dec 2016 14:31:45 +0200 Marcel Apfelbaum <[email protected]> wrote:
Quoted 4 lines · Igor Mammedov
From this patch all the memory hotplug related AML bits are consolidated in one place within DSTD. Follow up patches will utilize that to simplify memory hotplug related C/AML code.
I didn't quite understand what you mean...
me neither :/, it's quite useless commit message,
how about this one instead:
--
build hotplug event handler method body in generic hw/acpi/memory_hotplug.c and make hw/i386/acpi-build.c only provide target specific full name of the event handler.
That removes hardcoded MEMORY_HOTPLUG_HANDLER_PATH and allows to do target specific memory hotplug AML placement and wiring it with a target specific hotplug event handler (it's GPE for i386 and would be GPIO for ARM).
PS:
similar approach has been used with CPU hotplug as part of commit:
(d2238cb6 acpi: cpuhp: implement hot-add parts of CPU hotplug interface) --
Quoted 48 lines
Quoted 48 lines
Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/memory_hotplug.h | 6 +++--- hw/acpi/memory_hotplug.c | 42 ++++++++++++++++++++++++++-------------- hw/i386/acpi-build.c | 7 ++----- 3 files changed, 32 insertions(+), 23 deletions(-)include/hw/acpi/memory_hotplug.h +3
-3@@ -49,9 +49,9 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);#define MEMORY_HOTPLUG_DEVICE "MHPD"#define MEMORY_SLOT_SCAN_METHOD "MSCN" -#define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \ - MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHODvoid build_memory_hotplug_aml (Aml *table,uint32_t nr_mem, -uint16_t io_base,uint16_t io_len); +uint16_t io_base,uint16_t io_len, +const char *res_root, +const char *event_handler_method);#endif hw/acpi/memory_hotplug.c +5
-2@@ -308,18 +308,19 @@ const VMStateDescription vmstate_memory_hotplug = { };void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem, -uint16_t io_base,uint16_t io_len) +uint16_t io_base,uint16_t io_len, +const char *res_root, +const char *event_handler_method) {int i;Aml *ifctx;Aml *method; -Aml *pci_scope;Aml *sb_scope;Aml *mem_ctrl_dev; +char *scan_path; +char *mhp_res_path =g_strdup_printf ("%s." MEMORY_HOTPLUG_DEVICE , res_root);
Quoted 7 lines
hw/acpi/memory_hotplug.c const VMStateDescription vmstate_memory_hotplug = { · line 323
Quoted 4 lines
hw/acpi/memory_hotplug.c +1
-3-/* scope for memory hotplug controller device node */ - pci_scope =aml_scope ("_SB.PCI0" ); - mem_ctrl_dev =aml_device (MEMORY_HOTPLUG_DEVICE ); + mem_ctrl_dev =aml_device ("%s" , mhp_res_path);Will mem_ctrl_dev's name will have an extra "." suffix now?
nope it will be declared with target specific full path rather than within separately created static scope:
- Scope (_SB.PCI0)
+ Device (\_SB.PCI0.MHPD) // concat (res_root, ".", MEMORY_HOTPLUG_DEVICE)
{- Device (MHPD)
...
and event handler would change like this:
+ Method (\_GPE._E03, 0, NotSerialized) // _Exx: Edge-Triggered GPE
+ {
+ \_SB.PCI0.MHPD.MSCN ()
+ }
+
Scope (_GPE)
{
Name (_HID, "ACPI0006" /* GPE Block Device */) // _HID: Hardware ID- Method (_E03, 0, NotSerialized) // _Exx: Edge-Triggered GPE
- {
- \_SB.PCI0.MHPD.MSCN ()
- }
Quoted 24 lines
Quoted 24 lines
hw/acpi/memory_hotplug.c +2
-4{Aml *crs;Aml *field;@@ -610,47 +611,50 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, }aml_append (mem_ctrl_dev, method); } -aml_append (pci_scope, mem_ctrl_dev); -aml_append (table, pci_scope); +aml_append (table, mem_ctrl_dev); sb_scope =aml_scope ("_SB" );/* build memory devices */ for (i =0 ; i < nr_mem; i++) { -#define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."Aml *dev; -const char *s; +char *s; dev =aml_device ("MP%02X" , i);aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i)));aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" )));
Quoted 5 lines
hw/acpi/memory_hotplug.c void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, · line 627
Quoted 3 lines
hw/acpi/memory_hotplug.c +1
-1method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_CRS_METHOD; + s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_CRS_METHOD );Same question here, do we get ".." in the path? Maybe is OK?
nope, it dynamic equivalent of original static 'BASEPATH MEMORY_SLOT_CRS_METHOD;' where BASEPATH is replaced with
concat(mhp_res_path, ".", MEMORY_SLOT_CRS_METHOD)
this 'for' loop changes are temporary and are part of transition to dynamic mem hotplug AML placement. See patch 10/10 which simplifies names within this 'for' loop and reduces AML size as result by placing called methods within the same scope/container.
Quoted 81 lines
Thanks,
MarcelQuoted 77 lines
hw/acpi/memory_hotplug.c +18
-5aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +g_free (s);aml_append (dev, method); method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_STATUS_METHOD; + s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_STATUS_METHOD );aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +g_free (s);aml_append (dev, method); method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD; + s =g_strdup_printf ("%s.%s" , mhp_res_path, +MEMORY_SLOT_PROXIMITY_METHOD );aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +g_free (s);aml_append (dev, method); method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_OST_METHOD; - + s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_OST_METHOD );aml_append (method,aml_return (aml_call4 ( s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) ))); +g_free (s);aml_append (dev, method); method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_EJECT_METHOD; + s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_EJECT_METHOD );aml_append (method,aml_return (aml_call2 ( s,aml_name ("_UID" ),aml_arg (0 )))); +g_free (s);aml_append (dev, method);aml_append (sb_scope, dev);@@ -669,4 +673,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, }aml_append (sb_scope, method);aml_append (table, sb_scope); + + method =aml_method (event_handler_method,0 ,AML_NOTSERIALIZED ); + scan_path =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_SCAN_METHOD ); +aml_append (method,aml_call0 (scan_path)); +g_free (scan_path); +aml_append (table, method); + +g_free (mhp_res_path); }hw/i386/acpi-build.c +2
-5@@ -1926,7 +1926,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, "\\_SB.PCI0", "\\_GPE._E02"); }build_memory_hotplug_aml (dsdt, nr_mem, pm->mem_hp_io_base, - pm->mem_hp_io_len); + pm->mem_hp_io_len, +"\\_SB.PCI0" ,"\\_GPE._E03" ); scope =aml_scope ("_GPE" ); {@@ -1941,10 +1942,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (scope, method); } - method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH )); -aml_append (scope, method); -if (pcms->acpi_nvdimm_state.is_enabled) { method =aml_method ("_E04" ,0 ,AML_NOTSERIALIZED ); aml_append(method, aml_notify(aml_name("\\_SB.NVDR"),
Marcel Apfelbaum
Reviewed-byRe: [Qemu-devel] [PATCH for-2.9 07/10] memhp: move GPE handler_E03 into build_memory_hotplug_aml()
Quoted 14 lines · Igor Mammedov
Quoted 8 lines · On Wed, 21 Dec 2016 14:31:45 +0200 Marcel Apfelbaum <[email protected]> wrote:
Quoted 4 lines · Igor Mammedov
From this patch all the memory hotplug related AML bits are consolidated in one place within DSTD. Follow up patches will utilize that to simplify memory hotplug related C/AML code.
I didn't quite understand what you mean...
me neither :/, it's quite useless commit message,
how about this one instead:
Quoted 10 lines
--
build hotplug event handler method body in generichw/acpi/memory_hotplug.cand makehw/i386/acpi-build.conly provide target specific full name of the event handler.
That removes hardcodedMEMORY_HOTPLUG_HANDLER_PATHand allows to do target specific memory hotplug AML placement and wiring it with a target specific hotplug event handler (it's GPE for i386 and would be GPIO for ARM).
Works for me.
Quoted 61 lines
PS:
similar approach has been used with CPU hotplug as part of commit:
(d2238cb6acpi: cpuhp: implement hot-add parts of CPU hotplug interface) --Quoted 48 lines
Quoted 48 lines
Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/memory_hotplug.h | 6 +++--- hw/acpi/memory_hotplug.c | 42 ++++++++++++++++++++++++++-------------- hw/i386/acpi-build.c | 7 ++----- 3 files changed, 32 insertions(+), 23 deletions(-)include/hw/acpi/memory_hotplug.h +3
-3@@ -49,9 +49,9 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);#define MEMORY_HOTPLUG_DEVICE "MHPD"#define MEMORY_SLOT_SCAN_METHOD "MSCN" -#define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \ - MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHODvoid build_memory_hotplug_aml (Aml *table,uint32_t nr_mem, -uint16_t io_base,uint16_t io_len); +uint16_t io_base,uint16_t io_len, +const char *res_root, +const char *event_handler_method);#endif hw/acpi/memory_hotplug.c +5
-2@@ -308,18 +308,19 @@ const VMStateDescription vmstate_memory_hotplug = { };void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem, -uint16_t io_base,uint16_t io_len) +uint16_t io_base,uint16_t io_len, +const char *res_root, +const char *event_handler_method) {int i;Aml *ifctx;Aml *method; -Aml *pci_scope;Aml *sb_scope;Aml *mem_ctrl_dev; +char *scan_path; +char *mhp_res_path =g_strdup_printf ("%s." MEMORY_HOTPLUG_DEVICE , res_root);Quoted 7 lines
hw/acpi/memory_hotplug.c const VMStateDescription vmstate_memory_hotplug = { · line 323
Quoted 4 lines
hw/acpi/memory_hotplug.c +1
-3-/* scope for memory hotplug controller device node */ - pci_scope =aml_scope ("_SB.PCI0" ); - mem_ctrl_dev =aml_device (MEMORY_HOTPLUG_DEVICE ); + mem_ctrl_dev =aml_device ("%s" , mhp_res_path);Will mem_ctrl_dev's name will have an extra "." suffix now?
Quoted 2 lines
nope it will be declared with target specific full path rather than within separately created static scope:
Right, I mismatched the printf arguments..
Quoted 12 lines
(quoted diff) +1
-2- Scope (_SB.PCI0) + Device (\_SB.PCI0.MHPD) // concat (res_root, ".", MEMORY_HOTPLUG_DEVICE) { - Device (MHPD)and event handler would change like this:
(quoted diff) +2
-0+ Method (\_GPE._E03, 0, NotSerialized) // _Exx: Edge-Triggered GPE + {
Review
Quoted 10 lines
(quoted diff) +3
-4+ \_SB.PCI0.MHPD.MSCN () + } + Scope (_GPE) { Name (_HID, "ACPI0006" /* GPE Block Device */) // _HID: Hardware ID - Method (_E03, 0, NotSerialized) // _Exx: Edge-Triggered GPE - { - \_SB.PCI0.MHPD.MSCN () - }
OK
Quoted 30 lines
Quoted 25 lines
Quoted 25 lines
hw/acpi/memory_hotplug.c +2
-4{Aml *crs;Aml *field;@@ -610,47 +611,50 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, }aml_append (mem_ctrl_dev, method); } -aml_append (pci_scope, mem_ctrl_dev); -aml_append (table, pci_scope); +aml_append (table, mem_ctrl_dev); sb_scope =aml_scope ("_SB" );/* build memory devices */ for (i =0 ; i < nr_mem; i++) { -#define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."Aml *dev; -const char *s; +char *s; dev =aml_device ("MP%02X" , i);aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i)));aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" )));Quoted 5 lines
hw/acpi/memory_hotplug.c void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, · line 627
Quoted 3 lines
hw/acpi/memory_hotplug.c +1
-1method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_CRS_METHOD; + s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_CRS_METHOD );Same question here, do we get ".." in the path? Maybe is OK?
Quoted 9 lines
nope, it dynamic equivalent of original static 'BASEPATH
MEMORY_SLOT_CRS_METHOD;' where BASEPATH is replaced with
concat(mhp_res_path, ".", MEMORY_SLOT_CRS_METHOD)this 'for' loop changes are temporary and are part of transition to dynamic mem hotplug AML placement. See patch 10/10 which simplifies names within this 'for' loop and reduces AML size as result by placing called methods within the same scope/container.
Thanks for the explanations.
Quoted 72 lines
Quoted 72 lines
Thanks,
MarcelQuoted 69 lines
hw/acpi/memory_hotplug.c +18
-5aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +g_free (s);aml_append (dev, method); method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_STATUS_METHOD; + s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_STATUS_METHOD );aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +g_free (s);aml_append (dev, method); method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD; + s =g_strdup_printf ("%s.%s" , mhp_res_path, +MEMORY_SLOT_PROXIMITY_METHOD );aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +g_free (s);aml_append (dev, method); method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_OST_METHOD; - + s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_OST_METHOD );aml_append (method,aml_return (aml_call4 ( s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) ))); +g_free (s);aml_append (dev, method); method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); - s = BASEPATH MEMORY_SLOT_EJECT_METHOD; + s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_EJECT_METHOD );aml_append (method,aml_return (aml_call2 ( s,aml_name ("_UID" ),aml_arg (0 )))); +g_free (s);aml_append (dev, method);aml_append (sb_scope, dev);@@ -669,4 +673,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, }aml_append (sb_scope, method);aml_append (table, sb_scope); + + method =aml_method (event_handler_method,0 ,AML_NOTSERIALIZED ); + scan_path =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_SCAN_METHOD ); +aml_append (method,aml_call0 (scan_path)); +g_free (scan_path); +aml_append (table, method); + +g_free (mhp_res_path); }hw/i386/acpi-build.c +2
-1@@ -1926,7 +1926,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, "\\_SB.PCI0", "\\_GPE._E02"); }build_memory_hotplug_aml (dsdt, nr_mem, pm->mem_hp_io_base, - pm->mem_hp_io_len); + pm->mem_hp_io_len, +"\\_SB.PCI0" ,"\\_GPE._E03" ); scope =aml_scope ("_GPE" ); {@@ -1941,10 +1942,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (scope, method); }
Quoted 10 lines
Quoted 9 lines
hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1947
Quoted 8 lines
hw/i386/acpi-build.c +0
-4- method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH )); -aml_append (scope, method); -if (pcms->acpi_nvdimm_state.is_enabled) { method =aml_method ("_E04" ,0 ,AML_NOTSERIALIZED ); aml_append(method, aml_notify(aml_name("\\_SB.NVDR"),
Thanks,
Marcel
PATCH v2 7/10 memhp: move GPE handler_E03 into build_memory_hotplug_aml()
In reply to Igor Mammedovbuild hotplug event handler method body in generic hw/acpi/memory_hotplug.c and make hw/i386/acpi-build.c only provide target specific full name of the event handler.
That removes hardcoded MEMORY_HOTPLUG_HANDLER_PATH and allows to do target specific memory hotplug AML placement and wiring it with a target specific hotplug event handler (it's GPE for i386 and would be GPIO for ARM).
---
v2:
- fix commit message
--- include/hw/acpi/memory_hotplug.h | 6 +++--- hw/acpi/memory_hotplug.c | 42 ++++++++++++++++++++++++++-------------- hw/i386/acpi-build.c | 7 ++----- 3 files changed, 32 insertions(+), 23 deletions(-)
include/hw/acpi/memory_hotplug.h +3 -3
@@ -49,9 +49,9 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);#define MEMORY_HOTPLUG_DEVICE "MHPD"#define MEMORY_SLOT_SCAN_METHOD "MSCN" -#define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \ - MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHODvoid build_memory_hotplug_aml (Aml *table,uint32_t nr_mem, -uint16_t io_base,uint16_t io_len); +uint16_t io_base,uint16_t io_len, +const char *res_root, +const char *event_handler_method);#endif
hw/acpi/memory_hotplug.c +27 -15
96 lines not on this page · raw message
hw/i386/acpi-build.c +2 -5
@@ -1926,7 +1926,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, "\\_SB.PCI0", "\\_GPE._E02"); }build_memory_hotplug_aml (dsdt, nr_mem, pm->mem_hp_io_base, - pm->mem_hp_io_len); + pm->mem_hp_io_len, +"\\_SB.PCI0" ,"\\_GPE._E03" ); scope =aml_scope ("_GPE" ); {
@@ -1941,10 +1942,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (scope, method); } - method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH )); -aml_append (scope, method); -if (pcms->acpi_nvdimm_state.is_enabled) { method =aml_method ("_E04" ,0 ,AML_NOTSERIALIZED ); aml_append(method, aml_notify(aml_name("\\_SB.NVDR"),
Signature · 1 line
2.7.4
PATCH 8/10 memhp: move memory hotplug only defines to memory_hotplug.c
In reply to Igor MammedovMove defines used locally only by memory_hotplug.c into it from header files.
--- include/hw/acpi/memory_hotplug.h | 3 --- include/hw/acpi/pc-hotplug.h | 22 ---------------------- hw/acpi/memory_hotplug.c | 24 ++++++++++++++++++++++++ 3 files changed, 24 insertions(+), 25 deletions(-)
include/hw/acpi/memory_hotplug.h +0 -3
@@ -47,9 +47,6 @@ extern const VMStateDescription vmstate_memory_hotplug;void acpi_memory_ospm_status (MemHotplugState *mem_st,ACPIOSTInfoList ***list); -#define MEMORY_HOTPLUG_DEVICE "MHPD" -#define MEMORY_SLOT_SCAN_METHOD "MSCN" - void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, uint16_t io_base, uint16_t io_len, const char *res_root,
include/hw/acpi/pc-hotplug.h +0 -22
@@ -32,26 +32,4 @@#define ACPI_MEMORY_HOTPLUG_IO_LEN 24#define ACPI_MEMORY_HOTPLUG_BASE 0x0a00 -#define MEMORY_SLOTS_NUMBER "MDNR" -#define MEMORY_HOTPLUG_IO_REGION "HPMR" -#define MEMORY_SLOT_ADDR_LOW "MRBL" -#define MEMORY_SLOT_ADDR_HIGH "MRBH" -#define MEMORY_SLOT_SIZE_LOW "MRLL" -#define MEMORY_SLOT_SIZE_HIGH "MRLH" -#define MEMORY_SLOT_PROXIMITY "MPX" -#define MEMORY_SLOT_ENABLED "MES" -#define MEMORY_SLOT_INSERT_EVENT "MINS" -#define MEMORY_SLOT_REMOVE_EVENT "MRMV" -#define MEMORY_SLOT_EJECT "MEJ" -#define MEMORY_SLOT_SLECTOR "MSEL" -#define MEMORY_SLOT_OST_EVENT "MOEV" -#define MEMORY_SLOT_OST_STATUS "MOSC" -#define MEMORY_SLOT_LOCK "MLCK" -#define MEMORY_SLOT_STATUS_METHOD "MRST" -#define MEMORY_SLOT_CRS_METHOD "MCRS" -#define MEMORY_SLOT_OST_METHOD "MOST" -#define MEMORY_SLOT_PROXIMITY_METHOD "MPXM" -#define MEMORY_SLOT_EJECT_METHOD "MEJ0" -#define MEMORY_SLOT_NOTIFY_METHOD "MTFY" -#endif
hw/acpi/memory_hotplug.c +24 -0
@@ -7,6 +7,30 @@#include "trace.h" #include "qapi-event.h" +#define MEMORY_SLOTS_NUMBER "MDNR" +#define MEMORY_HOTPLUG_IO_REGION "HPMR" +#define MEMORY_SLOT_ADDR_LOW "MRBL" +#define MEMORY_SLOT_ADDR_HIGH "MRBH" +#define MEMORY_SLOT_SIZE_LOW "MRLL" +#define MEMORY_SLOT_SIZE_HIGH "MRLH" +#define MEMORY_SLOT_PROXIMITY "MPX" +#define MEMORY_SLOT_ENABLED "MES" +#define MEMORY_SLOT_INSERT_EVENT "MINS" +#define MEMORY_SLOT_REMOVE_EVENT "MRMV" +#define MEMORY_SLOT_EJECT "MEJ" +#define MEMORY_SLOT_SLECTOR "MSEL" +#define MEMORY_SLOT_OST_EVENT "MOEV" +#define MEMORY_SLOT_OST_STATUS "MOSC" +#define MEMORY_SLOT_LOCK "MLCK" +#define MEMORY_SLOT_STATUS_METHOD "MRST" +#define MEMORY_SLOT_CRS_METHOD "MCRS" +#define MEMORY_SLOT_OST_METHOD "MOST" +#define MEMORY_SLOT_PROXIMITY_METHOD "MPXM" +#define MEMORY_SLOT_EJECT_METHOD "MEJ0" +#define MEMORY_SLOT_NOTIFY_METHOD "MTFY" +#define MEMORY_SLOT_SCAN_METHOD "MSCN" +#define MEMORY_HOTPLUG_DEVICE "MHPD" +static ACPIOSTInfo *acpi_memory_device_status (int slot,MemStatus *mdev) {ACPIOSTInfo *info =g_new0 (ACPIOSTInfo,1 );
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH for-2.9 08/10] memhp: move memory hotplug only defines to memory_hotplug.c
Quoted 81 lines · Igor Mammedov
Move defines used locally only by
memory_hotplug.cinto it from header files.Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/memory_hotplug.h | 3 --- include/hw/acpi/pc-hotplug.h | 22 ---------------------- hw/acpi/memory_hotplug.c | 24 ++++++++++++++++++++++++ 3 files changed, 24 insertions(+), 25 deletions(-)include/hw/acpi/memory_hotplug.h +0
-3@@ -47,9 +47,6 @@ extern const VMStateDescription vmstate_memory_hotplug;void acpi_memory_ospm_status (MemHotplugState *mem_st,ACPIOSTInfoList ***list); -#define MEMORY_HOTPLUG_DEVICE "MHPD" -#define MEMORY_SLOT_SCAN_METHOD "MSCN" - void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, uint16_t io_base, uint16_t io_len, const char *res_root,include/hw/acpi/pc-hotplug.h +0
-22@@ -32,26 +32,4 @@#define ACPI_MEMORY_HOTPLUG_IO_LEN 24#define ACPI_MEMORY_HOTPLUG_BASE 0x0a00 -#define MEMORY_SLOTS_NUMBER "MDNR" -#define MEMORY_HOTPLUG_IO_REGION "HPMR" -#define MEMORY_SLOT_ADDR_LOW "MRBL" -#define MEMORY_SLOT_ADDR_HIGH "MRBH" -#define MEMORY_SLOT_SIZE_LOW "MRLL" -#define MEMORY_SLOT_SIZE_HIGH "MRLH" -#define MEMORY_SLOT_PROXIMITY "MPX" -#define MEMORY_SLOT_ENABLED "MES" -#define MEMORY_SLOT_INSERT_EVENT "MINS" -#define MEMORY_SLOT_REMOVE_EVENT "MRMV" -#define MEMORY_SLOT_EJECT "MEJ" -#define MEMORY_SLOT_SLECTOR "MSEL" -#define MEMORY_SLOT_OST_EVENT "MOEV" -#define MEMORY_SLOT_OST_STATUS "MOSC" -#define MEMORY_SLOT_LOCK "MLCK" -#define MEMORY_SLOT_STATUS_METHOD "MRST" -#define MEMORY_SLOT_CRS_METHOD "MCRS" -#define MEMORY_SLOT_OST_METHOD "MOST" -#define MEMORY_SLOT_PROXIMITY_METHOD "MPXM" -#define MEMORY_SLOT_EJECT_METHOD "MEJ0" -#define MEMORY_SLOT_NOTIFY_METHOD "MTFY" -#endif hw/acpi/memory_hotplug.c +17
-0@@ -7,6 +7,30 @@#include "trace.h" #include "qapi-event.h" +#define MEMORY_SLOTS_NUMBER "MDNR" +#define MEMORY_HOTPLUG_IO_REGION "HPMR" +#define MEMORY_SLOT_ADDR_LOW "MRBL" +#define MEMORY_SLOT_ADDR_HIGH "MRBH" +#define MEMORY_SLOT_SIZE_LOW "MRLL" +#define MEMORY_SLOT_SIZE_HIGH "MRLH" +#define MEMORY_SLOT_PROXIMITY "MPX" +#define MEMORY_SLOT_ENABLED "MES" +#define MEMORY_SLOT_INSERT_EVENT "MINS" +#define MEMORY_SLOT_REMOVE_EVENT "MRMV" +#define MEMORY_SLOT_EJECT "MEJ" +#define MEMORY_SLOT_SLECTOR "MSEL" +#define MEMORY_SLOT_OST_EVENT "MOEV" +#define MEMORY_SLOT_OST_STATUS "MOSC" +#define MEMORY_SLOT_LOCK "MLCK" +#define MEMORY_SLOT_STATUS_METHOD "MRST" +#define MEMORY_SLOT_CRS_METHOD "MCRS"
hw/acpi/memory_hotplug.c line 36
Quoted 10 lines
hw/acpi/memory_hotplug.c +7
-0+#define MEMORY_SLOT_OST_METHOD "MOST" +#define MEMORY_SLOT_PROXIMITY_METHOD "MPXM" +#define MEMORY_SLOT_EJECT_METHOD "MEJ0" +#define MEMORY_SLOT_NOTIFY_METHOD "MTFY" +#define MEMORY_SLOT_SCAN_METHOD "MSCN" +#define MEMORY_HOTPLUG_DEVICE "MHPD" +static ACPIOSTInfo *acpi_memory_device_status (int slot,MemStatus *mdev) {ACPIOSTInfo *info =g_new0 (ACPIOSTInfo,1 );
Thanks,
Marcel
PATCH 9/10 memhp: don't generate memory hotplug AML if it's not enabled/supported
In reply to Igor MammedovThat reduces DSDT by 910 bytes when memory hotplug isn't enabled.
While doing so drop intermediate variables/arguments passing around ACPI_MEMORY_HOTPLUG_IO_LEN and making it local to memory_hotplug.c, hardcoding it there as it can't change.
Also don't pass around ACPI_MEMORY_HOTPLUG_BASE through intermediate variables/arguments where it's not needed. Instead initialize in module static variable when MMIO region is mapped and use that within memory_hotplug.c whenever it's required.
That way MMIO base specified only at one place and AML with MMIO would always use the same value.
--- include/hw/acpi/memory_hotplug.h | 3 +-- include/hw/acpi/pc-hotplug.h | 1 - hw/acpi/ich9.c | 3 ++- hw/acpi/memory_hotplug.c | 24 +++++++++++++++++------- hw/acpi/piix4.c | 3 ++- hw/i386/acpi-build.c | 9 +-------- 6 files changed, 23 insertions(+), 20 deletions(-)
include/hw/acpi/memory_hotplug.h +1 -2
@@ -30,7 +30,7 @@ typedef struct MemHotplugState { } MemHotplugState;void acpi_memory_hotplug_init (MemoryRegion *as,Object *owner, -MemHotplugState *state); +MemHotplugState *state,uint16_t io_base);void acpi_memory_plug_cb (HotplugHandler *hotplug_dev,MemHotplugState *mem_st,DeviceState *dev,Error **errp);
@@ -48,7 +48,6 @@ extern const VMStateDescription vmstate_memory_hotplug;void acpi_memory_ospm_status (MemHotplugState *mem_st,ACPIOSTInfoList ***list);void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem, -uint16_t io_base,uint16_t io_len,const char *res_root,const char *event_handler_method);#endif
include/hw/acpi/pc-hotplug.h +0 -1
@@ -29,7 +29,6 @@#define PIIX4_CPU_HOTPLUG_IO_BASE 0xaf00#define CPU_HOTPLUG_RESOURCE_DEVICE PRES -#define ACPI_MEMORY_HOTPLUG_IO_LEN 24#define ACPI_MEMORY_HOTPLUG_BASE 0x0a00#endif
hw/acpi/ich9.c +2 -1
@@ -306,7 +306,8 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,if (pm->acpi_memory_hotplug.is_enabled) {acpi_memory_hotplug_init (pci_address_space_io (lpc_pci),OBJECT (lpc_pci), - &pm->acpi_memory_hotplug); + &pm->acpi_memory_hotplug, +ACPI_MEMORY_HOTPLUG_BASE ); } }
hw/acpi/memory_hotplug.c +17 -7
@@ -30,6 +30,9 @@#define MEMORY_SLOT_NOTIFY_METHOD "MTFY"#define MEMORY_SLOT_SCAN_METHOD "MSCN"#define MEMORY_HOTPLUG_DEVICE "MHPD" +#define MEMORY_HOTPLUG_IO_LEN 24 + +static uint16_t memhp_io_base;static ACPIOSTInfo *acpi_memory_device_status (int slot,MemStatus *mdev) {
@@ -202,7 +205,7 @@ static const MemoryRegionOps acpi_memory_hotplug_ops = { };void acpi_memory_hotplug_init (MemoryRegion *as,Object *owner, -MemHotplugState *state) +MemHotplugState *state,uint16_t io_base) {MachineState *machine =MACHINE (qdev_get_machine ());
@@ -211,10 +214,12 @@ 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" ,ACPI_MEMORY_HOTPLUG_IO_LEN ); -memory_region_add_subregion (as,ACPI_MEMORY_HOTPLUG_BASE , &state->io); +"acpi-mem-hotplug" ,MEMORY_HOTPLUG_IO_LEN ); +memory_region_add_subregion (as, memhp_io_base, &state->io); }/**
@@ -332,7 +337,6 @@ const VMStateDescription vmstate_memory_hotplug = { };void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem, -uint16_t io_base,uint16_t io_len,const char *res_root,const char *event_handler_method) {
@@ -342,8 +346,13 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,Aml *sb_scope;Aml *mem_ctrl_dev;char *scan_path; -char *mhp_res_path =g_strdup_printf ("%s." MEMORY_HOTPLUG_DEVICE , res_root); +char *mhp_res_path; + +if (!memhp_io_base) { +return ; + } + mhp_res_path =g_strdup_printf ("%s." MEMORY_HOTPLUG_DEVICE , res_root); mem_ctrl_dev =aml_device ("%s" , mhp_res_path); {Aml *crs;
@@ -367,13 +376,14 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, crs =aml_resource_template ();aml_append (crs, -aml_io (AML_DECODE16 , io_base, io_base,0 , io_len) +aml_io (AML_DECODE16 , memhp_io_base, memhp_io_base,0 , +MEMORY_HOTPLUG_IO_LEN ) );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 , -aml_int (io_base), io_len) +aml_int (memhp_io_base),MEMORY_HOTPLUG_IO_LEN ) ); field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
hw/acpi/piix4.c +2 -1
@@ -644,7 +644,8 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, PIIX4_CPU_HOTPLUG_IO_BASE);if (s->acpi_memory_hotplug.is_enabled) { -acpi_memory_hotplug_init (parent,OBJECT (s), &s->acpi_memory_hotplug); +acpi_memory_hotplug_init (parent,OBJECT (s), &s->acpi_memory_hotplug, +ACPI_MEMORY_HOTPLUG_BASE ); } }
hw/i386/acpi-build.c +1 -8
@@ -101,8 +101,6 @@ typedef struct AcpiPmInfo {uint32_t gpe0_blk_len;uint32_t io_base;uint16_t cpu_hp_io_base; -uint16_t mem_hp_io_base; -uint16_t mem_hp_io_len;uint16_t pcihp_io_base;uint16_t pcihp_io_len; } AcpiPmInfo;
@@ -148,9 +146,6 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) }assert (obj); - 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) {
@@ -1925,9 +1920,7 @@ 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, pm->mem_hp_io_base, - pm->mem_hp_io_len, -"\\_SB.PCI0" ,"\\_GPE._E03" ); +build_memory_hotplug_aml (dsdt, nr_mem,"\\_SB.PCI0" ,"\\_GPE._E03" ); scope =aml_scope ("_GPE" ); {
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH for-2.9 09/10] memhp: don't generate memory hotplug AML if it's not enabled/supported
Quoted 120 lines · Igor Mammedov
That reduces DSDT by 910 bytes when memory hotplug isn't enabled.
While doing so drop intermediate variables/arguments passing around
ACPI_MEMORY_HOTPLUG_IO_LENand making it local tomemory_hotplug.c, hardcoding it there as it can't change.Also don't pass around
ACPI_MEMORY_HOTPLUG_BASEthrough intermediate variables/arguments where it's not needed. Instead initialize in module static variable when MMIO region is mapped and use that withinmemory_hotplug.cwhenever it's required.
That way MMIO base specified only at one place and AML with MMIO would always use the same value.Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/memory_hotplug.h | 3 +-- include/hw/acpi/pc-hotplug.h | 1 - hw/acpi/ich9.c | 3 ++- hw/acpi/memory_hotplug.c | 24 +++++++++++++++++------- hw/acpi/piix4.c | 3 ++- hw/i386/acpi-build.c | 9 +-------- 6 files changed, 23 insertions(+), 20 deletions(-)include/hw/acpi/memory_hotplug.h +1
-2@@ -30,7 +30,7 @@ typedef struct MemHotplugState { } MemHotplugState;void acpi_memory_hotplug_init (MemoryRegion *as,Object *owner, -MemHotplugState *state); +MemHotplugState *state,uint16_t io_base);void acpi_memory_plug_cb (HotplugHandler *hotplug_dev,MemHotplugState *mem_st,DeviceState *dev,Error **errp);@@ -48,7 +48,6 @@ extern const VMStateDescription vmstate_memory_hotplug;void acpi_memory_ospm_status (MemHotplugState *mem_st,ACPIOSTInfoList ***list);void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem, -uint16_t io_base,uint16_t io_len,const char *res_root,const char *event_handler_method);#endif include/hw/acpi/pc-hotplug.h +0
-1@@ -29,7 +29,6 @@#define PIIX4_CPU_HOTPLUG_IO_BASE 0xaf00#define CPU_HOTPLUG_RESOURCE_DEVICE PRES -#define ACPI_MEMORY_HOTPLUG_IO_LEN 24#define ACPI_MEMORY_HOTPLUG_BASE 0x0a00#endif hw/acpi/ich9.c +2
-1@@ -306,7 +306,8 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,if (pm->acpi_memory_hotplug.is_enabled) {acpi_memory_hotplug_init (pci_address_space_io (lpc_pci),OBJECT (lpc_pci), - &pm->acpi_memory_hotplug); + &pm->acpi_memory_hotplug, +ACPI_MEMORY_HOTPLUG_BASE ); } }hw/acpi/memory_hotplug.c +8
-4@@ -30,6 +30,9 @@#define MEMORY_SLOT_NOTIFY_METHOD "MTFY"#define MEMORY_SLOT_SCAN_METHOD "MSCN"#define MEMORY_HOTPLUG_DEVICE "MHPD" +#define MEMORY_HOTPLUG_IO_LEN 24 + +static uint16_t memhp_io_base;static ACPIOSTInfo *acpi_memory_device_status (int slot,MemStatus *mdev) {@@ -202,7 +205,7 @@ static const MemoryRegionOps acpi_memory_hotplug_ops = { };void acpi_memory_hotplug_init (MemoryRegion *as,Object *owner, -MemHotplugState *state) +MemHotplugState *state,uint16_t io_base) {MachineState *machine =MACHINE (qdev_get_machine ());@@ -211,10 +214,12 @@ 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" ,ACPI_MEMORY_HOTPLUG_IO_LEN ); -memory_region_add_subregion (as,ACPI_MEMORY_HOTPLUG_BASE , &state->io); +"acpi-mem-hotplug" ,MEMORY_HOTPLUG_IO_LEN ); +memory_region_add_subregion (as, memhp_io_base, &state->io); }/** @@ -332,7 +337,6 @@ const VMStateDescription vmstate_memory_hotplug = { };void build_memory_hotplug_aml (Aml *table,uint32_t nr_mem, -uint16_t io_base,uint16_t io_len,const char *res_root,const char *event_handler_method) {
hw/acpi/memory_hotplug.c void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, · line 354
Quoted 10 lines
hw/acpi/memory_hotplug.c +5
-1@@ -342,8 +346,13 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,Aml *sb_scope;Aml *mem_ctrl_dev;char *scan_path; -char *mhp_res_path =g_strdup_printf ("%s." MEMORY_HOTPLUG_DEVICE , res_root); +char *mhp_res_path; + +if (!memhp_io_base) { +return ; + }
I would split the functional change from the refactoring code, but if Michael is OK with it:
Thanks,
Marcel
Quoted 70 lines
hw/acpi/memory_hotplug.c +4
-2+ mhp_res_path =g_strdup_printf ("%s." MEMORY_HOTPLUG_DEVICE , res_root); mem_ctrl_dev =aml_device ("%s" , mhp_res_path); {Aml *crs;@@ -367,13 +376,14 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, crs =aml_resource_template ();aml_append (crs, -aml_io (AML_DECODE16 , io_base, io_base,0 , io_len) +aml_io (AML_DECODE16 , memhp_io_base, memhp_io_base,0 , +MEMORY_HOTPLUG_IO_LEN ) );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 , -aml_int (io_base), io_len) +aml_int (memhp_io_base),MEMORY_HOTPLUG_IO_LEN ) ); field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,hw/acpi/piix4.c +2
-1@@ -644,7 +644,8 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, PIIX4_CPU_HOTPLUG_IO_BASE);if (s->acpi_memory_hotplug.is_enabled) { -acpi_memory_hotplug_init (parent,OBJECT (s), &s->acpi_memory_hotplug); +acpi_memory_hotplug_init (parent,OBJECT (s), &s->acpi_memory_hotplug, +ACPI_MEMORY_HOTPLUG_BASE ); } }hw/i386/acpi-build.c +1
-8@@ -101,8 +101,6 @@ typedef struct AcpiPmInfo {uint32_t gpe0_blk_len;uint32_t io_base;uint16_t cpu_hp_io_base; -uint16_t mem_hp_io_base; -uint16_t mem_hp_io_len;uint16_t pcihp_io_base;uint16_t pcihp_io_len; } AcpiPmInfo;@@ -148,9 +146,6 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) }assert (obj); - 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) {@@ -1925,9 +1920,7 @@ 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, pm->mem_hp_io_base, - pm->mem_hp_io_len, -"\\_SB.PCI0" ,"\\_GPE._E03" ); +build_memory_hotplug_aml (dsdt, nr_mem,"\\_SB.PCI0" ,"\\_GPE._E03" ); scope =aml_scope ("_GPE" ); {
PATCH 10/10 memhp: move DIMM devices into dedicated scope with related common methods
In reply to Igor MammedovMove DIMM devices from global _SB scope to a new \_SB.MHPC container along with common methods used by DIMMs:
MCRS, MRST, MPXM, MOST, MEJ00, MSCN, MTFY
this reduces AML size on 12 * #slots bytes,
i.e. up to 3072 bytes for 265 slots.
--- hw/acpi/memory_hotplug.c | 190 ++++++++++++++++++++++++----------------------- 1 file changed, 97 insertions(+), 93 deletions(-)
hw/acpi/memory_hotplug.c +97 -93
@@ -31,6 +31,7 @@#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;
@@ -343,9 +344,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,int i;Aml *ifctx;Aml *method; -Aml *sb_scope; +Aml *dev_container;Aml *mem_ctrl_dev; -char *scan_path;char *mhp_res_path;if (!memhp_io_base) {
@@ -356,24 +356,11 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, mem_ctrl_dev =aml_device ("%s" , mhp_res_path); {Aml *crs; -Aml *field; -Aml *one =aml_int (1 ); -Aml *zero =aml_int (0 ); -Aml *ret_val =aml_local (0 ); -Aml *slot_arg0 =aml_arg (0 ); -Aml *slots_nr =aml_name (MEMORY_SLOTS_NUMBER ); -Aml *ctrl_lock =aml_name (MEMORY_SLOT_LOCK ); -Aml *slot_selector =aml_name (MEMORY_SLOT_SLECTOR );aml_append (mem_ctrl_dev,aml_name_decl ("_HID" ,aml_string ("PNP0A06" )));aml_append (mem_ctrl_dev,aml_name_decl ("_UID" ,aml_string ("Memory hotplug resources" ))); -assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); -aml_append (mem_ctrl_dev, -aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) - ); - crs =aml_resource_template (); aml_append(crs, aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0,
@@ -386,7 +373,32 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, aml_int(memhp_io_base), MEMORY_HOTPLUG_IO_LEN) ); - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , + } +aml_append (table, mem_ctrl_dev); + + dev_container =aml_device (MEMORY_DEVICES_CONTAINER ); + { +Aml *field; +Aml *one =aml_int (1 ); +Aml *zero =aml_int (0 ); +Aml *ret_val =aml_local (0 ); +Aml *slot_arg0 =aml_arg (0 ); +Aml *slots_nr =aml_name (MEMORY_SLOTS_NUMBER ); +Aml *ctrl_lock =aml_name (MEMORY_SLOT_LOCK ); +Aml *slot_selector =aml_name (MEMORY_SLOT_SLECTOR ); +char *mmio_path =g_strdup_printf ("%s." MEMORY_HOTPLUG_IO_REGION , + mhp_res_path); + +aml_append (dev_container,aml_name_decl ("_HID" ,aml_string ("PNP0A06" ))); +aml_append (dev_container, +aml_name_decl ("_UID" ,aml_string ("DIMM devices" ))); + +assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); +aml_append (dev_container, +aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) + ); + + field =aml_field (mmio_path,AML_DWORD_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,/* read only */ aml_named_field (MEMORY_SLOT_ADDR_LOW ,32 ));
@@ -398,9 +410,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));aml_append (field,/* read only */ aml_named_field (MEMORY_SLOT_PROXIMITY ,32 )); -aml_append (mem_ctrl_dev, field); +aml_append (dev_container, field); - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_BYTE_ACC , + field =aml_field (mmio_path,AML_BYTE_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS );aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); aml_append(field, /* 1 if enabled, read only */
@@ -414,9 +426,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (field,/* initiates device eject, write only */ aml_named_field (MEMORY_SLOT_EJECT ,1 )); -aml_append (mem_ctrl_dev, field); +aml_append (dev_container, field); - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , + field =aml_field (mmio_path,AML_DWORD_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,/* DIMM selector, write only */ aml_named_field (MEMORY_SLOT_SLECTOR ,32 ));
@@ -424,7 +436,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, aml_named_field(MEMORY_SLOT_OST_EVENT, 32));aml_append (field,/* _OST status code, write only */ aml_named_field (MEMORY_SLOT_OST_STATUS ,32 )); -aml_append (mem_ctrl_dev, field); +aml_append (dev_container, field); +g_free (mmio_path); method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); ifctx =aml_if (aml_equal (slots_nr, zero));
@@ -434,9 +447,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method, ifctx);/* present, functioning, decoding, not shown in UI */ aml_append (method,aml_return (aml_int (0xB ))); -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); -aml_append (mem_ctrl_dev,aml_mutex (MEMORY_SLOT_LOCK ,0 )); +aml_append (dev_container,aml_mutex (MEMORY_SLOT_LOCK ,0 )); method =aml_method (MEMORY_SLOT_SCAN_METHOD ,0 ,AML_NOTSERIALIZED ); {
@@ -492,7 +505,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (one)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_STATUS_METHOD ,1 ,AML_NOTSERIALIZED ); {
@@ -512,7 +525,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (ret_val)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_CRS_METHOD ,1 ,AML_SERIALIZED ); {
@@ -603,7 +616,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (mr64)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_PROXIMITY_METHOD ,1 ,AML_NOTSERIALIZED );
@@ -617,7 +630,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (ret_val)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_OST_METHOD ,4 ,AML_NOTSERIALIZED ); {
@@ -631,7 +644,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_store (aml_arg (2 ), ost_status));aml_append (method,aml_release (ctrl_lock)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_EJECT_METHOD ,2 ,AML_NOTSERIALIZED ); {
@@ -643,75 +656,66 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_store (one, eject));aml_append (method,aml_release (ctrl_lock)); } -aml_append (mem_ctrl_dev, method); - } -aml_append (table, mem_ctrl_dev); - - sb_scope =aml_scope ("_SB" ); -/* build memory devices */ -for (i =0 ; i < nr_mem; i++) { -Aml *dev; -char *s; - - dev =aml_device ("MP%02X" , i); -aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); - - method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_CRS_METHOD ); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_STATUS_METHOD ); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path, -MEMORY_SLOT_PROXIMITY_METHOD ); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_OST_METHOD ); -aml_append (method,aml_return (aml_call4 ( - s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) - ))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_EJECT_METHOD ); -aml_append (method,aml_return (aml_call2 ( - s,aml_name ("_UID" ),aml_arg (0 )))); -g_free (s); -aml_append (dev, method); - -aml_append (sb_scope, dev); - } +aml_append (dev_container, method); + +/* build memory devices */ +for (i =0 ; i < nr_mem; i++) { +Aml *dev; +const char *s; + + dev =aml_device ("MP%02X" , i); +aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); + + method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_CRS_METHOD ; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_STATUS_METHOD ; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_PROXIMITY_METHOD ; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_OST_METHOD ; +aml_append (method,aml_return (aml_call4 ( + s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) + ))); +aml_append (dev, method); + + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_EJECT_METHOD ; +aml_append (method,aml_return (aml_call2 ( + s,aml_name ("_UID" ),aml_arg (0 )))); +aml_append (dev, method); + +aml_append (dev_container, dev); + } -/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { -* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } -*/ - method =aml_method (MEMORY_SLOT_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); -for (i =0 ; i < nr_mem; i++) { - ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); -aml_append (ifctx, -aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) - ); -aml_append (method, ifctx); +/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { +* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } +*/ + method =aml_method (MEMORY_SLOT_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); +for (i =0 ; i < nr_mem; i++) { + ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); +aml_append (ifctx, +aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) + ); +aml_append (method, ifctx); + } +aml_append (dev_container, method); } -aml_append (sb_scope, method); -aml_append (table, sb_scope); +aml_append (table, dev_container); method =aml_method (event_handler_method,0 ,AML_NOTSERIALIZED ); - scan_path =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_SCAN_METHOD ); -aml_append (method,aml_call0 (scan_path)); -g_free (scan_path); +aml_append (method, +aml_call0 (MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD ));aml_append (table, method);g_free (mhp_res_path);
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH for-2.9 10/10] memhp: move DIMM devices into dedicated scope with related common methods
Quoted 7 lines · Igor Mammedov
Move DIMM devices from global
_SBscope to a new \_SB.MHPC container along with common methods used by DIMMs:
MCRS, MRST, MPXM, MOST, MEJ00, MSCN, MTFYthis reduces AML size on 12 * #slots bytes,
i.e. up to 3072 bytes for 265 slots.
Can you please explain how the bytes number are reduced? Is it because the devices path is now relative to the new container? If so, can you give an example of before/after?
Quoted 32 lines
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/memory_hotplug.c | 190 ++++++++++++++++++++++++----------------------- 1 file changed, 97 insertions(+), 93 deletions(-)hw/acpi/memory_hotplug.c +2
-2@@ -31,6 +31,7 @@#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;@@ -343,9 +344,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,int i;Aml *ifctx;Aml *method; -Aml *sb_scope; +Aml *dev_container;Aml *mem_ctrl_dev; -char *scan_path;char *mhp_res_path;if (!memhp_io_base) {@@ -356,24 +356,11 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, mem_ctrl_dev =aml_device ("%s" , mhp_res_path); {Aml *crs;
hw/acpi/memory_hotplug.c void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, · line 360
Quoted 10 lines
hw/acpi/memory_hotplug.c +0
-8-Aml *field; -Aml *one =aml_int (1 ); -Aml *zero =aml_int (0 ); -Aml *ret_val =aml_local (0 ); -Aml *slot_arg0 =aml_arg (0 ); -Aml *slots_nr =aml_name (MEMORY_SLOTS_NUMBER ); -Aml *ctrl_lock =aml_name (MEMORY_SLOT_LOCK ); -Aml *slot_selector =aml_name (MEMORY_SLOT_SLECTOR );aml_append (mem_ctrl_dev,aml_name_decl ("_HID" ,aml_string ("PNP0A06" )));
Do we need the above declaration twice? Here is the first occurrence.
Quoted 23 lines
hw/acpi/memory_hotplug.c +7
-6aml_append (mem_ctrl_dev,aml_name_decl ("_UID" ,aml_string ("Memory hotplug resources" ))); -assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); -aml_append (mem_ctrl_dev, -aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) - ); - crs =aml_resource_template (); aml_append(crs, aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0,@@ -386,7 +373,32 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, aml_int(memhp_io_base), MEMORY_HOTPLUG_IO_LEN) ); - field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC, + } +aml_append (table, mem_ctrl_dev); + + dev_container =aml_device (MEMORY_DEVICES_CONTAINER ); + { +Aml *field; +Aml *one =aml_int (1 );
hw/acpi/memory_hotplug.c void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, · line 392
Quoted 10 lines
hw/acpi/memory_hotplug.c +10
-0+Aml *zero =aml_int (0 ); +Aml *ret_val =aml_local (0 ); +Aml *slot_arg0 =aml_arg (0 ); +Aml *slots_nr =aml_name (MEMORY_SLOTS_NUMBER ); +Aml *ctrl_lock =aml_name (MEMORY_SLOT_LOCK ); +Aml *slot_selector =aml_name (MEMORY_SLOT_SLECTOR ); +char *mmio_path =g_strdup_printf ("%s." MEMORY_HOTPLUG_IO_REGION , + mhp_res_path); + +aml_append (dev_container,aml_name_decl ("_HID" ,aml_string ("PNP0A06" )));
And here is the second occurrence.
Thanks,
Marcel
Quoted 236 lines
hw/acpi/memory_hotplug.c +78
-77+aml_append (dev_container, +aml_name_decl ("_UID" ,aml_string ("DIMM devices" ))); + +assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); +aml_append (dev_container, +aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) + ); + + field =aml_field (mmio_path,AML_DWORD_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,/* read only */ aml_named_field (MEMORY_SLOT_ADDR_LOW ,32 ));@@ -398,9 +410,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));aml_append (field,/* read only */ aml_named_field (MEMORY_SLOT_PROXIMITY ,32 )); -aml_append (mem_ctrl_dev, field); +aml_append (dev_container, field); - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_BYTE_ACC , + field =aml_field (mmio_path,AML_BYTE_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS );aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); aml_append(field, /* 1 if enabled, read only */@@ -414,9 +426,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (field,/* initiates device eject, write only */ aml_named_field (MEMORY_SLOT_EJECT ,1 )); -aml_append (mem_ctrl_dev, field); +aml_append (dev_container, field); - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , + field =aml_field (mmio_path,AML_DWORD_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,/* DIMM selector, write only */ aml_named_field (MEMORY_SLOT_SLECTOR ,32 ));@@ -424,7 +436,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, aml_named_field(MEMORY_SLOT_OST_EVENT, 32));aml_append (field,/* _OST status code, write only */ aml_named_field (MEMORY_SLOT_OST_STATUS ,32 )); -aml_append (mem_ctrl_dev, field); +aml_append (dev_container, field); +g_free (mmio_path); method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); ifctx =aml_if (aml_equal (slots_nr, zero));@@ -434,9 +447,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method, ifctx);/* present, functioning, decoding, not shown in UI */ aml_append (method,aml_return (aml_int (0xB ))); -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); -aml_append (mem_ctrl_dev,aml_mutex (MEMORY_SLOT_LOCK ,0 )); +aml_append (dev_container,aml_mutex (MEMORY_SLOT_LOCK ,0 )); method =aml_method (MEMORY_SLOT_SCAN_METHOD ,0 ,AML_NOTSERIALIZED ); {@@ -492,7 +505,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (one)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_STATUS_METHOD ,1 ,AML_NOTSERIALIZED ); {@@ -512,7 +525,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (ret_val)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_CRS_METHOD ,1 ,AML_SERIALIZED ); {@@ -603,7 +616,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (mr64)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_PROXIMITY_METHOD ,1 ,AML_NOTSERIALIZED );@@ -617,7 +630,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (ret_val)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_OST_METHOD ,4 ,AML_NOTSERIALIZED ); {@@ -631,7 +644,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_store (aml_arg (2 ), ost_status));aml_append (method,aml_release (ctrl_lock)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_EJECT_METHOD ,2 ,AML_NOTSERIALIZED ); {@@ -643,75 +656,66 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_store (one, eject));aml_append (method,aml_release (ctrl_lock)); } -aml_append (mem_ctrl_dev, method); - } -aml_append (table, mem_ctrl_dev); - - sb_scope =aml_scope ("_SB" ); -/* build memory devices */ -for (i =0 ; i < nr_mem; i++) { -Aml *dev; -char *s; - - dev =aml_device ("MP%02X" , i); -aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); - - method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_CRS_METHOD ); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_STATUS_METHOD ); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path, -MEMORY_SLOT_PROXIMITY_METHOD ); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_OST_METHOD ); -aml_append (method,aml_return (aml_call4 ( - s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) - ))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_EJECT_METHOD ); -aml_append (method,aml_return (aml_call2 ( - s,aml_name ("_UID" ),aml_arg (0 )))); -g_free (s); -aml_append (dev, method); - -aml_append (sb_scope, dev); - } +aml_append (dev_container, method); + +/* build memory devices */ +for (i =0 ; i < nr_mem; i++) { +Aml *dev; +const char *s; + + dev =aml_device ("MP%02X" , i); +aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); + + method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_CRS_METHOD ; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_STATUS_METHOD ; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_PROXIMITY_METHOD ; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_OST_METHOD ; +aml_append (method,aml_return (aml_call4 ( + s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) + ))); +aml_append (dev, method); + + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_EJECT_METHOD ; +aml_append (method,aml_return (aml_call2 ( + s,aml_name ("_UID" ),aml_arg (0 )))); +aml_append (dev, method); + +aml_append (dev_container, dev); + } -/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { -* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } -*/ - method =aml_method (MEMORY_SLOT_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); -for (i =0 ; i < nr_mem; i++) { - ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); -aml_append (ifctx, -aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) - ); -aml_append (method, ifctx); +/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { +* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } +*/ + method =aml_method (MEMORY_SLOT_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); +for (i =0 ; i < nr_mem; i++) { + ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); +aml_append (ifctx, +aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) + ); +aml_append (method, ifctx); + } +aml_append (dev_container, method); } -aml_append (sb_scope, method); -aml_append (table, sb_scope); +aml_append (table, dev_container); method =aml_method (event_handler_method,0 ,AML_NOTSERIALIZED ); - scan_path =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_SCAN_METHOD ); -aml_append (method,aml_call0 (scan_path)); -g_free (scan_path); +aml_append (method, +aml_call0 (MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD ));aml_append (table, method);g_free (mhp_res_path);
Re: [Qemu-devel] [PATCH for-2.9 10/10] memhp: move DIMM devices into dedicated scope with related common methods
Quoted 11 lines · On Thu, 22 Dec 2016 14:31:19 +0200 Marcel Apfelbaum <[email protected]> wrote:
Quoted 7 lines · Igor Mammedov
Move DIMM devices from global
_SBscope to a new \_SB.MHPC container along with common methods used by DIMMs:
MCRS, MRST, MPXM, MOST, MEJ00, MSCN, MTFYthis reduces AML size on 12 * #slots bytes,
i.e. up to 3072 bytes for 265 slots.Can you please explain how the bytes number are reduced? Is it because the devices path is now relative to the new container?
yes
Quoted 1 line
If so, can you give an example of before/after?
as example:
- Device (MP02)
- {
- Name (_UID, "0x02") // _UID: Unique ID
- Name (_HID, EisaId ("PNP0C80") /* Memory Device */) // _HID: Hardware ID
- Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings
- {- Return (\_SB.PCI0.MHPD.MCRS (_UID))
- }
-
- Method (_STA, 0, NotSerialized) // _STA: Status
- {
- Return (\_SB.PCI0.MHPD.MRST (_UID))
- }
-
- Method (_PXM, 0, NotSerialized) // _PXM: Device Proximity
- {
- Return (\_SB.PCI0.MHPD.MPXM (_UID))
- }
-
- Method (_OST, 3, NotSerialized) // _OST: OSPM Status Indication
- {
- Return (\_SB.PCI0.MHPD.MOST (_UID, Arg0, Arg1, Arg2))
- }
-
- Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device
- {
- Return (\_SB.PCI0.MHPD.MEJ0 (_UID, Arg0))
- }
- }
----
+ Device (MP02)
+ {
+ Name (_UID, "0x02") // _UID: Unique ID
+ Name (_HID, EisaId ("PNP0C80") /* Memory Device */) // _HID: Hardware ID
+ Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings
+ {+ Return (MCRS (_UID))
+ }
+
+ Method (_STA, 0, NotSerialized) // _STA: Status
+ {
+ Return (MRST (_UID))
+ }
+
+ Method (_PXM, 0, NotSerialized) // _PXM: Device Proximity
+ {
+ Return (MPXM (_UID))
+ }
+
+ Method (_OST, 3, NotSerialized) // _OST: OSPM Status Indication
+ {
+ Return (MOST (_UID, Arg0, Arg1, Arg2))
+ }
+
+ Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device
+ {
+ Return (MEJ0 (_UID, Arg0))
+ }
+ }
Quoted 48 lines
Quoted 33 lines
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/memory_hotplug.c | 190 ++++++++++++++++++++++++----------------------- 1 file changed, 97 insertions(+), 93 deletions(-)hw/acpi/memory_hotplug.c +2
-2@@ -31,6 +31,7 @@#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;@@ -343,9 +344,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,int i;Aml *ifctx;Aml *method; -Aml *sb_scope; +Aml *dev_container;Aml *mem_ctrl_dev; -char *scan_path;char *mhp_res_path;if (!memhp_io_base) {@@ -356,24 +356,11 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, mem_ctrl_dev =aml_device ("%s" , mhp_res_path); {Aml *crs;hw/acpi/memory_hotplug.c void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, · line 360
Quoted 10 lines
hw/acpi/memory_hotplug.c +0
-8-Aml *field; -Aml *one =aml_int (1 ); -Aml *zero =aml_int (0 ); -Aml *ret_val =aml_local (0 ); -Aml *slot_arg0 =aml_arg (0 ); -Aml *slots_nr =aml_name (MEMORY_SLOTS_NUMBER ); -Aml *ctrl_lock =aml_name (MEMORY_SLOT_LOCK ); -Aml *slot_selector =aml_name (MEMORY_SLOT_SLECTOR );aml_append (mem_ctrl_dev,aml_name_decl ("_HID" ,aml_string ("PNP0A06" )));Do we need the above declaration twice? Here is the first occurrence.
Quoted 2 lines
hw/acpi/memory_hotplug.c +0
-0aml_append (mem_ctrl_dev,aml_name_decl ("_UID" ,aml_string ("Memory hotplug resources" )));
[...]
Quoted 3 lines
Quoted 3 lines
hw/acpi/memory_hotplug.c +3
-0+ + dev_container =aml_device (MEMORY_DEVICES_CONTAINER ); + {
[...]
Quoted 3 lines
Quoted 1 line
+
aml_append(dev_container, aml_name_decl("_HID", aml_string("PNP0A06")));And here is the second occurrence.
It's different containers, the first one is for MMIO registers for x86 it's placed \_SB.PCI0.MHPD consumes resources from parent's PCI0._CRS and the second is for memory devices \_SB.MHPC which consumes resources outside of PCI0._CRS scope.
Quoted 241 lines
Thanks,
MarcelQuoted 236 lines
hw/acpi/memory_hotplug.c +78
-77+aml_append (dev_container, +aml_name_decl ("_UID" ,aml_string ("DIMM devices" ))); + +assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); +aml_append (dev_container, +aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) + ); + + field =aml_field (mmio_path,AML_DWORD_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,/* read only */ aml_named_field (MEMORY_SLOT_ADDR_LOW ,32 ));@@ -398,9 +410,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));aml_append (field,/* read only */ aml_named_field (MEMORY_SLOT_PROXIMITY ,32 )); -aml_append (mem_ctrl_dev, field); +aml_append (dev_container, field); - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_BYTE_ACC , + field =aml_field (mmio_path,AML_BYTE_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS );aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); aml_append(field, /* 1 if enabled, read only */@@ -414,9 +426,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (field,/* initiates device eject, write only */ aml_named_field (MEMORY_SLOT_EJECT ,1 )); -aml_append (mem_ctrl_dev, field); +aml_append (dev_container, field); - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , + field =aml_field (mmio_path,AML_DWORD_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,/* DIMM selector, write only */ aml_named_field (MEMORY_SLOT_SLECTOR ,32 ));@@ -424,7 +436,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, aml_named_field(MEMORY_SLOT_OST_EVENT, 32));aml_append (field,/* _OST status code, write only */ aml_named_field (MEMORY_SLOT_OST_STATUS ,32 )); -aml_append (mem_ctrl_dev, field); +aml_append (dev_container, field); +g_free (mmio_path); method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); ifctx =aml_if (aml_equal (slots_nr, zero));@@ -434,9 +447,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method, ifctx);/* present, functioning, decoding, not shown in UI */ aml_append (method,aml_return (aml_int (0xB ))); -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); -aml_append (mem_ctrl_dev,aml_mutex (MEMORY_SLOT_LOCK ,0 )); +aml_append (dev_container,aml_mutex (MEMORY_SLOT_LOCK ,0 )); method =aml_method (MEMORY_SLOT_SCAN_METHOD ,0 ,AML_NOTSERIALIZED ); {@@ -492,7 +505,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (one)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_STATUS_METHOD ,1 ,AML_NOTSERIALIZED ); {@@ -512,7 +525,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (ret_val)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_CRS_METHOD ,1 ,AML_SERIALIZED ); {@@ -603,7 +616,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (mr64)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_PROXIMITY_METHOD ,1 ,AML_NOTSERIALIZED );@@ -617,7 +630,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (ret_val)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_OST_METHOD ,4 ,AML_NOTSERIALIZED ); {@@ -631,7 +644,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_store (aml_arg (2 ), ost_status));aml_append (method,aml_release (ctrl_lock)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_EJECT_METHOD ,2 ,AML_NOTSERIALIZED ); {@@ -643,75 +656,66 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_store (one, eject));aml_append (method,aml_release (ctrl_lock)); } -aml_append (mem_ctrl_dev, method); - } -aml_append (table, mem_ctrl_dev); - - sb_scope =aml_scope ("_SB" ); -/* build memory devices */ -for (i =0 ; i < nr_mem; i++) { -Aml *dev; -char *s; - - dev =aml_device ("MP%02X" , i); -aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); - - method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_CRS_METHOD ); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_STATUS_METHOD ); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path, -MEMORY_SLOT_PROXIMITY_METHOD ); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_OST_METHOD ); -aml_append (method,aml_return (aml_call4 ( - s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) - ))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_EJECT_METHOD ); -aml_append (method,aml_return (aml_call2 ( - s,aml_name ("_UID" ),aml_arg (0 )))); -g_free (s); -aml_append (dev, method); - -aml_append (sb_scope, dev); - } +aml_append (dev_container, method); + +/* build memory devices */ +for (i =0 ; i < nr_mem; i++) { +Aml *dev; +const char *s; + + dev =aml_device ("MP%02X" , i); +aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); + + method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_CRS_METHOD ; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_STATUS_METHOD ; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_PROXIMITY_METHOD ; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_OST_METHOD ; +aml_append (method,aml_return (aml_call4 ( + s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) + ))); +aml_append (dev, method); + + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_EJECT_METHOD ; +aml_append (method,aml_return (aml_call2 ( + s,aml_name ("_UID" ),aml_arg (0 )))); +aml_append (dev, method); + +aml_append (dev_container, dev); + } -/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { -* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } -*/ - method =aml_method (MEMORY_SLOT_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); -for (i =0 ; i < nr_mem; i++) { - ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); -aml_append (ifctx, -aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) - ); -aml_append (method, ifctx); +/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { +* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } +*/ + method =aml_method (MEMORY_SLOT_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); +for (i =0 ; i < nr_mem; i++) { + ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); +aml_append (ifctx, +aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) + ); +aml_append (method, ifctx); + } +aml_append (dev_container, method); } -aml_append (sb_scope, method); -aml_append (table, sb_scope); +aml_append (table, dev_container); method =aml_method (event_handler_method,0 ,AML_NOTSERIALIZED ); - scan_path =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_SCAN_METHOD ); -aml_append (method,aml_call0 (scan_path)); -g_free (scan_path); +aml_append (method, +aml_call0 (MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD ));aml_append (table, method);g_free (mhp_res_path);
Marcel Apfelbaum
Reviewed-byRe: [Qemu-devel] [PATCH for-2.9 10/10] memhp: move DIMM devices into dedicated scope with related common methods
Quoted 69 lines · Igor Mammedov
Quoted 11 lines · On Thu, 22 Dec 2016 14:31:19 +0200 Marcel Apfelbaum <[email protected]> wrote:
Quoted 7 lines · Igor Mammedov
Move DIMM devices from global
_SBscope to a new \_SB.MHPC container along with common methods used by DIMMs:
MCRS, MRST, MPXM, MOST, MEJ00, MSCN, MTFYthis reduces AML size on 12 * #slots bytes,
i.e. up to 3072 bytes for 265 slots.Can you please explain how the bytes number are reduced? Is it because the devices path is now relative to the new container?
yes
Quoted 1 line
If so, can you give an example of before/after?
as example:
(quoted diff) +19
-30- Device (MP02) - { - Name (_UID, "0x02") // _UID: Unique ID - Name (_HID, EisaId ("PNP0C80") /* Memory Device */) // _HID: Hardware ID - Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings - { - Return (\_SB.PCI0.MHPD.MCRS (_UID)) - } - - Method (_STA, 0, NotSerialized) // _STA: Status - { - Return (\_SB.PCI0.MHPD.MRST (_UID)) - } - - Method (_PXM, 0, NotSerialized) // _PXM: Device Proximity - { - Return (\_SB.PCI0.MHPD.MPXM (_UID)) - } - - Method (_OST, 3, NotSerialized) // _OST: OSPM Status Indication - { - Return (\_SB.PCI0.MHPD.MOST (_UID, Arg0, Arg1, Arg2)) - } - - Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device - { - Return (\_SB.PCI0.MHPD.MEJ0 (_UID, Arg0)) - } - } ---- + Device (MP02) + { + Name (_UID, "0x02") // _UID: Unique ID + Name (_HID, EisaId ("PNP0C80") /* Memory Device */) // _HID: Hardware ID + Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings + { + Return (MCRS (_UID)) + } + + Method (_STA, 0, NotSerialized) // _STA: Status + { + Return (MRST (_UID)) + } + + Method (_PXM, 0, NotSerialized) // _PXM: Device Proximity + { + Return (MPXM (_UID)) + } +
Review
Quoted 10 lines
(quoted diff) +10
-0+ Method (_OST, 3, NotSerialized) // _OST: OSPM Status Indication + { + Return (MOST (_UID, Arg0, Arg1, Arg2)) + } + + Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device + { + Return (MEJ0 (_UID, Arg0)) + } + }
Thanks for the confirmation.
Quoted 53 lines
Quoted 48 lines
Quoted 33 lines
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/memory_hotplug.c | 190 ++++++++++++++++++++++++----------------------- 1 file changed, 97 insertions(+), 93 deletions(-)hw/acpi/memory_hotplug.c +2
-2@@ -31,6 +31,7 @@#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;@@ -343,9 +344,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,int i;Aml *ifctx;Aml *method; -Aml *sb_scope; +Aml *dev_container;Aml *mem_ctrl_dev; -char *scan_path;char *mhp_res_path;if (!memhp_io_base) {@@ -356,24 +356,11 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, mem_ctrl_dev =aml_device ("%s" , mhp_res_path); {Aml *crs;hw/acpi/memory_hotplug.c void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, · line 360
Quoted 10 lines
hw/acpi/memory_hotplug.c +0
-8-Aml *field; -Aml *one =aml_int (1 ); -Aml *zero =aml_int (0 ); -Aml *ret_val =aml_local (0 ); -Aml *slot_arg0 =aml_arg (0 ); -Aml *slots_nr =aml_name (MEMORY_SLOTS_NUMBER ); -Aml *ctrl_lock =aml_name (MEMORY_SLOT_LOCK ); -Aml *slot_selector =aml_name (MEMORY_SLOT_SLECTOR );aml_append (mem_ctrl_dev,aml_name_decl ("_HID" ,aml_string ("PNP0A06" )));Do we need the above declaration twice? Here is the first occurrence.
Quoted 2 lines
hw/acpi/memory_hotplug.c +0
-0aml_append (mem_ctrl_dev,aml_name_decl ("_UID" ,aml_string ("Memory hotplug resources" )));[...]
Quoted 3 lines
hw/acpi/memory_hotplug.c void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, · line 380
Quoted 3 lines
hw/acpi/memory_hotplug.c +3
-0+ + dev_container =aml_device (MEMORY_DEVICES_CONTAINER ); + {
Quoted 9 lines
[...]
Quoted 3 lines
Quoted 1 line
+
aml_append(dev_container, aml_name_decl("_HID", aml_string("PNP0A06")));And here is the second occurrence.
It's different containers, the first one is for MMIO registers for x86 it's placed \_SB.PCI0.MHPD consumes resources from parent's PCI0._CRS and the second is for memory devices \_SB.MHPC which consumes resources outside of PCI0._CRS scope.
Understood, here is my last R-b tag, however I want to point out that I only looked at the re-factoring steps and my acpi-based memory hotplug knowledge is rather limited.
Thanks,
Marcel
Quoted 243 lines
Quoted 242 lines
Thanks,
MarcelQuoted 236 lines
hw/acpi/memory_hotplug.c +78
-77+aml_append (dev_container, +aml_name_decl ("_UID" ,aml_string ("DIMM devices" ))); + +assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); +aml_append (dev_container, +aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) + ); + + field =aml_field (mmio_path,AML_DWORD_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,/* read only */ aml_named_field (MEMORY_SLOT_ADDR_LOW ,32 ));@@ -398,9 +410,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));aml_append (field,/* read only */ aml_named_field (MEMORY_SLOT_PROXIMITY ,32 )); -aml_append (mem_ctrl_dev, field); +aml_append (dev_container, field); - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_BYTE_ACC , + field =aml_field (mmio_path,AML_BYTE_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS );aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); aml_append(field, /* 1 if enabled, read only */@@ -414,9 +426,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (field,/* initiates device eject, write only */ aml_named_field (MEMORY_SLOT_EJECT ,1 )); -aml_append (mem_ctrl_dev, field); +aml_append (dev_container, field); - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , + field =aml_field (mmio_path,AML_DWORD_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,/* DIMM selector, write only */ aml_named_field (MEMORY_SLOT_SLECTOR ,32 ));@@ -424,7 +436,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, aml_named_field(MEMORY_SLOT_OST_EVENT, 32));aml_append (field,/* _OST status code, write only */ aml_named_field (MEMORY_SLOT_OST_STATUS ,32 )); -aml_append (mem_ctrl_dev, field); +aml_append (dev_container, field); +g_free (mmio_path); method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); ifctx =aml_if (aml_equal (slots_nr, zero));@@ -434,9 +447,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method, ifctx);/* present, functioning, decoding, not shown in UI */ aml_append (method,aml_return (aml_int (0xB ))); -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); -aml_append (mem_ctrl_dev,aml_mutex (MEMORY_SLOT_LOCK ,0 )); +aml_append (dev_container,aml_mutex (MEMORY_SLOT_LOCK ,0 )); method =aml_method (MEMORY_SLOT_SCAN_METHOD ,0 ,AML_NOTSERIALIZED ); {@@ -492,7 +505,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (one)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_STATUS_METHOD ,1 ,AML_NOTSERIALIZED ); {@@ -512,7 +525,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (ret_val)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_CRS_METHOD ,1 ,AML_SERIALIZED ); {@@ -603,7 +616,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (mr64)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_PROXIMITY_METHOD ,1 ,AML_NOTSERIALIZED );@@ -617,7 +630,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (ret_val)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_OST_METHOD ,4 ,AML_NOTSERIALIZED ); {@@ -631,7 +644,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_store (aml_arg (2 ), ost_status));aml_append (method,aml_release (ctrl_lock)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_EJECT_METHOD ,2 ,AML_NOTSERIALIZED ); {@@ -643,75 +656,66 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_store (one, eject));aml_append (method,aml_release (ctrl_lock)); } -aml_append (mem_ctrl_dev, method); - } -aml_append (table, mem_ctrl_dev); - - sb_scope =aml_scope ("_SB" ); -/* build memory devices */ -for (i =0 ; i < nr_mem; i++) { -Aml *dev; -char *s; - - dev =aml_device ("MP%02X" , i); -aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); - - method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_CRS_METHOD ); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_STATUS_METHOD ); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path, -MEMORY_SLOT_PROXIMITY_METHOD ); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_OST_METHOD ); -aml_append (method,aml_return (aml_call4 ( - s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) - ))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_EJECT_METHOD ); -aml_append (method,aml_return (aml_call2 ( - s,aml_name ("_UID" ),aml_arg (0 )))); -g_free (s); -aml_append (dev, method); - -aml_append (sb_scope, dev); - } +aml_append (dev_container, method); + +/* build memory devices */ +for (i =0 ; i < nr_mem; i++) { +Aml *dev; +const char *s; + + dev =aml_device ("MP%02X" , i); +aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); + + method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_CRS_METHOD ; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_STATUS_METHOD ; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_PROXIMITY_METHOD ; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_OST_METHOD ; +aml_append (method,aml_return (aml_call4 ( + s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) + ))); +aml_append (dev, method); + + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_EJECT_METHOD ; +aml_append (method,aml_return (aml_call2 ( + s,aml_name ("_UID" ),aml_arg (0 )))); +aml_append (dev, method); + +aml_append (dev_container, dev); + } -/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { -* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } -*/ - method =aml_method (MEMORY_SLOT_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); -for (i =0 ; i < nr_mem; i++) { - ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); -aml_append (ifctx, -aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) - ); -aml_append (method, ifctx); +/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { +* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } +*/ + method =aml_method (MEMORY_SLOT_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); +for (i =0 ; i < nr_mem; i++) { + ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); +aml_append (ifctx, +aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) + ); +aml_append (method, ifctx); + } +aml_append (dev_container, method); } -aml_append (sb_scope, method); -aml_append (table, sb_scope); +aml_append (table, dev_container); method =aml_method (event_handler_method,0 ,AML_NOTSERIALIZED ); - scan_path =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_SCAN_METHOD ); -aml_append (method,aml_call0 (scan_path)); -g_free (scan_path); +aml_append (method, +aml_call0 (MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD ));aml_append (table, method);g_free (mhp_res_path);
Re: [Qemu-devel] [PATCH for-2.9 10/10] memhp: move DIMM devices into dedicated scope with related common methods
Quoted 146 lines · On Thu, 22 Dec 2016 15:53:55 +0200 Marcel Apfelbaum <[email protected]> wrote:
Quoted 69 lines · Igor Mammedov
Quoted 11 lines · On Thu, 22 Dec 2016 14:31:19 +0200 Marcel Apfelbaum <[email protected]> wrote:
Quoted 7 lines · Igor Mammedov
Move DIMM devices from global
_SBscope to a new \_SB.MHPC container along with common methods used by DIMMs:
MCRS, MRST, MPXM, MOST, MEJ00, MSCN, MTFYthis reduces AML size on 12 * #slots bytes,
i.e. up to 3072 bytes for 265 slots.Can you please explain how the bytes number are reduced? Is it because the devices path is now relative to the new container?
yes
Quoted 1 line
If so, can you give an example of before/after?
as example:
(quoted diff) +19
-30- Device (MP02) - { - Name (_UID, "0x02") // _UID: Unique ID - Name (_HID, EisaId ("PNP0C80") /* Memory Device */) // _HID: Hardware ID - Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings - { - Return (\_SB.PCI0.MHPD.MCRS (_UID)) - } - - Method (_STA, 0, NotSerialized) // _STA: Status - { - Return (\_SB.PCI0.MHPD.MRST (_UID)) - } - - Method (_PXM, 0, NotSerialized) // _PXM: Device Proximity - { - Return (\_SB.PCI0.MHPD.MPXM (_UID)) - } - - Method (_OST, 3, NotSerialized) // _OST: OSPM Status Indication - { - Return (\_SB.PCI0.MHPD.MOST (_UID, Arg0, Arg1, Arg2)) - } - - Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device - { - Return (\_SB.PCI0.MHPD.MEJ0 (_UID, Arg0)) - } - } ---- + Device (MP02) + { + Name (_UID, "0x02") // _UID: Unique ID + Name (_HID, EisaId ("PNP0C80") /* Memory Device */) // _HID: Hardware ID + Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings + { + Return (MCRS (_UID)) + } + + Method (_STA, 0, NotSerialized) // _STA: Status + { + Return (MRST (_UID)) + } + + Method (_PXM, 0, NotSerialized) // _PXM: Device Proximity + { + Return (MPXM (_UID)) + } +Review
Quoted 10 lines
(quoted diff) +10
-0+ Method (_OST, 3, NotSerialized) // _OST: OSPM Status Indication + { + Return (MOST (_UID, Arg0, Arg1, Arg2)) + } + + Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device + { + Return (MEJ0 (_UID, Arg0)) + } + }Thanks for the confirmation.
Quoted 53 lines
Quoted 48 lines
Quoted 33 lines
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/memory_hotplug.c | 190 ++++++++++++++++++++++++----------------------- 1 file changed, 97 insertions(+), 93 deletions(-)hw/acpi/memory_hotplug.c +2
-2@@ -31,6 +31,7 @@#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;@@ -343,9 +344,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,int i;Aml *ifctx;Aml *method; -Aml *sb_scope; +Aml *dev_container;Aml *mem_ctrl_dev; -char *scan_path;char *mhp_res_path;if (!memhp_io_base) {@@ -356,24 +356,11 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, mem_ctrl_dev =aml_device ("%s" , mhp_res_path); {Aml *crs;hw/acpi/memory_hotplug.c void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, · line 360
Quoted 10 lines
hw/acpi/memory_hotplug.c +0
-8-Aml *field; -Aml *one =aml_int (1 ); -Aml *zero =aml_int (0 ); -Aml *ret_val =aml_local (0 ); -Aml *slot_arg0 =aml_arg (0 ); -Aml *slots_nr =aml_name (MEMORY_SLOTS_NUMBER ); -Aml *ctrl_lock =aml_name (MEMORY_SLOT_LOCK ); -Aml *slot_selector =aml_name (MEMORY_SLOT_SLECTOR );aml_append (mem_ctrl_dev,aml_name_decl ("_HID" ,aml_string ("PNP0A06" )));Do we need the above declaration twice? Here is the first occurrence.
Quoted 2 lines
hw/acpi/memory_hotplug.c +0
-0aml_append (mem_ctrl_dev,aml_name_decl ("_UID" ,aml_string ("Memory hotplug resources" )));[...]
Quoted 3 lines
hw/acpi/memory_hotplug.c void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, · line 380
Quoted 3 lines
hw/acpi/memory_hotplug.c +3
-0+ + dev_container =aml_device (MEMORY_DEVICES_CONTAINER ); + {Quoted 9 lines
[...]
Quoted 3 lines
Quoted 1 line
+
aml_append(dev_container, aml_name_decl("_HID", aml_string("PNP0A06")));And here is the second occurrence.
It's different containers, the first one is for MMIO registers for x86 it's placed \_SB.PCI0.MHPD consumes resources from parent's PCI0._CRS and the second is for memory devices \_SB.MHPC which consumes resources outside of PCI0._CRS scope.
Quoted 6 lines
Understood, here is my last R-b tag, however I want to point out that I only looked at the re-factoring steps and my acpi-based memory hotplug knowledge is rather limited.
Reviewed-by Marcel Apfelbaum <[email protected]>
Thanks,
It's pretty much series subj says cleanups/consolidation. The only sort of 'functional' change is that memory hotplug AML is generated only if memory hotplug is enabled, freeing some guest memory when memory hotplug in not in use.
Quoted 248 lines
Thanks,
MarcelQuoted 243 lines
Quoted 242 lines
Thanks,
MarcelQuoted 236 lines
hw/acpi/memory_hotplug.c +78
-77+aml_append (dev_container, +aml_name_decl ("_UID" ,aml_string ("DIMM devices" ))); + +assert (nr_mem <=ACPI_MAX_RAM_SLOTS ); +aml_append (dev_container, +aml_name_decl (MEMORY_SLOTS_NUMBER ,aml_int (nr_mem)) + ); + + field =aml_field (mmio_path,AML_DWORD_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,/* read only */ aml_named_field (MEMORY_SLOT_ADDR_LOW ,32 ));@@ -398,9 +410,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, aml_named_field(MEMORY_SLOT_SIZE_HIGH, 32));aml_append (field,/* read only */ aml_named_field (MEMORY_SLOT_PROXIMITY ,32 )); -aml_append (mem_ctrl_dev, field); +aml_append (dev_container, field); - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_BYTE_ACC , + field =aml_field (mmio_path,AML_BYTE_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS );aml_append (field,aml_reserved_field (160 /* bits, Offset(20) */ )); aml_append(field, /* 1 if enabled, read only */@@ -414,9 +426,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (field,/* initiates device eject, write only */ aml_named_field (MEMORY_SLOT_EJECT ,1 )); -aml_append (mem_ctrl_dev, field); +aml_append (dev_container, field); - field =aml_field (MEMORY_HOTPLUG_IO_REGION ,AML_DWORD_ACC , + field =aml_field (mmio_path,AML_DWORD_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,/* DIMM selector, write only */ aml_named_field (MEMORY_SLOT_SLECTOR ,32 ));@@ -424,7 +436,8 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, aml_named_field(MEMORY_SLOT_OST_EVENT, 32));aml_append (field,/* _OST status code, write only */ aml_named_field (MEMORY_SLOT_OST_STATUS ,32 )); -aml_append (mem_ctrl_dev, field); +aml_append (dev_container, field); +g_free (mmio_path); method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); ifctx =aml_if (aml_equal (slots_nr, zero));@@ -434,9 +447,9 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method, ifctx);/* present, functioning, decoding, not shown in UI */ aml_append (method,aml_return (aml_int (0xB ))); -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); -aml_append (mem_ctrl_dev,aml_mutex (MEMORY_SLOT_LOCK ,0 )); +aml_append (dev_container,aml_mutex (MEMORY_SLOT_LOCK ,0 )); method =aml_method (MEMORY_SLOT_SCAN_METHOD ,0 ,AML_NOTSERIALIZED ); {@@ -492,7 +505,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (one)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_STATUS_METHOD ,1 ,AML_NOTSERIALIZED ); {@@ -512,7 +525,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (ret_val)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_CRS_METHOD ,1 ,AML_SERIALIZED ); {@@ -603,7 +616,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (mr64)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_PROXIMITY_METHOD ,1 ,AML_NOTSERIALIZED );@@ -617,7 +630,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_release (ctrl_lock));aml_append (method,aml_return (ret_val)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_OST_METHOD ,4 ,AML_NOTSERIALIZED ); {@@ -631,7 +644,7 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_store (aml_arg (2 ), ost_status));aml_append (method,aml_release (ctrl_lock)); } -aml_append (mem_ctrl_dev, method); +aml_append (dev_container, method); method =aml_method (MEMORY_SLOT_EJECT_METHOD ,2 ,AML_NOTSERIALIZED ); {@@ -643,75 +656,66 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,aml_append (method,aml_store (one, eject));aml_append (method,aml_release (ctrl_lock)); } -aml_append (mem_ctrl_dev, method); - } -aml_append (table, mem_ctrl_dev); - - sb_scope =aml_scope ("_SB" ); -/* build memory devices */ -for (i =0 ; i < nr_mem; i++) { -Aml *dev; -char *s; - - dev =aml_device ("MP%02X" , i); -aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); -aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); - - method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_CRS_METHOD ); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_STATUS_METHOD ); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path, -MEMORY_SLOT_PROXIMITY_METHOD ); -aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_OST_METHOD ); -aml_append (method,aml_return (aml_call4 ( - s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) - ))); -g_free (s); -aml_append (dev, method); - - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); - s =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_EJECT_METHOD ); -aml_append (method,aml_return (aml_call2 ( - s,aml_name ("_UID" ),aml_arg (0 )))); -g_free (s); -aml_append (dev, method); - -aml_append (sb_scope, dev); - } +aml_append (dev_container, method); + +/* build memory devices */ +for (i =0 ; i < nr_mem; i++) { +Aml *dev; +const char *s; + + dev =aml_device ("MP%02X" , i); +aml_append (dev,aml_name_decl ("_UID" ,aml_string ("0x%02X" , i))); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C80" ))); + + method =aml_method ("_CRS" ,0 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_CRS_METHOD ; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_STATUS_METHOD ; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_PXM" ,0 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_PROXIMITY_METHOD ; +aml_append (method,aml_return (aml_call1 (s,aml_name ("_UID" )))); +aml_append (dev, method); + + method =aml_method ("_OST" ,3 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_OST_METHOD ; +aml_append (method,aml_return (aml_call4 ( + s,aml_name ("_UID" ),aml_arg (0 ),aml_arg (1 ),aml_arg (2 ) + ))); +aml_append (dev, method); + + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); + s =MEMORY_SLOT_EJECT_METHOD ; +aml_append (method,aml_return (aml_call2 ( + s,aml_name ("_UID" ),aml_arg (0 )))); +aml_append (dev, method); + +aml_append (dev_container, dev); + } -/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { -* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } -*/ - method =aml_method (MEMORY_SLOT_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); -for (i =0 ; i < nr_mem; i++) { - ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); -aml_append (ifctx, -aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) - ); -aml_append (method, ifctx); +/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) { +* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... } +*/ + method =aml_method (MEMORY_SLOT_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); +for (i =0 ; i < nr_mem; i++) { + ifctx =aml_if (aml_equal (aml_arg (0 ),aml_int (i))); +aml_append (ifctx, +aml_notify (aml_name ("MP%.02X" , i),aml_arg (1 )) + ); +aml_append (method, ifctx); + } +aml_append (dev_container, method); } -aml_append (sb_scope, method); -aml_append (table, sb_scope); +aml_append (table, dev_container); method =aml_method (event_handler_method,0 ,AML_NOTSERIALIZED ); - scan_path =g_strdup_printf ("%s.%s" , mhp_res_path,MEMORY_SLOT_SCAN_METHOD ); -aml_append (method,aml_call0 (scan_path)); -g_free (scan_path); +aml_append (method, +aml_call0 (MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD ));aml_append (table, method);g_free (mhp_res_path);
Quoted 30 lines · On Tue, 6 Dec 2016 00:32:19 +0100 Igor Mammedov <[email protected]> wrote:
Series cleanups and consolidates scattered memory hotplug code so it could be easily reused by ARM target later.
As result:
* added memory hotplug variant to bios tables test
* all ACPI related parts of memory hotplug are consolidated withinmemory_hotplug.c
* DSDT table size is reduced ~900 bytes when memory hotplug is not enabled (by not generating not used AML)
* DSDT table size is reduced on 12 bytes per slot
(i.e. up to ~3000 bytes savings for 256 DIMMs) with memory hotplug enabled due AML reorganization that makes calls to common functions smaller as devices and common functions are now within the same scope.Tested with following guests:
- RHEL7.3, WS2008DC, WS2008R2DC, WS2012R2DC, WS2016TP5 - no regressions found
- XP3 and WS2003 - boots fine even if memhotplug is enabled (but otherwise it never worked as memhp is not supported there)Git tree for testing:
https://github.com/imammedo/qemu.gitmemhp_consolidate_v1
viewing:
https://github.com/imammedo/qemu/commits/memhp_consolidate_v1Note to maintaner:
* blobs patch 2/10 should be merged to patch 1/10
* ACPI tables should be regenarated and applied after series is merged as DSDT will cange for all tests cases due removal of inactive memory hotplug code.
Quoted 3 lines
CC "Michael S. Tsirkin" <[email protected]>CC Eduardo Habkost <[email protected]>CC Marcel Apfelbaum <[email protected]>
ping,
Michael, Marcel
Could you take a look
Quoted 33 lines
Igor Mammedov (10):
tests: pc: add memory hotplug acpi tables tests
tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant
memhp: movebuild_memory_hotplug_aml()intomemory_hotplug.c
memhp: movebuild_memory_devices()intomemory_hotplug.c
memhp: consolidate scattered MHPD device declaration
memhp: mergebuild_memory_devices()intobuild_memory_hotplug_aml()
memhp: move GPEhandler_E03intobuild_memory_hotplug_aml()
memhp: move memory hotplug only defines tomemory_hotplug.c
memhp: don't generate memory hotplug AML if it's not enabled/supported
memhp: move DIMM devices into dedicated scope with related common
methodsinclude/hw/acpi/memory_hotplug.h | 12 +- include/hw/acpi/pc-hotplug.h | 23 -- hw/acpi/Makefile.objs | 2 +- hw/acpi/ich9.c | 3 +- hw/acpi/memory_hotplug.c | 420 +++++++++++++++++++++++++++++++++++- hw/acpi/memory_hotplug_acpi_table.c | 262 ---------------------- hw/acpi/piix4.c | 3 +- hw/i386/acpi-build.c | 197 +++-------------- tests/acpi-test-data/pc/DSDT.memhp | Bin 0 -> 6613 bytes tests/acpi-test-data/pc/SRAT.memhp | Bin 0 -> 224 bytes tests/acpi-test-data/q35/DSDT.memhp | Bin 0 -> 9375 bytes tests/acpi-test-data/q35/SRAT.memhp | Bin 0 -> 224 bytes tests/bios-tables-test.c | 24 +++ 13 files changed, 479 insertions(+), 467 deletions(-) delete mode 100644 hw/acpi/memory_hotplug_acpi_table.c create mode 100644 tests/acpi-test-data/pc/DSDT.memhp create mode 100644 tests/acpi-test-data/pc/SRAT.memhp create mode 100644 tests/acpi-test-data/q35/DSDT.memhp create mode 100644 tests/acpi-test-data/q35/SRAT.memhp
Quoted 14 lines · On Tue, 6 Dec 2016 00:32:19 +0100 Igor Mammedov <[email protected]> wrote:
Series cleanups and consolidates scattered memory hotplug code so it could be easily reused by ARM target later.
As result:
* added memory hotplug variant to bios tables test
* all ACPI related parts of memory hotplug are consolidated withinmemory_hotplug.c
* DSDT table size is reduced ~900 bytes when memory hotplug is not enabled (by not generating not used AML)
* DSDT table size is reduced on 12 bytes per slot
(i.e. up to ~3000 bytes savings for 256 DIMMs) with memory hotplug enabled due AML reorganization that makes calls to common functions smaller as devices and common functions are now within the same scope.
Quoted 4 lines
Tested with following guests:
- RHEL7.3, WS2008DC, WS2008R2DC, WS2012R2DC, WS2016TP5 - no regressions found
- XP3 and WS2003 - boots fine even if memhotplug is enabled (but otherwise it never worked as memhp is not supported there)
Michael,
Marcel's already reviewed this series a while ago could you pull it in your tree if there aren't any questions?
Quoted 49 lines
Git tree for testing:
https://github.com/imammedo/qemu.gitmemhp_consolidate_v1
viewing:
https://github.com/imammedo/qemu/commits/memhp_consolidate_v1Note to maintaner:
* blobs patch 2/10 should be merged to patch 1/10
* ACPI tables should be regenarated and applied after series is merged as DSDT will cange for all tests cases due removal of inactive memory hotplug code.CC "Michael S. Tsirkin" <[email protected]>CC Eduardo Habkost <[email protected]>CC Marcel Apfelbaum <[email protected]>Igor Mammedov (10):
tests: pc: add memory hotplug acpi tables tests
tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant
memhp: movebuild_memory_hotplug_aml()intomemory_hotplug.c
memhp: movebuild_memory_devices()intomemory_hotplug.c
memhp: consolidate scattered MHPD device declaration
memhp: mergebuild_memory_devices()intobuild_memory_hotplug_aml()
memhp: move GPEhandler_E03intobuild_memory_hotplug_aml()
memhp: move memory hotplug only defines tomemory_hotplug.c
memhp: don't generate memory hotplug AML if it's not enabled/supported
memhp: move DIMM devices into dedicated scope with related common
methodsinclude/hw/acpi/memory_hotplug.h | 12 +- include/hw/acpi/pc-hotplug.h | 23 -- hw/acpi/Makefile.objs | 2 +- hw/acpi/ich9.c | 3 +- hw/acpi/memory_hotplug.c | 420 +++++++++++++++++++++++++++++++++++- hw/acpi/memory_hotplug_acpi_table.c | 262 ---------------------- hw/acpi/piix4.c | 3 +- hw/i386/acpi-build.c | 197 +++-------------- tests/acpi-test-data/pc/DSDT.memhp | Bin 0 -> 6613 bytes tests/acpi-test-data/pc/SRAT.memhp | Bin 0 -> 224 bytes tests/acpi-test-data/q35/DSDT.memhp | Bin 0 -> 9375 bytes tests/acpi-test-data/q35/SRAT.memhp | Bin 0 -> 224 bytes tests/bios-tables-test.c | 24 +++ 13 files changed, 479 insertions(+), 467 deletions(-) delete mode 100644 hw/acpi/memory_hotplug_acpi_table.c create mode 100644 tests/acpi-test-data/pc/DSDT.memhp create mode 100644 tests/acpi-test-data/pc/SRAT.memhp create mode 100644 tests/acpi-test-data/q35/DSDT.memhp create mode 100644 tests/acpi-test-data/q35/SRAT.memhp
Quoted 22 lines · Igor Mammedov
Quoted 14 lines · On Tue, 6 Dec 2016 00:32:19 +0100 Igor Mammedov <[email protected]> wrote:
Series cleanups and consolidates scattered memory hotplug code so it could be easily reused by ARM target later.
As result:
* added memory hotplug variant to bios tables test
* all ACPI related parts of memory hotplug are consolidated withinmemory_hotplug.c
* DSDT table size is reduced ~900 bytes when memory hotplug is not enabled (by not generating not used AML)
* DSDT table size is reduced on 12 bytes per slot
(i.e. up to ~3000 bytes savings for 256 DIMMs) with memory hotplug enabled due AML reorganization that makes calls to common functions smaller as devices and common functions are now within the same scope.Quoted 4 lines
Tested with following guests:
- RHEL7.3, WS2008DC, WS2008R2DC, WS2012R2DC, WS2016TP5 - no regressions found
- XP3 and WS2003 - boots fine even if memhotplug is enabled (but otherwise it never worked as memhp is not supported there)
Quoted 4 lines
Michael,
Marcel's already reviewed this series a while ago could you pull it in your tree if there aren't any questions?
Yes I plan to merge it., just trying to figure out why my previous pull did not get there.
Quoted 50 lines
Quoted 50 lines
Git tree for testing:
https://github.com/imammedo/qemu.gitmemhp_consolidate_v1
viewing:
https://github.com/imammedo/qemu/commits/memhp_consolidate_v1Note to maintaner:
* blobs patch 2/10 should be merged to patch 1/10
* ACPI tables should be regenarated and applied after series is merged as DSDT will cange for all tests cases due removal of inactive memory hotplug code.CC "Michael S. Tsirkin" <[email protected]>CC Eduardo Habkost <[email protected]>CC Marcel Apfelbaum <[email protected]>Igor Mammedov (10):
tests: pc: add memory hotplug acpi tables tests
tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant
memhp: movebuild_memory_hotplug_aml()intomemory_hotplug.c
memhp: movebuild_memory_devices()intomemory_hotplug.c
memhp: consolidate scattered MHPD device declaration
memhp: mergebuild_memory_devices()intobuild_memory_hotplug_aml()
memhp: move GPEhandler_E03intobuild_memory_hotplug_aml()
memhp: move memory hotplug only defines tomemory_hotplug.c
memhp: don't generate memory hotplug AML if it's not enabled/supported
memhp: move DIMM devices into dedicated scope with related common
methodsinclude/hw/acpi/memory_hotplug.h | 12 +- include/hw/acpi/pc-hotplug.h | 23 -- hw/acpi/Makefile.objs | 2 +- hw/acpi/ich9.c | 3 +- hw/acpi/memory_hotplug.c | 420 +++++++++++++++++++++++++++++++++++- hw/acpi/memory_hotplug_acpi_table.c | 262 ---------------------- hw/acpi/piix4.c | 3 +- hw/i386/acpi-build.c | 197 +++-------------- tests/acpi-test-data/pc/DSDT.memhp | Bin 0 -> 6613 bytes tests/acpi-test-data/pc/SRAT.memhp | Bin 0 -> 224 bytes tests/acpi-test-data/q35/DSDT.memhp | Bin 0 -> 9375 bytes tests/acpi-test-data/q35/SRAT.memhp | Bin 0 -> 224 bytes tests/bios-tables-test.c | 24 +++ 13 files changed, 479 insertions(+), 467 deletions(-) delete mode 100644 hw/acpi/memory_hotplug_acpi_table.c create mode 100644 tests/acpi-test-data/pc/DSDT.memhp create mode 100644 tests/acpi-test-data/pc/SRAT.memhp create mode 100644 tests/acpi-test-data/q35/DSDT.memhp create mode 100644 tests/acpi-test-data/q35/SRAT.memhp
Quoted 22 lines · Igor Mammedov
Quoted 14 lines · On Tue, 6 Dec 2016 00:32:19 +0100 Igor Mammedov <[email protected]> wrote:
Series cleanups and consolidates scattered memory hotplug code so it could be easily reused by ARM target later.
As result:
* added memory hotplug variant to bios tables test
* all ACPI related parts of memory hotplug are consolidated withinmemory_hotplug.c
* DSDT table size is reduced ~900 bytes when memory hotplug is not enabled (by not generating not used AML)
* DSDT table size is reduced on 12 bytes per slot
(i.e. up to ~3000 bytes savings for 256 DIMMs) with memory hotplug enabled due AML reorganization that makes calls to common functions smaller as devices and common functions are now within the same scope.Quoted 4 lines
Tested with following guests:
- RHEL7.3, WS2008DC, WS2008R2DC, WS2012R2DC, WS2016TP5 - no regressions found
- XP3 and WS2003 - boots fine even if memhotplug is enabled (but otherwise it never worked as memhp is not supported there)
Quoted 4 lines
Michael,
Marcel's already reviewed this series a while ago could you pull it in your tree if there aren't any questions?
I merged this and updated expected files accordingly.
Could you please check expected files in my tree
to make sure it looks good?
Thanks!
Quoted 50 lines
Quoted 50 lines
Git tree for testing:
https://github.com/imammedo/qemu.gitmemhp_consolidate_v1
viewing:
https://github.com/imammedo/qemu/commits/memhp_consolidate_v1Note to maintaner:
* blobs patch 2/10 should be merged to patch 1/10
* ACPI tables should be regenarated and applied after series is merged as DSDT will cange for all tests cases due removal of inactive memory hotplug code.CC "Michael S. Tsirkin" <[email protected]>CC Eduardo Habkost <[email protected]>CC Marcel Apfelbaum <[email protected]>Igor Mammedov (10):
tests: pc: add memory hotplug acpi tables tests
tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant
memhp: movebuild_memory_hotplug_aml()intomemory_hotplug.c
memhp: movebuild_memory_devices()intomemory_hotplug.c
memhp: consolidate scattered MHPD device declaration
memhp: mergebuild_memory_devices()intobuild_memory_hotplug_aml()
memhp: move GPEhandler_E03intobuild_memory_hotplug_aml()
memhp: move memory hotplug only defines tomemory_hotplug.c
memhp: don't generate memory hotplug AML if it's not enabled/supported
memhp: move DIMM devices into dedicated scope with related common
methodsinclude/hw/acpi/memory_hotplug.h | 12 +- include/hw/acpi/pc-hotplug.h | 23 -- hw/acpi/Makefile.objs | 2 +- hw/acpi/ich9.c | 3 +- hw/acpi/memory_hotplug.c | 420 +++++++++++++++++++++++++++++++++++- hw/acpi/memory_hotplug_acpi_table.c | 262 ---------------------- hw/acpi/piix4.c | 3 +- hw/i386/acpi-build.c | 197 +++-------------- tests/acpi-test-data/pc/DSDT.memhp | Bin 0 -> 6613 bytes tests/acpi-test-data/pc/SRAT.memhp | Bin 0 -> 224 bytes tests/acpi-test-data/q35/DSDT.memhp | Bin 0 -> 9375 bytes tests/acpi-test-data/q35/SRAT.memhp | Bin 0 -> 224 bytes tests/bios-tables-test.c | 24 +++ 13 files changed, 479 insertions(+), 467 deletions(-) delete mode 100644 hw/acpi/memory_hotplug_acpi_table.c create mode 100644 tests/acpi-test-data/pc/DSDT.memhp create mode 100644 tests/acpi-test-data/pc/SRAT.memhp create mode 100644 tests/acpi-test-data/q35/DSDT.memhp create mode 100644 tests/acpi-test-data/q35/SRAT.memhp
Quoted 25 lines · On Tue, 10 Jan 2017 07:08:57 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 24 lines · Igor Mammedov
Quoted 14 lines · On Tue, 6 Dec 2016 00:32:19 +0100 Igor Mammedov <[email protected]> wrote:
Series cleanups and consolidates scattered memory hotplug code so it could be easily reused by ARM target later.
As result:
* added memory hotplug variant to bios tables test
* all ACPI related parts of memory hotplug are consolidated withinmemory_hotplug.c
* DSDT table size is reduced ~900 bytes when memory hotplug is not enabled (by not generating not used AML)
* DSDT table size is reduced on 12 bytes per slot
(i.e. up to ~3000 bytes savings for 256 DIMMs) with memory hotplug enabled due AML reorganization that makes calls to common functions smaller as devices and common functions are now within the same scope.Quoted 4 lines
Tested with following guests:
- RHEL7.3, WS2008DC, WS2008R2DC, WS2012R2DC, WS2016TP5 - no regressions found
- XP3 and WS2003 - boots fine even if memhotplug is enabled (but otherwise it never worked as memhp is not supported there)Michael,
Quoted 7 lines
Quoted 2 lines
Marcel's already reviewed this series a while ago could you pull it in your tree if there aren't any questions?
I merged this and updated expected files accordingly.
Could you please check expected files in my tree
to make sure it looks good?
Merge looks good to me.
I've gave your pci branch a quick memhp testing, hot-add/remove works as expected with RHEL7/WS2012r2.
Thanks!
Quoted 54 lines
Thanks!
Quoted 50 lines
Quoted 50 lines
Git tree for testing:
https://github.com/imammedo/qemu.gitmemhp_consolidate_v1
viewing:
https://github.com/imammedo/qemu/commits/memhp_consolidate_v1Note to maintaner:
* blobs patch 2/10 should be merged to patch 1/10
* ACPI tables should be regenarated and applied after series is merged as DSDT will cange for all tests cases due removal of inactive memory hotplug code.CC "Michael S. Tsirkin" <[email protected]>CC Eduardo Habkost <[email protected]>CC Marcel Apfelbaum <[email protected]>Igor Mammedov (10):
tests: pc: add memory hotplug acpi tables tests
tests: pc: acpi: add SRAT and DSDT blobs for memory hotplug variant
memhp: movebuild_memory_hotplug_aml()intomemory_hotplug.c
memhp: movebuild_memory_devices()intomemory_hotplug.c
memhp: consolidate scattered MHPD device declaration
memhp: mergebuild_memory_devices()intobuild_memory_hotplug_aml()
memhp: move GPEhandler_E03intobuild_memory_hotplug_aml()
memhp: move memory hotplug only defines tomemory_hotplug.c
memhp: don't generate memory hotplug AML if it's not enabled/supported
memhp: move DIMM devices into dedicated scope with related common
methodsinclude/hw/acpi/memory_hotplug.h | 12 +- include/hw/acpi/pc-hotplug.h | 23 -- hw/acpi/Makefile.objs | 2 +- hw/acpi/ich9.c | 3 +- hw/acpi/memory_hotplug.c | 420 +++++++++++++++++++++++++++++++++++- hw/acpi/memory_hotplug_acpi_table.c | 262 ---------------------- hw/acpi/piix4.c | 3 +- hw/i386/acpi-build.c | 197 +++-------------- tests/acpi-test-data/pc/DSDT.memhp | Bin 0 -> 6613 bytes tests/acpi-test-data/pc/SRAT.memhp | Bin 0 -> 224 bytes tests/acpi-test-data/q35/DSDT.memhp | Bin 0 -> 9375 bytes tests/acpi-test-data/q35/SRAT.memhp | Bin 0 -> 224 bytes tests/bios-tables-test.c | 24 +++ 13 files changed, 479 insertions(+), 467 deletions(-) delete mode 100644 hw/acpi/memory_hotplug_acpi_table.c create mode 100644 tests/acpi-test-data/pc/DSDT.memhp create mode 100644 tests/acpi-test-data/pc/SRAT.memhp create mode 100644 tests/acpi-test-data/q35/DSDT.memhp create mode 100644 tests/acpi-test-data/q35/SRAT.memhp