mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-20 10:30:11 +01:00
Unitialize mutexes on cleanup, fixes panics on 5.0 with WITNESS.
This commit is contained in:
parent
6f79735e8a
commit
6e37c20647
13 changed files with 44 additions and 29 deletions
|
|
@ -520,6 +520,7 @@ extern int DRM(write_string)(drm_device_t *dev, const char *s);
|
|||
|
||||
/* Memory management support (drm_memory.h) */
|
||||
extern void DRM(mem_init)(void);
|
||||
extern void DRM(mem_uninit)(void);
|
||||
extern void *DRM(alloc)(size_t size, int area);
|
||||
extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
|
||||
int area);
|
||||
|
|
|
|||
|
|
@ -116,25 +116,20 @@ int DRM(getmagic)(DRM_IOCTL_ARGS)
|
|||
{
|
||||
static drm_magic_t sequence = 0;
|
||||
drm_auth_t auth;
|
||||
static DRM_SPINTYPE lock;
|
||||
static int first = 1;
|
||||
DRM_DEVICE;
|
||||
DRM_PRIV;
|
||||
|
||||
if (first) {
|
||||
DRM_SPININIT(lock, "drm getmagic");
|
||||
first = 0;
|
||||
}
|
||||
|
||||
/* Find unique magic */
|
||||
if (priv->magic) {
|
||||
auth.magic = priv->magic;
|
||||
} else {
|
||||
do {
|
||||
DRM_SPINLOCK(&lock);
|
||||
if (!sequence) ++sequence; /* reserve 0 */
|
||||
auth.magic = sequence++;
|
||||
DRM_SPINUNLOCK(&lock);
|
||||
int old = sequence;
|
||||
|
||||
auth.magic = old+1;
|
||||
|
||||
if (!atomic_cmpset_int(&sequence, old, auth.magic))
|
||||
continue;
|
||||
} while (DRM(find_file)(dev, auth.magic));
|
||||
priv->magic = auth.magic;
|
||||
DRM(add_magic)(dev, priv, auth.magic);
|
||||
|
|
|
|||
|
|
@ -814,6 +814,8 @@ static void DRM(cleanup)(drm_device_t *dev)
|
|||
}
|
||||
#endif
|
||||
DRIVER_POSTCLEANUP();
|
||||
DRM(mem_uninit)();
|
||||
DRM_SPINUNINIT(dev->count_lock);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -95,6 +95,11 @@ void DRM(mem_init)(void)
|
|||
DRM(ram_used) = 0;
|
||||
}
|
||||
|
||||
void DRM(mem_uninit)(void)
|
||||
{
|
||||
DRM_SPINUNINIT(DRM(mem_lock));
|
||||
}
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
/* drm_mem_info is called whenever a process reads /dev/drm/mem. */
|
||||
static int DRM(_mem_info) DRM_SYSCTL_HANDLER_ARGS
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@
|
|||
#define DRM_STRUCTPROC struct thread
|
||||
#define DRM_SPINTYPE struct mtx
|
||||
#define DRM_SPININIT(l,name) mtx_init(&l, name, NULL, MTX_DEF)
|
||||
#define DRM_SPINUNINIT(l) mtx_destroy(&l)
|
||||
#define DRM_SPINLOCK(l) mtx_lock(l)
|
||||
#define DRM_SPINUNLOCK(u) mtx_unlock(u);
|
||||
#define DRM_CURRENTPID curthread->td_proc->p_pid
|
||||
|
|
@ -87,6 +88,7 @@
|
|||
#define DRM_STRUCTPROC struct proc
|
||||
#define DRM_SPINTYPE struct simplelock
|
||||
#define DRM_SPININIT(l,name) simple_lock_init(&l)
|
||||
#define DRM_SPINUNINIT(l,name)
|
||||
#define DRM_SPINLOCK(l) simple_lock(l)
|
||||
#define DRM_SPINUNLOCK(u) simple_unlock(u);
|
||||
#define DRM_CURRENTPID curproc->p_pid
|
||||
|
|
|
|||
|
|
@ -60,12 +60,13 @@ extern struct cfdriver DRM(_cd);
|
|||
#define CDEV_MAJOR 90
|
||||
|
||||
#define DRM_CURPROC curproc
|
||||
#define DRM_STRUCTPROC struct proc
|
||||
#define DRM_STRUCTPROC struct proc
|
||||
#define DRM_SPINTYPE struct simplelock
|
||||
#define DRM_SPININIT(l,name) simple_lock_init(&l)
|
||||
#define DRM_SPINLOCK(l) simple_lock(l)
|
||||
#define DRM_SPINUNINIT(l)
|
||||
#define DRM_SPINLOCK(l) simple_lock(l)
|
||||
#define DRM_SPINUNLOCK(u) simple_unlock(u);
|
||||
#define DRM_CURRENTPID curproc->p_pid
|
||||
#define DRM_CURRENTPID curproc->p_pid
|
||||
|
||||
#define DRM_IOCTL_ARGS dev_t kdev, u_long cmd, caddr_t data, int flags, DRM_STRUCTPROC *p
|
||||
#define DRM_LOCK lockmgr(&dev->dev_lock, LK_EXCLUSIVE, NULL)
|
||||
|
|
|
|||
|
|
@ -520,6 +520,7 @@ extern int DRM(write_string)(drm_device_t *dev, const char *s);
|
|||
|
||||
/* Memory management support (drm_memory.h) */
|
||||
extern void DRM(mem_init)(void);
|
||||
extern void DRM(mem_uninit)(void);
|
||||
extern void *DRM(alloc)(size_t size, int area);
|
||||
extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
|
||||
int area);
|
||||
|
|
|
|||
|
|
@ -116,25 +116,20 @@ int DRM(getmagic)(DRM_IOCTL_ARGS)
|
|||
{
|
||||
static drm_magic_t sequence = 0;
|
||||
drm_auth_t auth;
|
||||
static DRM_SPINTYPE lock;
|
||||
static int first = 1;
|
||||
DRM_DEVICE;
|
||||
DRM_PRIV;
|
||||
|
||||
if (first) {
|
||||
DRM_SPININIT(lock, "drm getmagic");
|
||||
first = 0;
|
||||
}
|
||||
|
||||
/* Find unique magic */
|
||||
if (priv->magic) {
|
||||
auth.magic = priv->magic;
|
||||
} else {
|
||||
do {
|
||||
DRM_SPINLOCK(&lock);
|
||||
if (!sequence) ++sequence; /* reserve 0 */
|
||||
auth.magic = sequence++;
|
||||
DRM_SPINUNLOCK(&lock);
|
||||
int old = sequence;
|
||||
|
||||
auth.magic = old+1;
|
||||
|
||||
if (!atomic_cmpset_int(&sequence, old, auth.magic))
|
||||
continue;
|
||||
} while (DRM(find_file)(dev, auth.magic));
|
||||
priv->magic = auth.magic;
|
||||
DRM(add_magic)(dev, priv, auth.magic);
|
||||
|
|
|
|||
|
|
@ -814,6 +814,8 @@ static void DRM(cleanup)(drm_device_t *dev)
|
|||
}
|
||||
#endif
|
||||
DRIVER_POSTCLEANUP();
|
||||
DRM(mem_uninit)();
|
||||
DRM_SPINUNINIT(dev->count_lock);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ int DRM(waitlist_create)(drm_waitlist_t *bl, int count)
|
|||
|
||||
if(!bl->bufs) return DRM_ERR(ENOMEM);
|
||||
|
||||
memset(bl->bufs, 0, sizeof(*bl->bufs));
|
||||
bzero(bl->bufs, sizeof(*bl->bufs));
|
||||
|
||||
bl->count = count;
|
||||
bl->rp = bl->bufs;
|
||||
|
|
@ -66,6 +66,8 @@ int DRM(waitlist_destroy)(drm_waitlist_t *bl)
|
|||
bl->rp = NULL;
|
||||
bl->wp = NULL;
|
||||
bl->end = NULL;
|
||||
DRM_SPINUNINIT( bl->write_lock );
|
||||
DRM_SPINUNINIT( bl->read_lock );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -137,6 +139,7 @@ int DRM(freelist_destroy)(drm_freelist_t *bl)
|
|||
{
|
||||
atomic_set(&bl->count, 0);
|
||||
bl->next = NULL;
|
||||
DRM_SPINUNINIT( bl->lock );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,6 +95,11 @@ void DRM(mem_init)(void)
|
|||
DRM(ram_used) = 0;
|
||||
}
|
||||
|
||||
void DRM(mem_uninit)(void)
|
||||
{
|
||||
DRM_SPINUNINIT(DRM(mem_lock));
|
||||
}
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
/* drm_mem_info is called whenever a process reads /dev/drm/mem. */
|
||||
static int DRM(_mem_info) DRM_SYSCTL_HANDLER_ARGS
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@
|
|||
#define DRM_STRUCTPROC struct thread
|
||||
#define DRM_SPINTYPE struct mtx
|
||||
#define DRM_SPININIT(l,name) mtx_init(&l, name, NULL, MTX_DEF)
|
||||
#define DRM_SPINUNINIT(l) mtx_destroy(&l)
|
||||
#define DRM_SPINLOCK(l) mtx_lock(l)
|
||||
#define DRM_SPINUNLOCK(u) mtx_unlock(u);
|
||||
#define DRM_CURRENTPID curthread->td_proc->p_pid
|
||||
|
|
@ -87,6 +88,7 @@
|
|||
#define DRM_STRUCTPROC struct proc
|
||||
#define DRM_SPINTYPE struct simplelock
|
||||
#define DRM_SPININIT(l,name) simple_lock_init(&l)
|
||||
#define DRM_SPINUNINIT(l,name)
|
||||
#define DRM_SPINLOCK(l) simple_lock(l)
|
||||
#define DRM_SPINUNLOCK(u) simple_unlock(u);
|
||||
#define DRM_CURRENTPID curproc->p_pid
|
||||
|
|
|
|||
|
|
@ -60,12 +60,13 @@ extern struct cfdriver DRM(_cd);
|
|||
#define CDEV_MAJOR 90
|
||||
|
||||
#define DRM_CURPROC curproc
|
||||
#define DRM_STRUCTPROC struct proc
|
||||
#define DRM_STRUCTPROC struct proc
|
||||
#define DRM_SPINTYPE struct simplelock
|
||||
#define DRM_SPININIT(l,name) simple_lock_init(&l)
|
||||
#define DRM_SPINLOCK(l) simple_lock(l)
|
||||
#define DRM_SPINUNINIT(l)
|
||||
#define DRM_SPINLOCK(l) simple_lock(l)
|
||||
#define DRM_SPINUNLOCK(u) simple_unlock(u);
|
||||
#define DRM_CURRENTPID curproc->p_pid
|
||||
#define DRM_CURRENTPID curproc->p_pid
|
||||
|
||||
#define DRM_IOCTL_ARGS dev_t kdev, u_long cmd, caddr_t data, int flags, DRM_STRUCTPROC *p
|
||||
#define DRM_LOCK lockmgr(&dev->dev_lock, LK_EXCLUSIVE, NULL)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue