diff options
author | Bob Moore <robert.moore@intel.com> | 2009-03-09 04:31:04 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-03-27 12:11:02 -0400 |
commit | 8a335a2331c72e60c6b3ef09b2dedd3ba00da1b1 (patch) | |
tree | f538a4f68499dab0d59e253bc55a5cf4aff66ec1 /drivers/acpi/acpica/nsxfeval.c | |
parent | aab61b676a024d3527f6201e2b31285a96f7a1d2 (diff) |
ACPICA: Fix AcpiWalkNamespace race condition with table unload
Added a reader/writer locking mechanism to allow multiple
concurrent namespace walks (readers), but a dynamic table unload
will have exclusive access to the namespace. This fixes a problem
where a table unload could delete the portion of the namespace that
is currently being examined by a walk. Adds a new file, utlock.c
that implements the reader/writer lock mechanism. ACPICA BZ 749.
http://www.acpica.org/bugzilla/show_bug.cgi?id=749
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/acpica/nsxfeval.c')
-rw-r--r-- | drivers/acpi/acpica/nsxfeval.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c index 2583a66a60a7..045054037c2d 100644 --- a/drivers/acpi/acpica/nsxfeval.c +++ b/drivers/acpi/acpica/nsxfeval.c | |||
@@ -475,21 +475,40 @@ acpi_walk_namespace(acpi_object_type type, | |||
475 | } | 475 | } |
476 | 476 | ||
477 | /* | 477 | /* |
478 | * Lock the namespace around the walk. | 478 | * Need to acquire the namespace reader lock to prevent interference |
479 | * The namespace will be unlocked/locked around each call | 479 | * with any concurrent table unloads (which causes the deletion of |
480 | * to the user function - since this function | 480 | * namespace objects). We cannot allow the deletion of a namespace node |
481 | * must be allowed to make Acpi calls itself. | 481 | * while the user function is using it. The exception to this are the |
482 | * nodes created and deleted during control method execution -- these | ||
483 | * nodes are marked as temporary nodes and are ignored by the namespace | ||
484 | * walk. Thus, control methods can be executed while holding the | ||
485 | * namespace deletion lock (and the user function can execute control | ||
486 | * methods.) | ||
487 | */ | ||
488 | status = acpi_ut_acquire_read_lock(&acpi_gbl_namespace_rw_lock); | ||
489 | if (ACPI_FAILURE(status)) { | ||
490 | return status; | ||
491 | } | ||
492 | |||
493 | /* | ||
494 | * Lock the namespace around the walk. The namespace will be | ||
495 | * unlocked/locked around each call to the user function - since the user | ||
496 | * function must be allowed to make ACPICA calls itself (for example, it | ||
497 | * will typically execute control methods during device enumeration.) | ||
482 | */ | 498 | */ |
483 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); | 499 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
484 | if (ACPI_FAILURE(status)) { | 500 | if (ACPI_FAILURE(status)) { |
485 | return_ACPI_STATUS(status); | 501 | goto unlock_and_exit; |
486 | } | 502 | } |
487 | 503 | ||
488 | status = acpi_ns_walk_namespace(type, start_object, max_depth, | 504 | status = acpi_ns_walk_namespace(type, start_object, max_depth, |
489 | ACPI_NS_WALK_UNLOCK, | 505 | ACPI_NS_WALK_UNLOCK, user_function, |
490 | user_function, context, return_value); | 506 | context, return_value); |
491 | 507 | ||
492 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | 508 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
509 | |||
510 | unlock_and_exit: | ||
511 | (void)acpi_ut_release_read_lock(&acpi_gbl_namespace_rw_lock); | ||
493 | return_ACPI_STATUS(status); | 512 | return_ACPI_STATUS(status); |
494 | } | 513 | } |
495 | 514 | ||