summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorChristian König <[email protected]>2013-11-19 10:47:36 +0100
committerChristian König <[email protected]>2013-11-21 10:24:20 +0100
commitecb37a6e77f34d9c082fc38a36798a42c851d952 (patch)
tree0498b4e60247b80b46b1d0344b3e00f44f62fecf /src/gallium/winsys
parentf56f875b8b72eda5abf124c8c4203b77b44b9670 (diff)
winsys/radeon: cleanup virtual memory nonsense
The alignment of a virtual memory area must always be at least 4096 bytes. It only worked because size was aligned to 4096 outside of the function. Signed-off-by: Christian König <[email protected]>
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_bo.c37
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_bo.h1
2 files changed, 18 insertions, 20 deletions
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 19e271555e7..3019a525cf8 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -202,15 +202,15 @@ static uint64_t radeon_bomgr_find_va(struct radeon_bomgr *mgr, uint64_t size, ui
struct radeon_bo_va_hole *hole, *n;
uint64_t offset = 0, waste = 0;
+ alignment = MAX2(alignment, 4096);
+ size = align(size, 4096);
+
pipe_mutex_lock(mgr->bo_va_mutex);
/* first look for a hole */
LIST_FOR_EACH_ENTRY_SAFE(hole, n, &mgr->va_holes, list) {
offset = hole->offset;
- waste = 0;
- if (alignment) {
- waste = offset % alignment;
- waste = waste ? alignment - waste : 0;
- }
+ waste = offset % alignment;
+ waste = waste ? alignment - waste : 0;
offset += waste;
if (offset >= (hole->offset + hole->size)) {
continue;
@@ -242,11 +242,8 @@ static uint64_t radeon_bomgr_find_va(struct radeon_bomgr *mgr, uint64_t size, ui
}
offset = mgr->va_offset;
- waste = 0;
- if (alignment) {
- waste = offset % alignment;
- waste = waste ? alignment - waste : 0;
- }
+ waste = offset % alignment;
+ waste = waste ? alignment - waste : 0;
if (waste) {
n = CALLOC_STRUCT(radeon_bo_va_hole);
n->size = waste;
@@ -261,6 +258,8 @@ static uint64_t radeon_bomgr_find_va(struct radeon_bomgr *mgr, uint64_t size, ui
static void radeon_bomgr_force_va(struct radeon_bomgr *mgr, uint64_t va, uint64_t size)
{
+ size = align(size, 4096);
+
pipe_mutex_lock(mgr->bo_va_mutex);
if (va >= mgr->va_offset) {
if (va > mgr->va_offset) {
@@ -303,6 +302,8 @@ static void radeon_bomgr_free_va(struct radeon_bomgr *mgr, uint64_t va, uint64_t
{
struct radeon_bo_va_hole *hole;
+ size = align(size, 4096);
+
pipe_mutex_lock(mgr->bo_va_mutex);
if ((va + size) == mgr->va_offset) {
mgr->va_offset = va;
@@ -385,7 +386,7 @@ static void radeon_bo_destroy(struct pb_buffer *_buf)
drmIoctl(bo->rws->fd, DRM_IOCTL_GEM_CLOSE, &args);
if (mgr->va) {
- radeon_bomgr_free_va(mgr, bo->va, bo->va_size);
+ radeon_bomgr_free_va(mgr, bo->va, bo->base.size);
}
pipe_mutex_destroy(bo->map_mutex);
@@ -600,8 +601,7 @@ static struct pb_buffer *radeon_bomgr_create_bo(struct pb_manager *_mgr,
if (mgr->va) {
struct drm_radeon_gem_va va;
- bo->va_size = align(size, 4096);
- bo->va = radeon_bomgr_find_va(mgr, bo->va_size, desc->alignment);
+ bo->va = radeon_bomgr_find_va(mgr, size, desc->alignment);
va.handle = bo->handle;
va.vm_id = 0;
@@ -621,9 +621,9 @@ static struct pb_buffer *radeon_bomgr_create_bo(struct pb_manager *_mgr,
return NULL;
}
if (va.operation == RADEON_VA_RESULT_VA_EXIST) {
- radeon_bomgr_free_va(mgr, bo->va, bo->va_size);
+ radeon_bomgr_free_va(mgr, bo->va, size);
bo->va = va.offset;
- radeon_bomgr_force_va(mgr, bo->va, bo->va_size);
+ radeon_bomgr_force_va(mgr, bo->va, size);
}
}
@@ -931,8 +931,7 @@ done:
if (mgr->va && !bo->va) {
struct drm_radeon_gem_va va;
- bo->va_size = ((bo->base.size + 4095) & ~4095);
- bo->va = radeon_bomgr_find_va(mgr, bo->va_size, 1 << 20);
+ bo->va = radeon_bomgr_find_va(mgr, bo->base.size, 1 << 20);
va.handle = bo->handle;
va.operation = RADEON_VA_MAP;
@@ -949,9 +948,9 @@ done:
return NULL;
}
if (va.operation == RADEON_VA_RESULT_VA_EXIST) {
- radeon_bomgr_free_va(mgr, bo->va, bo->va_size);
+ radeon_bomgr_free_va(mgr, bo->va, bo->base.size);
bo->va = va.offset;
- radeon_bomgr_force_va(mgr, bo->va, bo->va_size);
+ radeon_bomgr_force_va(mgr, bo->va, bo->base.size);
}
}
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.h b/src/gallium/winsys/radeon/drm/radeon_drm_bo.h
index ee8919b7ff4..5536bc1022f 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.h
@@ -56,7 +56,6 @@ struct radeon_bo {
uint32_t handle;
uint32_t name;
uint64_t va;
- uint64_t va_size;
enum radeon_bo_domain initial_domain;
/* how many command streams is this bo referenced in? */