Example #1
0
acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
{
	acpi_thread_id this_thread_id;

	ACPI_FUNCTION_NAME(ut_release_mutex);

	this_thread_id = acpi_os_get_thread_id();
	ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
			  "Thread %X releasing Mutex [%s]\n", (u32) this_thread_id,
			  acpi_ut_get_mutex_name(mutex_id)));

	if (mutex_id > ACPI_MAX_MUTEX) {
		return (AE_BAD_PARAMETER);
	}

	/*
	 * Mutex must be acquired in order to release it!
	 */
	if (acpi_gbl_mutex_info[mutex_id].thread_id == ACPI_MUTEX_NOT_ACQUIRED) {
		ACPI_ERROR((AE_INFO,
			    "Mutex [%X] is not acquired, cannot release",
			    mutex_id));

		return (AE_NOT_ACQUIRED);
	}
#ifdef ACPI_MUTEX_DEBUG
	{
		u32 i;
		/*
		 * Mutex debug code, for internal debugging only.
		 *
		 * Deadlock prevention.  Check if this thread owns any mutexes of value
		 * greater than this one.  If so, the thread has violated the mutex
		 * ordering rule.  This indicates a coding error somewhere in
		 * the ACPI subsystem code.
		 */
		for (i = mutex_id; i < ACPI_MAX_MUTEX; i++) {
			if (acpi_gbl_mutex_info[i].thread_id == this_thread_id) {
				if (i == mutex_id) {
					continue;
				}

				ACPI_ERROR((AE_INFO,
					    "Invalid release order: owns [%s], releasing [%s]",
					    acpi_ut_get_mutex_name(i),
					    acpi_ut_get_mutex_name(mutex_id)));

				return (AE_RELEASE_DEADLOCK);
			}
		}
	}
#endif

	/* Mark unlocked FIRST */

	acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;

	acpi_os_release_mutex(acpi_gbl_mutex_info[mutex_id].mutex);
	return (AE_OK);
}
Example #2
0
void acpi_db_display_locks(void)
{
	u32 i;

	for (i = 0; i < ACPI_MAX_MUTEX; i++) {
		acpi_os_printf("%26s : %s\n", acpi_ut_get_mutex_name(i),
			       acpi_gbl_mutex_info[i].thread_id ==
			       ACPI_MUTEX_NOT_ACQUIRED ? "Locked" : "Unlocked");
	}
}
acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
{
	acpi_status status;
	acpi_thread_id this_thread_id;

	ACPI_FUNCTION_NAME(ut_acquire_mutex);

	if (mutex_id > ACPI_MAX_MUTEX) {
		return (AE_BAD_PARAMETER);
	}

	this_thread_id = acpi_os_get_thread_id();

#ifdef ACPI_MUTEX_DEBUG
	{
		u32 i;
		/*
		 * Mutex debug code, for internal debugging only.
		 *
		 * Deadlock prevention.  Check if this thread owns any mutexes of value
		 * greater than or equal to this one.  If so, the thread has violated
		 * the mutex ordering rule.  This indicates a coding error somewhere in
		 * the ACPI subsystem code.
		 */
		for (i = mutex_id; i < ACPI_NUM_MUTEX; i++) {
			if (acpi_gbl_mutex_info[i].thread_id == this_thread_id) {
				if (i == mutex_id) {
					ACPI_ERROR((AE_INFO,
						    "Mutex [%s] already acquired by this thread [%p]",
						    acpi_ut_get_mutex_name
						    (mutex_id),
						    ACPI_CAST_PTR(void,
								  this_thread_id)));

					return (AE_ALREADY_ACQUIRED);
				}

				ACPI_ERROR((AE_INFO,
					    "Invalid acquire order: Thread %p owns [%s], wants [%s]",
					    ACPI_CAST_PTR(void, this_thread_id),
					    acpi_ut_get_mutex_name(i),
					    acpi_ut_get_mutex_name(mutex_id)));

				return (AE_ACQUIRE_DEADLOCK);
			}
		}
	}
Example #4
0
acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
{
	acpi_status status;
	acpi_thread_id this_thread_id;

	ACPI_FUNCTION_NAME(ut_acquire_mutex);

	if (mutex_id > ACPI_MAX_MUTEX) {
		return (AE_BAD_PARAMETER);
	}

	this_thread_id = acpi_os_get_thread_id();

#ifdef ACPI_MUTEX_DEBUG
	{
		u32 i;
		/*
		 * Mutex debug code, for internal debugging only.
		 *
		 * Deadlock prevention. Check if this thread owns any mutexes of value
		 * greater than or equal to this one. If so, the thread has violated
		 * the mutex ordering rule. This indicates a coding error somewhere in
		 * the ACPI subsystem code.
		 */
		for (i = mutex_id; i < ACPI_NUM_MUTEX; i++) {
			if (acpi_gbl_mutex_info[i].thread_id == this_thread_id) {
				if (i == mutex_id) {
					ACPI_ERROR((AE_INFO,
						    "Mutex [%s] already acquired by this thread [%u]",
						    acpi_ut_get_mutex_name
						    (mutex_id),
						    (u32)this_thread_id));

					return (AE_ALREADY_ACQUIRED);
				}

				ACPI_ERROR((AE_INFO,
					    "Invalid acquire order: Thread %u owns [%s], wants [%s]",
					    (u32)this_thread_id,
					    acpi_ut_get_mutex_name(i),
					    acpi_ut_get_mutex_name(mutex_id)));

				return (AE_ACQUIRE_DEADLOCK);
			}
		}
	}
#endif

	ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
			  "Thread %u attempting to acquire Mutex [%s]\n",
			  (u32)this_thread_id,
			  acpi_ut_get_mutex_name(mutex_id)));

	status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex,
				       ACPI_WAIT_FOREVER);
	if (ACPI_SUCCESS(status)) {
		ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
				  "Thread %u acquired Mutex [%s]\n",
				  (u32)this_thread_id,
				  acpi_ut_get_mutex_name(mutex_id)));

		acpi_gbl_mutex_info[mutex_id].use_count++;
		acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id;
	} else {
		ACPI_EXCEPTION((AE_INFO, status,
				"Thread %u could not acquire Mutex [0x%X]",
				(u32)this_thread_id, mutex_id));
	}

	return (status);
}
Example #5
0
acpi_status acpi_db_display_statistics(char *type_arg)
{
	u32 i;
	u32 temp;

	acpi_ut_strupr(type_arg);
	temp = acpi_db_match_argument(type_arg, acpi_db_stat_types);
	if (temp == ACPI_TYPE_NOT_FOUND) {
		acpi_os_printf("Invalid or unsupported argument\n");
		return (AE_OK);
	}

	switch (temp) {
	case CMD_STAT_ALLOCATIONS:

#ifdef ACPI_DBG_TRACK_ALLOCATIONS
		acpi_ut_dump_allocation_info();
#endif
		break;

	case CMD_STAT_TABLES:

		acpi_os_printf("ACPI Table Information (not implemented):\n\n");
		break;

	case CMD_STAT_OBJECTS:

		acpi_db_count_namespace_objects();

		acpi_os_printf
		    ("\nObjects defined in the current namespace:\n\n");

		acpi_os_printf("%16.16s %10.10s %10.10s\n",
			       "ACPI_TYPE", "NODES", "OBJECTS");

		for (i = 0; i < ACPI_TYPE_NS_NODE_MAX; i++) {
			acpi_os_printf("%16.16s % 10ld% 10ld\n",
				       acpi_ut_get_type_name(i),
				       acpi_gbl_node_type_count[i],
				       acpi_gbl_obj_type_count[i]);
		}

		acpi_os_printf("%16.16s % 10ld% 10ld\n", "Misc/Unknown",
			       acpi_gbl_node_type_count_misc,
			       acpi_gbl_obj_type_count_misc);

		acpi_os_printf("%16.16s % 10ld% 10ld\n", "TOTALS:",
			       acpi_gbl_num_nodes, acpi_gbl_num_objects);
		break;

	case CMD_STAT_MEMORY:

#ifdef ACPI_DBG_TRACK_ALLOCATIONS
		acpi_os_printf
		    ("\n----Object Statistics (all in hex)---------\n");

		acpi_db_list_info(acpi_gbl_global_list);
		acpi_db_list_info(acpi_gbl_ns_node_list);
#endif

#ifdef ACPI_USE_LOCAL_CACHE
		acpi_os_printf
		    ("\n----Cache Statistics (all in hex)---------\n");
		acpi_db_list_info(acpi_gbl_operand_cache);
		acpi_db_list_info(acpi_gbl_ps_node_cache);
		acpi_db_list_info(acpi_gbl_ps_node_ext_cache);
		acpi_db_list_info(acpi_gbl_state_cache);
#endif

		break;

	case CMD_STAT_MISC:

		acpi_os_printf("\nMiscellaneous Statistics:\n\n");
		acpi_os_printf("Calls to AcpiPsFind:.. ........% 7ld\n",
			       acpi_gbl_ps_find_count);
		acpi_os_printf("Calls to AcpiNsLookup:..........% 7ld\n",
			       acpi_gbl_ns_lookup_count);

		acpi_os_printf("\n");

		acpi_os_printf("Mutex usage:\n\n");
		for (i = 0; i < ACPI_NUM_MUTEX; i++) {
			acpi_os_printf("%-28s:     % 7ld\n",
				       acpi_ut_get_mutex_name(i),
				       acpi_gbl_mutex_info[i].use_count);
		}
		break;

	case CMD_STAT_SIZES:

		acpi_os_printf("\nInternal object sizes:\n\n");

		acpi_os_printf("Common         %3d\n",
			       sizeof(struct acpi_object_common));
		acpi_os_printf("Number         %3d\n",
			       sizeof(struct acpi_object_integer));
		acpi_os_printf("String         %3d\n",
			       sizeof(struct acpi_object_string));
		acpi_os_printf("Buffer         %3d\n",
			       sizeof(struct acpi_object_buffer));
		acpi_os_printf("Package        %3d\n",
			       sizeof(struct acpi_object_package));
		acpi_os_printf("BufferField    %3d\n",
			       sizeof(struct acpi_object_buffer_field));
		acpi_os_printf("Device         %3d\n",
			       sizeof(struct acpi_object_device));
		acpi_os_printf("Event          %3d\n",
			       sizeof(struct acpi_object_event));
		acpi_os_printf("Method         %3d\n",
			       sizeof(struct acpi_object_method));
		acpi_os_printf("Mutex          %3d\n",
			       sizeof(struct acpi_object_mutex));
		acpi_os_printf("Region         %3d\n",
			       sizeof(struct acpi_object_region));
		acpi_os_printf("PowerResource  %3d\n",
			       sizeof(struct acpi_object_power_resource));
		acpi_os_printf("Processor      %3d\n",
			       sizeof(struct acpi_object_processor));
		acpi_os_printf("ThermalZone    %3d\n",
			       sizeof(struct acpi_object_thermal_zone));
		acpi_os_printf("RegionField    %3d\n",
			       sizeof(struct acpi_object_region_field));
		acpi_os_printf("BankField      %3d\n",
			       sizeof(struct acpi_object_bank_field));
		acpi_os_printf("IndexField     %3d\n",
			       sizeof(struct acpi_object_index_field));
		acpi_os_printf("Reference      %3d\n",
			       sizeof(struct acpi_object_reference));
		acpi_os_printf("Notify         %3d\n",
			       sizeof(struct acpi_object_notify_handler));
		acpi_os_printf("AddressSpace   %3d\n",
			       sizeof(struct acpi_object_addr_handler));
		acpi_os_printf("Extra          %3d\n",
			       sizeof(struct acpi_object_extra));
		acpi_os_printf("Data           %3d\n",
			       sizeof(struct acpi_object_data));

		acpi_os_printf("\n");

		acpi_os_printf("ParseObject    %3d\n",
			       sizeof(struct acpi_parse_obj_common));
		acpi_os_printf("ParseObjectNamed %3d\n",
			       sizeof(struct acpi_parse_obj_named));
		acpi_os_printf("ParseObjectAsl %3d\n",
			       sizeof(struct acpi_parse_obj_asl));
		acpi_os_printf("OperandObject  %3d\n",
			       sizeof(union acpi_operand_object));
		acpi_os_printf("NamespaceNode  %3d\n",
			       sizeof(struct acpi_namespace_node));
		acpi_os_printf("AcpiObject     %3d\n",
			       sizeof(union acpi_object));

		acpi_os_printf("\n");

		acpi_os_printf("Generic State  %3d\n",
			       sizeof(union acpi_generic_state));
		acpi_os_printf("Common State   %3d\n",
			       sizeof(struct acpi_common_state));
		acpi_os_printf("Control State  %3d\n",
			       sizeof(struct acpi_control_state));
		acpi_os_printf("Update State   %3d\n",
			       sizeof(struct acpi_update_state));
		acpi_os_printf("Scope State    %3d\n",
			       sizeof(struct acpi_scope_state));
		acpi_os_printf("Parse Scope    %3d\n",
			       sizeof(struct acpi_pscope_state));
		acpi_os_printf("Package State  %3d\n",
			       sizeof(struct acpi_pkg_state));
		acpi_os_printf("Thread State   %3d\n",
			       sizeof(struct acpi_thread_state));
		acpi_os_printf("Result Values  %3d\n",
			       sizeof(struct acpi_result_values));
		acpi_os_printf("Notify Info    %3d\n",
			       sizeof(struct acpi_notify_info));
		break;

	case CMD_STAT_STACK:
#if defined(ACPI_DEBUG_OUTPUT)

		temp =
		    (u32)ACPI_PTR_DIFF(acpi_gbl_entry_stack_pointer,
				       acpi_gbl_lowest_stack_pointer);

		acpi_os_printf("\nSubsystem Stack Usage:\n\n");
		acpi_os_printf("Entry Stack Pointer        %p\n",
			       acpi_gbl_entry_stack_pointer);
		acpi_os_printf("Lowest Stack Pointer       %p\n",
			       acpi_gbl_lowest_stack_pointer);
		acpi_os_printf("Stack Use                  %X (%u)\n", temp,
			       temp);
		acpi_os_printf("Deepest Procedure Nesting  %u\n",
			       acpi_gbl_deepest_nesting);
#endif
		break;

	default:

		break;
	}

	acpi_os_printf("\n");
	return (AE_OK);
}
Example #6
0
acpi_status
acpi_ut_release_mutex (
	acpi_mutex_handle               mutex_id)
{
	acpi_status                     status;
	u32                             i;
	u32                             this_thread_id;


	ACPI_FUNCTION_NAME ("ut_release_mutex");


	this_thread_id = acpi_os_get_thread_id ();
	ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
		"Thread %X releasing Mutex [%s]\n", this_thread_id,
		acpi_ut_get_mutex_name (mutex_id)));

	if (mutex_id > MAX_MUTEX) {
		return (AE_BAD_PARAMETER);
	}

	/*
	 * Mutex must be acquired in order to release it!
	 */
	if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) {
		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
			"Mutex [%s] is not acquired, cannot release\n",
			acpi_ut_get_mutex_name (mutex_id)));

		return (AE_NOT_ACQUIRED);
	}

	/*
	 * Deadlock prevention.  Check if this thread owns any mutexes of value
	 * greater than this one.  If so, the thread has violated the mutex
	 * ordering rule.  This indicates a coding error somewhere in
	 * the ACPI subsystem code.
	 */
	for (i = mutex_id; i < MAX_MUTEX; i++) {
		if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
			if (i == mutex_id) {
				continue;
			}

			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
				"Invalid release order: owns [%s], releasing [%s]\n",
				acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id)));

			return (AE_RELEASE_DEADLOCK);
		}
	}

	/* Mark unlocked FIRST */

	acpi_gbl_mutex_info[mutex_id].owner_id = ACPI_MUTEX_NOT_ACQUIRED;

	status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1);

	if (ACPI_FAILURE (status)) {
		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
			"Thread %X could not release Mutex [%s] %s\n",
			this_thread_id, acpi_ut_get_mutex_name (mutex_id),
			acpi_format_exception (status)));
	}
	else {
		ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n",
			this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
	}

	return (status);
}
Example #7
0
acpi_status
acpi_db_display_statistics (
	NATIVE_CHAR             *type_arg)
{
	u32                     i;
	u32                     type;
	u32                     outstanding;
	u32                     size;


	if (!acpi_gbl_DSDT)
	{
		acpi_os_printf ("*** Warning: There is no DSDT loaded\n");
	}

	if (!type_arg)
	{
		acpi_os_printf ("The following subcommands are available:\n  ALLOCATIONS, OBJECTS, MEMORY, MISC, SIZES, TABLES\n");
		return (AE_OK);
	}

	STRUPR (type_arg);
	type = acpi_db_match_argument (type_arg, acpi_db_stat_types);
	if (type == (u32) -1)
	{
		acpi_os_printf ("Invalid or unsupported argument\n");
		return (AE_OK);
	}


	switch (type)
	{
#ifndef PARSER_ONLY
	case CMD_ALLOCATIONS:
#ifdef ACPI_DBG_TRACK_ALLOCATIONS
		acpi_ut_dump_allocation_info ();
#endif
		break;
#endif

	case CMD_TABLES:

		acpi_os_printf ("ACPI Table Information:\n\n");
		if (acpi_gbl_DSDT)
		{
			acpi_os_printf ("DSDT Length:................% 7ld (%X)\n", acpi_gbl_DSDT->length, acpi_gbl_DSDT->length);
		}
		break;

	case CMD_OBJECTS:

#ifndef PARSER_ONLY

		acpi_db_count_namespace_objects ();

		acpi_os_printf ("\n_objects defined in the current namespace:\n\n");

		acpi_os_printf ("%16.16s % 10.10s % 10.10s\n", "ACPI_TYPE", "NODES", "OBJECTS");

		for (i = 0; i < INTERNAL_TYPE_NODE_MAX; i++)
		{
			acpi_os_printf ("%16.16s % 10ld% 10ld\n", acpi_ut_get_type_name (i),
				acpi_gbl_node_type_count [i], acpi_gbl_obj_type_count [i]);
		}
		acpi_os_printf ("%16.16s % 10ld% 10ld\n", "Misc/Unknown",
			acpi_gbl_node_type_count_misc, acpi_gbl_obj_type_count_misc);

		acpi_os_printf ("%16.16s % 10ld% 10ld\n", "TOTALS:",
			acpi_gbl_num_nodes, acpi_gbl_num_objects);

#endif
		break;

	case CMD_MEMORY:

#ifdef ACPI_DBG_TRACK_ALLOCATIONS
		acpi_os_printf ("\n----Object and Cache Statistics---------------------------------------------\n");

		for (i = 0; i < ACPI_NUM_MEM_LISTS; i++)
		{
			acpi_os_printf ("\n%s\n", acpi_gbl_memory_lists[i].list_name);

			if (acpi_gbl_memory_lists[i].max_cache_depth > 0)
			{
				acpi_os_printf ("  Cache: [Depth Max Avail Size]         % 7d % 7d % 7d % 7d B\n",
						acpi_gbl_memory_lists[i].cache_depth,
						acpi_gbl_memory_lists[i].max_cache_depth,
						acpi_gbl_memory_lists[i].max_cache_depth - acpi_gbl_memory_lists[i].cache_depth,
						(acpi_gbl_memory_lists[i].cache_depth * acpi_gbl_memory_lists[i].object_size));

				acpi_os_printf ("  Cache: [Requests Hits Misses Obj_size] % 7d % 7d % 7d % 7d B\n",
						acpi_gbl_memory_lists[i].cache_requests,
						acpi_gbl_memory_lists[i].cache_hits,
						acpi_gbl_memory_lists[i].cache_requests - acpi_gbl_memory_lists[i].cache_hits,
						acpi_gbl_memory_lists[i].object_size);
			}

			outstanding = acpi_gbl_memory_lists[i].total_allocated -
					  acpi_gbl_memory_lists[i].total_freed -
					  acpi_gbl_memory_lists[i].cache_depth;

			if (acpi_gbl_memory_lists[i].object_size)
			{
				size = ROUND_UP_TO_1K (outstanding * acpi_gbl_memory_lists[i].object_size);
			}
			else
			{
				size = ROUND_UP_TO_1K (acpi_gbl_memory_lists[i].current_total_size);
			}

			acpi_os_printf ("  Mem:   [Alloc Free Outstanding Size]  % 7d % 7d % 7d % 7d Kb\n",
					acpi_gbl_memory_lists[i].total_allocated,
					acpi_gbl_memory_lists[i].total_freed,
					outstanding, size);
		}
#endif

		break;

	case CMD_MISC:

		acpi_os_printf ("\n_miscellaneous Statistics:\n\n");
		acpi_os_printf ("Calls to Acpi_ps_find:.. ........% 7ld\n", acpi_gbl_ps_find_count);
		acpi_os_printf ("Calls to Acpi_ns_lookup:..........% 7ld\n", acpi_gbl_ns_lookup_count);

		acpi_os_printf ("\n");

		acpi_os_printf ("Mutex usage:\n\n");
		for (i = 0; i < NUM_MTX; i++)
		{
			acpi_os_printf ("%-28s:     % 7ld\n", acpi_ut_get_mutex_name (i), acpi_gbl_acpi_mutex_info[i].use_count);
		}
		break;


	case CMD_SIZES:

		acpi_os_printf ("\n_internal object sizes:\n\n");

		acpi_os_printf ("Common         %3d\n", sizeof (ACPI_OBJECT_COMMON));
		acpi_os_printf ("Number         %3d\n", sizeof (ACPI_OBJECT_INTEGER));
		acpi_os_printf ("String         %3d\n", sizeof (ACPI_OBJECT_STRING));
		acpi_os_printf ("Buffer         %3d\n", sizeof (ACPI_OBJECT_BUFFER));
		acpi_os_printf ("Package        %3d\n", sizeof (ACPI_OBJECT_PACKAGE));
		acpi_os_printf ("Buffer_field   %3d\n", sizeof (ACPI_OBJECT_BUFFER_FIELD));
		acpi_os_printf ("Device         %3d\n", sizeof (ACPI_OBJECT_DEVICE));
		acpi_os_printf ("Event          %3d\n", sizeof (ACPI_OBJECT_EVENT));
		acpi_os_printf ("Method         %3d\n", sizeof (ACPI_OBJECT_METHOD));
		acpi_os_printf ("Mutex          %3d\n", sizeof (ACPI_OBJECT_MUTEX));
		acpi_os_printf ("Region         %3d\n", sizeof (ACPI_OBJECT_REGION));
		acpi_os_printf ("Power_resource %3d\n", sizeof (ACPI_OBJECT_POWER_RESOURCE));
		acpi_os_printf ("Processor      %3d\n", sizeof (ACPI_OBJECT_PROCESSOR));
		acpi_os_printf ("Thermal_zone   %3d\n", sizeof (ACPI_OBJECT_THERMAL_ZONE));
		acpi_os_printf ("Region_field   %3d\n", sizeof (ACPI_OBJECT_REGION_FIELD));
		acpi_os_printf ("Bank_field     %3d\n", sizeof (ACPI_OBJECT_BANK_FIELD));
		acpi_os_printf ("Index_field    %3d\n", sizeof (ACPI_OBJECT_INDEX_FIELD));
		acpi_os_printf ("Reference      %3d\n", sizeof (ACPI_OBJECT_REFERENCE));
		acpi_os_printf ("Notify_handler %3d\n", sizeof (ACPI_OBJECT_NOTIFY_HANDLER));
		acpi_os_printf ("Addr_handler   %3d\n", sizeof (ACPI_OBJECT_ADDR_HANDLER));
		acpi_os_printf ("Extra          %3d\n", sizeof (ACPI_OBJECT_EXTRA));

		acpi_os_printf ("\n");

		acpi_os_printf ("Parse_object   %3d\n", sizeof (acpi_parse_object));
		acpi_os_printf ("Parse2_object  %3d\n", sizeof (acpi_parse2_object));
		acpi_os_printf ("Operand_object %3d\n", sizeof (acpi_operand_object));
		acpi_os_printf ("Namespace_node %3d\n", sizeof (acpi_namespace_node));

		break;


	case CMD_STACK:

		size = acpi_gbl_entry_stack_pointer - acpi_gbl_lowest_stack_pointer;

		acpi_os_printf ("\n_subsystem Stack Usage:\n\n");
		acpi_os_printf ("Entry Stack Pointer        %X\n", acpi_gbl_entry_stack_pointer);
		acpi_os_printf ("Lowest Stack Pointer       %X\n", acpi_gbl_lowest_stack_pointer);
		acpi_os_printf ("Stack Use                  %X (%d)\n", size, size);
		acpi_os_printf ("Deepest Procedure Nesting  %d\n", acpi_gbl_deepest_nesting);
		break;
	}

	acpi_os_printf ("\n");
	return (AE_OK);
}
Example #8
0
acpi_status
acpi_ut_acquire_mutex (
	ACPI_MUTEX_HANDLE       mutex_id)
{
	acpi_status             status;
	u32                     i;
	u32                     this_thread_id;


	PROC_NAME ("Ut_acquire_mutex");


	if (mutex_id > MAX_MTX) {
		return (AE_BAD_PARAMETER);
	}


	this_thread_id = acpi_os_get_thread_id ();

	/*
	 * Deadlock prevention.  Check if this thread owns any mutexes of value
	 * greater than or equal to this one.  If so, the thread has violated
	 * the mutex ordering rule.  This indicates a coding error somewhere in
	 * the ACPI subsystem code.
	 */
	for (i = mutex_id; i < MAX_MTX; i++) {
		if (acpi_gbl_acpi_mutex_info[i].owner_id == this_thread_id) {
			if (i == mutex_id) {
				ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
						"Mutex [%s] already acquired by this thread [%X]\n",
						acpi_ut_get_mutex_name (mutex_id), this_thread_id));

				return (AE_ALREADY_ACQUIRED);
			}

			ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
					"Invalid acquire order: Thread %X owns [%s], wants [%s]\n",
					this_thread_id, acpi_ut_get_mutex_name (i),
					acpi_ut_get_mutex_name (mutex_id)));

			return (AE_ACQUIRE_DEADLOCK);
		}
	}


	ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
			 "Thread %X attempting to acquire Mutex [%s]\n",
			 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));

	status = acpi_os_wait_semaphore (acpi_gbl_acpi_mutex_info[mutex_id].mutex,
			   1, WAIT_FOREVER);

	if (ACPI_SUCCESS (status)) {
		ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n",
				 this_thread_id, acpi_ut_get_mutex_name (mutex_id)));

		acpi_gbl_acpi_mutex_info[mutex_id].use_count++;
		acpi_gbl_acpi_mutex_info[mutex_id].owner_id = this_thread_id;
	}

	else {
		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not acquire Mutex [%s] %s\n",
				 this_thread_id, acpi_ut_get_mutex_name (mutex_id),
				 acpi_format_exception (status)));
	}

	return (status);
}