ttm_lock.c (256281) | ttm_lock.c (259742) |
---|---|
1/************************************************************************** 2 * 3 * Copyright (c) 2007-2009 VMware, Inc., Palo Alto, CA., USA 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including --- 22 unchanged lines hidden (view full) --- 31 * Copyright (c) 2013 The FreeBSD Foundation 32 * All rights reserved. 33 * 34 * Portions of this software were developed by Konstantin Belousov 35 * <kib@FreeBSD.org> under sponsorship from the FreeBSD Foundation. 36 */ 37 38#include <sys/cdefs.h> | 1/************************************************************************** 2 * 3 * Copyright (c) 2007-2009 VMware, Inc., Palo Alto, CA., USA 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including --- 22 unchanged lines hidden (view full) --- 31 * Copyright (c) 2013 The FreeBSD Foundation 32 * All rights reserved. 33 * 34 * Portions of this software were developed by Konstantin Belousov 35 * <kib@FreeBSD.org> under sponsorship from the FreeBSD Foundation. 36 */ 37 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: stable/10/sys/dev/drm2/ttm/ttm_lock.c 247835 2013-03-05 09:49:34Z kib $"); | 39__FBSDID("$FreeBSD: stable/10/sys/dev/drm2/ttm/ttm_lock.c 259742 2013-12-22 21:18:21Z dumbbell $"); |
40 41#include <dev/drm2/ttm/ttm_lock.h> 42#include <dev/drm2/ttm/ttm_module.h> 43 44#define TTM_WRITE_LOCK_PENDING (1 << 0) 45#define TTM_VT_LOCK_PENDING (1 << 1) 46#define TTM_SUSPEND_LOCK_PENDING (1 << 2) 47#define TTM_VT_LOCK (1 << 3) --- 54 unchanged lines hidden (view full) --- 102 wmsg = "ttmri"; 103 } else { 104 flags = 0; 105 wmsg = "ttmr"; 106 } 107 mtx_lock(&lock->lock); 108 while (!__ttm_read_lock(lock)) { 109 ret = msleep(lock, &lock->lock, flags, wmsg, 0); | 40 41#include <dev/drm2/ttm/ttm_lock.h> 42#include <dev/drm2/ttm/ttm_module.h> 43 44#define TTM_WRITE_LOCK_PENDING (1 << 0) 45#define TTM_VT_LOCK_PENDING (1 << 1) 46#define TTM_SUSPEND_LOCK_PENDING (1 << 2) 47#define TTM_VT_LOCK (1 << 3) --- 54 unchanged lines hidden (view full) --- 102 wmsg = "ttmri"; 103 } else { 104 flags = 0; 105 wmsg = "ttmr"; 106 } 107 mtx_lock(&lock->lock); 108 while (!__ttm_read_lock(lock)) { 109 ret = msleep(lock, &lock->lock, flags, wmsg, 0); |
110 if (ret == EINTR) 111 ret = ERESTARTSYS; |
|
110 if (ret != 0) 111 break; 112 } 113 return (-ret); 114} 115 116static bool __ttm_read_trylock(struct ttm_lock *lock, bool *locked) 117{ --- 28 unchanged lines hidden (view full) --- 146 wmsg = "ttmrti"; 147 } else { 148 flags = 0; 149 wmsg = "ttmrt"; 150 } 151 mtx_lock(&lock->lock); 152 while (!__ttm_read_trylock(lock, &locked)) { 153 ret = msleep(lock, &lock->lock, flags, wmsg, 0); | 112 if (ret != 0) 113 break; 114 } 115 return (-ret); 116} 117 118static bool __ttm_read_trylock(struct ttm_lock *lock, bool *locked) 119{ --- 28 unchanged lines hidden (view full) --- 148 wmsg = "ttmrti"; 149 } else { 150 flags = 0; 151 wmsg = "ttmrt"; 152 } 153 mtx_lock(&lock->lock); 154 while (!__ttm_read_trylock(lock, &locked)) { 155 ret = msleep(lock, &lock->lock, flags, wmsg, 0); |
156 if (ret == EINTR) 157 ret = ERESTARTSYS; |
|
154 if (ret != 0) 155 break; 156 } 157 MPASS(!locked || ret == 0); 158 mtx_unlock(&lock->lock); 159 160 return (locked) ? 0 : -EBUSY; 161} --- 37 unchanged lines hidden (view full) --- 199 } else { 200 flags = 0; 201 wmsg = "ttmw"; 202 } 203 mtx_lock(&lock->lock); 204 /* XXXKIB: linux uses __ttm_read_lock for uninterruptible sleeps */ 205 while (!__ttm_write_lock(lock)) { 206 ret = msleep(lock, &lock->lock, flags, wmsg, 0); | 158 if (ret != 0) 159 break; 160 } 161 MPASS(!locked || ret == 0); 162 mtx_unlock(&lock->lock); 163 164 return (locked) ? 0 : -EBUSY; 165} --- 37 unchanged lines hidden (view full) --- 203 } else { 204 flags = 0; 205 wmsg = "ttmw"; 206 } 207 mtx_lock(&lock->lock); 208 /* XXXKIB: linux uses __ttm_read_lock for uninterruptible sleeps */ 209 while (!__ttm_write_lock(lock)) { 210 ret = msleep(lock, &lock->lock, flags, wmsg, 0); |
211 if (ret == EINTR) 212 ret = ERESTARTSYS; |
|
207 if (interruptible && ret != 0) { 208 lock->flags &= ~TTM_WRITE_LOCK_PENDING; 209 wakeup(lock); 210 break; 211 } 212 } 213 mtx_unlock(&lock->lock); 214 --- 60 unchanged lines hidden (view full) --- 275 wmsg = "ttmwi"; 276 } else { 277 flags = 0; 278 wmsg = "ttmw"; 279 } 280 mtx_lock(&lock->lock); 281 while (!__ttm_vt_lock(lock)) { 282 ret = msleep(lock, &lock->lock, flags, wmsg, 0); | 213 if (interruptible && ret != 0) { 214 lock->flags &= ~TTM_WRITE_LOCK_PENDING; 215 wakeup(lock); 216 break; 217 } 218 } 219 mtx_unlock(&lock->lock); 220 --- 60 unchanged lines hidden (view full) --- 281 wmsg = "ttmwi"; 282 } else { 283 flags = 0; 284 wmsg = "ttmw"; 285 } 286 mtx_lock(&lock->lock); 287 while (!__ttm_vt_lock(lock)) { 288 ret = msleep(lock, &lock->lock, flags, wmsg, 0); |
289 if (ret == EINTR) 290 ret = ERESTARTSYS; |
|
283 if (interruptible && ret != 0) { 284 lock->flags &= ~TTM_VT_LOCK_PENDING; 285 wakeup(lock); 286 break; 287 } 288 } 289 290 /* --- 50 unchanged lines hidden --- | 291 if (interruptible && ret != 0) { 292 lock->flags &= ~TTM_VT_LOCK_PENDING; 293 wakeup(lock); 294 break; 295 } 296 } 297 298 /* --- 50 unchanged lines hidden --- |