Skip to content

Commit

Permalink
[ACPI] ACPICA 20060317
Browse files Browse the repository at this point in the history
Implemented the use of a cache object for all internal
namespace nodes. Since there are about 1000 static nodes
in a typical system, this will decrease memory use for
cache implementations that minimize per-allocation overhead
(such as a slab allocator.)

Removed the reference count mechanism for internal
namespace nodes, since it was deemed unnecessary. This
reduces the size of each namespace node by about 5%-10%
on all platforms. Nodes are now 20 bytes for the 32-bit
case, and 32 bytes for the 64-bit case.

Optimized several internal data structures to reduce
object size on 64-bit platforms by packing data within
the 64-bit alignment. This includes the frequently used
ACPI_OPERAND_OBJECT, of which there can be ~1000 static
instances corresponding to the namespace objects.

Added two new strings for the predefined _OSI method:
"Windows 2001.1 SP1" and "Windows 2006".

Split the allocation tracking mechanism out to a separate
file, from utalloc.c to uttrack.c. This mechanism appears
to be only useful for application-level code. Kernels may
wish to not include uttrack.c in distributions.

Removed all remnants of the obsolete ACPI_REPORT_* macros
and the associated code. (These macros have been replaced
by the ACPI_ERROR and ACPI_WARNING macros.)

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Bob Moore authored and Len Brown committed Jun 14, 2006
1 parent 144c87b commit 6168612
Show file tree
Hide file tree
Showing 40 changed files with 558 additions and 1,153 deletions.
4 changes: 2 additions & 2 deletions drivers/acpi/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@ void __init acpi_early_init(void)
if (acpi_disabled)
return_VOID;

printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION);

/* enable workarounds, unless strict ACPI spec. compliance */
if (!acpi_strict)
acpi_gbl_enable_interpreter_slack = TRUE;
Expand Down Expand Up @@ -743,8 +745,6 @@ static int __init acpi_init(void)

ACPI_FUNCTION_TRACE("acpi_init");

printk(KERN_INFO PREFIX "Subsystem revision %08x\n", ACPI_CA_VERSION);

if (acpi_disabled) {
printk(KERN_INFO PREFIX "Interpreter disabled.\n");
return_VALUE(-ENODEV);
Expand Down
12 changes: 6 additions & 6 deletions drivers/acpi/dispatcher/dsmthdat.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ void acpi_ds_method_data_init(struct acpi_walk_state *walk_state)
ACPI_MOVE_32_TO_32(&walk_state->arguments[i].name,
NAMEOF_ARG_NTE);
walk_state->arguments[i].name.integer |= (i << 24);
walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED;
walk_state->arguments[i].descriptor_type = ACPI_DESC_TYPE_NAMED;
walk_state->arguments[i].type = ACPI_TYPE_ANY;
walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST |
ANOBJ_METHOD_ARG;
walk_state->arguments[i].flags =
ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG;
}

/* Init the method locals */
Expand All @@ -113,11 +113,11 @@ void acpi_ds_method_data_init(struct acpi_walk_state *walk_state)
NAMEOF_LOCAL_NTE);

walk_state->local_variables[i].name.integer |= (i << 24);
walk_state->local_variables[i].descriptor =
walk_state->local_variables[i].descriptor_type =
ACPI_DESC_TYPE_NAMED;
walk_state->local_variables[i].type = ACPI_TYPE_ANY;
walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST |
ANOBJ_METHOD_LOCAL;
walk_state->local_variables[i].flags =
ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL;
}

return_VOID;
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/dispatcher/dswscope.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ acpi_ds_scope_stack_push(struct acpi_namespace_node *node,

/* Init new scope object */

scope_info->common.data_type = ACPI_DESC_TYPE_STATE_WSCOPE;
scope_info->common.descriptor_type = ACPI_DESC_TYPE_STATE_WSCOPE;
scope_info->scope.node = node;
scope_info->common.value = (u16) type;

Expand Down
12 changes: 6 additions & 6 deletions drivers/acpi/dispatcher/dswstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ acpi_status acpi_ds_result_stack_push(struct acpi_walk_state * walk_state)
return (AE_NO_MEMORY);
}

state->common.data_type = ACPI_DESC_TYPE_STATE_RESULT;
state->common.descriptor_type = ACPI_DESC_TYPE_STATE_RESULT;
acpi_ut_push_generic_state(&walk_state->results, state);

ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Results=%p State=%p\n",
Expand Down Expand Up @@ -620,7 +620,7 @@ struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state *thread)
*
* PARAMETERS: owner_id - ID for object creation
* Origin - Starting point for this walk
* mth_desc - Method object
* method_desc - Method object
* Thread - Current thread state
*
* RETURN: Pointer to the new walk state.
Expand All @@ -634,7 +634,7 @@ struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id,
union acpi_parse_object
*origin,
union acpi_operand_object
*mth_desc,
*method_desc,
struct acpi_thread_state
*thread)
{
Expand All @@ -648,10 +648,10 @@ struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id,
return_PTR(NULL);
}

walk_state->data_type = ACPI_DESC_TYPE_WALK;
walk_state->descriptor_type = ACPI_DESC_TYPE_WALK;
walk_state->method_desc = method_desc;
walk_state->owner_id = owner_id;
walk_state->origin = origin;
walk_state->method_desc = mth_desc;
walk_state->thread = thread;

walk_state->parser_state.start_op = origin;
Expand Down Expand Up @@ -819,7 +819,7 @@ void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state)
return;
}

if (walk_state->data_type != ACPI_DESC_TYPE_WALK) {
if (walk_state->descriptor_type != ACPI_DESC_TYPE_WALK) {
ACPI_ERROR((AE_INFO, "%p is not a valid walk state",
walk_state));
return;
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/events/evgpeblk.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info)
*
******************************************************************************/

acpi_status acpi_ev_walk_gpe_list(ACPI_GPE_CALLBACK gpe_walk_callback)
acpi_status acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback)
{
struct acpi_gpe_block_info *gpe_block;
struct acpi_gpe_xrupt_info *gpe_xrupt_info;
Expand Down
3 changes: 2 additions & 1 deletion drivers/acpi/events/evmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
return (AE_NO_MEMORY);
}

notify_info->common.data_type = ACPI_DESC_TYPE_STATE_NOTIFY;
notify_info->common.descriptor_type =
ACPI_DESC_TYPE_STATE_NOTIFY;
notify_info->notify.node = node;
notify_info->notify.value = (u16) notify_value;
notify_info->notify.handler_obj = handler_obj;
Expand Down
15 changes: 6 additions & 9 deletions drivers/acpi/events/evregion.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)

cleanup:
acpi_ut_remove_reference(params[0]);

return_ACPI_STATUS(status);
}

Expand Down Expand Up @@ -389,9 +388,8 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
acpi_ut_get_region_name(region_obj->region.
space_id)));

if (!
(handler_desc->address_space.
hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
if (!(handler_desc->address_space.handler_flags &
ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
/*
* For handlers other than the default (supplied) handlers, we must
* exit the interpreter because the handler *might* block -- we don't
Expand All @@ -412,9 +410,8 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
space_id)));
}

if (!
(handler_desc->address_space.
hflags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
if (!(handler_desc->address_space.handler_flags &
ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
/*
* We just returned from a non-default handler, we must re-enter the
* interpreter
Expand Down Expand Up @@ -772,7 +769,7 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
union acpi_operand_object *handler_obj;
acpi_status status;
acpi_object_type type;
u16 flags = 0;
u8 flags = 0;

ACPI_FUNCTION_TRACE("ev_install_space_handler");

Expand Down Expand Up @@ -930,7 +927,7 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
/* Init handler obj */

handler_obj->address_space.space_id = (u8) space_id;
handler_obj->address_space.hflags = flags;
handler_obj->address_space.handler_flags = flags;
handler_obj->address_space.region_list = NULL;
handler_obj->address_space.node = node;
handler_obj->address_space.handler = handler;
Expand Down
7 changes: 4 additions & 3 deletions drivers/acpi/executer/excreate.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,9 @@ acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state)
obj_desc->mutex.node =
(struct acpi_namespace_node *)walk_state->operands[0];

status = acpi_ns_attach_object(obj_desc->mutex.node,
obj_desc, ACPI_TYPE_MUTEX);
status =
acpi_ns_attach_object(obj_desc->mutex.node, obj_desc,
ACPI_TYPE_MUTEX);

cleanup:
/*
Expand Down Expand Up @@ -464,9 +465,9 @@ acpi_status acpi_ex_create_processor(struct acpi_walk_state *walk_state)
/* Initialize the processor object from the operands */

obj_desc->processor.proc_id = (u8) operand[1]->integer.value;
obj_desc->processor.length = (u8) operand[3]->integer.value;
obj_desc->processor.address =
(acpi_io_address) operand[2]->integer.value;
obj_desc->processor.length = (u8) operand[3]->integer.value;

/* Install the processor object in the parent Node */

Expand Down
2 changes: 0 additions & 2 deletions drivers/acpi/executer/exdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ static struct acpi_exdump_info acpi_ex_dump_node[6] = {
{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_node), NULL},
{ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(flags), "Flags"},
{ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(owner_id), "Owner Id"},
{ACPI_EXD_UINT16, ACPI_EXD_NSOFFSET(reference_count),
"Reference Count"},
{ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(child), "Child List"},
{ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET(peer), "Next Peer"}
};
Expand Down
104 changes: 11 additions & 93 deletions drivers/acpi/namespace/nsalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME("nsalloc")

/* Local prototypes */
static void acpi_ns_remove_reference(struct acpi_namespace_node *node);

/*******************************************************************************
*
* FUNCTION: acpi_ns_create_node
Expand All @@ -61,24 +58,21 @@ static void acpi_ns_remove_reference(struct acpi_namespace_node *node);
* DESCRIPTION: Create a namespace node
*
******************************************************************************/

struct acpi_namespace_node *acpi_ns_create_node(u32 name)
{
struct acpi_namespace_node *node;

ACPI_FUNCTION_TRACE("ns_create_node");

node = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_namespace_node));
node = acpi_os_acquire_object(acpi_gbl_namespace_cache);
if (!node) {
return_PTR(NULL);
}

ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_allocated++);

node->name.integer = name;
node->reference_count = 1;
ACPI_SET_DESCRIPTOR_TYPE(node, ACPI_DESC_TYPE_NAMED);

return_PTR(node);
}

Expand Down Expand Up @@ -139,10 +133,10 @@ void acpi_ns_delete_node(struct acpi_namespace_node *node)
ACPI_MEM_TRACKING(acpi_gbl_ns_node_list->total_freed++);

/*
* Detach an object if there is one then delete the node
* Detach an object if there is one, then delete the node
*/
acpi_ns_detach_object(node);
ACPI_FREE(node);
(void)acpi_os_release_object(acpi_gbl_namespace_cache, node);
return_VOID;
}

Expand Down Expand Up @@ -217,16 +211,6 @@ void acpi_ns_install_node(struct acpi_walk_state *walk_state, struct acpi_namesp
acpi_ut_get_node_name(parent_node),
acpi_ut_get_type_name(parent_node->type),
parent_node));

/*
* Increment the reference count(s) of all parents up to
* the root!
*/
while ((node = acpi_ns_get_parent_node(node)) != NULL) {
node->reference_count++;
}

return_VOID;
}

/*******************************************************************************
Expand All @@ -246,7 +230,6 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
{
struct acpi_namespace_node *child_node;
struct acpi_namespace_node *next_node;
struct acpi_namespace_node *node;
u8 flags;

ACPI_FUNCTION_TRACE_PTR("ns_delete_children", parent_node);
Expand Down Expand Up @@ -292,26 +275,10 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent_node)
*/
acpi_ns_detach_object(child_node);

/*
* Decrement the reference count(s) of all parents up to
* the root! (counts were incremented when the node was created)
*/
node = child_node;
while ((node = acpi_ns_get_parent_node(node)) != NULL) {
node->reference_count--;
}

/* There should be only one reference remaining on this node */

if (child_node->reference_count != 1) {
ACPI_WARNING((AE_INFO,
"Existing references (%d) on node being deleted (%p)",
child_node->reference_count, child_node));
}

/* Now we can delete the node */

ACPI_FREE(child_node);
(void)acpi_os_release_object(acpi_gbl_namespace_cache,
child_node);

/* And move on to the next child in the list */

Expand Down Expand Up @@ -358,8 +325,9 @@ void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)

/* Get the next node in this scope (NULL if none) */

child_node = acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
child_node);
child_node =
acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node,
child_node);
if (child_node) {

/* Found a child node - detach any attached object */
Expand Down Expand Up @@ -404,57 +372,6 @@ void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
return_VOID;
}

/*******************************************************************************
*
* FUNCTION: acpi_ns_remove_reference
*
* PARAMETERS: Node - Named node whose reference count is to be
* decremented
*
* RETURN: None.
*
* DESCRIPTION: Remove a Node reference. Decrements the reference count
* of all parent Nodes up to the root. Any node along
* the way that reaches zero references is freed.
*
******************************************************************************/

static void acpi_ns_remove_reference(struct acpi_namespace_node *node)
{
struct acpi_namespace_node *parent_node;
struct acpi_namespace_node *this_node;

ACPI_FUNCTION_ENTRY();

/*
* Decrement the reference count(s) of this node and all
* nodes up to the root, Delete anything with zero remaining references.
*/
this_node = node;
while (this_node) {

/* Prepare to move up to parent */

parent_node = acpi_ns_get_parent_node(this_node);

/* Decrement the reference count on this node */

this_node->reference_count--;

/* Delete the node if no more references */

if (!this_node->reference_count) {

/* Delete all children and delete the node */

acpi_ns_delete_children(this_node);
acpi_ns_delete_node(this_node);
}

this_node = parent_node;
}
}

/*******************************************************************************
*
* FUNCTION: acpi_ns_delete_namespace_by_owner
Expand Down Expand Up @@ -482,9 +399,9 @@ void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
return_VOID;
}

deletion_node = NULL;
parent_node = acpi_gbl_root_node;
child_node = NULL;
deletion_node = NULL;
level = 1;

/*
Expand All @@ -501,7 +418,8 @@ void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id)
child_node);

if (deletion_node) {
acpi_ns_remove_reference(deletion_node);
acpi_ns_delete_children(deletion_node);
acpi_ns_delete_node(deletion_node);
deletion_node = NULL;
}

Expand Down
Loading

0 comments on commit 6168612

Please sign in to comment.