[Mesa-dev] [PATCH 5/6] winsys/amdgpu: add guard pages when R600_DEBUG=check_vm is enabled

Nicolai Hähnle nhaehnle at gmail.com
Wed Jun 22 09:40:40 UTC 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

This should help flush out GPU VM faults.
---
 src/gallium/winsys/amdgpu/drm/amdgpu_bo.c     | 4 +++-
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 4 +++-
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h | 2 ++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index 2555d57..aa415c4 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -294,6 +294,7 @@ static struct amdgpu_winsys_bo *amdgpu_create_bo(struct amdgpu_winsys *ws,
    uint64_t va = 0;
    struct amdgpu_winsys_bo *bo;
    amdgpu_va_handle va_handle;
+   unsigned va_gap_size;
    int r;
 
    assert(initial_domain & RADEON_DOMAIN_VRAM_GTT);
@@ -327,8 +328,9 @@ static struct amdgpu_winsys_bo *amdgpu_create_bo(struct amdgpu_winsys *ws,
       goto error_bo_alloc;
    }
 
+   va_gap_size = ws->check_vm ? MAX2(4 * alignment, 64 * 1024) : 0;
    r = amdgpu_va_range_alloc(ws->dev, amdgpu_gpu_va_range_general,
-                             size, alignment, 0, &va, &va_handle, 0);
+                             size + va_gap_size, alignment, 0, &va, &va_handle, 0);
    if (r)
       goto error_va_alloc;
 
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
index 7ef3529..afd4fd3 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
@@ -294,6 +294,8 @@ static boolean do_winsys_init(struct amdgpu_winsys *ws, int fd)
 
    ws->info.gart_page_size = alignment_info.size_remote;
 
+   ws->check_vm = strstr(debug_get_option("R600_DEBUG", ""), "check_vm") != NULL;
+
    return TRUE;
 
 fail:
@@ -469,7 +471,7 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create)
       goto fail;
 
    /* Create managers. */
-   pb_cache_init(&ws->bo_cache, 500000, 2.0f, 0,
+   pb_cache_init(&ws->bo_cache, 500000, ws->check_vm ? 1.0f : 2.0f, 0,
                  (ws->info.vram_size + ws->info.gart_size) / 8,
                  amdgpu_bo_destroy, amdgpu_bo_can_reclaim);
 
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h
index b13a17e..8489530 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h
@@ -66,6 +66,8 @@ struct amdgpu_winsys {
    uint32_t rev_id;
    unsigned family;
 
+   bool check_vm;
+
    /* List of all allocated buffers */
    pipe_mutex global_bo_list_lock;
    struct list_head global_bo_list;
-- 
2.7.4



More information about the mesa-dev mailing list