From 5c1d043535fa03f0f6ddde954e4cc00123fab0e0 Mon Sep 17 00:00:00 2001 From: Doug Rabson Date: Fri, 4 May 2001 12:22:52 +0000 Subject: [PATCH] More fixes for FreeBSD-current. --- bsd-core/drm_os_freebsd.h | 4 ++++ bsd/drm_os_freebsd.h | 4 ++++ linux-core/drmP.h | 2 +- linux-core/drm_auth.c | 9 ++++++++- linux-core/drm_drv.c | 10 +++++++++- linux-core/drm_memory.h | 6 +++++- linux/drmP.h | 2 +- linux/drm_auth.h | 9 ++++++++- linux/drm_drv.h | 10 +++++++++- linux/drm_memory.h | 6 +++++- 10 files changed, 54 insertions(+), 8 deletions(-) diff --git a/bsd-core/drm_os_freebsd.h b/bsd-core/drm_os_freebsd.h index ce949c4c..b1388b20 100644 --- a/bsd-core/drm_os_freebsd.h +++ b/bsd-core/drm_os_freebsd.h @@ -43,9 +43,13 @@ #define DRM_OS_LOCK lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc) #define DRM_OS_UNLOCK lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc) #if __FreeBSD_version >= 500000 +#define DRM_OS_SPINTYPE struct mtx +#define DRM_OS_SPININIT(l,name) mtx_init(l, name, MTX_DEF) #define DRM_OS_SPINLOCK(l) mtx_lock(l) #define DRM_OS_SPINUNLOCK(u) mtx_unlock(u); #else +#define DRM_OS_SPINTYPE struct simplelock +#define DRM_OS_SPININIT(l,name) simple_lock_init(l) #define DRM_OS_SPINLOCK(l) simple_lock(l) #define DRM_OS_SPINUNLOCK(u) simple_unlock(u); #endif diff --git a/bsd/drm_os_freebsd.h b/bsd/drm_os_freebsd.h index ce949c4c..b1388b20 100644 --- a/bsd/drm_os_freebsd.h +++ b/bsd/drm_os_freebsd.h @@ -43,9 +43,13 @@ #define DRM_OS_LOCK lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc) #define DRM_OS_UNLOCK lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc) #if __FreeBSD_version >= 500000 +#define DRM_OS_SPINTYPE struct mtx +#define DRM_OS_SPININIT(l,name) mtx_init(l, name, MTX_DEF) #define DRM_OS_SPINLOCK(l) mtx_lock(l) #define DRM_OS_SPINUNLOCK(u) mtx_unlock(u); #else +#define DRM_OS_SPINTYPE struct simplelock +#define DRM_OS_SPININIT(l,name) simple_lock_init(l) #define DRM_OS_SPINLOCK(l) simple_lock(l) #define DRM_OS_SPINUNLOCK(u) simple_unlock(u); #endif diff --git a/linux-core/drmP.h b/linux-core/drmP.h index e9da9ecc..831b2879 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -448,7 +448,7 @@ typedef struct drm_device { struct semaphore struct_sem; /* For others */ #endif #ifdef __FreeBSD__ - struct simplelock count_lock; /* For inuse, open_count, buf_use */ + DRM_OS_SPINTYPE count_lock; /* For inuse, open_count, buf_use */ struct lock dev_lock; /* For others */ #endif /* Usage Counters */ diff --git a/linux-core/drm_auth.c b/linux-core/drm_auth.c index c7969f76..bf2385f2 100644 --- a/linux-core/drm_auth.c +++ b/linux-core/drm_auth.c @@ -123,11 +123,18 @@ int DRM(getmagic)(DRM_OS_IOCTL) static spinlock_t lock = SPIN_LOCK_UNLOCKED; #endif #ifdef __FreeBSD__ - static struct simplelock lock; + static DRM_OS_SPINTYPE lock; + static int first = 1; #endif DRM_OS_DEVICE; DRM_OS_PRIV; +#ifdef __FreeBSD__ + if (first) { + DRM_OS_SPININIT(&lock, "drm getmagic"); + first = 0; + } +#endif /* Find unique magic */ if (priv->magic) { diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index 60a5a09c..af2c8078 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -286,7 +286,11 @@ static struct cdevsw DRM( cdevsw) = { /* dump */ nodump, /* psize */ nopsize, /* flags */ D_TTY | D_TRACKCLOSE, +#if __FreeBSD_version >= 500000 + /* kqfilter */ 0 +#else /* bmaj */ -1 +#endif }; #endif @@ -387,7 +391,11 @@ static int DRM(setup)( drm_device_t *dev ) init_waitqueue_head( &dev->context_wait ); #endif #ifdef __FreeBSD__ +#if __FreeBSD_version >= 500000 + callout_init( &dev->timer, 1 ); +#else callout_init( &dev->timer ); +#endif dev->context_wait = 0; #endif @@ -638,7 +646,7 @@ static int DRM(init)( device_t nbdev ) #endif #endif #ifdef __FreeBSD__ - simple_lock_init(&dev->count_lock); + DRM_OS_SPININIT(&dev->count_lock, "drm device"); lockinit(&dev->dev_lock, PZERO, "drmlk", 0, 0); #endif diff --git a/linux-core/drm_memory.h b/linux-core/drm_memory.h index dddaa75f..943e16e4 100644 --- a/linux-core/drm_memory.h +++ b/linux-core/drm_memory.h @@ -65,7 +65,7 @@ typedef struct drm_mem_stats { static spinlock_t DRM(mem_lock) = SPIN_LOCK_UNLOCKED; #endif #ifdef __FreeBSD__ -static struct simplelock DRM(mem_lock); +static DRM_OS_SPINTYPE DRM(mem_lock); #endif static unsigned long DRM(ram_available) = 0; /* In pages */ static unsigned long DRM(ram_used) = 0; @@ -101,6 +101,10 @@ void DRM(mem_init)(void) struct sysinfo si; #endif +#if defined(__FreeBSD__) + DRM_OS_SPININIT(&DRM(mem_lock), "drm memory"); +#endif + for (mem = DRM(mem_stats); mem->name; ++mem) { mem->succeed_count = 0; mem->free_count = 0; diff --git a/linux/drmP.h b/linux/drmP.h index e9da9ecc..831b2879 100644 --- a/linux/drmP.h +++ b/linux/drmP.h @@ -448,7 +448,7 @@ typedef struct drm_device { struct semaphore struct_sem; /* For others */ #endif #ifdef __FreeBSD__ - struct simplelock count_lock; /* For inuse, open_count, buf_use */ + DRM_OS_SPINTYPE count_lock; /* For inuse, open_count, buf_use */ struct lock dev_lock; /* For others */ #endif /* Usage Counters */ diff --git a/linux/drm_auth.h b/linux/drm_auth.h index c7969f76..bf2385f2 100644 --- a/linux/drm_auth.h +++ b/linux/drm_auth.h @@ -123,11 +123,18 @@ int DRM(getmagic)(DRM_OS_IOCTL) static spinlock_t lock = SPIN_LOCK_UNLOCKED; #endif #ifdef __FreeBSD__ - static struct simplelock lock; + static DRM_OS_SPINTYPE lock; + static int first = 1; #endif DRM_OS_DEVICE; DRM_OS_PRIV; +#ifdef __FreeBSD__ + if (first) { + DRM_OS_SPININIT(&lock, "drm getmagic"); + first = 0; + } +#endif /* Find unique magic */ if (priv->magic) { diff --git a/linux/drm_drv.h b/linux/drm_drv.h index 60a5a09c..af2c8078 100644 --- a/linux/drm_drv.h +++ b/linux/drm_drv.h @@ -286,7 +286,11 @@ static struct cdevsw DRM( cdevsw) = { /* dump */ nodump, /* psize */ nopsize, /* flags */ D_TTY | D_TRACKCLOSE, +#if __FreeBSD_version >= 500000 + /* kqfilter */ 0 +#else /* bmaj */ -1 +#endif }; #endif @@ -387,7 +391,11 @@ static int DRM(setup)( drm_device_t *dev ) init_waitqueue_head( &dev->context_wait ); #endif #ifdef __FreeBSD__ +#if __FreeBSD_version >= 500000 + callout_init( &dev->timer, 1 ); +#else callout_init( &dev->timer ); +#endif dev->context_wait = 0; #endif @@ -638,7 +646,7 @@ static int DRM(init)( device_t nbdev ) #endif #endif #ifdef __FreeBSD__ - simple_lock_init(&dev->count_lock); + DRM_OS_SPININIT(&dev->count_lock, "drm device"); lockinit(&dev->dev_lock, PZERO, "drmlk", 0, 0); #endif diff --git a/linux/drm_memory.h b/linux/drm_memory.h index dddaa75f..943e16e4 100644 --- a/linux/drm_memory.h +++ b/linux/drm_memory.h @@ -65,7 +65,7 @@ typedef struct drm_mem_stats { static spinlock_t DRM(mem_lock) = SPIN_LOCK_UNLOCKED; #endif #ifdef __FreeBSD__ -static struct simplelock DRM(mem_lock); +static DRM_OS_SPINTYPE DRM(mem_lock); #endif static unsigned long DRM(ram_available) = 0; /* In pages */ static unsigned long DRM(ram_used) = 0; @@ -101,6 +101,10 @@ void DRM(mem_init)(void) struct sysinfo si; #endif +#if defined(__FreeBSD__) + DRM_OS_SPININIT(&DRM(mem_lock), "drm memory"); +#endif + for (mem = DRM(mem_stats); mem->name; ++mem) { mem->succeed_count = 0; mem->free_count = 0;