Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPICA: Make acpi_thread_id no longer configurable, always u64

Change definition of acpi_thread_id to always be a u64. This
simplifies the code, especially any printf output. u64 is
the only common data type for all thread_id types across all
operating systems. We now force the OSL to cast the native
thread_id type to u64 before returning the value to ACPICA
(via acpi_os_get_thread_id).

Signed-off-by: Lin Ming <ming.m.lin@intel.com
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>

authored by

Lin Ming and committed by
Len Brown
28eb3fcf 8f40f171

+41 -37
+1 -1
drivers/acpi/acpica/achware.h
··· 121 121 struct acpi_gpe_block_info *gpe_block, 122 122 void *context); 123 123 124 - #ifdef ACPI_FUTURE_USAGE 125 124 /* 126 125 * hwpci - PCI configuration support 127 126 */ ··· 128 129 acpi_hw_derive_pci_id(struct acpi_pci_id *pci_id, 129 130 acpi_handle root_pci_device, acpi_handle pci_region); 130 131 132 + #ifdef ACPI_FUTURE_USAGE 131 133 /* 132 134 * hwtimer - ACPI Timer prototypes 133 135 */
+1 -1
drivers/acpi/acpica/aclocal.h
··· 1001 1001 struct acpi_db_method_info { 1002 1002 acpi_handle main_thread_gate; 1003 1003 acpi_handle thread_complete_gate; 1004 - u32 *threads; 1004 + acpi_thread_id *threads; 1005 1005 u32 num_threads; 1006 1006 u32 num_created; 1007 1007 u32 num_completed;
+1 -1
drivers/acpi/acpica/dsmethod.c
··· 573 573 574 574 acpi_os_release_mutex(method_desc->method. 575 575 mutex->mutex.os_mutex); 576 - method_desc->method.mutex->mutex.thread_id = NULL; 576 + method_desc->method.mutex->mutex.thread_id = 0; 577 577 } 578 578 } 579 579
+1 -1
drivers/acpi/acpica/evmisc.c
··· 553 553 acpi_gbl_global_lock_acquired = FALSE; 554 554 555 555 /* Release the local GL mutex */ 556 - acpi_ev_global_lock_thread_id = NULL; 556 + acpi_ev_global_lock_thread_id = 0; 557 557 acpi_ev_global_lock_acquired = 0; 558 558 acpi_os_release_mutex(acpi_gbl_global_lock_mutex->mutex.os_mutex); 559 559 return_ACPI_STATUS(status);
+5 -5
drivers/acpi/acpica/exmutex.c
··· 336 336 337 337 /* Clear mutex info */ 338 338 339 - obj_desc->mutex.thread_id = NULL; 339 + obj_desc->mutex.thread_id = 0; 340 340 return_ACPI_STATUS(status); 341 341 } 342 342 ··· 393 393 if ((owner_thread->thread_id != walk_state->thread->thread_id) && 394 394 (obj_desc != acpi_gbl_global_lock_mutex)) { 395 395 ACPI_ERROR((AE_INFO, 396 - "Thread %p cannot release Mutex [%4.4s] acquired by thread %p", 397 - ACPI_CAST_PTR(void, walk_state->thread->thread_id), 396 + "Thread %u cannot release Mutex [%4.4s] acquired by thread %u", 397 + (u32)walk_state->thread->thread_id, 398 398 acpi_ut_get_node_name(obj_desc->mutex.node), 399 - ACPI_CAST_PTR(void, owner_thread->thread_id))); 399 + (u32)owner_thread->thread_id)); 400 400 return_ACPI_STATUS(AE_AML_NOT_OWNER); 401 401 } 402 402 ··· 488 488 /* Mark mutex unowned */ 489 489 490 490 obj_desc->mutex.owner_thread = NULL; 491 - obj_desc->mutex.thread_id = NULL; 491 + obj_desc->mutex.thread_id = 0; 492 492 493 493 /* Update Thread sync_level (Last mutex is the important one) */ 494 494
+3 -4
drivers/acpi/acpica/utdebug.c
··· 179 179 if (thread_id != acpi_gbl_prev_thread_id) { 180 180 if (ACPI_LV_THREADS & acpi_dbg_level) { 181 181 acpi_os_printf 182 - ("\n**** Context Switch from TID %p to TID %p ****\n\n", 183 - ACPI_CAST_PTR(void, acpi_gbl_prev_thread_id), 184 - ACPI_CAST_PTR(void, thread_id)); 182 + ("\n**** Context Switch from TID %u to TID %u ****\n\n", 183 + (u32)acpi_gbl_prev_thread_id, (u32)thread_id); 185 184 } 186 185 187 186 acpi_gbl_prev_thread_id = thread_id; ··· 193 194 acpi_os_printf("%8s-%04ld ", module_name, line_number); 194 195 195 196 if (ACPI_LV_THREADS & acpi_dbg_level) { 196 - acpi_os_printf("[%p] ", ACPI_CAST_PTR(void, thread_id)); 197 + acpi_os_printf("[%u] ", (u32)thread_id); 197 198 } 198 199 199 200 acpi_os_printf("[%02ld] %-22.22s: ",
+16 -13
drivers/acpi/acpica/utmutex.c
··· 228 228 if (acpi_gbl_mutex_info[i].thread_id == this_thread_id) { 229 229 if (i == mutex_id) { 230 230 ACPI_ERROR((AE_INFO, 231 - "Mutex [%s] already acquired by this thread [%p]", 231 + "Mutex [%s] already acquired by this thread [%u]", 232 232 acpi_ut_get_mutex_name 233 233 (mutex_id), 234 - ACPI_CAST_PTR(void, 235 - this_thread_id))); 234 + (u32)this_thread_id)); 236 235 237 236 return (AE_ALREADY_ACQUIRED); 238 237 } 239 238 240 239 ACPI_ERROR((AE_INFO, 241 - "Invalid acquire order: Thread %p owns [%s], wants [%s]", 242 - ACPI_CAST_PTR(void, this_thread_id), 240 + "Invalid acquire order: Thread %u owns [%s], wants [%s]", 241 + (u32)this_thread_id, 243 242 acpi_ut_get_mutex_name(i), 244 243 acpi_ut_get_mutex_name(mutex_id))); 245 244 ··· 249 250 #endif 250 251 251 252 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 252 - "Thread %p attempting to acquire Mutex [%s]\n", 253 - ACPI_CAST_PTR(void, this_thread_id), 253 + "Thread %u attempting to acquire Mutex [%s]\n", 254 + (u32)this_thread_id, 254 255 acpi_ut_get_mutex_name(mutex_id))); 255 256 256 257 status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex, 257 258 ACPI_WAIT_FOREVER); 258 259 if (ACPI_SUCCESS(status)) { 259 260 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 260 - "Thread %p acquired Mutex [%s]\n", 261 - ACPI_CAST_PTR(void, this_thread_id), 261 + "Thread %u acquired Mutex [%s]\n", 262 + (u32)this_thread_id, 262 263 acpi_ut_get_mutex_name(mutex_id))); 263 264 264 265 acpi_gbl_mutex_info[mutex_id].use_count++; 265 266 acpi_gbl_mutex_info[mutex_id].thread_id = this_thread_id; 266 267 } else { 267 268 ACPI_EXCEPTION((AE_INFO, status, 268 - "Thread %p could not acquire Mutex [0x%X]", 269 - ACPI_CAST_PTR(void, this_thread_id), mutex_id)); 269 + "Thread %u could not acquire Mutex [0x%X]", 270 + (u32)this_thread_id, mutex_id)); 270 271 } 271 272 272 273 return (status); ··· 286 287 287 288 acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) 288 289 { 290 + acpi_thread_id this_thread_id; 291 + 289 292 ACPI_FUNCTION_NAME(ut_release_mutex); 290 293 291 - ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Thread %p releasing Mutex [%s]\n", 292 - ACPI_CAST_PTR(void, acpi_os_get_thread_id()), 294 + this_thread_id = acpi_os_get_thread_id(); 295 + 296 + ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Thread %u releasing Mutex [%s]\n", 297 + (u32)this_thread_id, 293 298 acpi_ut_get_mutex_name(mutex_id))); 294 299 295 300 if (mutex_id > ACPI_MAX_MUTEX) {
+10 -7
include/acpi/actypes.h
··· 115 115 * 116 116 * ACPI_SIZE 16/32/64-bit unsigned value 117 117 * ACPI_NATIVE_INT 16/32/64-bit signed value 118 - * 119 118 */ 120 119 121 120 /******************************************************************************* ··· 130 131 typedef COMPILER_DEPENDENT_INT64 INT64; 131 132 132 133 /*! [End] no source code translation !*/ 134 + 135 + /* 136 + * Value returned by acpi_os_get_thread_id. There is no standard "thread_id" 137 + * across operating systems or even the various UNIX systems. Since ACPICA 138 + * only needs the thread ID as a unique thread identifier, we use a u64 139 + * as the only common data type - it will accommodate any type of pointer or 140 + * any type of integer. It is up to the host-dependent OSL to cast the 141 + * native thread ID type to a u64 (in acpi_os_get_thread_id). 142 + */ 143 + #define acpi_thread_id u64 133 144 134 145 /******************************************************************************* 135 146 * ··· 219 210 * be defined in the OS-specific header, and this will take precedence. 220 211 * 221 212 ******************************************************************************/ 222 - 223 - /* Value returned by acpi_os_get_thread_id */ 224 - 225 - #ifndef acpi_thread_id 226 - #define acpi_thread_id acpi_size 227 - #endif 228 213 229 214 /* Flags for acpi_os_acquire_lock/acpi_os_release_lock */ 230 215
+3 -4
include/acpi/platform/aclinux.h
··· 75 75 #define acpi_cache_t struct kmem_cache 76 76 #define acpi_spinlock spinlock_t * 77 77 #define acpi_cpu_flags unsigned long 78 - #define acpi_thread_id struct task_struct * 79 78 80 79 #else /* !__KERNEL__ */ 81 80 ··· 87 88 /* Host-dependent types and defines for user-space ACPICA */ 88 89 89 90 #define ACPI_FLUSH_CPU_CACHE() 90 - #define acpi_thread_id pthread_t 91 + #define ACPI_CAST_PTHREAD_T(pthread) ((acpi_thread_id) (pthread)) 91 92 92 93 #if defined(__ia64__) || defined(__x86_64__) 93 94 #define ACPI_MACHINE_WIDTH 64 ··· 112 113 113 114 114 115 #ifdef __KERNEL__ 116 + #include <acpi/actypes.h> 115 117 /* 116 118 * Overrides for in-kernel ACPICA 117 119 */ 118 120 static inline acpi_thread_id acpi_os_get_thread_id(void) 119 121 { 120 - return current; 122 + return (acpi_thread_id)(unsigned long)current; 121 123 } 122 124 123 125 /* ··· 127 127 * However, boot has (system_state != SYSTEM_RUNNING) 128 128 * to quiet __might_sleep() in kmalloc() and resume does not. 129 129 */ 130 - #include <acpi/actypes.h> 131 130 static inline void *acpi_os_allocate(acpi_size size) 132 131 { 133 132 return kmalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL);