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/drmP.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'bsd-core/drmP.h') diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h index 17af0d18..43e22039 100644 --- a/bsd-core/drmP.h +++ b/bsd-core/drmP.h @@ -197,6 +197,7 @@ MALLOC_DECLARE(M_DRM); #define DRM_SPINUNINIT(l) #define DRM_SPINLOCK(l) #define DRM_SPINUNLOCK(u) +#define DRM_SPINLOCK_ASSERT(l) #define DRM_CURRENTPID curproc->p_pid #define DRM_LOCK() #define DRM_UNLOCK() @@ -353,9 +354,7 @@ do { \ DRM_ERROR("filp doesn't match curproc\n"); \ return EINVAL; \ } \ - DRM_LOCK(); \ _priv = drm_find_file_by_proc(dev, DRM_CURPROC); \ - DRM_UNLOCK(); \ if (_priv == NULL) { \ DRM_ERROR("can't find authenticator\n"); \ return EINVAL; \ @@ -375,6 +374,7 @@ do { \ #define DRM_GETSAREA() \ do { \ drm_map_list_entry_t *listentry; \ + DRM_SPINLOCK_ASSERT(&dev->dev_lock); \ TAILQ_FOREACH(listentry, dev->maplist, link) { \ drm_local_map_t *map = listentry->map; \ if (map->type == _DRM_SHM && \ @@ -388,11 +388,13 @@ do { \ #if defined(__FreeBSD__) && __FreeBSD_version > 500000 #define DRM_WAIT_ON( ret, queue, timeout, condition ) \ for ( ret = 0 ; !ret && !(condition) ; ) { \ + DRM_UNLOCK(); \ mtx_lock(&dev->irq_lock); \ if (!(condition)) \ - ret = msleep(&(queue), &dev->irq_lock, \ + ret = msleep(&(queue), &dev->irq_lock, \ PZERO | PCATCH, "drmwtq", (timeout)); \ - mtx_unlock(&dev->irq_lock); \ + mtx_unlock(&dev->irq_lock); \ + DRM_LOCK(); \ } #else #define DRM_WAIT_ON( ret, queue, timeout, condition ) \ @@ -527,10 +529,6 @@ typedef struct drm_device_dma { _DRM_DMA_USE_AGP = 0x01, _DRM_DMA_USE_SG = 0x02 } flags; - - /* DMA support */ - drm_buf_t *this_buffer; /* Buffer being sent */ - drm_buf_t *next_buffer; /* Selected buffer to send */ } drm_device_dma_t; typedef struct drm_agp_mem { -- cgit v1.2.3