Mesa (9.0): winsys/radeon: fix relocs caching

Marek Olšák mareko at kemper.freedesktop.org
Mon Sep 24 01:06:59 UTC 2012


Module: Mesa
Branch: 9.0
Commit: f6a66a33f7ba52e36242db9346573bf477efa04e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f6a66a33f7ba52e36242db9346573bf477efa04e

Author: Vadim Girlin <vadimgirlin at gmail.com>
Date:   Wed Sep 19 04:48:16 2012 +0400

winsys/radeon: fix relocs caching

Don't cache pointers to elements of reallocatable array.
In some circumstances it caused false cache hits resulting in incorrect
command stream and gpu lockup.

Note: This is a candidate for the stable branches.

Signed-off-by: Vadim Girlin <vadimgirlin at gmail.com>
Reviewed-by: Marek Olšák <maraeo at gmail.com>
(cherry picked from commit 9aa8bac98b823e8783bc3a06a6e5b23fbf8d87fb)

---

 src/gallium/winsys/radeon/drm/radeon_drm_cs.c |   13 ++++++-------
 src/gallium/winsys/radeon/drm/radeon_drm_cs.h |    1 -
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
index 7e0f2f9..983c915 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
@@ -214,9 +214,10 @@ int radeon_get_reloc(struct radeon_cs_context *csc, struct radeon_bo *bo)
     unsigned hash = bo->handle & (sizeof(csc->is_handle_added)-1);
 
     if (csc->is_handle_added[hash]) {
-        reloc = csc->relocs_hashlist[hash];
+        i = csc->reloc_indices_hashlist[hash];
+        reloc = &csc->relocs[i];
         if (reloc->handle == bo->handle) {
-            return csc->reloc_indices_hashlist[hash];
+            return i;
         }
 
         /* Hash collision, look for the BO in the list of relocs linearly. */
@@ -233,7 +234,6 @@ int radeon_get_reloc(struct radeon_cs_context *csc, struct radeon_bo *bo)
                  *         AAAAAAAAAAABBBBBBBBBBBBBBCCCCCCCC
                  * will collide here: ^ and here:   ^,
                  * meaning that we should get very few collisions in the end. */
-                csc->relocs_hashlist[hash] = reloc;
                 csc->reloc_indices_hashlist[hash] = i;
                 /*printf("write_reloc collision, hash: %i, handle: %i\n", hash, bo->handle);*/
                 return i;
@@ -257,10 +257,11 @@ static unsigned radeon_add_reloc(struct radeon_cs_context *csc,
     enum radeon_bo_domain wd = usage & RADEON_USAGE_WRITE ? domains : 0;
 
     if (csc->is_handle_added[hash]) {
-        reloc = csc->relocs_hashlist[hash];
+        i = csc->reloc_indices_hashlist[hash];
+        reloc = &csc->relocs[i];
         if (reloc->handle == bo->handle) {
             update_reloc_domains(reloc, rd, wd, added_domains);
-            return csc->reloc_indices_hashlist[hash];
+            return i;
         }
 
         /* Hash collision, look for the BO in the list of relocs linearly. */
@@ -270,7 +271,6 @@ static unsigned radeon_add_reloc(struct radeon_cs_context *csc,
             if (reloc->handle == bo->handle) {
                 update_reloc_domains(reloc, rd, wd, added_domains);
 
-                csc->relocs_hashlist[hash] = reloc;
                 csc->reloc_indices_hashlist[hash] = i;
                 /*printf("write_reloc collision, hash: %i, handle: %i\n", hash, bo->handle);*/
                 return i;
@@ -303,7 +303,6 @@ static unsigned radeon_add_reloc(struct radeon_cs_context *csc,
     reloc->flags = 0;
 
     csc->is_handle_added[hash] = TRUE;
-    csc->relocs_hashlist[hash] = reloc;
     csc->reloc_indices_hashlist[hash] = csc->crelocs;
 
     csc->chunks[1].length_dw += RELOC_DWORDS;
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.h b/src/gallium/winsys/radeon/drm/radeon_drm_cs.h
index 5ce0002..6336d3a 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.h
@@ -48,7 +48,6 @@ struct radeon_cs_context {
 
     /* 0 = BO not added, 1 = BO added */
     char                        is_handle_added[256];
-    struct drm_radeon_cs_reloc  *relocs_hashlist[256];
     unsigned                    reloc_indices_hashlist[256];
 
     unsigned                    used_vram;




More information about the mesa-commit mailing list