Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 22b5afce authored by Bob Moore's avatar Bob Moore Committed by Rafael J. Wysocki
Browse files

ACPICA: Add auto-serialization support for ill-behaved control methods.

This change adds support to automatically mark a control method as
"serialized" if the method creates any named objects. This will
positively prevent the method from being entered by more than one
thread and thus preventing a possible abort when an attempt is
made to create an object twice.

Implemented by parsing all non-serialize control methods at table
load time.

This feature is disabled by default and this patch also adds a new
Linux kernel parameter "acpi_auto_serialize" to allow this feature
to be turned on for a specific boot.

References: https://bugzilla.kernel.org/show_bug.cgi?id=52191


Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent e2b8ddcc
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -229,6 +229,14 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
			use by PCI
			use by PCI
			Format: <irq>,<irq>...
			Format: <irq>,<irq>...


	acpi_auto_serialize	[HW,ACPI]
			Enable auto-serialization of AML methods
			AML control methods that contain the opcodes to create
			named objects will be marked as "Serialized" by the
			auto-serialization feature.
			This feature is disabled by default.
			This option allows to turn on the feature.

	acpi_no_auto_ssdt	[HW,ACPI] Disable automatic loading of SSDT
	acpi_no_auto_ssdt	[HW,ACPI] Disable automatic loading of SSDT


	acpica_no_return_repair [HW, ACPI]
	acpica_no_return_repair [HW, ACPI]
+8 −5
Original line number Original line Diff line number Diff line
@@ -139,20 +139,21 @@ acpi_ds_init_field_objects(union acpi_parse_object *op,
			   struct acpi_walk_state *walk_state);
			   struct acpi_walk_state *walk_state);


/*
/*
 * dsload - Parser/Interpreter interface, pass 1 namespace load callbacks
 * dsload - Parser/Interpreter interface
 */
 */
acpi_status
acpi_status
acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number);
acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number);


/* dsload - pass 1 namespace load callbacks */

acpi_status
acpi_status
acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state,
acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state,
		       union acpi_parse_object **out_op);
		       union acpi_parse_object **out_op);


acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state);
acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state);


/*
/* dsload - pass 2 namespace load callbacks */
 * dsload - Parser/Interpreter interface, pass 2 namespace load callbacks

 */
acpi_status
acpi_status
acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
		       union acpi_parse_object **out_op);
		       union acpi_parse_object **out_op);
@@ -200,7 +201,9 @@ void acpi_ds_method_data_init(struct acpi_walk_state *walk_state);
/*
/*
 * dsmethod - Parser/Interpreter interface - control method parsing
 * dsmethod - Parser/Interpreter interface - control method parsing
 */
 */
acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node);
acpi_status
acpi_ds_auto_serialize_method(struct acpi_namespace_node *node,
			      union acpi_operand_object *obj_desc);


acpi_status
acpi_status
acpi_ds_call_control_method(struct acpi_thread_state *thread,
acpi_ds_call_control_method(struct acpi_thread_state *thread,
+9 −0
Original line number Original line Diff line number Diff line
@@ -92,6 +92,15 @@
 */
 */
ACPI_INIT_GLOBAL(u8, acpi_gbl_enable_interpreter_slack, FALSE);
ACPI_INIT_GLOBAL(u8, acpi_gbl_enable_interpreter_slack, FALSE);


/*
 * Automatically serialize all methods that create named objects? Default
 * is TRUE, meaning that all non_serialized methods are scanned once at
 * table load time to determine those that create named objects. Methods
 * that create named objects are marked Serialized in order to prevent
 * possible run-time problems if they are entered by more than one thread.
 */
ACPI_INIT_GLOBAL(u8, acpi_gbl_auto_serialize_methods, FALSE);

/*
/*
 * Create the predefined _OSI method in the namespace? Default is TRUE
 * Create the predefined _OSI method in the namespace? Default is TRUE
 * because ACPI CA is fully compatible with other ACPI implementations.
 * because ACPI CA is fully compatible with other ACPI implementations.
+3 −0
Original line number Original line Diff line number Diff line
@@ -133,6 +133,9 @@ struct acpi_init_walk_info {
	u32 table_index;
	u32 table_index;
	u32 object_count;
	u32 object_count;
	u32 method_count;
	u32 method_count;
	u32 serial_method_count;
	u32 non_serial_method_count;
	u32 serialized_method_count;
	u32 device_count;
	u32 device_count;
	u32 op_region_count;
	u32 op_region_count;
	u32 field_count;
	u32 field_count;
+47 −12
Original line number Original line Diff line number Diff line
@@ -83,8 +83,8 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
	    (struct acpi_init_walk_info *)context;
	    (struct acpi_init_walk_info *)context;
	struct acpi_namespace_node *node =
	struct acpi_namespace_node *node =
	    (struct acpi_namespace_node *)obj_handle;
	    (struct acpi_namespace_node *)obj_handle;
	acpi_object_type type;
	acpi_status status;
	acpi_status status;
	union acpi_operand_object *obj_desc;


	ACPI_FUNCTION_ENTRY();
	ACPI_FUNCTION_ENTRY();


@@ -100,9 +100,7 @@ acpi_ds_init_one_object(acpi_handle obj_handle,


	/* And even then, we are only interested in a few object types */
	/* And even then, we are only interested in a few object types */


	type = acpi_ns_get_type(obj_handle);
	switch (acpi_ns_get_type(obj_handle)) {

	switch (type) {
	case ACPI_TYPE_REGION:
	case ACPI_TYPE_REGION:


		status = acpi_ds_initialize_region(obj_handle);
		status = acpi_ds_initialize_region(obj_handle);
@@ -117,8 +115,44 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
		break;
		break;


	case ACPI_TYPE_METHOD:
	case ACPI_TYPE_METHOD:

		/*
		 * Auto-serialization support. We will examine each method that is
		 * not_serialized to determine if it creates any Named objects. If
		 * it does, it will be marked serialized to prevent problems if
		 * the method is entered by two or more threads and an attempt is
		 * made to create the same named object twice -- which results in
		 * an AE_ALREADY_EXISTS exception and method abort.
		 */
		info->method_count++;
		info->method_count++;
		obj_desc = acpi_ns_get_attached_object(node);
		if (!obj_desc) {
			break;
		}

		/* Ignore if already serialized */

		if (obj_desc->method.info_flags & ACPI_METHOD_SERIALIZED) {
			info->serial_method_count++;
			break;
		}

		if (acpi_gbl_auto_serialize_methods) {

			/* Parse/scan method and serialize it if necessary */

			acpi_ds_auto_serialize_method(node, obj_desc);
			if (obj_desc->method.
			    info_flags & ACPI_METHOD_SERIALIZED) {

				/* Method was just converted to Serialized */

				info->serial_method_count++;
				info->serialized_method_count++;
				break;
			}
		}

		info->non_serial_method_count++;
		break;
		break;


	case ACPI_TYPE_DEVICE:
	case ACPI_TYPE_DEVICE:
@@ -170,7 +204,6 @@ acpi_ds_initialize_objects(u32 table_index,


	ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
	ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
			  "**** Starting initialization of namespace objects ****\n"));
			  "**** Starting initialization of namespace objects ****\n"));
	ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "Parsing all Control Methods:"));


	/* Set all init info to zero */
	/* Set all init info to zero */


@@ -205,14 +238,16 @@ acpi_ds_initialize_objects(u32 table_index,
	}
	}


	ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
	ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
			      "\nTable [%4.4s](id %4.4X) - %u Objects with %u Devices %u Methods %u Regions\n",
			      "Table [%4.4s] (id %4.4X) - %4u Objects with %3u Devices, "
			      "%3u Regions, %3u Methods (%u/%u/%u Serial/Non/Cvt)\n",
			      table->signature, owner_id, info.object_count,
			      table->signature, owner_id, info.object_count,
			      info.device_count, info.method_count,
			      info.device_count, info.op_region_count,
			      info.op_region_count));
			      info.method_count, info.serial_method_count,
			      info.non_serial_method_count,
			      info.serialized_method_count));


	ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
	ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "%u Methods, %u Regions\n",
			  "%u Methods, %u Regions\n", info.method_count,
			  info.method_count, info.op_region_count));
			  info.op_region_count));


	return_ACPI_STATUS(AE_OK);
	return_ACPI_STATUS(AE_OK);
}
}
Loading