From 05d841b38b42704c92dd656dbffc988600ea7656 Mon Sep 17 00:00:00 2001 From: Robert Noland Date: Fri, 23 Apr 2010 14:48:30 +0000 Subject: [PATCH] Address some WITNESS panics that occur when using the via driver. Some of these cases should be safe in a non-atomic fashion, however since all of the driver ioctls are locked, a lot of work is required to fix it correctly. Just don't sleep now. MFC after: 2 weeks --- sys/dev/drm/drmP.h | 2 +- sys/dev/drm/drm_hashtab.c | 3 ++- sys/dev/drm/drm_mm.c | 3 ++- sys/dev/drm/drm_sman.c | 10 +++++----- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/sys/dev/drm/drmP.h b/sys/dev/drm/drmP.h index 26bda43659dc..3699460a706b 100644 --- a/sys/dev/drm/drmP.h +++ b/sys/dev/drm/drmP.h @@ -228,7 +228,7 @@ enum { #define DRM_MTRR_WC MDF_WRITECOMBINE #define jiffies ticks -typedef unsigned long dma_addr_t; +typedef vm_paddr_t dma_addr_t; typedef u_int64_t u64; typedef u_int32_t u32; typedef u_int16_t u16; diff --git a/sys/dev/drm/drm_hashtab.c b/sys/dev/drm/drm_hashtab.c index e98f1026cf52..360c02bfada5 100644 --- a/sys/dev/drm/drm_hashtab.c +++ b/sys/dev/drm/drm_hashtab.c @@ -46,7 +46,8 @@ int drm_ht_create(struct drm_open_hash *ht, unsigned int order) ht->size = 1 << order; ht->order = order; ht->table = NULL; - ht->table = hashinit(ht->size, DRM_MEM_HASHTAB, &ht->mask); + ht->table = hashinit_flags(ht->size, DRM_MEM_HASHTAB, &ht->mask, + HASH_NOWAIT); if (!ht->table) { DRM_ERROR("Out of memory for hash table\n"); return -ENOMEM; diff --git a/sys/dev/drm/drm_mm.c b/sys/dev/drm/drm_mm.c index 344436fd22d9..bab36c1117a7 100644 --- a/sys/dev/drm/drm_mm.c +++ b/sys/dev/drm/drm_mm.c @@ -333,7 +333,8 @@ int drm_mm_init(struct drm_mm * mm, unsigned long start, unsigned long size) mm->num_unused = 0; mtx_init(&mm->unused_lock, "drm_unused", NULL, MTX_DEF); - return drm_mm_create_tail_node(mm, start, size, 0); + /* XXX This could be non-atomic but gets called from a locked path */ + return drm_mm_create_tail_node(mm, start, size, 1); } void drm_mm_takedown(struct drm_mm * mm) diff --git a/sys/dev/drm/drm_sman.c b/sys/dev/drm/drm_sman.c index 9f1132ce2b2f..32f9eb9e4655 100644 --- a/sys/dev/drm/drm_sman.c +++ b/sys/dev/drm/drm_sman.c @@ -96,7 +96,8 @@ static void *drm_sman_mm_allocate(void *private, unsigned long size, if (!tmp) { return NULL; } - tmp = drm_mm_get_block(tmp, size, alignment); + /* This could be non-atomic, but we are called from a locked path */ + tmp = drm_mm_get_block_atomic(tmp, size, alignment); return tmp; } @@ -131,7 +132,7 @@ drm_sman_set_range(struct drm_sman * sman, unsigned int manager, KASSERT(manager < sman->num_managers, ("Invalid manager")); sman_mm = &sman->mm[manager]; - mm = malloc(sizeof(*mm), DRM_MEM_MM, M_WAITOK | M_ZERO); + mm = malloc(sizeof(*mm), DRM_MEM_MM, M_NOWAIT | M_ZERO); if (!mm) { return -ENOMEM; } @@ -174,7 +175,7 @@ static struct drm_owner_item *drm_sman_get_owner_item(struct drm_sman * sman, owner_hash); } - owner_item = malloc(sizeof(*owner_item), DRM_MEM_MM, M_WAITOK | M_ZERO); + owner_item = malloc(sizeof(*owner_item), DRM_MEM_MM, M_NOWAIT | M_ZERO); if (!owner_item) goto out; @@ -206,12 +207,11 @@ struct drm_memblock_item *drm_sman_alloc(struct drm_sman *sman, unsigned int man sman_mm = &sman->mm[manager]; tmp = sman_mm->allocate(sman_mm->private, size, alignment); - if (!tmp) { return NULL; } - memblock = malloc(sizeof(*memblock), DRM_MEM_MM, M_WAITOK | M_ZERO); + memblock = malloc(sizeof(*memblock), DRM_MEM_MM, M_NOWAIT | M_ZERO); DRM_DEBUG("allocated mem_block %p\n", memblock); if (!memblock) goto out;