From 6676e773cbc069d86f621fc00a7abe4257ab93db Mon Sep 17 00:00:00 2001 From: oga Date: Sun, 17 Aug 2008 14:37:31 +0000 Subject: [PATCH] Make sure we can't sleep with a spinlock held --- sys/dev/pci/drm/drm_context.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sys/dev/pci/drm/drm_context.c b/sys/dev/pci/drm/drm_context.c index beb363f98ab..d2c5fb4391f 100644 --- a/sys/dev/pci/drm/drm_context.c +++ b/sys/dev/pci/drm/drm_context.c @@ -80,15 +80,15 @@ drm_ctxbitmap_next(struct drm_device *dev) int drm_ctxbitmap_init(struct drm_device *dev) { - int i; - int temp; + atomic_t *bitmap; + int i, temp; + + bitmap = drm_calloc(1, PAGE_SIZE, DRM_MEM_CTXBITMAP); + if (bitmap == NULL) + return (ENOMEM); DRM_LOCK(); - dev->ctx_bitmap = drm_calloc(1, PAGE_SIZE, DRM_MEM_CTXBITMAP); - if (dev->ctx_bitmap == NULL) { - DRM_UNLOCK(); - return ENOMEM; - } + dev->ctx_bitmap = bitmap; dev->max_context = -1; DRM_UNLOCK(); @@ -103,9 +103,13 @@ drm_ctxbitmap_init(struct drm_device *dev) void drm_ctxbitmap_cleanup(struct drm_device *dev) { + atomic_t *bitmap; + DRM_LOCK(); - drm_free(dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP); + bitmap = dev->ctx_bitmap; + dev->ctx_bitmap = NULL; DRM_UNLOCK(); + drm_free(bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP); } int -- 2.20.1