xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Keir Fraser <keir@xen.org>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH, v2] ACPI: move tables.c fully into .init.*
Date: Wed, 19 Sep 2012 15:45:12 +0100	[thread overview]
Message-ID: <CC7F9908.4C668%keir@xen.org> (raw)
In-Reply-To: <5059DCFD020000780009C50F@nat28.tlf.novell.com>

On 19/09/2012 13:55, "Jan Beulich" <JBeulich@suse.com> wrote:

> 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 <jbeulich@suse.com>

Acked-by: Keir Fraser <keir@xen.org>

> ---
> 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 += tables
>  subdir-y += utilities
>  subdir-$(x86) += apei
>  
> -obj-y += tables.o
> +obj-bin-y += tables.init.o
>  obj-y += numa.o
>  obj-y += osl.o
>  obj-y += pmstat.o
> --- a/xen/drivers/acpi/osl.c
> +++ b/xen/drivers/acpi/osl.c
> @@ -27,6 +27,7 @@
>  #include <asm/io.h>
>  #include <xen/config.h>
>  #include <xen/init.h>
> +#include <xen/pfn.h>
>  #include <xen/types.h>
>  #include <xen/errno.h>
>  #include <xen/acpi.h>
> @@ -182,3 +183,38 @@ acpi_os_write_memory(acpi_physical_addre
>  
> 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 == SYS_STATE_early_boot)
> +  return mfn_to_virt(alloc_boot_pages(PFN_UP(sz), 1));
> +
> + ptr = 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 != SYS_STATE_early_boot) {
> +  ptr = xzalloc_bytes(sz);
> +  ASSERT(!ptr || is_xmalloc_memory(ptr));
> +  return ptr;
> + }
> + ptr = 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 == 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[] = { "dfl", "hi
>  static const char *__initdata
>  mps_inti_flags_trigger[] = { "dfl", "edge", "res", "level" };
>  
> -static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES];
> -
>  static int acpi_apic_instance __initdata;
>  
>  void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
> @@ -324,7 +322,7 @@ static void __init check_multiple_madt(v
>  
>  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 @@
>  
>  #define acpi_thread_id struct vcpu *
>  
> -#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)
>  
>  #endif    /* __ACLINUX_H__ */
> 
> 
> 

      reply	other threads:[~2012-09-19 14:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-19 12:55 [PATCH, v2] ACPI: move tables.c fully into .init.* Jan Beulich
2012-09-19 14:45 ` Keir Fraser [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CC7F9908.4C668%keir@xen.org \
    --to=keir@xen.org \
    --cc=JBeulich@suse.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).