From: "Jan Beulich" Subject: [PATCH, v2] ACPI: move tables.c fully into .init.* Date: Wed, 19 Sep 2012 13:55:57 +0100 Message-ID: <5059DCFD020000780009C50F@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part6C5D68CD.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Keir Fraser Cc: xen-devel List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part6C5D68CD.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The only non-init item was the space reserved for the initial tables, but we can as well dynamically allocate that array. Signed-off-by: Jan Beulich --- v2: Do allocation via the already existing, but so far broken re-sizing logic (requires properly handling the early boot case in ACPI's allocation abstractions). --- a/xen/drivers/acpi/Makefile +++ b/xen/drivers/acpi/Makefile @@ -2,7 +2,7 @@ subdir-y +=3D tables subdir-y +=3D utilities subdir-$(x86) +=3D apei =20 -obj-y +=3D tables.o +obj-bin-y +=3D tables.init.o obj-y +=3D numa.o obj-y +=3D osl.o obj-y +=3D pmstat.o --- a/xen/drivers/acpi/osl.c +++ b/xen/drivers/acpi/osl.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -182,3 +183,38 @@ acpi_os_write_memory(acpi_physical_addre =20 return AE_OK; } + +#define is_xmalloc_memory(ptr) ((unsigned long)(ptr) & (PAGE_SIZE - 1)) + +void *__init acpi_os_alloc_memory(size_t sz) +{ + void *ptr; + + if (system_state =3D=3D SYS_STATE_early_boot) + return mfn_to_virt(alloc_boot_pages(PFN_UP(sz), 1)); + + ptr =3D xmalloc_bytes(sz); + ASSERT(!ptr || is_xmalloc_memory(ptr)); + return ptr; +} + +void *__init acpi_os_zalloc_memory(size_t sz) +{ + void *ptr; + + if (system_state !=3D SYS_STATE_early_boot) { + ptr =3D xzalloc_bytes(sz); + ASSERT(!ptr || is_xmalloc_memory(ptr)); + return ptr; + } + ptr =3D acpi_os_alloc_memory(sz); + return ptr ? memset(ptr, 0, sz) : NULL; +} + +void __init acpi_os_free_memory(void *ptr) +{ + if (is_xmalloc_memory(ptr)) + xfree(ptr); + else if (ptr && system_state =3D=3D SYS_STATE_early_boot) + init_boot_pages(__pa(ptr), __pa(ptr) + PAGE_SIZE); +} --- a/xen/drivers/acpi/tables.c +++ b/xen/drivers/acpi/tables.c @@ -41,8 +41,6 @@ mps_inti_flags_polarity[] =3D { "dfl", "hi static const char *__initdata mps_inti_flags_trigger[] =3D { "dfl", "edge", "res", "level" }; =20 -static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES]; - static int acpi_apic_instance __initdata; =20 void __init acpi_table_print_madt_entry(struct acpi_subtable_header = *header) @@ -324,7 +322,7 @@ static void __init check_multiple_madt(v =20 int __init acpi_table_init(void) { - acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0); + acpi_initialize_tables(NULL, ACPI_MAX_TABLES, 0); check_multiple_madt(); return 0; } --- a/xen/include/acpi/platform/aclinux.h +++ b/xen/include/acpi/platform/aclinux.h @@ -76,8 +76,12 @@ =20 #define acpi_thread_id struct vcpu * =20 -#define ACPI_ALLOCATE(a) xmalloc_bytes(a) -#define ACPI_ALLOCATE_ZEROED(a) xzalloc_bytes(a) -#define ACPI_FREE(a) xfree(a) +void *acpi_os_alloc_memory(size_t); +void *acpi_os_zalloc_memory(size_t); +void acpi_os_free_memory(void *); + +#define ACPI_ALLOCATE(a) acpi_os_alloc_memory(a) +#define ACPI_ALLOCATE_ZEROED(a) acpi_os_zalloc_memory(a) +#define ACPI_FREE(a) acpi_os_free_memory(a) =20 #endif /* __ACLINUX_H__ */ --=__Part6C5D68CD.0__= Content-Type: text/plain; name="ACPI-tables-init.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ACPI-tables-init.patch" ACPI: move tables.c fully into .init.*=0A=0AThe only non-init item was the = space reserved for the initial tables,=0Abut we can as well dynamically = allocate that array.=0A=0ASigned-off-by: Jan Beulich =0A= ---=0Av2: Do allocation via the already existing, but so far broken = re-sizing=0A logic (requires properly handling the early boot case in = ACPI's=0A allocation abstractions).=0A=0A--- a/xen/drivers/acpi/Makefile= =0A+++ b/xen/drivers/acpi/Makefile=0A@@ -2,7 +2,7 @@ subdir-y +=3D = tables=0A subdir-y +=3D utilities=0A subdir-$(x86) +=3D apei=0A =0A-obj-y = +=3D tables.o=0A+obj-bin-y +=3D tables.init.o=0A obj-y +=3D numa.o=0A = obj-y +=3D osl.o=0A obj-y +=3D pmstat.o=0A--- a/xen/drivers/acpi/osl.c=0A++= + b/xen/drivers/acpi/osl.c=0A@@ -27,6 +27,7 @@=0A #include =0A = #include =0A #include =0A+#include =0A= #include =0A #include =0A #include = =0A@@ -182,3 +183,38 @@ acpi_os_write_memory(acpi_physical_addre=0A =0A = return AE_OK;=0A }=0A+=0A+#define is_xmalloc_memory(ptr) ((unsigned = long)(ptr) & (PAGE_SIZE - 1))=0A+=0A+void *__init acpi_os_alloc_memory(size= _t sz)=0A+{=0A+ void *ptr;=0A+=0A+ if (system_state =3D=3D SYS_STATE_e= arly_boot)=0A+ return mfn_to_virt(alloc_boot_pages(PFN_UP(sz), = 1));=0A+=0A+ ptr =3D xmalloc_bytes(sz);=0A+ ASSERT(!ptr || is_xmalloc_m= emory(ptr));=0A+ return ptr;=0A+}=0A+=0A+void *__init acpi_os_zalloc= _memory(size_t sz)=0A+{=0A+ void *ptr;=0A+=0A+ if (system_state = !=3D SYS_STATE_early_boot) {=0A+ ptr =3D xzalloc_bytes(sz);= =0A+ ASSERT(!ptr || is_xmalloc_memory(ptr));=0A+ = return ptr;=0A+ }=0A+ ptr =3D acpi_os_alloc_memory(sz);=0A+ return ptr = ? memset(ptr, 0, sz) : NULL;=0A+}=0A+=0A+void __init acpi_os_free_memory(vo= id *ptr)=0A+{=0A+ if (is_xmalloc_memory(ptr))=0A+ xfree(ptr);= =0A+ else if (ptr && system_state =3D=3D SYS_STATE_early_boot)=0A+ = init_boot_pages(__pa(ptr), __pa(ptr) + PAGE_SIZE);=0A+}=0A--- a/xen/drivers= /acpi/tables.c=0A+++ b/xen/drivers/acpi/tables.c=0A@@ -41,8 +41,6 @@ = mps_inti_flags_polarity[] =3D { "dfl", "hi=0A static const char *__initdata= =0A mps_inti_flags_trigger[] =3D { "dfl", "edge", "res", "level" };=0A = =0A-static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES];=0A-=0A = static int acpi_apic_instance __initdata;=0A =0A void __init acpi_table_pri= nt_madt_entry(struct acpi_subtable_header *header)=0A@@ -324,7 +322,7 @@ = static void __init check_multiple_madt(v=0A =0A int __init acpi_table_init(= void)=0A {=0A- acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, = 0);=0A+ acpi_initialize_tables(NULL, ACPI_MAX_TABLES, 0);=0A check_multi= ple_madt();=0A return 0;=0A }=0A--- a/xen/include/acpi/platform/aclinux.h= =0A+++ b/xen/include/acpi/platform/aclinux.h=0A@@ -76,8 +76,12 @@=0A =0A = #define acpi_thread_id struct vcpu *=0A =0A-#define ACPI_ALLOCATE(a) = xmalloc_bytes(a)=0A-#define ACPI_ALLOCATE_ZEROED(a) xzalloc_bytes(a)=0A= -#define ACPI_FREE(a) xfree(a)=0A+void *acpi_os_alloc_memory(size= _t);=0A+void *acpi_os_zalloc_memory(size_t);=0A+void acpi_os_free_memory(vo= id *);=0A+=0A+#define ACPI_ALLOCATE(a) acpi_os_alloc_memory(a)=0A+#define = ACPI_ALLOCATE_ZEROED(a) acpi_os_zalloc_memory(a)=0A+#define ACPI_FREE(a) = acpi_os_free_memory(a)=0A =0A #endif /* = __ACLINUX_H__ */=0A --=__Part6C5D68CD.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part6C5D68CD.0__=--