Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Module Name: utdelete - object deletion and reference count utilities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include "acinterp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "acevents.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #define _COMPONENT          ACPI_UTILITIES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) ACPI_MODULE_NAME("utdelete")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) static void acpi_ut_delete_internal_obj(union acpi_operand_object *object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * FUNCTION:    acpi_ut_delete_internal_obj
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * PARAMETERS:  object         - Object to be deleted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * DESCRIPTION: Low level object deletion, after reference counts have been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *              updated (All reference counts, including sub-objects!)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	void *obj_pointer = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	union acpi_operand_object *handler_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	union acpi_operand_object *second_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	union acpi_operand_object *next_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	union acpi_operand_object *start_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	union acpi_operand_object **last_obj_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	ACPI_FUNCTION_TRACE_PTR(ut_delete_internal_obj, object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	if (!object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	 * Must delete or free any pointers within the object that are not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	 * actual ACPI objects (for example, a raw buffer pointer).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	switch (object->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 				  "**** String %p, ptr %p\n", object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 				  object->string.pointer));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		/* Free the actual string buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		if (!(object->common.flags & AOPOBJ_STATIC_POINTER)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 			/* But only if it is NOT a pointer into an ACPI table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 			obj_pointer = object->string.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 				  "**** Buffer %p, ptr %p\n", object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 				  object->buffer.pointer));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		/* Free the actual buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		if (!(object->common.flags & AOPOBJ_STATIC_POINTER)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			/* But only if it is NOT a pointer into an ACPI table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			obj_pointer = object->buffer.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	case ACPI_TYPE_PACKAGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 				  " **** Package of count %X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 				  object->package.count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		 * Elements of the package are not handled here, they are deleted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		 * separately
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		/* Free the (variable length) element pointer array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		obj_pointer = object->package.elements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		 * These objects have a possible list of notify handlers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		 * Device object also may have a GPE block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	case ACPI_TYPE_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		if (object->device.gpe_block) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			(void)acpi_ev_delete_gpe_block(object->device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 						       gpe_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		/*lint -fallthrough */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	case ACPI_TYPE_PROCESSOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	case ACPI_TYPE_THERMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		/* Walk the address handler list for this object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		handler_desc = object->common_notify.handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		while (handler_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 			next_desc = handler_desc->address_space.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 			acpi_ut_remove_reference(handler_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 			handler_desc = next_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	case ACPI_TYPE_MUTEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 				  "***** Mutex %p, OS Mutex %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 				  object, object->mutex.os_mutex));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		if (object == acpi_gbl_global_lock_mutex) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			/* Global Lock has extra semaphore */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 			(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 			    acpi_os_delete_semaphore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 			    (acpi_gbl_global_lock_semaphore);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			acpi_gbl_global_lock_semaphore = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 			acpi_os_delete_mutex(object->mutex.os_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 			acpi_gbl_global_lock_mutex = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 			acpi_ex_unlink_mutex(object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 			acpi_os_delete_mutex(object->mutex.os_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	case ACPI_TYPE_EVENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 				  "***** Event %p, OS Semaphore %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 				  object, object->event.os_semaphore));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		(void)acpi_os_delete_semaphore(object->event.os_semaphore);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		object->event.os_semaphore = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	case ACPI_TYPE_METHOD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 				  "***** Method %p\n", object));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		/* Delete the method mutex if it exists */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		if (object->method.mutex) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 			acpi_os_delete_mutex(object->method.mutex->mutex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 					     os_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 			acpi_ut_delete_object_desc(object->method.mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 			object->method.mutex = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		if (object->method.node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			object->method.node = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	case ACPI_TYPE_REGION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 				  "***** Region %p\n", object));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		 * Update address_range list. However, only permanent regions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		 * are installed in this list. (Not created within a method)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		if (!(object->region.node->flags & ANOBJ_TEMPORARY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 			acpi_ut_remove_address_range(object->region.space_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 						     object->region.node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		second_desc = acpi_ns_get_secondary_object(object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		if (second_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 			 * Free the region_context if and only if the handler is one of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 			 * default handlers -- and therefore, we created the context object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 			 * locally, it was not created by an external caller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 			handler_desc = object->region.handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 			if (handler_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 				next_desc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 				    handler_desc->address_space.region_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 				start_desc = next_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 				last_obj_ptr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 				    &handler_desc->address_space.region_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 				/* Remove the region object from the handler list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 				while (next_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 					if (next_desc == object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 						*last_obj_ptr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 						    next_desc->region.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 						break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 					}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 					/* Walk the linked list of handlers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 					last_obj_ptr = &next_desc->region.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 					next_desc = next_desc->region.next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 					/* Prevent infinite loop if list is corrupted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 					if (next_desc == start_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 						ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 							    "Circular region list in address handler object %p",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 							    handler_desc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 						return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 					}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 				if (handler_desc->address_space.handler_flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 				    ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 					/* Deactivate region and free region context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 					if (handler_desc->address_space.setup) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 						(void)handler_desc->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 						    address_space.setup(object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 									ACPI_REGION_DEACTIVATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 									handler_desc->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 									address_space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 									context,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 									&second_desc->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 									extra.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 									region_context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 					}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 				acpi_ut_remove_reference(handler_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 			/* Now we can free the Extra object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 			acpi_ut_delete_object_desc(second_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		if (object->field.internal_pcc_buffer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 			ACPI_FREE(object->field.internal_pcc_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	case ACPI_TYPE_BUFFER_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 				  "***** Buffer Field %p\n", object));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		second_desc = acpi_ns_get_secondary_object(object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		if (second_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 			acpi_ut_delete_object_desc(second_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	case ACPI_TYPE_LOCAL_BANK_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 				  "***** Bank Field %p\n", object));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		second_desc = acpi_ns_get_secondary_object(object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		if (second_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 			acpi_ut_delete_object_desc(second_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	case ACPI_TYPE_LOCAL_ADDRESS_HANDLER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 				  "***** Address handler %p\n", object));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 		acpi_os_delete_mutex(object->address_space.context_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	/* Free any allocated memory (pointer within the object) found above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	if (obj_pointer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 				  "Deleting Object Subptr %p\n", obj_pointer));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		ACPI_FREE(obj_pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	/* Now the object can be safely deleted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	ACPI_DEBUG_PRINT_RAW((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 			      "%s: Deleting Object %p [%s]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 			      ACPI_GET_FUNCTION_NAME, object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 			      acpi_ut_get_object_type_name(object)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	acpi_ut_delete_object_desc(object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	return_VOID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)  * FUNCTION:    acpi_ut_delete_internal_object_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)  * PARAMETERS:  obj_list        - Pointer to the list to be deleted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)  * DESCRIPTION: This function deletes an internal object list, including both
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)  *              simple objects and package objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	union acpi_operand_object **internal_obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	ACPI_FUNCTION_ENTRY();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	/* Walk the null-terminated internal list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	for (internal_obj = obj_list; *internal_obj; internal_obj++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 		acpi_ut_remove_reference(*internal_obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	/* Free the combined parameter pointer list and object array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	ACPI_FREE(obj_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)  * FUNCTION:    acpi_ut_update_ref_count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)  * PARAMETERS:  object          - Object whose ref count is to be updated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)  *              action          - What to do (REF_INCREMENT or REF_DECREMENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)  * RETURN:      None. Sets new reference count within the object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)  * DESCRIPTION: Modify the reference count for an internal acpi object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	u16 original_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	u16 new_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	acpi_cpu_flags lock_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	char *message;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	ACPI_FUNCTION_NAME(ut_update_ref_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	if (!object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	 * Always get the reference count lock. Note: Interpreter and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	 * Namespace is not always locked when this function is called.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	lock_flags = acpi_os_acquire_lock(acpi_gbl_reference_count_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	original_count = object->common.reference_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	/* Perform the reference count action (increment, decrement) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	switch (action) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	case REF_INCREMENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 		new_count = original_count + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 		object->common.reference_count = new_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 		acpi_os_release_lock(acpi_gbl_reference_count_lock, lock_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		/* The current reference count should never be zero here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 		if (!original_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 			ACPI_WARNING((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 				      "Obj %p, Reference Count was zero before increment\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 				      object));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 		ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 				  "Obj %p Type %.2X [%s] Refs %.2X [Incremented]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 				  object, object->common.type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 				  acpi_ut_get_object_type_name(object),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 				  new_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 		message = "Incremement";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	case REF_DECREMENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 		/* The current reference count must be non-zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		if (original_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 			new_count = original_count - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 			object->common.reference_count = new_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 		acpi_os_release_lock(acpi_gbl_reference_count_lock, lock_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 		if (!original_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 			ACPI_WARNING((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 				      "Obj %p, Reference Count is already zero, cannot decrement\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 				      object));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 		ACPI_DEBUG_PRINT_RAW((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 				      "%s: Obj %p Type %.2X Refs %.2X [Decremented]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 				      ACPI_GET_FUNCTION_NAME, object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 				      object->common.type, new_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 		/* Actually delete the object on a reference count of zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 		if (new_count == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 			acpi_ut_delete_internal_obj(object);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 		message = "Decrement";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 		acpi_os_release_lock(acpi_gbl_reference_count_lock, lock_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 		ACPI_ERROR((AE_INFO, "Unknown Reference Count action (0x%X)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 			    action));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	 * Sanity check the reference count, for debug purposes only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	 * (A deleted object will have a huge reference count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	if (new_count > ACPI_MAX_REFERENCE_COUNT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 		ACPI_WARNING((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 			      "Large Reference Count (0x%X) in object %p, Type=0x%.2X Operation=%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 			      new_count, object, object->common.type, message));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)  * FUNCTION:    acpi_ut_update_object_reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)  * PARAMETERS:  object              - Increment or decrement the ref count for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)  *                                    this object and all sub-objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)  *              action              - Either REF_INCREMENT or REF_DECREMENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)  * DESCRIPTION: Increment or decrement the object reference count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)  * Object references are incremented when:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)  * 1) An object is attached to a Node (namespace object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)  * 2) An object is copied (all subobjects must be incremented)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)  * Object references are decremented when:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)  * 1) An object is detached from an Node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	union acpi_generic_state *state_list = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	union acpi_operand_object *next_object = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	union acpi_operand_object *prev_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	union acpi_generic_state *state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	ACPI_FUNCTION_NAME(ut_update_object_reference);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	while (object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 		/* Make sure that this isn't a namespace handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 		if (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 			ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 					  "Object %p is NS handle\n", object));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 			return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 		 * All sub-objects must have their reference count updated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 		 * also. Different object types have different subobjects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 		switch (object->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 		case ACPI_TYPE_DEVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 		case ACPI_TYPE_PROCESSOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 		case ACPI_TYPE_POWER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 		case ACPI_TYPE_THERMAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 			 * Update the notify objects for these types (if present)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 			 * Two lists, system and device notify handlers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 			for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 				prev_object =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 				    object->common_notify.notify_list[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 				while (prev_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 					next_object =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 					    prev_object->notify.next[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 					acpi_ut_update_ref_count(prev_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 								 action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 					prev_object = next_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 		case ACPI_TYPE_PACKAGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 			 * We must update all the sub-objects of the package,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 			 * each of whom may have their own sub-objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 			for (i = 0; i < object->package.count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 				/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 				 * Null package elements are legal and can be simply
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 				 * ignored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 				next_object = object->package.elements[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 				if (!next_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 					continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 				switch (next_object->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 				case ACPI_TYPE_INTEGER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 				case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 				case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 					/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 					 * For these very simple sub-objects, we can just
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 					 * update the reference count here and continue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 					 * Greatly increases performance of this operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 					 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 					acpi_ut_update_ref_count(next_object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 								 action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 					break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 				default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 					/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 					 * For complex sub-objects, push them onto the stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 					 * for later processing (this eliminates recursion.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 					 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 					status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 					    acpi_ut_create_update_state_and_push
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 					    (next_object, action, &state_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 					if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 						goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 					}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 					break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 			next_object = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 		case ACPI_TYPE_BUFFER_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 			next_object = object->buffer_field.buffer_obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 		case ACPI_TYPE_LOCAL_BANK_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 			next_object = object->bank_field.bank_obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 			    acpi_ut_create_update_state_and_push(object->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 								 bank_field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 								 region_obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 								 action,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 								 &state_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 				goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 		case ACPI_TYPE_LOCAL_INDEX_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 			next_object = object->index_field.index_obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 			status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 			    acpi_ut_create_update_state_and_push(object->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 								 index_field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 								 data_obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 								 action,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 								 &state_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 			if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 				goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 		case ACPI_TYPE_LOCAL_REFERENCE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 			 * The target of an Index (a package, string, or buffer) or a named
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 			 * reference must track changes to the ref count of the index or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 			 * target object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 			if ((object->reference.class == ACPI_REFCLASS_INDEX) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 			    (object->reference.class == ACPI_REFCLASS_NAME)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 				next_object = object->reference.object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 		case ACPI_TYPE_LOCAL_REGION_FIELD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 		case ACPI_TYPE_REGION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 			break;	/* No subobjects for all other types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 		 * Now we can update the count in the main object. This can only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 		 * happen after we update the sub-objects in case this causes the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 		 * main object to be deleted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 		acpi_ut_update_ref_count(object, action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 		object = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 		/* Move on to the next object to be updated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 		if (next_object) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 			object = next_object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 			next_object = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 		} else if (state_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 			state = acpi_ut_pop_generic_state(&state_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 			object = state->update.object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 			acpi_ut_delete_generic_state(state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 	return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) error_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 	ACPI_EXCEPTION((AE_INFO, status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 			"Could not update object reference count"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 	/* Free any stacked Update State objects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 	while (state_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 		state = acpi_ut_pop_generic_state(&state_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 		acpi_ut_delete_generic_state(state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 	return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666)  * FUNCTION:    acpi_ut_add_reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668)  * PARAMETERS:  object          - Object whose reference count is to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)  *                                incremented
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673)  * DESCRIPTION: Add one reference to an ACPI object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) void acpi_ut_add_reference(union acpi_operand_object *object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 	ACPI_FUNCTION_NAME(ut_add_reference);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 	/* Ensure that we have a valid object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 	if (!acpi_ut_valid_internal_object(object)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 	ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 			  "Obj %p Current Refs=%X [To Be Incremented]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) 			  object, object->common.reference_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 	/* Increment the reference count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 	(void)acpi_ut_update_object_reference(object, REF_INCREMENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700)  * FUNCTION:    acpi_ut_remove_reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702)  * PARAMETERS:  object         - Object whose ref count will be decremented
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706)  * DESCRIPTION: Decrement the reference count of an ACPI internal object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) void acpi_ut_remove_reference(union acpi_operand_object *object)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) 	ACPI_FUNCTION_NAME(ut_remove_reference);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 	 * Allow a NULL pointer to be passed in, just ignore it. This saves
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 	 * each caller from having to check. Also, ignore NS nodes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 	if (!object ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 	    (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) 	/* Ensure that we have a valid object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) 	if (!acpi_ut_valid_internal_object(object)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) 	ACPI_DEBUG_PRINT_RAW((ACPI_DB_ALLOCATIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) 			      "%s: Obj %p Current Refs=%X [To Be Decremented]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) 			      ACPI_GET_FUNCTION_NAME, object,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) 			      object->common.reference_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) 	 * Decrement the reference count, and only actually delete the object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) 	 * if the reference count becomes 0. (Must also decrement the ref count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) 	 * of all subobjects!)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) 	(void)acpi_ut_update_object_reference(object, REF_DECREMENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) }