ACPICA: Reduce source code differences between Linux and ACPICA.
Subsystems (2)
Lv Zheng
cover ACPICA: Reduce source code differences between Linux and ACPICA.
This patch set is based on the ACPICA 20121220 release.
This patch set has passed basic build and boot tests.
The source code differences between Linux and ACPICA can be summarized as follows:
1. 1976 Lines (70.5 Kbytes) before applying the patch set;
2. 1796 Lines (64.8 Kbytes) after applying the patch set.
Please review.
Lv Zheng (3):
ACPICA: Cleanup PM_TIMER_FREQUENCY definition.
ACPICA: Cleanup table handler naming conflicts.
ACPICA: Add new statistics interface.
drivers/acpi/acpica/acglobal.h | 4 +++- drivers/acpi/acpica/dsmethod.c | 1 + drivers/acpi/acpica/evsci.c | 1 + drivers/acpi/acpica/tbxface.c | 4 ++-- drivers/acpi/acpica/utglobal.c | 11 +++++++++++ drivers/acpi/acpica/utxface.c | 38 ++++++++++++++++++++++++++++++++++++++ drivers/acpi/numa.c | 2 +- drivers/acpi/processor_idle.c | 5 +++-- drivers/acpi/tables.c | 6 +++--- include/acpi/acpixf.h | 6 ++++-- include/acpi/actypes.h | 16 +++++++++++----- include/linux/acpi.h | 15 ++++++++++----- 12 files changed, 88 insertions(+), 21 deletions(-)
---
Background of "ACPICA <-> Linux Divergences Fixes"
The divergences fixes are meant to make the ACPICA release engineering work easier. More jobs can be done by the scripts running on the machines without the human intervention if the divergences can be controlled down to an acceptable level.
The fixes will use the following two steps to reduce the divergences:
1. Fix the "cosmetic" stuff:
The ACPICA release engineers will focus on the divergences that relate to the "commentary", "indentation", "coding styles", "debug messages", "code block offsetting", etc. in this step.
Such divergences are fixed so that the "useful" stuff can rise to the surface. Most of the fixes do not affect the generation of the Linux binary, some of them do not affect the functionality of the generated Linux binary. Since introducing such fixes to Linux is low risk and some release patches depend on the divergences fixes, the work might be done by the ACPICA release engineers using a reduced community process. Such fixes will be attached on top of the release patch set directly during the release work.
Such "cosmetic" fixes are expected to be done in 2-4 merge cycles.
2. Fix the "useful" stuff:
Either by porting the Linux bug fixes to the ACPICA.
Or by merging the lost ACPICA features to the Linux.
These patches will be sent to community one by one, awaiting comments, then get merged. They will not appear in the release patch set.
Every "cosmetic" divergences fix patch lists the line number of the divergences reduced by the patch.
The divergences result is generated by the following steps:
---------------------------------------------------------------------------
1. pop the patch from the kernel
2. divergence.sh -s <kernel source tree>
3. push the patch to the kernel
4. divergence.sh -s <kernel source tree>
---------------------------------------------------------------------------
Where the divergence.sh can be found in the generate/linux folder of the acpica project source tree.
If a "cosmetic" divergences fix patch does not affect the generation of the Linux binary, you can find a binary comparision result in the patch description.
The comparision result is generated by the following steps:
---------------------------------------------------------------------------
1. pop the patch and build the kernel
2. objcopy -R .notes binary1 > binary2
3. objdump -d binary2 > before.dump
4. push the patch and build the kernel
5. objcopy -R .notes binary1 > binary2
6. objdump -d binary2 > after.dump
7. diff -u before.dump after.dump
---------------------------------------------------------------------------
Where:
1. Basically, binary1 will be "drivers/acpi/acpica/acpi.o". The same process will be executed on "vmlinux" for confirmation if there are header file changes that will seriously affect the generation of the vmlinux.
2. The build step is done by an i386 toolchain so we need to delete .note section which belongs to the .text section to avoid confusions.
If you have concerns about such fixes, please do not send your blame to the code authors or the subsystem maintainers as they have done the right things to help improve the Linux or the ACPICA. Please send your blame to the following mail address whose owner is the culprit doing the bad things (ex. introducing the mistakes) during the release engineering work.
---------------------------------------------------------------------------
Lv "ZETALOG" Zheng <lv.zheng(a)intel.com>
---------------------------------------------------------------------------
Signature · 1 line
1.7.10
Lv Zheng
PATCH 1/3 ACPICA: Cleanup PM_TIMER_FREQUENCY definition.
This is a cosmetic patch only. Comparison of the resulting binary showed only line number differences.
This patch does not affect the generation of the Linux binary. This patch decreases 13 lines of 20121114 divergence.diff.
There is updates in ACPICA for PM_TIMER_FREQUENCY macro, this patch cleans up the usage of this macro in Linux. This patch can also reduce the source code diff between Linux and ACPICA.
---
Binary comparision result:
Changes can be found are caused by the line folding:
-c153f6f9: 68 e6 04 00 00 push $0x4e6 +c153f6f9: 68 e7 04 00 00 push $0x4e7
drivers/acpi/processor_idle.c(1255-1): acpi_processor_power_init ACPI_EXCEPTION -> AE_INFO -> __LINE__
---
Divergences fixing result:
Before applying: 1976 Lines, 70.5 Kbytes
After applying: 1963 Lines, 70.0 Kbytes
--- drivers/acpi/processor_idle.c | 5 +++-- include/acpi/actypes.h | 4 ---- 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/acpi/processor_idle.c +3 -2
@@ -64,10 +64,11 @@#define ACPI_PROCESSOR_CLASS "processor"#define _COMPONENT ACPI_PROCESSOR_COMPONENTACPI_MODULE_NAME ("processor_idle" ); -#define PM_TIMER_TICK_NS (1000000000ULL/PM_TIMER_FREQUENCY) +#define PM_TIMER_TICK_NS (1000000000ULL/ACPI_PM_TIMER_FREQUENCY)#define C2_OVERHEAD 1/* 1us */ #define C3_OVERHEAD 1/* 1us */ -#define PM_TIMER_TICKS_TO_US (p) (((p) * 1000)/(PM_TIMER_FREQUENCY/1000)) +#define PM_TIMER_TICKS_TO_US (p) \ + (((p) * 1000)/(ACPI_PM_TIMER_FREQUENCY/1000))static unsigned int max_cstate__read_mostly =ACPI_PROCESSOR_MAX_POWER ;module_param (max_cstate, uint,0000 );
include/acpi/actypes.h +0 -4
@@ -405,10 +405,6 @@ typedef u8 acpi_owner_id;#define ACPI_MAX16_DECIMAL_DIGITS 5#define ACPI_MAX8_DECIMAL_DIGITS 3 -/* PM Timer ticks per second (HZ) */ - -#define PM_TIMER_FREQUENCY 3579545 -/* * Constants with special meanings */
Signature · 1 line
1.7.10
Lv Zheng
PATCH 2/3 ACPICA: Cleanup table handler naming conflicts.
In reply to Lv ZhengThis is a cosmetic patch only. Comparison of the resulting binary showed no differences.
This patch does not affect the generation of the Linux binary. This patch decreases 44 lines of 20121114 divergence.diff.
There are naming conflicts between Linux and ACPICA on table handlers. This patch cleans up this conflicts to reduce the source code diff between Linux and ACPICA.
---
Binary comparision result:
None
---
Divergences fixing result:
Before applying: 1963 Lines, 70.0 Kbytes
After applying: 1919 Lines, 68.3 Kbytes
--- drivers/acpi/acpica/acglobal.h | 2 +- drivers/acpi/acpica/tbxface.c | 4 ++-- drivers/acpi/numa.c | 2 +- drivers/acpi/tables.c | 6 +++--- include/acpi/acpixf.h | 4 ++-- include/acpi/actypes.h | 2 +- include/linux/acpi.h | 15 ++++++++++----- 7 files changed, 20 insertions(+), 15 deletions(-)
drivers/acpi/acpica/acglobal.h +1 -1
@@ -252,7 +252,7 @@ ACPI_EXTERN acpi_cache_t *acpi_gbl_operand_cache; ACPI_EXTERN struct acpi_global_notify_handler acpi_gbl_global_notify[2]; ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler; ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler; -ACPI_EXTERN acpi_tbl_handler acpi_gbl_table_handler; +ACPI_EXTERN acpi_table_handler acpi_gbl_table_handler; ACPI_EXTERN void *acpi_gbl_table_handler_context; ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk; ACPI_EXTERN acpi_interface_handler acpi_gbl_interface_handler;
drivers/acpi/acpica/tbxface.c +2 -2
@@ -436,7 +436,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_table_by_index)* ******************************************************************************/ acpi_status -acpi_install_table_handler (acpi_tbl_handler handler,void *context) +acpi_install_table_handler (acpi_table_handler handler,void *context) {acpi_status status;
@@ -482,7 +482,7 @@ ACPI_EXPORT_SYMBOL(acpi_install_table_handler)* DESCRIPTION: Remove table event handler * ******************************************************************************/ -acpi_status acpi_remove_table_handler (acpi_tbl_handler handler) +acpi_status acpi_remove_table_handler (acpi_table_handler handler) {acpi_status status;
drivers/acpi/numa.c +1 -1
@@ -273,7 +273,7 @@ static int __init acpi_parse_srat(struct acpi_table_header *table)static int __init acpi_table_parse_srat (enum acpi_srat_type id, -acpi_table_entry_handler handler,unsigned int max_entries) +acpi_tbl_entry_handler handler,unsigned int max_entries) { return acpi_table_parse_entries(ACPI_SIG_SRAT, sizeof(struct acpi_table_srat), id,
drivers/acpi/tables.c +3 -3
@@ -204,7 +204,7 @@ int __initacpi_table_parse_entries (char *id, unsigned long table_size, int entry_id, - acpi_table_entry_handler handler, + acpi_tbl_entry_handler handler, unsigned int max_entries) {struct acpi_table_header *table_header =NULL ;
@@ -269,7 +269,7 @@ err:int __init acpi_table_parse_madt (enum acpi_madt_type id, -acpi_table_entry_handler handler,unsigned int max_entries) +acpi_tbl_entry_handler handler,unsigned int max_entries) { return acpi_table_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt), id,
@@ -285,7 +285,7 @@ acpi_table_parse_madt(enum acpi_madt_type id,* Scan the ACPI System Descriptor Table (STD) for a table matching @id, * run @handler on it. Return 0 if table found, return on if not. */ -int __init acpi_table_parse (char *id,acpi_table_handler handler) +int __init acpi_table_parse (char *id,acpi_tbl_table_handler handler) {struct acpi_table_header *table =NULL ;acpi_size tbl_size;
include/acpi/acpixf.h +2 -2
@@ -197,9 +197,9 @@ acpi_status acpi_get_table_by_index(u32 table_index, struct acpi_table_header **out_table);acpi_status -acpi_install_table_handler (acpi_tbl_handler handler,void *context); +acpi_install_table_handler (acpi_table_handler handler,void *context); -acpi_status acpi_remove_table_handler (acpi_tbl_handler handler); +acpi_status acpi_remove_table_handler (acpi_table_handler handler);/* * Namespace and name interfaces
include/acpi/actypes.h +1 -1
@@ -984,7 +984,7 @@ acpi_status(*acpi_exception_handler) (acpi_status aml_status,/* Table Event handler (Load, load_table, etc.) and types */ typedef -acpi_status (*acpi_tbl_handler ) (u32 event,void *table,void *context); +acpi_status (*acpi_table_handler ) (u32 event,void *table,void *context);#define ACPI_TABLE_LOAD 0x0#define ACPI_TABLE_UNLOAD 0x1
include/linux/acpi.h +10 -5
@@ -72,9 +72,10 @@ enum acpi_address_range_id {/* Table Handlers */ -typedef int (*acpi_table_handler ) (struct acpi_table_header *table); +typedef int (*acpi_tbl_table_handler )(struct acpi_table_header *table); -typedef int (*acpi_table_entry_handler ) (struct acpi_subtable_header *header,const unsigned long end); +typedef int (*acpi_tbl_entry_handler )(struct acpi_subtable_header *header, +const unsigned long end);char *__acpi_map_table (unsigned long phys_addr,unsigned long size);void __acpi_unmap_table (char *map,unsigned long size);
@@ -85,10 +86,14 @@ int acpi_mps_check (void);int acpi_numa_init (void );int acpi_table_init (void ); -int acpi_table_parse (char *id,acpi_table_handler handler); +int acpi_table_parse (char *id,acpi_tbl_table_handler handler);int __init acpi_table_parse_entries (char *id,unsigned long table_size, -int entry_id,acpi_table_entry_handler handler,unsigned int max_entries); -int acpi_table_parse_madt (enum acpi_madt_type id,acpi_table_entry_handler handler,unsigned int max_entries); +int entry_id, +acpi_tbl_entry_handler handler, +unsigned int max_entries); +int acpi_table_parse_madt (enum acpi_madt_type id, +acpi_tbl_entry_handler handler, +unsigned int max_entries);int acpi_parse_mcfg (struct acpi_table_header *header);void acpi_table_print_madt_entry (struct acpi_subtable_header *madt);
Signature · 1 line
1.7.10
Lv Zheng
PATCH 3/3 ACPICA: Add new statistics interface.
In reply to Lv ZhengThis patch decreases 123 lines of 20121114 divergence.diff.
This patch ports new counters and statistics interface to Linux as such enhancement has already been implemented in ACPICA. This patch can also reduce the source code differences between Linux and ACPICA.
---
Divergences fixing result:
Before applying: 1919 Lines, 68.3 Kbytes
After applying: 1796 Lines, 64.3 Kbytes
--- drivers/acpi/acpica/acglobal.h | 2 ++ drivers/acpi/acpica/dsmethod.c | 1 + drivers/acpi/acpica/evsci.c | 1 + drivers/acpi/acpica/utglobal.c | 11 +++++++++++ drivers/acpi/acpica/utxface.c | 38 ++++++++++++++++++++++++++++++++++++++ include/acpi/acpixf.h | 2 ++ include/acpi/actypes.h | 10 ++++++++++ 7 files changed, 65 insertions(+)
drivers/acpi/acpica/acglobal.h +2 -0
@@ -393,7 +393,9 @@ extern u32 acpi_gbl_nesting_level;/* Event counters */ +ACPI_EXTERN u32 acpi_method_count; ACPI_EXTERN u32 acpi_gpe_count; +ACPI_EXTERN u32 acpi_sci_count; ACPI_EXTERN u32 acpi_fixed_event_count[ACPI_NUM_FIXED_EVENTS];/* Support for dynamic control method tracing mechanism */
drivers/acpi/acpica/dsmethod.c +1 -0
@@ -292,6 +292,7 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,* reentered one more time (even if it is the same thread) */ obj_desc->method.thread_count++; + acpi_method_count++;return_ACPI_STATUS (status); cleanup:
drivers/acpi/acpica/evsci.c +1 -0
@@ -89,6 +89,7 @@ static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context)*/ interrupt_handled |=acpi_ev_gpe_detect (gpe_xrupt_list); + acpi_sci_count++;return_VALUE (interrupt_handled); }
drivers/acpi/acpica/utglobal.c +11 -0
@@ -289,6 +289,16 @@ acpi_status acpi_ut_init_globals(void) acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS -1 ] =0x80000000 ; +/* Event counters */ + + acpi_method_count =0 ; + acpi_sci_count =0 ; + acpi_gpe_count =0 ; + +for (i =0 ; i <ACPI_NUM_FIXED_EVENTS ; i++) { + acpi_fixed_event_count[i] =0 ; + } +#if (!ACPI_REDUCED_HARDWARE )/* GPE support */
@@ -378,4 +388,5 @@ acpi_status acpi_ut_init_globals(void) ACPI_EXPORT_SYMBOL(acpi_gbl_FADT) ACPI_EXPORT_SYMBOL(acpi_dbg_level) ACPI_EXPORT_SYMBOL(acpi_dbg_layer) + ACPI_EXPORT_SYMBOL(acpi_gpe_count) ACPI_EXPORT_SYMBOL(acpi_current_gpe_count)
drivers/acpi/acpica/utxface.c +38 -0
@@ -207,6 +207,44 @@ acpi_status acpi_get_system_info(struct acpi_buffer * out_buffer)ACPI_EXPORT_SYMBOL (acpi_get_system_info) +/******************************************************************************* +* +* FUNCTION: acpi_get_statistics +* +* PARAMETERS: stats - Where the statistics are returned +* +* RETURN: status - the status of the call +* +* DESCRIPTION: Get the contents of the various system counters +* +******************************************************************************/ +acpi_status acpi_get_statistics(struct acpi_statistics *stats) +{ +ACPI_FUNCTION_TRACE (acpi_get_statistics); + +/* Parameter validation */ + +if (!stats) { +return_ACPI_STATUS (AE_BAD_PARAMETER ); + } + +/* Various interrupt-based event counters */ + + stats->sci_count = acpi_sci_count; + stats->gpe_count = acpi_gpe_count; + +ACPI_MEMCPY (stats->fixed_event_count, acpi_fixed_event_count, +sizeof (acpi_fixed_event_count)); + +/* Other counters */ + + stats->method_count = acpi_method_count; + +return_ACPI_STATUS (AE_OK ); +} + +ACPI_EXPORT_SYMBOL (acpi_get_statistics) +/***************************************************************************** * * FUNCTION: acpi_install_initialization_handler
include/acpi/acpixf.h +2 -0
@@ -137,6 +137,8 @@ acpi_status acpi_subsystem_status(void);acpi_status acpi_get_system_info (struct acpi_buffer *ret_buffer);#endif +acpi_status acpi_get_statistics (struct acpi_statistics *stats); +const char *acpi_format_exception (acpi_status exception);acpi_status acpi_purge_cached_objects (void );
include/acpi/actypes.h +10 -0
@@ -933,6 +933,16 @@ struct acpi_system_info {u32 debug_layer; }; +/* +* System statistics returned by acpi_get_statistics() +*/ +struct acpi_statistics { +u32 sci_count; +u32 gpe_count; +u32 fixed_event_count[ACPI_NUM_FIXED_EVENTS ]; +u32 method_count; +}; +/* Table Event Types */ #define ACPI_TABLE_EVENT_LOAD 0x0
Signature · 1 line
1.7.10