-/* $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
*/
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 *);
-/* $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
*
/* 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);
-/* $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>
*
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;
}
*/
err:
- drm_free(reloc);
- drm_free(reloc_offset);
+ drm_free_large(reloc);
+ drm_free_large(reloc_offset);
return ret;
}
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);
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;
}
}
}
- drm_free(exec2_list);
+ drm_free_large(exec2_list);
return ret;
}