From a1d9e5abafe60ca2b7f96cadd1013695ada4ac41 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 7 Nov 2004 04:11:15 +0000 Subject: 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). --- bsd-core/drm_context.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'bsd-core/drm_context.c') 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); } -- cgit v1.2.3