diff --git a/sys/dev/drm/drmP.h b/sys/dev/drm/drmP.h index af50893..3ae7d9f 100644 --- a/sys/dev/drm/drmP.h +++ b/sys/dev/drm/drmP.h @@ -93,6 +93,7 @@ struct drm_file; #endif /* __FreeBSD_version >= 800004 */ #include #include +#include #include #include #include @@ -192,10 +193,10 @@ SYSCTL_DECL(_hw_drm); (void)irqflags; \ } while (0) #define DRM_SPINUNLOCK_IRQRESTORE(u, irqflags) mtx_unlock(u) -#define DRM_SPINLOCK_ASSERT(l) mtx_assert(l, MA_OWNED) +#define DRM_SPINLOCK_ASSERT(l) sx_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_LOCK() sx_xlock(&dev->dev_lock) +#define DRM_UNLOCK() sx_xunlock(&dev->dev_lock) #define DRM_SYSCTL_HANDLER_ARGS (SYSCTL_HANDLER_ARGS) #define DRM_IRQ_ARGS void *arg @@ -630,7 +631,7 @@ struct drm_device { struct mtx vbl_lock; /* protects vblank operations */ struct mtx dma_lock; /* protects dev->dma */ struct mtx irq_lock; /* protects irq condition checks */ - struct mtx dev_lock; /* protects everything else */ + struct sx dev_lock; /* protects everything else */ DRM_SPINTYPE drw_lock; /* Usage Counters */ diff --git a/sys/dev/drm/drm_drv.c b/sys/dev/drm/drm_drv.c index 8d9bc69..7d2cfa1 100644 --- a/sys/dev/drm/drm_drv.c +++ b/sys/dev/drm/drm_drv.c @@ -254,7 +254,7 @@ int drm_attach(device_t kdev, drm_pci_id_list_t *idlist) dev->irq = (int) rman_get_start(dev->irqr); } - mtx_init(&dev->dev_lock, "drmdev", NULL, MTX_DEF); + sx_init(&dev->dev_lock, "drmdev"); mtx_init(&dev->irq_lock, "drmirq", NULL, MTX_DEF); mtx_init(&dev->vbl_lock, "drmvbl", NULL, MTX_DEF); mtx_init(&dev->drw_lock, "drmdrw", NULL, MTX_DEF); @@ -516,7 +516,7 @@ error: mtx_destroy(&dev->drw_lock); mtx_destroy(&dev->vbl_lock); mtx_destroy(&dev->irq_lock); - mtx_destroy(&dev->dev_lock); + sx_destroy(&dev->dev_lock); return retcode; } @@ -581,7 +581,7 @@ static void drm_unload(struct drm_device *dev) mtx_destroy(&dev->drw_lock); mtx_destroy(&dev->vbl_lock); mtx_destroy(&dev->irq_lock); - mtx_destroy(&dev->dev_lock); + sx_destroy(&dev->dev_lock); } int drm_version(struct drm_device *dev, void *data, struct drm_file *file_priv) @@ -683,7 +683,7 @@ void drm_close(void *data) break; /* Got lock */ } /* Contention */ - retcode = mtx_sleep((void *)&dev->lock.lock_queue, + retcode = sx_sleep((void *)&dev->lock.lock_queue, &dev->dev_lock, PCATCH, "drmlk2", 0); if (retcode) break; diff --git a/sys/dev/drm/drm_lock.c b/sys/dev/drm/drm_lock.c index 28573c8..0b6bd82 100644 --- a/sys/dev/drm/drm_lock.c +++ b/sys/dev/drm/drm_lock.c @@ -81,7 +81,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv) } /* Contention */ - ret = mtx_sleep((void *)&dev->lock.lock_queue, &dev->dev_lock, + ret = sx_sleep((void *)&dev->lock.lock_queue, &dev->dev_lock, PCATCH, "drmlk2", 0); if (ret != 0) break; diff --git a/sys/dev/drm/drm_pci.c b/sys/dev/drm/drm_pci.c index afd6604..815eb3f 100644 --- a/sys/dev/drm/drm_pci.c +++ b/sys/dev/drm/drm_pci.c @@ -72,8 +72,8 @@ drm_pci_alloc(struct drm_device *dev, size_t size, return NULL; /* Make sure we aren't holding locks here */ - mtx_assert(&dev->dev_lock, MA_NOTOWNED); - if (mtx_owned(&dev->dev_lock)) + sx_assert(&dev->dev_lock, MA_NOTOWNED); + if (sx_xlocked(&dev->dev_lock)) DRM_ERROR("called while holding dev_lock\n"); mtx_assert(&dev->dma_lock, MA_NOTOWNED); if (mtx_owned(&dev->dma_lock)) diff --git a/sys/dev/drm/radeon_cp.c b/sys/dev/drm/radeon_cp.c index 0a486af..2dbde73 100644 --- a/sys/dev/drm/radeon_cp.c +++ b/sys/dev/drm/radeon_cp.c @@ -1697,13 +1697,13 @@ void radeon_do_release(struct drm_device * dev) if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600) { while ((ret = r600_do_cp_idle(dev_priv)) != 0) { DRM_DEBUG("radeon_do_cp_idle %d\n", ret); - mtx_sleep(&ret, &dev->dev_lock, 0, + sx_sleep(&ret, &dev->dev_lock, 0, "rdnrel", 1); } } else { while ((ret = radeon_do_cp_idle(dev_priv)) != 0) { DRM_DEBUG("radeon_do_cp_idle %d\n", ret); - mtx_sleep(&ret, &dev->dev_lock, 0, + sx_sleep(&ret, &dev->dev_lock, 0, "rdnrel", 1); } }