History

mmiowb: Hook up mmiowb helpers to spinlocks and generic I/O accessors

Removing explicit calls to mmiowb() from driver code means that we must now call into the generic mmiowb_spin_{lock,unlock}() functions from the core spinlock code. In order to elide barriers following critical sections without any I/O writes, we also hook into the asm-generic I/O routines.

Will Deacon committed 7 years ago

Commit 60ca1e51 parent fdcd06a3 files · +17 −3Browse files

Unified · Split

3 files
  1. include/asm-generic/io.h +2 −1
  2. include/linux/spinlock.h +10 −1
  3. kernel/locking/spinlock_debug.c +5 −1
include/asm-generic/io.h+2−1
@@ -19,6 +19,7 @@ · 18 unmodified lines
1919 #include <asm-generic/iomap.h>
2020 #endif
2121
22+#include <asm/mmiowb.h>
2223 #include <asm-generic/pci_iomap.h>
2324
2425 #ifndef mmiowb
@@ -49,7 +50,7 @@ · 24 unmodified lines
4950
5051 /* serialize device access against a spin_unlock, usually handled there. */
5152 #ifndef __io_aw
52−#define __io_aw() barrier()
53+#define __io_aw() mmiowb_set_pending()
5354 #endif
5455
5556 #ifndef __io_pbw
include/linux/spinlock.h+10−1
@@ -57,6 +57,7 @@ · 56 unmodified lines
5757 #include <linux/stringify.h>
5858 #include <linux/bottom_half.h>
5959 #include <asm/barrier.h>
60+#include <asm/mmiowb.h>
6061
6162
6263 /*
@@ -178,6 +179,7 @@ static inline void do_raw_spin_lock(raw_spinlock_t *lock) __acquires(lock) · 115 unmodified lines
178179 {
179180 __acquire(lock);
180181 arch_spin_lock(&lock->raw_lock);
182+ mmiowb_spin_lock();
181183 }
182184
183185 #ifndef arch_spin_lock_flags
@@ -189,15 +191,22 @@ do_raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long *flags) __acquires(lo · 5 unmodified lines
189191 {
190192 __acquire(lock);
191193 arch_spin_lock_flags(&lock->raw_lock, *flags);
194+ mmiowb_spin_lock();
192195 }
193196
194197 static inline int do_raw_spin_trylock(raw_spinlock_t *lock)
195198 {
196− return arch_spin_trylock(&(lock)->raw_lock);
199+ int ret = arch_spin_trylock(&(lock)->raw_lock);
200+
201+ if (ret)
202+ mmiowb_spin_lock();
203+
204+ return ret;
197205 }
198206
199207 static inline void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock)
200208 {
209+ mmiowb_spin_unlock();
201210 arch_spin_unlock(&lock->raw_lock);
202211 __release(lock);
203212 }
kernel/locking/spinlock_debug.c+5−1
@@ -111,6 +111,7 @@ void do_raw_spin_lock(raw_spinlock_t *lock) · 110 unmodified lines
111111 {
112112 debug_spin_lock_before(lock);
113113 arch_spin_lock(&lock->raw_lock);
114+ mmiowb_spin_lock();
114115 debug_spin_lock_after(lock);
115116 }
116117
@@ -118,8 +119,10 @@ int do_raw_spin_trylock(raw_spinlock_t *lock) · 1 unmodified line
118119 {
119120 int ret = arch_spin_trylock(&lock->raw_lock);
120121
121− if (ret)
122+ if (ret) {
123+ mmiowb_spin_lock();
122124 debug_spin_lock_after(lock);
125+ }
123126 #ifndef CONFIG_SMP
124127 /*
125128 * Must not happen on UP:
@@ -131,6 +134,7 @@ int do_raw_spin_trylock(raw_spinlock_t *lock) · 5 unmodified lines
131134
132135 void do_raw_spin_unlock(raw_spinlock_t *lock)
133136 {
137+ mmiowb_spin_unlock();
134138 debug_spin_unlock(lock);
135139 arch_spin_unlock(&lock->raw_lock);
136140 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t