Deleted Added
sdiff udiff text old ( 256281 ) new ( 259742 )
full compact
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 $");
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 != 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);
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);
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);
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 ---