aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_context.c
diff options
context:
space:
mode:
authorSteven Whitehouse <steve@men-an-tol.chygwyn.com>2006-02-23 04:49:43 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2006-02-23 04:49:43 -0500
commitd35462b4bb847b68321c55e95c926aa485aecce2 (patch)
treeb08e18bf6e672633402871ee763102fdb5e63229 /drivers/char/drm/drm_context.c
parent91ffd7db71e7451f89941a8f428b4daa2a7c1e38 (diff)
parent9e956c2dac9bec602ed1ba29181b45ba6d2b6448 (diff)
Merge branch 'master'
Diffstat (limited to 'drivers/char/drm/drm_context.c')
-rw-r--r--drivers/char/drm/drm_context.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/drivers/char/drm/drm_context.c b/drivers/char/drm/drm_context.c
index f84254526949..83094c73da67 100644
--- a/drivers/char/drm/drm_context.c
+++ b/drivers/char/drm/drm_context.c
@@ -53,7 +53,7 @@
53 * \param ctx_handle context handle. 53 * \param ctx_handle context handle.
54 * 54 *
55 * Clears the bit specified by \p ctx_handle in drm_device::ctx_bitmap and the entry 55 * Clears the bit specified by \p ctx_handle in drm_device::ctx_bitmap and the entry
56 * in drm_device::context_sareas, while holding the drm_device::struct_sem 56 * in drm_device::context_sareas, while holding the drm_device::struct_mutex
57 * lock. 57 * lock.
58 */ 58 */
59void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle) 59void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
@@ -64,10 +64,10 @@ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
64 goto failed; 64 goto failed;
65 65
66 if (ctx_handle < DRM_MAX_CTXBITMAP) { 66 if (ctx_handle < DRM_MAX_CTXBITMAP) {
67 down(&dev->struct_sem); 67 mutex_lock(&dev->struct_mutex);
68 clear_bit(ctx_handle, dev->ctx_bitmap); 68 clear_bit(ctx_handle, dev->ctx_bitmap);
69 dev->context_sareas[ctx_handle] = NULL; 69 dev->context_sareas[ctx_handle] = NULL;
70 up(&dev->struct_sem); 70 mutex_unlock(&dev->struct_mutex);
71 return; 71 return;
72 } 72 }
73 failed: 73 failed:
@@ -83,7 +83,7 @@ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle)
83 * 83 *
84 * Find the first zero bit in drm_device::ctx_bitmap and (re)allocates 84 * Find the first zero bit in drm_device::ctx_bitmap and (re)allocates
85 * drm_device::context_sareas to accommodate the new entry while holding the 85 * drm_device::context_sareas to accommodate the new entry while holding the
86 * drm_device::struct_sem lock. 86 * drm_device::struct_mutex lock.
87 */ 87 */
88static int drm_ctxbitmap_next(drm_device_t * dev) 88static int drm_ctxbitmap_next(drm_device_t * dev)
89{ 89{
@@ -92,7 +92,7 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
92 if (!dev->ctx_bitmap) 92 if (!dev->ctx_bitmap)
93 return -1; 93 return -1;
94 94
95 down(&dev->struct_sem); 95 mutex_lock(&dev->struct_mutex);
96 bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP); 96 bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP);
97 if (bit < DRM_MAX_CTXBITMAP) { 97 if (bit < DRM_MAX_CTXBITMAP) {
98 set_bit(bit, dev->ctx_bitmap); 98 set_bit(bit, dev->ctx_bitmap);
@@ -113,7 +113,7 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
113 DRM_MEM_MAPS); 113 DRM_MEM_MAPS);
114 if (!ctx_sareas) { 114 if (!ctx_sareas) {
115 clear_bit(bit, dev->ctx_bitmap); 115 clear_bit(bit, dev->ctx_bitmap);
116 up(&dev->struct_sem); 116 mutex_unlock(&dev->struct_mutex);
117 return -1; 117 return -1;
118 } 118 }
119 dev->context_sareas = ctx_sareas; 119 dev->context_sareas = ctx_sareas;
@@ -126,16 +126,16 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
126 DRM_MEM_MAPS); 126 DRM_MEM_MAPS);
127 if (!dev->context_sareas) { 127 if (!dev->context_sareas) {
128 clear_bit(bit, dev->ctx_bitmap); 128 clear_bit(bit, dev->ctx_bitmap);
129 up(&dev->struct_sem); 129 mutex_unlock(&dev->struct_mutex);
130 return -1; 130 return -1;
131 } 131 }
132 dev->context_sareas[bit] = NULL; 132 dev->context_sareas[bit] = NULL;
133 } 133 }
134 } 134 }
135 up(&dev->struct_sem); 135 mutex_unlock(&dev->struct_mutex);
136 return bit; 136 return bit;
137 } 137 }
138 up(&dev->struct_sem); 138 mutex_unlock(&dev->struct_mutex);
139 return -1; 139 return -1;
140} 140}
141 141
@@ -145,24 +145,24 @@ static int drm_ctxbitmap_next(drm_device_t * dev)
145 * \param dev DRM device. 145 * \param dev DRM device.
146 * 146 *
147 * Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding 147 * Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding
148 * the drm_device::struct_sem lock. 148 * the drm_device::struct_mutex lock.
149 */ 149 */
150int drm_ctxbitmap_init(drm_device_t * dev) 150int drm_ctxbitmap_init(drm_device_t * dev)
151{ 151{
152 int i; 152 int i;
153 int temp; 153 int temp;
154 154
155 down(&dev->struct_sem); 155 mutex_lock(&dev->struct_mutex);
156 dev->ctx_bitmap = (unsigned long *)drm_alloc(PAGE_SIZE, 156 dev->ctx_bitmap = (unsigned long *)drm_alloc(PAGE_SIZE,
157 DRM_MEM_CTXBITMAP); 157 DRM_MEM_CTXBITMAP);
158 if (dev->ctx_bitmap == NULL) { 158 if (dev->ctx_bitmap == NULL) {
159 up(&dev->struct_sem); 159 mutex_unlock(&dev->struct_mutex);
160 return -ENOMEM; 160 return -ENOMEM;
161 } 161 }
162 memset((void *)dev->ctx_bitmap, 0, PAGE_SIZE); 162 memset((void *)dev->ctx_bitmap, 0, PAGE_SIZE);
163 dev->context_sareas = NULL; 163 dev->context_sareas = NULL;
164 dev->max_context = -1; 164 dev->max_context = -1;
165 up(&dev->struct_sem); 165 mutex_unlock(&dev->struct_mutex);
166 166
167 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { 167 for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
168 temp = drm_ctxbitmap_next(dev); 168 temp = drm_ctxbitmap_next(dev);
@@ -178,17 +178,17 @@ int drm_ctxbitmap_init(drm_device_t * dev)
178 * \param dev DRM device. 178 * \param dev DRM device.
179 * 179 *
180 * Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding 180 * Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding
181 * the drm_device::struct_sem lock. 181 * the drm_device::struct_mutex lock.
182 */ 182 */
183void drm_ctxbitmap_cleanup(drm_device_t * dev) 183void drm_ctxbitmap_cleanup(drm_device_t * dev)
184{ 184{
185 down(&dev->struct_sem); 185 mutex_lock(&dev->struct_mutex);
186 if (dev->context_sareas) 186 if (dev->context_sareas)
187 drm_free(dev->context_sareas, 187 drm_free(dev->context_sareas,
188 sizeof(*dev->context_sareas) * 188 sizeof(*dev->context_sareas) *
189 dev->max_context, DRM_MEM_MAPS); 189 dev->max_context, DRM_MEM_MAPS);
190 drm_free((void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP); 190 drm_free((void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP);
191 up(&dev->struct_sem); 191 mutex_unlock(&dev->struct_mutex);
192} 192}
193 193
194/*@}*/ 194/*@}*/
@@ -222,15 +222,15 @@ int drm_getsareactx(struct inode *inode, struct file *filp,
222 if (copy_from_user(&request, argp, sizeof(request))) 222 if (copy_from_user(&request, argp, sizeof(request)))
223 return -EFAULT; 223 return -EFAULT;
224 224
225 down(&dev->struct_sem); 225 mutex_lock(&dev->struct_mutex);
226 if (dev->max_context < 0 226 if (dev->max_context < 0
227 || request.ctx_id >= (unsigned)dev->max_context) { 227 || request.ctx_id >= (unsigned)dev->max_context) {
228 up(&dev->struct_sem); 228 mutex_unlock(&dev->struct_mutex);
229 return -EINVAL; 229 return -EINVAL;
230 } 230 }
231 231
232 map = dev->context_sareas[request.ctx_id]; 232 map = dev->context_sareas[request.ctx_id];
233 up(&dev->struct_sem); 233 mutex_unlock(&dev->struct_mutex);
234 234
235 request.handle = NULL; 235 request.handle = NULL;
236 list_for_each_entry(_entry, &dev->maplist->head, head) { 236 list_for_each_entry(_entry, &dev->maplist->head, head) {
@@ -274,7 +274,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
274 (drm_ctx_priv_map_t __user *) arg, sizeof(request))) 274 (drm_ctx_priv_map_t __user *) arg, sizeof(request)))
275 return -EFAULT; 275 return -EFAULT;
276 276
277 down(&dev->struct_sem); 277 mutex_lock(&dev->struct_mutex);
278 list_for_each(list, &dev->maplist->head) { 278 list_for_each(list, &dev->maplist->head) {
279 r_list = list_entry(list, drm_map_list_t, head); 279 r_list = list_entry(list, drm_map_list_t, head);
280 if (r_list->map 280 if (r_list->map
@@ -282,7 +282,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
282 goto found; 282 goto found;
283 } 283 }
284 bad: 284 bad:
285 up(&dev->struct_sem); 285 mutex_unlock(&dev->struct_mutex);
286 return -EINVAL; 286 return -EINVAL;
287 287
288 found: 288 found:
@@ -294,7 +294,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp,
294 if (request.ctx_id >= (unsigned)dev->max_context) 294 if (request.ctx_id >= (unsigned)dev->max_context)
295 goto bad; 295 goto bad;
296 dev->context_sareas[request.ctx_id] = map; 296 dev->context_sareas[request.ctx_id] = map;
297 up(&dev->struct_sem); 297 mutex_unlock(&dev->struct_mutex);
298 return 0; 298 return 0;
299} 299}
300 300
@@ -448,10 +448,10 @@ int drm_addctx(struct inode *inode, struct file *filp,
448 ctx_entry->handle = ctx.handle; 448 ctx_entry->handle = ctx.handle;
449 ctx_entry->tag = priv; 449 ctx_entry->tag = priv;
450 450
451 down(&dev->ctxlist_sem); 451 mutex_lock(&dev->ctxlist_mutex);
452 list_add(&ctx_entry->head, &dev->ctxlist->head); 452 list_add(&ctx_entry->head, &dev->ctxlist->head);
453 ++dev->ctx_count; 453 ++dev->ctx_count;
454 up(&dev->ctxlist_sem); 454 mutex_unlock(&dev->ctxlist_mutex);
455 455
456 if (copy_to_user(argp, &ctx, sizeof(ctx))) 456 if (copy_to_user(argp, &ctx, sizeof(ctx)))
457 return -EFAULT; 457 return -EFAULT;
@@ -574,7 +574,7 @@ int drm_rmctx(struct inode *inode, struct file *filp,
574 drm_ctxbitmap_free(dev, ctx.handle); 574 drm_ctxbitmap_free(dev, ctx.handle);
575 } 575 }
576 576
577 down(&dev->ctxlist_sem); 577 mutex_lock(&dev->ctxlist_mutex);
578 if (!list_empty(&dev->ctxlist->head)) { 578 if (!list_empty(&dev->ctxlist->head)) {
579 drm_ctx_list_t *pos, *n; 579 drm_ctx_list_t *pos, *n;
580 580
@@ -586,7 +586,7 @@ int drm_rmctx(struct inode *inode, struct file *filp,
586 } 586 }
587 } 587 }
588 } 588 }
589 up(&dev->ctxlist_sem); 589 mutex_unlock(&dev->ctxlist_mutex);
590 590
591 return 0; 591 return 0;
592} 592}