~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/acpi/acpica/exmutex.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 *****************************************************************************/
7
7
 
8
8
/*
9
 
 * Copyright (C) 2000 - 2008, Intel Corp.
 
9
 * Copyright (C) 2000 - 2011, Intel Corp.
10
10
 * All rights reserved.
11
11
 *
12
12
 * Redistribution and use in source and binary forms, with or without
85
85
                (obj_desc->mutex.prev)->mutex.next = obj_desc->mutex.next;
86
86
 
87
87
                /*
88
 
                 * Migrate the previous sync level associated with this mutex to the
89
 
                 * previous mutex on the list so that it may be preserved. This handles
90
 
                 * the case where several mutexes have been acquired at the same level,
91
 
                 * but are not released in opposite order.
 
88
                 * Migrate the previous sync level associated with this mutex to
 
89
                 * the previous mutex on the list so that it may be preserved.
 
90
                 * This handles the case where several mutexes have been acquired
 
91
                 * at the same level, but are not released in opposite order.
92
92
                 */
93
93
                (obj_desc->mutex.prev)->mutex.original_sync_level =
94
94
                    obj_desc->mutex.original_sync_level;
101
101
 *
102
102
 * FUNCTION:    acpi_ex_link_mutex
103
103
 *
104
 
 * PARAMETERS:  obj_desc        - The mutex to be linked
105
 
 *              Thread          - Current executing thread object
 
104
 * PARAMETERS:  obj_desc            - The mutex to be linked
 
105
 *              Thread              - Current executing thread object
106
106
 *
107
107
 * RETURN:      None
108
108
 *
138
138
 *
139
139
 * FUNCTION:    acpi_ex_acquire_mutex_object
140
140
 *
141
 
 * PARAMETERS:  time_desc           - Timeout in milliseconds
 
141
 * PARAMETERS:  Timeout             - Timeout in milliseconds
142
142
 *              obj_desc            - Mutex object
143
 
 *              Thread              - Current thread state
 
143
 *              thread_id           - Current thread state
144
144
 *
145
145
 * RETURN:      Status
146
146
 *
234
234
                return_ACPI_STATUS(AE_BAD_PARAMETER);
235
235
        }
236
236
 
237
 
        /* Must have a valid thread ID */
 
237
        /* Must have a valid thread state struct */
238
238
 
239
239
        if (!walk_state->thread) {
240
240
                ACPI_ERROR((AE_INFO,
249
249
         */
250
250
        if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {
251
251
                ACPI_ERROR((AE_INFO,
252
 
                            "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%d)",
 
252
                            "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%u)",
253
253
                            acpi_ut_get_node_name(obj_desc->mutex.node),
254
254
                            walk_state->thread->current_sync_level));
255
255
                return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
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
 
359
359
{
360
360
        acpi_status status = AE_OK;
361
361
        u8 previous_sync_level;
 
362
        struct acpi_thread_state *owner_thread;
362
363
 
363
364
        ACPI_FUNCTION_TRACE(ex_release_mutex);
364
365
 
366
367
                return_ACPI_STATUS(AE_BAD_PARAMETER);
367
368
        }
368
369
 
 
370
        owner_thread = obj_desc->mutex.owner_thread;
 
371
 
369
372
        /* The mutex must have been previously acquired in order to release it */
370
373
 
371
 
        if (!obj_desc->mutex.owner_thread) {
 
374
        if (!owner_thread) {
372
375
                ACPI_ERROR((AE_INFO,
373
376
                            "Cannot release Mutex [%4.4s], not acquired",
374
377
                            acpi_ut_get_node_name(obj_desc->mutex.node)));
375
378
                return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
376
379
        }
377
380
 
 
381
        /* Must have a valid thread. */
 
382
        if (!walk_state->thread) {
 
383
                ACPI_ERROR((AE_INFO,
 
384
                            "Cannot release Mutex [%4.4s], null thread info",
 
385
                            acpi_ut_get_node_name(obj_desc->mutex.node)));
 
386
                return_ACPI_STATUS(AE_AML_INTERNAL);
 
387
        }
 
388
 
378
389
        /*
379
390
         * The Mutex is owned, but this thread must be the owner.
380
391
         * Special case for Global Lock, any thread can release
381
392
         */
382
 
        if ((obj_desc->mutex.owner_thread->thread_id !=
383
 
             walk_state->thread->thread_id)
384
 
            && (obj_desc != acpi_gbl_global_lock_mutex)) {
 
393
        if ((owner_thread->thread_id != walk_state->thread->thread_id) &&
 
394
            (obj_desc != acpi_gbl_global_lock_mutex)) {
385
395
                ACPI_ERROR((AE_INFO,
386
 
                            "Thread %p cannot release Mutex [%4.4s] acquired by thread %p",
387
 
                            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,
388
398
                            acpi_ut_get_node_name(obj_desc->mutex.node),
389
 
                            ACPI_CAST_PTR(void,
390
 
                                          obj_desc->mutex.owner_thread->
391
 
                                          thread_id)));
 
399
                            (u32)owner_thread->thread_id));
392
400
                return_ACPI_STATUS(AE_AML_NOT_OWNER);
393
401
        }
394
402
 
395
 
        /* Must have a valid thread ID */
396
 
 
397
 
        if (!walk_state->thread) {
398
 
                ACPI_ERROR((AE_INFO,
399
 
                            "Cannot release Mutex [%4.4s], null thread info",
400
 
                            acpi_ut_get_node_name(obj_desc->mutex.node)));
401
 
                return_ACPI_STATUS(AE_AML_INTERNAL);
402
 
        }
403
 
 
404
403
        /*
405
404
         * The sync level of the mutex must be equal to the current sync level. In
406
405
         * other words, the current level means that at least one mutex at that
408
407
         * different level can only mean that the mutex ordering rule is being
409
408
         * violated. This behavior is clarified in ACPI 4.0 specification.
410
409
         */
411
 
        if (obj_desc->mutex.sync_level !=
412
 
            walk_state->thread->current_sync_level) {
 
410
        if (obj_desc->mutex.sync_level != owner_thread->current_sync_level) {
413
411
                ACPI_ERROR((AE_INFO,
414
 
                            "Cannot release Mutex [%4.4s], SyncLevel mismatch: mutex %d current %d",
 
412
                            "Cannot release Mutex [%4.4s], SyncLevel mismatch: mutex %u current %u",
415
413
                            acpi_ut_get_node_name(obj_desc->mutex.node),
416
414
                            obj_desc->mutex.sync_level,
417
415
                            walk_state->thread->current_sync_level));
424
422
         * acquired, but are not released in reverse order.
425
423
         */
426
424
        previous_sync_level =
427
 
            walk_state->thread->acquired_mutex_list->mutex.original_sync_level;
 
425
            owner_thread->acquired_mutex_list->mutex.original_sync_level;
428
426
 
429
427
        status = acpi_ex_release_mutex_object(obj_desc);
430
428
        if (ACPI_FAILURE(status)) {
435
433
 
436
434
                /* Restore the previous sync_level */
437
435
 
438
 
                walk_state->thread->current_sync_level = previous_sync_level;
 
436
                owner_thread->current_sync_level = previous_sync_level;
439
437
        }
 
438
 
440
439
        return_ACPI_STATUS(status);
441
440
}
442
441
 
444
443
 *
445
444
 * FUNCTION:    acpi_ex_release_all_mutexes
446
445
 *
447
 
 * PARAMETERS:  Thread          - Current executing thread object
 
446
 * PARAMETERS:  Thread              - Current executing thread object
448
447
 *
449
448
 * RETURN:      Status
450
449
 *
489
488
                /* Mark mutex unowned */
490
489
 
491
490
                obj_desc->mutex.owner_thread = NULL;
492
 
                obj_desc->mutex.thread_id = NULL;
 
491
                obj_desc->mutex.thread_id = 0;
493
492
 
494
493
                /* Update Thread sync_level (Last mutex is the important one) */
495
494