diff --git a/amdgpu.c b/amdgpu.c index ff1336d..da11081 100644 --- a/amdgpu.c +++ b/amdgpu.c @@ -436,6 +436,7 @@ struct backend backend_amdgpu = { .bo_destroy = drv_gem_bo_destroy, .bo_import = drv_prime_bo_import, .bo_map = amdgpu_bo_map, + .bo_unmap = drv_bo_munmap, .resolve_format = amdgpu_resolve_format, }; diff --git a/cirrus.c b/cirrus.c index 4f0e983..d92bab4 100644 --- a/cirrus.c +++ b/cirrus.c @@ -29,4 +29,5 @@ struct backend backend_cirrus = { .bo_destroy = drv_dumb_bo_destroy, .bo_import = drv_prime_bo_import, .bo_map = drv_dumb_bo_map, + .bo_unmap = drv_bo_munmap, }; diff --git a/drv.c b/drv.c index 92e9b24..ff99893 100644 --- a/drv.c +++ b/drv.c @@ -429,10 +429,7 @@ int drv_bo_unmap(struct bo *bo, struct map_info *data) pthread_mutex_lock(&bo->drv->driver_lock); if (!--data->refcount) { - if (bo->drv->backend->bo_unmap) - ret = bo->drv->backend->bo_unmap(bo, data); - else - ret = munmap(data->addr, data->length); + ret = bo->drv->backend->bo_unmap(bo, data); drmHashDelete(bo->drv->map_table, data->handle); free(data); } diff --git a/evdi.c b/evdi.c index f66fb2d..829d6ea 100644 --- a/evdi.c +++ b/evdi.c @@ -28,4 +28,5 @@ struct backend backend_evdi = { .bo_destroy = drv_dumb_bo_destroy, .bo_import = drv_prime_bo_import, .bo_map = drv_dumb_bo_map, + .bo_unmap = drv_bo_munmap, }; diff --git a/exynos.c b/exynos.c index 0d935eb..b21cc2b 100644 --- a/exynos.c +++ b/exynos.c @@ -112,6 +112,7 @@ struct backend backend_exynos = { .bo_destroy = drv_gem_bo_destroy, .bo_import = drv_prime_bo_import, .bo_map = drv_dumb_bo_map, + .bo_unmap = drv_bo_munmap, }; #endif diff --git a/gma500.c b/gma500.c index 5b08bc3..c3f3c12 100644 --- a/gma500.c +++ b/gma500.c @@ -28,4 +28,5 @@ struct backend backend_gma500 = { .bo_destroy = drv_dumb_bo_destroy, .bo_import = drv_prime_bo_import, .bo_map = drv_dumb_bo_map, + .bo_unmap = drv_bo_munmap, }; diff --git a/helpers.c b/helpers.c index 0a09b5a..9d72a6c 100644 --- a/helpers.c +++ b/helpers.c @@ -313,6 +313,11 @@ void *drv_dumb_bo_map(struct bo *bo, struct map_info *data, size_t plane, int pr return mmap(0, data->length, prot, MAP_SHARED, bo->drv->fd, map_dumb.offset); } +int drv_bo_munmap(struct bo *bo, struct map_info *data) +{ + return munmap(data->addr, data->length); +} + uintptr_t drv_get_reference_count(struct driver *drv, struct bo *bo, size_t plane) { void *count; diff --git a/helpers.h b/helpers.h index dc1a7c0..b580643 100644 --- a/helpers.h +++ b/helpers.h @@ -17,6 +17,7 @@ int drv_dumb_bo_destroy(struct bo *bo); int drv_gem_bo_destroy(struct bo *bo); int drv_prime_bo_import(struct bo *bo, struct drv_import_fd_data *data); void *drv_dumb_bo_map(struct bo *bo, struct map_info *data, size_t plane, int prot); +int drv_bo_munmap(struct bo *bo, struct map_info *data); uintptr_t drv_get_reference_count(struct driver *drv, struct bo *bo, size_t plane); void drv_increment_reference_count(struct driver *drv, struct bo *bo, size_t plane); void drv_decrement_reference_count(struct driver *drv, struct bo *bo, size_t plane); diff --git a/marvell.c b/marvell.c index 8114ac7..455b033 100644 --- a/marvell.c +++ b/marvell.c @@ -31,6 +31,7 @@ struct backend backend_marvell = { .bo_destroy = drv_dumb_bo_destroy, .bo_import = drv_prime_bo_import, .bo_map = drv_dumb_bo_map, + .bo_unmap = drv_bo_munmap, }; #endif diff --git a/nouveau.c b/nouveau.c index 7cdab3a..e8a02e3 100644 --- a/nouveau.c +++ b/nouveau.c @@ -28,4 +28,5 @@ struct backend backend_nouveau = { .bo_destroy = drv_dumb_bo_destroy, .bo_import = drv_prime_bo_import, .bo_map = drv_dumb_bo_map, + .bo_unmap = drv_bo_munmap, }; diff --git a/radeon.c b/radeon.c index baf42ed..3af0be1 100644 --- a/radeon.c +++ b/radeon.c @@ -28,4 +28,5 @@ struct backend backend_radeon = { .bo_destroy = drv_dumb_bo_destroy, .bo_import = drv_prime_bo_import, .bo_map = drv_dumb_bo_map, + .bo_unmap = drv_bo_munmap, }; diff --git a/udl.c b/udl.c index eb15fbe..dc3c4eb 100644 --- a/udl.c +++ b/udl.c @@ -28,4 +28,5 @@ struct backend backend_udl = { .bo_destroy = drv_dumb_bo_destroy, .bo_import = drv_prime_bo_import, .bo_map = drv_dumb_bo_map, + .bo_unmap = drv_bo_munmap, }; diff --git a/vc4.c b/vc4.c index c797bd9..6dca979 100644 --- a/vc4.c +++ b/vc4.c @@ -87,6 +87,7 @@ struct backend backend_vc4 = { .bo_import = drv_prime_bo_import, .bo_destroy = drv_gem_bo_destroy, .bo_map = vc4_bo_map, + .bo_unmap = drv_bo_munmap, }; #endif diff --git a/vgem.c b/vgem.c index 4e6eefb..0152b47 100644 --- a/vgem.c +++ b/vgem.c @@ -67,5 +67,6 @@ struct backend backend_vgem = { .bo_destroy = drv_dumb_bo_destroy, .bo_import = drv_prime_bo_import, .bo_map = drv_dumb_bo_map, + .bo_unmap = drv_bo_munmap, .resolve_format = vgem_resolve_format, }; diff --git a/virtio_gpu.c b/virtio_gpu.c index fe580cd..afdb5a2 100644 --- a/virtio_gpu.c +++ b/virtio_gpu.c @@ -67,5 +67,6 @@ struct backend backend_virtio_gpu = { .bo_destroy = drv_dumb_bo_destroy, .bo_import = drv_prime_bo_import, .bo_map = drv_dumb_bo_map, + .bo_unmap = drv_bo_munmap, .resolve_format = virtio_gpu_resolve_format, };