Mesa (master): radeon-gallium: Don' t permit reading and writing a BO in one CS.

Corbin Simpson csimpson at kemper.freedesktop.org
Wed May 20 14:19:48 UTC 2009


Module: Mesa
Branch: master
Commit: 4550423211063010a2fa482037d8233bb80e3773
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4550423211063010a2fa482037d8233bb80e3773

Author: Corbin Simpson <MostAwesomeDude at gmail.com>
Date:   Wed May 20 07:18:08 2009 -0700

radeon-gallium: Don't permit reading and writing a BO in one CS.

This fixes some silent problems in current libdrm_radeon.

surface_copy still locks up hard.

---

 src/gallium/drivers/r300/r300_cs.h               |    5 +++--
 src/gallium/winsys/drm/radeon/core/radeon_r300.c |   18 +++++++++++++++++-
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h
index 82a3942..2abf04d 100644
--- a/src/gallium/drivers/r300/r300_cs.h
+++ b/src/gallium/drivers/r300/r300_cs.h
@@ -93,8 +93,9 @@
 } while (0)
 
 #define OUT_CS_RELOC(bo, offset, rd, wd, flags) do { \
-    debug_printf("r300: writing relocation for buffer %p, offset %d\n", \
-        bo, offset); \
+    debug_printf("r300: writing relocation for buffer %p, offset %d, " \
+            "domains (%d, %d, %d)\n", \
+        bo, offset, rd, wd, flags); \
     assert(bo); \
     OUT_CS(offset); \
     cs_winsys->write_cs_reloc(cs_winsys, bo, rd, wd, flags); \
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c
index 65366e2..995bf6a 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c
@@ -69,6 +69,16 @@ static boolean radeon_r300_validate(struct r300_winsys* winsys)
         return TRUE;
     }
 
+    /* XXX should probably be its own function */
+    for (i = 0; i < priv->bo_count; i++) {
+        if (sc[i].read_domains && sc[i].write_domain) {
+            /* Cute, cute. We need to flush first. */
+            debug_printf("radeon: BO %p can't be read and written; "
+                    "requesting flush.\n", sc[i].bo);
+            return TRUE;
+        }
+    }
+
     /* Things are fine, we can proceed as normal. */
     return FALSE;
 }
@@ -109,9 +119,15 @@ static void radeon_r300_write_cs_reloc(struct r300_winsys* winsys,
 {
     struct radeon_winsys_priv* priv =
         (struct radeon_winsys_priv*)winsys->radeon_winsys;
+    int retval = 0;
 
-    radeon_cs_write_reloc(priv->cs,
+    retval = radeon_cs_write_reloc(priv->cs,
             ((struct radeon_pipe_buffer*)pbuffer)->bo, rd, wd, flags);
+
+    if (retval) {
+        debug_printf("radeon: Relocation of %p (%d, %d, %d) failed!\n",
+                pbuffer, rd, wd, flags);
+    }
 }
 
 static void radeon_r300_end_cs(struct r300_winsys* winsys,




More information about the mesa-commit mailing list