summaryrefslogtreecommitdiff
path: root/bsd-core/drm_context.c
diff options
context:
space:
mode:
authorEric Anholt <anholt@freebsd.org>2004-11-07 04:11:15 +0000
committerEric Anholt <anholt@freebsd.org>2004-11-07 04:11:15 +0000
commita1d9e5abafe60ca2b7f96cadd1013695ada4ac41 (patch)
treeff8a462ecf2fea9ee35c8988ac0d9a37b7206808 /bsd-core/drm_context.c
parentc5bededa5130a58273448188c04c15bc9c1097f3 (diff)
Refine the locking of the DRM. Most significant is covering the driver
ioctls with dev_lock, which is a major step toward being able to remove Giant. Covers some new pieces (dev->unique*) in the core, and avoids one call down into system internals with the drm lock held, which is usually bad (FreeBSD LOR #23, #27).
Diffstat (limited to 'bsd-core/drm_context.c')
-rw-r--r--bsd-core/drm_context.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/bsd-core/drm_context.c b/bsd-core/drm_context.c
index d785d361..714edccc 100644
--- a/bsd-core/drm_context.c
+++ b/bsd-core/drm_context.c
@@ -229,15 +229,12 @@ int drm_context_switch_complete(drm_device_t *dev, int new)
int drm_resctx(DRM_IOCTL_ARGS)
{
drm_ctx_res_t res;
- drm_ctx_t ctx;
int i;
DRM_COPY_FROM_USER_IOCTL( res, (drm_ctx_res_t *)data, sizeof(res) );
if ( res.count >= DRM_RESERVED_CONTEXTS ) {
- bzero(&ctx, sizeof(ctx));
for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) {
- ctx.handle = i;
if ( DRM_COPY_TO_USER( &res.contexts[i],
&i, sizeof(i) ) )
return DRM_ERR(EFAULT);
@@ -269,8 +266,11 @@ int drm_addctx(DRM_IOCTL_ARGS)
return DRM_ERR(ENOMEM);
}
- if (dev->context_ctor && ctx.handle != DRM_KERNEL_CONTEXT)
+ if (dev->context_ctor && ctx.handle != DRM_KERNEL_CONTEXT) {
+ DRM_LOCK();
dev->context_ctor(dev, ctx.handle);
+ DRM_UNLOCK();
+ }
DRM_COPY_TO_USER_IOCTL( (drm_ctx_t *)data, ctx, sizeof(ctx) );
@@ -330,8 +330,11 @@ int drm_rmctx(DRM_IOCTL_ARGS)
DRM_DEBUG( "%d\n", ctx.handle );
if ( ctx.handle != DRM_KERNEL_CONTEXT ) {
- if (dev->context_dtor)
+ if (dev->context_dtor) {
+ DRM_LOCK();
dev->context_dtor(dev, ctx.handle);
+ DRM_UNLOCK();
+ }
drm_ctxbitmap_free(dev, ctx.handle);
}