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

ACPICA: provide abstraction for raw_spinlock_t

Provide a new lock type acpi_raw_spinlock which is implemented as
raw_spinlock_t on Linux. This type should be used in code which covers
small areas of code and disables interrupts only for short time even on
a realtime OS.
There is a fallback to spinlock_t if an OS does not provide an
implementation for acpi_raw_spinlock.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Sebastian Andrzej Siewior and committed by
Rafael J. Wysocki
c3052594 75bc37fe

+60
+21
include/acpi/acpiosxf.h
··· 98 98 #endif 99 99 100 100 /* 101 + * RAW spinlock primitives. If the OS does not provide them, fallback to 102 + * spinlock primitives 103 + */ 104 + #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_raw_lock 105 + # define acpi_os_create_raw_lock(out_handle) acpi_os_create_lock(out_handle) 106 + #endif 107 + 108 + #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_raw_lock 109 + # define acpi_os_delete_raw_lock(handle) acpi_os_delete_lock(handle) 110 + #endif 111 + 112 + #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_raw_lock 113 + # define acpi_os_acquire_raw_lock(handle) acpi_os_acquire_lock(handle) 114 + #endif 115 + 116 + #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_raw_lock 117 + # define acpi_os_release_raw_lock(handle, flags) \ 118 + acpi_os_release_lock(handle, flags) 119 + #endif 120 + 121 + /* 101 122 * Semaphore primitives 102 123 */ 103 124 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_semaphore
+4
include/acpi/actypes.h
··· 245 245 #define acpi_spinlock void * 246 246 #endif 247 247 248 + #ifndef acpi_raw_spinlock 249 + #define acpi_raw_spinlock acpi_spinlock 250 + #endif 251 + 248 252 #ifndef acpi_semaphore 249 253 #define acpi_semaphore void * 250 254 #endif
+5
include/acpi/platform/aclinux.h
··· 102 102 103 103 #define acpi_cache_t struct kmem_cache 104 104 #define acpi_spinlock spinlock_t * 105 + #define acpi_raw_spinlock raw_spinlock_t * 105 106 #define acpi_cpu_flags unsigned long 106 107 107 108 /* Use native linux version of acpi_os_allocate_zeroed */ ··· 120 119 #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object 121 120 #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id 122 121 #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock 122 + #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_raw_lock 123 + #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_raw_lock 124 + #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_raw_lock 125 + #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_raw_lock 123 126 124 127 /* 125 128 * OSL interfaces used by debugger/disassembler
+30
include/acpi/platform/aclinuxex.h
··· 90 90 lock ? AE_OK : AE_NO_MEMORY; \ 91 91 }) 92 92 93 + 94 + #define acpi_os_create_raw_lock(__handle) \ 95 + ({ \ 96 + raw_spinlock_t *lock = ACPI_ALLOCATE(sizeof(*lock)); \ 97 + if (lock) { \ 98 + *(__handle) = lock; \ 99 + raw_spin_lock_init(*(__handle)); \ 100 + } \ 101 + lock ? AE_OK : AE_NO_MEMORY; \ 102 + }) 103 + 104 + static inline acpi_cpu_flags acpi_os_acquire_raw_lock(acpi_raw_spinlock lockp) 105 + { 106 + acpi_cpu_flags flags; 107 + 108 + raw_spin_lock_irqsave(lockp, flags); 109 + return flags; 110 + } 111 + 112 + static inline void acpi_os_release_raw_lock(acpi_raw_spinlock lockp, 113 + acpi_cpu_flags flags) 114 + { 115 + raw_spin_unlock_irqrestore(lockp, flags); 116 + } 117 + 118 + static inline void acpi_os_delete_raw_lock(acpi_raw_spinlock handle) 119 + { 120 + ACPI_FREE(handle); 121 + } 122 + 93 123 static inline u8 acpi_os_readable(void *pointer, acpi_size length) 94 124 { 95 125 return TRUE;