diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2015-04-11 04:36:11 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2015-04-11 04:36:11 +0000 |
commit | d6b7c3afe533b7a0bc6c851ee172eff3ec76dac6 (patch) | |
tree | 26f24d46c36720d7f43875142b2898805e28d206 /sys | |
parent | 79a79347380689a5798fed37c1d8b097c9fa7e21 (diff) |
change back to drm_free_large/drm_malloc_ab
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/drm/drmP.h | 4 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_mem_util.h | 7 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/i915_gem_execbuffer.c | 22 |
3 files changed, 18 insertions, 15 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h index 129b3c01fb8..c36d8a9843a 100644 --- a/sys/dev/pci/drm/drmP.h +++ b/sys/dev/pci/drm/drmP.h @@ -1,4 +1,4 @@ -/* $OpenBSD: drmP.h,v 1.190 2015/04/10 12:06:52 jsg Exp $ */ +/* $OpenBSD: drmP.h,v 1.191 2015/04/11 04:36:10 jsg Exp $ */ /* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*- * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com */ @@ -678,6 +678,8 @@ void *drm_calloc(size_t, size_t); void *drm_realloc(void *, size_t, size_t); void drm_free(void *); +#include "drm_mem_util.h" + /* XXX until we get PAT support */ #define drm_core_ioremap_wc drm_core_ioremap void drm_core_ioremap(struct drm_local_map *, struct drm_device *); diff --git a/sys/dev/pci/drm/drm_mem_util.h b/sys/dev/pci/drm/drm_mem_util.h index ead94b188a2..f9582b54144 100644 --- a/sys/dev/pci/drm/drm_mem_util.h +++ b/sys/dev/pci/drm/drm_mem_util.h @@ -1,4 +1,4 @@ -/* $OpenBSD: drm_mem_util.h,v 1.2 2014/07/12 18:48:52 tedu Exp $ */ +/* $OpenBSD: drm_mem_util.h,v 1.3 2015/04/11 04:36:10 jsg Exp $ */ /* * Copyright © 2008 Intel Corporation * @@ -49,14 +49,13 @@ static __inline__ void *drm_calloc_large(size_t nmemb, size_t size) /* Modeled after cairo's malloc_ab, it's like calloc but without the zeroing. */ static __inline__ void *drm_malloc_ab(size_t nmemb, size_t size) { - printf("%s stub\n", __func__); - return NULL; + return (mallocarray(nmemb, size, M_DRM, M_WAITOK | M_CANFAIL)); #ifdef notyet if (size != 0 && nmemb > SIZE_MAX / size) return NULL; if (size * nmemb <= PAGE_SIZE) - return malloc(nmemb * size, M_DRM, M_WAITOK); + return kmalloc(nmemb * size, GFP_KERNEL); return __vmalloc(size * nmemb, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL); diff --git a/sys/dev/pci/drm/i915/i915_gem_execbuffer.c b/sys/dev/pci/drm/i915/i915_gem_execbuffer.c index 0b4f56765ed..0123ae7a7ba 100644 --- a/sys/dev/pci/drm/i915/i915_gem_execbuffer.c +++ b/sys/dev/pci/drm/i915/i915_gem_execbuffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i915_gem_execbuffer.c,v 1.36 2015/04/05 11:53:53 kettenis Exp $ */ +/* $OpenBSD: i915_gem_execbuffer.c,v 1.37 2015/04/11 04:36:10 jsg Exp $ */ /* * Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org> * @@ -542,12 +542,11 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev, for (i = 0; i < count; i++) total += exec[i].relocation_count; - reloc_offset = mallocarray(count, sizeof(*reloc_offset), M_DRM, - M_WAITOK); - reloc = mallocarray(total, sizeof(*reloc), M_DRM, M_WAITOK); + reloc_offset = drm_malloc_ab(count, sizeof(*reloc_offset)); + reloc = drm_malloc_ab(total, sizeof(*reloc)); if (reloc == NULL || reloc_offset == NULL) { - drm_free(reloc); - drm_free(reloc_offset); + drm_free_large(reloc); + drm_free_large(reloc_offset); mutex_lock(&dev->struct_mutex); return -ENOMEM; } @@ -633,8 +632,8 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev, */ err: - drm_free(reloc); - drm_free(reloc_offset); + drm_free_large(reloc); + drm_free_large(reloc_offset); return ret; } @@ -1225,6 +1224,9 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data, exec2_list = kmalloc(sizeof(*exec2_list)*args->buffer_count, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY); + if (exec2_list == NULL) + exec2_list = drm_malloc_ab(sizeof(*exec2_list), + args->buffer_count); if (exec2_list == NULL) { DRM_DEBUG("Failed to allocate exec list for %d buffers\n", args->buffer_count); @@ -1237,7 +1239,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data, if (ret != 0) { DRM_DEBUG("copy %d exec entries failed %d\n", args->buffer_count, ret); - drm_free(exec2_list); + drm_free_large(exec2_list); return -EFAULT; } @@ -1255,7 +1257,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data, } } - drm_free(exec2_list); + drm_free_large(exec2_list); return ret; } |