aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/rt.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/kernel/rt.c b/kernel/rt.c
index 710cef59ee8a..fd033a9bd7c2 100644
--- a/kernel/rt.c
+++ b/kernel/rt.c
@@ -204,10 +204,14 @@ int __lockfunc rt_read_trylock(rwlock_t *rwlock)
204 int ret = 1; 204 int ret = 1;
205 205
206 /* 206 /*
207 * recursive read locks succeed when current owns the lock 207 * recursive read locks succeed when current owns the lock,
208 * but not when read_depth == 0 which means that the lock is
209 * write locked.
208 */ 210 */
209 if (rt_mutex_real_owner(lock) != current) 211 if (rt_mutex_real_owner(lock) != current)
210 ret = rt_mutex_trylock(lock); 212 ret = rt_mutex_trylock(lock);
213 else if (!rwlock->read_depth)
214 ret = 0;
211 215
212 if (ret) { 216 if (ret) {
213 rwlock->read_depth++; 217 rwlock->read_depth++;
@@ -348,8 +352,15 @@ int rt_down_read_trylock(struct rw_semaphore *rwsem)
348 struct rt_mutex *lock = &rwsem->lock; 352 struct rt_mutex *lock = &rwsem->lock;
349 int ret = 1; 353 int ret = 1;
350 354
355 /*
356 * recursive read locks succeed when current owns the rwsem,
357 * but not when read_depth == 0 which means that the rwsem is
358 * write locked.
359 */
351 if (rt_mutex_real_owner(lock) != current) 360 if (rt_mutex_real_owner(lock) != current)
352 ret = rt_mutex_trylock(&rwsem->lock); 361 ret = rt_mutex_trylock(&rwsem->lock);
362 else if (!rwsem->read_depth)
363 ret = 0;
353 364
354 if (ret) { 365 if (ret) {
355 rwsem->read_depth++; 366 rwsem->read_depth++;