with locks held.
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
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;
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;
drm_map_list_entry_t *list;
int i;
+ DRM_SPINLOCK_ASSERT(&dev->dev_lock);
+
DRM_DEBUG( "\n" );
DRIVER_PRETAKEDOWN();
#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
#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;
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 {
#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)
#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()
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
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;
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;
drm_map_list_entry_t *list;
int i;
+ DRM_SPINLOCK_ASSERT(&dev->dev_lock);
+
DRM_DEBUG( "\n" );
DRIVER_PRETAKEDOWN();
#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
#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;
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 {
#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)
#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()