summaryrefslogtreecommitdiff
path: root/include/acpi
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2013-10-29 09:29:27 +0800
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-10-30 12:24:21 +0100
commitb3c86c30efd83ebfa7010c5890e2ebf2678e49f8 (patch)
treef354d1d0a7a01d40345b155e3d271ca9275adb09 /include/acpi
parent73424473d0801f7079258897901ba1edc660dbd3 (diff)
ACPICA: Cleanup memory allocation macros and configurability.
In the common case, the ACPI_ALLOCATE and related macros now resolve directly to their respective acpi_os* OSL interfaces. Two options: 1) The ACPI_ALLOCATE_ZEROED macro defaults to a simple local implementation by default, unless overridden by the USE_NATIVE_ALLOCATE_ZEROED define. 2) For ACPI execution simulation environment (AcpiExec) which is not shipped with the Linux kernel, the macros can optionally be resolved to the local interfaces that track each allocation (used to immediately detect memory leaks). Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'include/acpi')
-rw-r--r--include/acpi/acpiosxf.h2
-rw-r--r--include/acpi/acpixf.h9
-rw-r--r--include/acpi/actypes.h27
-rw-r--r--include/acpi/platform/aclinux.h15
4 files changed, 41 insertions, 12 deletions
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
index 64b8c7639520..7f95215e7754 100644
--- a/include/acpi/acpiosxf.h
+++ b/include/acpi/acpiosxf.h
@@ -146,6 +146,8 @@ void acpi_os_release_mutex(acpi_mutex handle);
*/
void *acpi_os_allocate(acpi_size size);
+void *acpi_os_allocate_zeroed(acpi_size size);
+
void acpi_os_free(void *memory);
void __iomem *acpi_os_map_memory(acpi_physical_address where,
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index ebab0d89c70b..ddde61b43041 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -159,15 +159,6 @@ acpi_decode_pld_buffer(u8 *in_buffer,
acpi_size length, struct acpi_pld_info **return_buffer);
/*
- * ACPI Memory management
- */
-void *acpi_allocate(u32 size);
-
-void *acpi_callocate(u32 size);
-
-void acpi_free(void *address);
-
-/*
* ACPI table load/unload interfaces
*/
acpi_status acpi_load_table(struct acpi_table_header *table);
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index f6abf23ad0a7..fed5af2bcb93 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -306,6 +306,33 @@ typedef u32 acpi_physical_address;
#define ACPI_EXPORT_SYMBOL(symbol)
#endif
+/*******************************************************************************
+ *
+ * Configuration
+ *
+ ******************************************************************************/
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+/*
+ * Memory allocation tracking (used by acpi_exec to detect memory leaks)
+ */
+#define ACPI_MEM_PARAMETERS _COMPONENT, _acpi_module_name, __LINE__
+#define ACPI_ALLOCATE(a) acpi_ut_allocate_and_track ((acpi_size) (a), ACPI_MEM_PARAMETERS)
+#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed_and_track ((acpi_size) (a), ACPI_MEM_PARAMETERS)
+#define ACPI_FREE(a) acpi_ut_free_and_track (a, ACPI_MEM_PARAMETERS)
+#define ACPI_MEM_TRACKING(a) a
+
+#else
+/*
+ * Normal memory allocation directly via the OS services layer
+ */
+#define ACPI_ALLOCATE(a) acpi_os_allocate ((acpi_size) (a))
+#define ACPI_ALLOCATE_ZEROED(a) acpi_os_allocate_zeroed ((acpi_size) (a))
+#define ACPI_FREE(a) acpi_os_free (a)
+#define ACPI_MEM_TRACKING(a)
+
+#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
+
/******************************************************************************
*
* ACPI Specification constants (Do not change unless the specification changes)
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index fda0f3e35c03..7346a9235a4c 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -119,6 +119,14 @@ static inline acpi_thread_id acpi_os_get_thread_id(void)
}
/*
+ * Memory allocation/deallocation
+ */
+
+/* Use native linux version of acpi_os_allocate_zeroed */
+
+#define USE_NATIVE_ALLOCATE_ZEROED
+
+/*
* The irqs_disabled() check is for resume from RAM.
* Interrupts are off during resume, just like they are for boot.
* However, boot has (system_state != SYSTEM_RUNNING)
@@ -140,9 +148,10 @@ static inline void *acpi_os_acquire_object(acpi_cache_t * cache)
irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL);
}
-#define ACPI_ALLOCATE(a) acpi_os_allocate(a)
-#define ACPI_ALLOCATE_ZEROED(a) acpi_os_allocate_zeroed(a)
-#define ACPI_FREE(a) kfree(a)
+static inline void acpi_os_free(void *a)
+{
+ kfree(a);
+}
#ifndef CONFIG_PREEMPT
/*