mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-20 19:50:12 +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) */
|
/* Memory management support (drm_memory.h) */
|
||||||
extern void DRM(mem_init)(void);
|
extern void DRM(mem_init)(void);
|
||||||
|
extern void DRM(mem_uninit)(void);
|
||||||
extern void *DRM(alloc)(size_t size, int area);
|
extern void *DRM(alloc)(size_t size, int area);
|
||||||
extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
|
extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
|
||||||
int area);
|
int area);
|
||||||
|
|
|
||||||
|
|
@ -116,25 +116,20 @@ int DRM(getmagic)(DRM_IOCTL_ARGS)
|
||||||
{
|
{
|
||||||
static drm_magic_t sequence = 0;
|
static drm_magic_t sequence = 0;
|
||||||
drm_auth_t auth;
|
drm_auth_t auth;
|
||||||
static DRM_SPINTYPE lock;
|
|
||||||
static int first = 1;
|
|
||||||
DRM_DEVICE;
|
DRM_DEVICE;
|
||||||
DRM_PRIV;
|
DRM_PRIV;
|
||||||
|
|
||||||
if (first) {
|
|
||||||
DRM_SPININIT(lock, "drm getmagic");
|
|
||||||
first = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find unique magic */
|
/* Find unique magic */
|
||||||
if (priv->magic) {
|
if (priv->magic) {
|
||||||
auth.magic = priv->magic;
|
auth.magic = priv->magic;
|
||||||
} else {
|
} else {
|
||||||
do {
|
do {
|
||||||
DRM_SPINLOCK(&lock);
|
int old = sequence;
|
||||||
if (!sequence) ++sequence; /* reserve 0 */
|
|
||||||
auth.magic = sequence++;
|
auth.magic = old+1;
|
||||||
DRM_SPINUNLOCK(&lock);
|
|
||||||
|
if (!atomic_cmpset_int(&sequence, old, auth.magic))
|
||||||
|
continue;
|
||||||
} while (DRM(find_file)(dev, auth.magic));
|
} while (DRM(find_file)(dev, auth.magic));
|
||||||
priv->magic = auth.magic;
|
priv->magic = auth.magic;
|
||||||
DRM(add_magic)(dev, priv, auth.magic);
|
DRM(add_magic)(dev, priv, auth.magic);
|
||||||
|
|
|
||||||
|
|
@ -814,6 +814,8 @@ static void DRM(cleanup)(drm_device_t *dev)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
DRIVER_POSTCLEANUP();
|
DRIVER_POSTCLEANUP();
|
||||||
|
DRM(mem_uninit)();
|
||||||
|
DRM_SPINUNINIT(dev->count_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,11 @@ void DRM(mem_init)(void)
|
||||||
DRM(ram_used) = 0;
|
DRM(ram_used) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DRM(mem_uninit)(void)
|
||||||
|
{
|
||||||
|
DRM_SPINUNINIT(DRM(mem_lock));
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
/* drm_mem_info is called whenever a process reads /dev/drm/mem. */
|
/* drm_mem_info is called whenever a process reads /dev/drm/mem. */
|
||||||
static int DRM(_mem_info) DRM_SYSCTL_HANDLER_ARGS
|
static int DRM(_mem_info) DRM_SYSCTL_HANDLER_ARGS
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@
|
||||||
#define DRM_STRUCTPROC struct thread
|
#define DRM_STRUCTPROC struct thread
|
||||||
#define DRM_SPINTYPE struct mtx
|
#define DRM_SPINTYPE struct mtx
|
||||||
#define DRM_SPININIT(l,name) mtx_init(&l, name, NULL, MTX_DEF)
|
#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_SPINLOCK(l) mtx_lock(l)
|
||||||
#define DRM_SPINUNLOCK(u) mtx_unlock(u);
|
#define DRM_SPINUNLOCK(u) mtx_unlock(u);
|
||||||
#define DRM_CURRENTPID curthread->td_proc->p_pid
|
#define DRM_CURRENTPID curthread->td_proc->p_pid
|
||||||
|
|
@ -87,6 +88,7 @@
|
||||||
#define DRM_STRUCTPROC struct proc
|
#define DRM_STRUCTPROC struct proc
|
||||||
#define DRM_SPINTYPE struct simplelock
|
#define DRM_SPINTYPE struct simplelock
|
||||||
#define DRM_SPININIT(l,name) simple_lock_init(&l)
|
#define DRM_SPININIT(l,name) simple_lock_init(&l)
|
||||||
|
#define DRM_SPINUNINIT(l,name)
|
||||||
#define DRM_SPINLOCK(l) simple_lock(l)
|
#define DRM_SPINLOCK(l) simple_lock(l)
|
||||||
#define DRM_SPINUNLOCK(u) simple_unlock(u);
|
#define DRM_SPINUNLOCK(u) simple_unlock(u);
|
||||||
#define DRM_CURRENTPID curproc->p_pid
|
#define DRM_CURRENTPID curproc->p_pid
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ extern struct cfdriver DRM(_cd);
|
||||||
#define DRM_STRUCTPROC struct proc
|
#define DRM_STRUCTPROC struct proc
|
||||||
#define DRM_SPINTYPE struct simplelock
|
#define DRM_SPINTYPE struct simplelock
|
||||||
#define DRM_SPININIT(l,name) simple_lock_init(&l)
|
#define DRM_SPININIT(l,name) simple_lock_init(&l)
|
||||||
|
#define DRM_SPINUNINIT(l)
|
||||||
#define DRM_SPINLOCK(l) simple_lock(l)
|
#define DRM_SPINLOCK(l) simple_lock(l)
|
||||||
#define DRM_SPINUNLOCK(u) simple_unlock(u);
|
#define DRM_SPINUNLOCK(u) simple_unlock(u);
|
||||||
#define DRM_CURRENTPID curproc->p_pid
|
#define DRM_CURRENTPID curproc->p_pid
|
||||||
|
|
|
||||||
|
|
@ -520,6 +520,7 @@ extern int DRM(write_string)(drm_device_t *dev, const char *s);
|
||||||
|
|
||||||
/* Memory management support (drm_memory.h) */
|
/* Memory management support (drm_memory.h) */
|
||||||
extern void DRM(mem_init)(void);
|
extern void DRM(mem_init)(void);
|
||||||
|
extern void DRM(mem_uninit)(void);
|
||||||
extern void *DRM(alloc)(size_t size, int area);
|
extern void *DRM(alloc)(size_t size, int area);
|
||||||
extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
|
extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
|
||||||
int area);
|
int area);
|
||||||
|
|
|
||||||
|
|
@ -116,25 +116,20 @@ int DRM(getmagic)(DRM_IOCTL_ARGS)
|
||||||
{
|
{
|
||||||
static drm_magic_t sequence = 0;
|
static drm_magic_t sequence = 0;
|
||||||
drm_auth_t auth;
|
drm_auth_t auth;
|
||||||
static DRM_SPINTYPE lock;
|
|
||||||
static int first = 1;
|
|
||||||
DRM_DEVICE;
|
DRM_DEVICE;
|
||||||
DRM_PRIV;
|
DRM_PRIV;
|
||||||
|
|
||||||
if (first) {
|
|
||||||
DRM_SPININIT(lock, "drm getmagic");
|
|
||||||
first = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find unique magic */
|
/* Find unique magic */
|
||||||
if (priv->magic) {
|
if (priv->magic) {
|
||||||
auth.magic = priv->magic;
|
auth.magic = priv->magic;
|
||||||
} else {
|
} else {
|
||||||
do {
|
do {
|
||||||
DRM_SPINLOCK(&lock);
|
int old = sequence;
|
||||||
if (!sequence) ++sequence; /* reserve 0 */
|
|
||||||
auth.magic = sequence++;
|
auth.magic = old+1;
|
||||||
DRM_SPINUNLOCK(&lock);
|
|
||||||
|
if (!atomic_cmpset_int(&sequence, old, auth.magic))
|
||||||
|
continue;
|
||||||
} while (DRM(find_file)(dev, auth.magic));
|
} while (DRM(find_file)(dev, auth.magic));
|
||||||
priv->magic = auth.magic;
|
priv->magic = auth.magic;
|
||||||
DRM(add_magic)(dev, priv, auth.magic);
|
DRM(add_magic)(dev, priv, auth.magic);
|
||||||
|
|
|
||||||
|
|
@ -814,6 +814,8 @@ static void DRM(cleanup)(drm_device_t *dev)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
DRIVER_POSTCLEANUP();
|
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);
|
if(!bl->bufs) return DRM_ERR(ENOMEM);
|
||||||
|
|
||||||
memset(bl->bufs, 0, sizeof(*bl->bufs));
|
bzero(bl->bufs, sizeof(*bl->bufs));
|
||||||
|
|
||||||
bl->count = count;
|
bl->count = count;
|
||||||
bl->rp = bl->bufs;
|
bl->rp = bl->bufs;
|
||||||
|
|
@ -66,6 +66,8 @@ int DRM(waitlist_destroy)(drm_waitlist_t *bl)
|
||||||
bl->rp = NULL;
|
bl->rp = NULL;
|
||||||
bl->wp = NULL;
|
bl->wp = NULL;
|
||||||
bl->end = NULL;
|
bl->end = NULL;
|
||||||
|
DRM_SPINUNINIT( bl->write_lock );
|
||||||
|
DRM_SPINUNINIT( bl->read_lock );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,6 +139,7 @@ int DRM(freelist_destroy)(drm_freelist_t *bl)
|
||||||
{
|
{
|
||||||
atomic_set(&bl->count, 0);
|
atomic_set(&bl->count, 0);
|
||||||
bl->next = NULL;
|
bl->next = NULL;
|
||||||
|
DRM_SPINUNINIT( bl->lock );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,11 @@ void DRM(mem_init)(void)
|
||||||
DRM(ram_used) = 0;
|
DRM(ram_used) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DRM(mem_uninit)(void)
|
||||||
|
{
|
||||||
|
DRM_SPINUNINIT(DRM(mem_lock));
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
/* drm_mem_info is called whenever a process reads /dev/drm/mem. */
|
/* drm_mem_info is called whenever a process reads /dev/drm/mem. */
|
||||||
static int DRM(_mem_info) DRM_SYSCTL_HANDLER_ARGS
|
static int DRM(_mem_info) DRM_SYSCTL_HANDLER_ARGS
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@
|
||||||
#define DRM_STRUCTPROC struct thread
|
#define DRM_STRUCTPROC struct thread
|
||||||
#define DRM_SPINTYPE struct mtx
|
#define DRM_SPINTYPE struct mtx
|
||||||
#define DRM_SPININIT(l,name) mtx_init(&l, name, NULL, MTX_DEF)
|
#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_SPINLOCK(l) mtx_lock(l)
|
||||||
#define DRM_SPINUNLOCK(u) mtx_unlock(u);
|
#define DRM_SPINUNLOCK(u) mtx_unlock(u);
|
||||||
#define DRM_CURRENTPID curthread->td_proc->p_pid
|
#define DRM_CURRENTPID curthread->td_proc->p_pid
|
||||||
|
|
@ -87,6 +88,7 @@
|
||||||
#define DRM_STRUCTPROC struct proc
|
#define DRM_STRUCTPROC struct proc
|
||||||
#define DRM_SPINTYPE struct simplelock
|
#define DRM_SPINTYPE struct simplelock
|
||||||
#define DRM_SPININIT(l,name) simple_lock_init(&l)
|
#define DRM_SPININIT(l,name) simple_lock_init(&l)
|
||||||
|
#define DRM_SPINUNINIT(l,name)
|
||||||
#define DRM_SPINLOCK(l) simple_lock(l)
|
#define DRM_SPINLOCK(l) simple_lock(l)
|
||||||
#define DRM_SPINUNLOCK(u) simple_unlock(u);
|
#define DRM_SPINUNLOCK(u) simple_unlock(u);
|
||||||
#define DRM_CURRENTPID curproc->p_pid
|
#define DRM_CURRENTPID curproc->p_pid
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ extern struct cfdriver DRM(_cd);
|
||||||
#define DRM_STRUCTPROC struct proc
|
#define DRM_STRUCTPROC struct proc
|
||||||
#define DRM_SPINTYPE struct simplelock
|
#define DRM_SPINTYPE struct simplelock
|
||||||
#define DRM_SPININIT(l,name) simple_lock_init(&l)
|
#define DRM_SPININIT(l,name) simple_lock_init(&l)
|
||||||
|
#define DRM_SPINUNINIT(l)
|
||||||
#define DRM_SPINLOCK(l) simple_lock(l)
|
#define DRM_SPINLOCK(l) simple_lock(l)
|
||||||
#define DRM_SPINUNLOCK(u) simple_unlock(u);
|
#define DRM_SPINUNLOCK(u) simple_unlock(u);
|
||||||
#define DRM_CURRENTPID curproc->p_pid
|
#define DRM_CURRENTPID curproc->p_pid
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue