Skip to content

Commit

Permalink
ACPICA: haiku: Fix invalid value used for semaphores
Browse files Browse the repository at this point in the history
ACPICA commit 49fe4f25483feec2f685b204ef19e28d92979e95

In Haiku, semaphores are represented by integers, not pointers.
So, we can't use NULL as the invalid/destroyed value, the correct value
is -1. Introduce a platform overridable define to allow this.

Fixes torvalds#162 (which was closed after coming to the conclusion that this
should be done, but the change was never done).

Link: acpica/acpica@49fe4f25
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
pulkomandy authored and rafaeljw committed Aug 29, 2024
1 parent 36b5c1d commit 7afea7b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions drivers/acpi/acpica/utdelete.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
(void)
acpi_os_delete_semaphore
(acpi_gbl_global_lock_semaphore);
acpi_gbl_global_lock_semaphore = NULL;
acpi_gbl_global_lock_semaphore = ACPI_SEMAPHORE_NULL;

acpi_os_delete_mutex(object->mutex.os_mutex);
acpi_gbl_global_lock_mutex = NULL;
Expand All @@ -157,7 +157,7 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
object, object->event.os_semaphore));

(void)acpi_os_delete_semaphore(object->event.os_semaphore);
object->event.os_semaphore = NULL;
object->event.os_semaphore = ACPI_SEMAPHORE_NULL;
break;

case ACPI_TYPE_METHOD:
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/utinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ acpi_status acpi_ut_init_globals(void)

/* Global Lock support */

acpi_gbl_global_lock_semaphore = NULL;
acpi_gbl_global_lock_semaphore = ACPI_SEMAPHORE_NULL;
acpi_gbl_global_lock_mutex = NULL;
acpi_gbl_global_lock_acquired = FALSE;
acpi_gbl_global_lock_handle = 0;
Expand Down
6 changes: 6 additions & 0 deletions include/acpi/platform/acenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@
#define ACPI_RELEASE_GLOBAL_LOCK(Glptr, pending) pending = 0
#endif

/* NULL/invalid value to use for destroyed or not-yet-created semaphores. */

#ifndef ACPI_SEMAPHORE_NULL
#define ACPI_SEMAPHORE_NULL NULL
#endif

/* Flush CPU cache - used when going to sleep. Wbinvd or similar. */

#ifndef ACPI_FLUSH_CPU_CACHE
Expand Down

0 comments on commit 7afea7b

Please sign in to comment.