aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2018-04-25 10:28:26 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-05-10 11:18:45 -0400
commitc3052594c8ded984ceab3725f63990dfdea1e58f (patch)
tree5971f70a7f1b4109e1c008a6e919b038a186ccb6
parent75bc37fefc4471e718ba8e651aa74673d4e0a9eb (diff)
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>
-rw-r--r--include/acpi/acpiosxf.h21
-rw-r--r--include/acpi/actypes.h4
-rw-r--r--include/acpi/platform/aclinux.h5
-rw-r--r--include/acpi/platform/aclinuxex.h30
4 files changed, 60 insertions, 0 deletions
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
index 540d35f06ad6..eb1f21af7556 100644
--- a/include/acpi/acpiosxf.h
+++ b/include/acpi/acpiosxf.h
@@ -98,6 +98,27 @@ void acpi_os_release_lock(acpi_spinlock handle, acpi_cpu_flags flags);
98#endif 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 * Semaphore primitives 122 * Semaphore primitives
102 */ 123 */
103#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_semaphore 124#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_semaphore
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 1c530f95dc34..2b1bafa197c0 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -245,6 +245,10 @@ typedef u64 acpi_physical_address;
245#define acpi_spinlock void * 245#define acpi_spinlock void *
246#endif 246#endif
247 247
248#ifndef acpi_raw_spinlock
249#define acpi_raw_spinlock acpi_spinlock
250#endif
251
248#ifndef acpi_semaphore 252#ifndef acpi_semaphore
249#define acpi_semaphore void * 253#define acpi_semaphore void *
250#endif 254#endif
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index a0b232703302..7451b3bca83a 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -102,6 +102,7 @@
102 102
103#define acpi_cache_t struct kmem_cache 103#define acpi_cache_t struct kmem_cache
104#define acpi_spinlock spinlock_t * 104#define acpi_spinlock spinlock_t *
105#define acpi_raw_spinlock raw_spinlock_t *
105#define acpi_cpu_flags unsigned long 106#define acpi_cpu_flags unsigned long
106 107
107/* Use native linux version of acpi_os_allocate_zeroed */ 108/* Use native linux version of acpi_os_allocate_zeroed */
@@ -119,6 +120,10 @@
119#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object 120#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
120#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id 121#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
121#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock 122#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
123#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_raw_lock
124#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_delete_raw_lock
125#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_raw_lock
126#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_release_raw_lock
122 127
123/* 128/*
124 * OSL interfaces used by debugger/disassembler 129 * OSL interfaces used by debugger/disassembler
diff --git a/include/acpi/platform/aclinuxex.h b/include/acpi/platform/aclinuxex.h
index 7e81475fe034..d754a1b12721 100644
--- a/include/acpi/platform/aclinuxex.h
+++ b/include/acpi/platform/aclinuxex.h
@@ -90,6 +90,36 @@ static inline acpi_thread_id acpi_os_get_thread_id(void)
90 lock ? AE_OK : AE_NO_MEMORY; \ 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
104static 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
112static 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
118static inline void acpi_os_delete_raw_lock(acpi_raw_spinlock handle)
119{
120 ACPI_FREE(handle);
121}
122
93static inline u8 acpi_os_readable(void *pointer, acpi_size length) 123static inline u8 acpi_os_readable(void *pointer, acpi_size length)
94{ 124{
95 return TRUE; 125 return TRUE;