diff options
author | Eric Anholt <anholt@freebsd.org> | 2003-11-12 20:30:51 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2003-11-12 20:30:51 +0000 |
commit | 6e56c39371a551af1e05e53231162e0fc42c6ce0 (patch) | |
tree | 208ddc8abb26093a9da37732eaf903649e4971b0 | |
parent | 1f7598245af7e73b34130a44fbaac230e29d7aad (diff) |
Fix a locking nit, and add asserts in some things that should be callednewmesa-0-0-1-20031209driinterface-0-0-1-branch
with locks held.
-rw-r--r-- | bsd-core/drm_bufs.c | 2 | ||||
-rw-r--r-- | bsd-core/drm_drv.c | 10 | ||||
-rw-r--r-- | bsd-core/drm_fops.c | 5 | ||||
-rw-r--r-- | bsd-core/drm_os_freebsd.h | 2 | ||||
-rw-r--r-- | bsd/drm_bufs.h | 2 | ||||
-rw-r--r-- | bsd/drm_drv.h | 10 | ||||
-rw-r--r-- | bsd/drm_fops.h | 5 | ||||
-rw-r--r-- | bsd/drm_os_freebsd.h | 2 |
8 files changed, 24 insertions, 14 deletions
diff --git a/bsd-core/drm_bufs.c b/bsd-core/drm_bufs.c index 0915da84..15d4a3b1 100644 --- a/bsd-core/drm_bufs.c +++ b/bsd-core/drm_bufs.c @@ -145,8 +145,8 @@ int DRM(addmap)( DRM_IOCTL_ARGS ) DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); return DRM_ERR(EBUSY); } - DRM_UNLOCK(); dev->lock.hw_lock = map->handle; /* Pointer to lock */ + DRM_UNLOCK(); } break; #if __REALLY_HAVE_AGP diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c index 1083f9f9..bf1e2ac4 100644 --- a/bsd-core/drm_drv.c +++ b/bsd-core/drm_drv.c @@ -417,11 +417,13 @@ const char *DRM(find_description)(int vendor, int device) { return NULL; } -/* Initialize the DRM on first open. Called with device's lock held */ +/* Initialize the DRM on first open. */ static int DRM(setup)( drm_device_t *dev ) { int i; + DRM_SPINLOCK_ASSERT(&dev->dev_lock); + DRIVER_PRESETUP(); dev->buf_use = 0; @@ -496,9 +498,7 @@ static int DRM(setup)( drm_device_t *dev ) return 0; } -/* Free resources associated with the DRM on the last close. - * Called with the device's lock held. - */ +/* Free resources associated with the DRM on the last close. */ static int DRM(takedown)( drm_device_t *dev ) { drm_magic_entry_t *pt, *next; @@ -506,6 +506,8 @@ static int DRM(takedown)( drm_device_t *dev ) drm_map_list_entry_t *list; int i; + DRM_SPINLOCK_ASSERT(&dev->dev_lock); + DRM_DEBUG( "\n" ); DRIVER_PRETAKEDOWN(); diff --git a/bsd-core/drm_fops.c b/bsd-core/drm_fops.c index 55ef8ce0..e9c5d7a0 100644 --- a/bsd-core/drm_fops.c +++ b/bsd-core/drm_fops.c @@ -33,7 +33,6 @@ #include "drmP.h" -/* Requires device lock held */ drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_STRUCTPROC *p) { #if __FreeBSD_version >= 500021 @@ -45,6 +44,8 @@ drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_STRUCTPROC *p) #endif drm_file_t *priv; + DRM_SPINLOCK_ASSERT(&dev->dev_lock); + TAILQ_FOREACH(priv, &dev->files, link) if (priv->pid == pid && priv->uid == uid) return priv; @@ -65,7 +66,7 @@ int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p, DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m); DRM_LOCK(); - priv = (drm_file_t *) DRM(find_file_by_proc)(dev, p); + priv = DRM(find_file_by_proc)(dev, p); if (priv) { priv->refs++; } else { diff --git a/bsd-core/drm_os_freebsd.h b/bsd-core/drm_os_freebsd.h index 00a44023..31379b6a 100644 --- a/bsd-core/drm_os_freebsd.h +++ b/bsd-core/drm_os_freebsd.h @@ -122,6 +122,7 @@ #define DRM_SPINUNINIT(l) mtx_destroy(&l) #define DRM_SPINLOCK(l) mtx_lock(l) #define DRM_SPINUNLOCK(u) mtx_unlock(u); +#define DRM_SPINLOCK_ASSERT(l) mtx_assert(l, MA_OWNED) #define DRM_CURRENTPID curthread->td_proc->p_pid #define DRM_LOCK() mtx_lock(&dev->dev_lock) #define DRM_UNLOCK() mtx_unlock(&dev->dev_lock) @@ -137,6 +138,7 @@ #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() diff --git a/bsd/drm_bufs.h b/bsd/drm_bufs.h index 0915da84..15d4a3b1 100644 --- a/bsd/drm_bufs.h +++ b/bsd/drm_bufs.h @@ -145,8 +145,8 @@ int DRM(addmap)( DRM_IOCTL_ARGS ) DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); return DRM_ERR(EBUSY); } - DRM_UNLOCK(); dev->lock.hw_lock = map->handle; /* Pointer to lock */ + DRM_UNLOCK(); } break; #if __REALLY_HAVE_AGP diff --git a/bsd/drm_drv.h b/bsd/drm_drv.h index 1083f9f9..bf1e2ac4 100644 --- a/bsd/drm_drv.h +++ b/bsd/drm_drv.h @@ -417,11 +417,13 @@ const char *DRM(find_description)(int vendor, int device) { return NULL; } -/* Initialize the DRM on first open. Called with device's lock held */ +/* Initialize the DRM on first open. */ static int DRM(setup)( drm_device_t *dev ) { int i; + DRM_SPINLOCK_ASSERT(&dev->dev_lock); + DRIVER_PRESETUP(); dev->buf_use = 0; @@ -496,9 +498,7 @@ static int DRM(setup)( drm_device_t *dev ) return 0; } -/* Free resources associated with the DRM on the last close. - * Called with the device's lock held. - */ +/* Free resources associated with the DRM on the last close. */ static int DRM(takedown)( drm_device_t *dev ) { drm_magic_entry_t *pt, *next; @@ -506,6 +506,8 @@ static int DRM(takedown)( drm_device_t *dev ) drm_map_list_entry_t *list; int i; + DRM_SPINLOCK_ASSERT(&dev->dev_lock); + DRM_DEBUG( "\n" ); DRIVER_PRETAKEDOWN(); diff --git a/bsd/drm_fops.h b/bsd/drm_fops.h index 55ef8ce0..e9c5d7a0 100644 --- a/bsd/drm_fops.h +++ b/bsd/drm_fops.h @@ -33,7 +33,6 @@ #include "drmP.h" -/* Requires device lock held */ drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_STRUCTPROC *p) { #if __FreeBSD_version >= 500021 @@ -45,6 +44,8 @@ drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_STRUCTPROC *p) #endif drm_file_t *priv; + DRM_SPINLOCK_ASSERT(&dev->dev_lock); + TAILQ_FOREACH(priv, &dev->files, link) if (priv->pid == pid && priv->uid == uid) return priv; @@ -65,7 +66,7 @@ int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p, DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m); DRM_LOCK(); - priv = (drm_file_t *) DRM(find_file_by_proc)(dev, p); + priv = DRM(find_file_by_proc)(dev, p); if (priv) { priv->refs++; } else { diff --git a/bsd/drm_os_freebsd.h b/bsd/drm_os_freebsd.h index 00a44023..31379b6a 100644 --- a/bsd/drm_os_freebsd.h +++ b/bsd/drm_os_freebsd.h @@ -122,6 +122,7 @@ #define DRM_SPINUNINIT(l) mtx_destroy(&l) #define DRM_SPINLOCK(l) mtx_lock(l) #define DRM_SPINUNLOCK(u) mtx_unlock(u); +#define DRM_SPINLOCK_ASSERT(l) mtx_assert(l, MA_OWNED) #define DRM_CURRENTPID curthread->td_proc->p_pid #define DRM_LOCK() mtx_lock(&dev->dev_lock) #define DRM_UNLOCK() mtx_unlock(&dev->dev_lock) @@ -137,6 +138,7 @@ #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() |