intel: use drm_mmap/drm_munmap wrappers

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
main
Emil Velikov 2014-09-07 19:47:06 +01:00
parent 84badffe5e
commit 537b1ca8d5
2 changed files with 9 additions and 10 deletions

View File

@ -48,7 +48,6 @@
#include <assert.h> #include <assert.h>
#include <pthread.h> #include <pthread.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdbool.h> #include <stdbool.h>
@ -1051,11 +1050,11 @@ drm_intel_gem_bo_free(drm_intel_bo *bo)
DRMLISTDEL(&bo_gem->vma_list); DRMLISTDEL(&bo_gem->vma_list);
if (bo_gem->mem_virtual) { if (bo_gem->mem_virtual) {
VG(VALGRIND_FREELIKE_BLOCK(bo_gem->mem_virtual, 0)); VG(VALGRIND_FREELIKE_BLOCK(bo_gem->mem_virtual, 0));
munmap(bo_gem->mem_virtual, bo_gem->bo.size); drm_munmap(bo_gem->mem_virtual, bo_gem->bo.size);
bufmgr_gem->vma_count--; bufmgr_gem->vma_count--;
} }
if (bo_gem->gtt_virtual) { if (bo_gem->gtt_virtual) {
munmap(bo_gem->gtt_virtual, bo_gem->bo.size); drm_munmap(bo_gem->gtt_virtual, bo_gem->bo.size);
bufmgr_gem->vma_count--; bufmgr_gem->vma_count--;
} }
@ -1140,12 +1139,12 @@ static void drm_intel_gem_bo_purge_vma_cache(drm_intel_bufmgr_gem *bufmgr_gem)
DRMLISTDELINIT(&bo_gem->vma_list); DRMLISTDELINIT(&bo_gem->vma_list);
if (bo_gem->mem_virtual) { if (bo_gem->mem_virtual) {
munmap(bo_gem->mem_virtual, bo_gem->bo.size); drm_munmap(bo_gem->mem_virtual, bo_gem->bo.size);
bo_gem->mem_virtual = NULL; bo_gem->mem_virtual = NULL;
bufmgr_gem->vma_count--; bufmgr_gem->vma_count--;
} }
if (bo_gem->gtt_virtual) { if (bo_gem->gtt_virtual) {
munmap(bo_gem->gtt_virtual, bo_gem->bo.size); drm_munmap(bo_gem->gtt_virtual, bo_gem->bo.size);
bo_gem->gtt_virtual = NULL; bo_gem->gtt_virtual = NULL;
bufmgr_gem->vma_count--; bufmgr_gem->vma_count--;
} }
@ -1381,7 +1380,7 @@ map_gtt(drm_intel_bo *bo)
} }
/* and mmap it */ /* and mmap it */
bo_gem->gtt_virtual = mmap(0, bo->size, PROT_READ | PROT_WRITE, bo_gem->gtt_virtual = drm_mmap(0, bo->size, PROT_READ | PROT_WRITE,
MAP_SHARED, bufmgr_gem->fd, MAP_SHARED, bufmgr_gem->fd,
mmap_arg.offset); mmap_arg.offset);
if (bo_gem->gtt_virtual == MAP_FAILED) { if (bo_gem->gtt_virtual == MAP_FAILED) {

View File

@ -32,9 +32,9 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/mman.h>
#include <err.h> #include <err.h>
#include "libdrm.h"
#include "intel_bufmgr.h" #include "intel_bufmgr.h"
#include "intel_chipset.h" #include "intel_chipset.h"
@ -64,7 +64,7 @@ read_file(const char *filename, void **ptr, size_t *size)
errx(1, "couldn't stat `%s'", filename); errx(1, "couldn't stat `%s'", filename);
*size = st.st_size; *size = st.st_size;
*ptr = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); *ptr = drm_mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (*ptr == MAP_FAILED) if (*ptr == MAP_FAILED)
errx(1, "couldn't map `%s'", filename); errx(1, "couldn't map `%s'", filename);