radeon: add support for write followed by read relocs.
authorDave Airlie <airlied@redhat.com>
Tue, 30 Jun 2009 02:19:28 +0000 (12:19 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 30 Jun 2009 02:19:28 +0000 (12:19 +1000)
the DDX does this and used to handle it internally

libdrm/radeon/radeon_cs_gem.c

index b9f6f4b..82ef16c 100644 (file)
@@ -144,12 +144,19 @@ static int cs_gem_write_reloc(struct radeon_cs *cs,
              * domain set then the read_domain should also be set for this
              * new relocation.
              */
-            if (reloc->read_domain && !read_domain) {
-                return -EINVAL;
-            }
-            if (reloc->write_domain && !write_domain) {
-                return -EINVAL;
+            /* the DDX expects to read and write from same pixmap */
+            if (write_domain && (reloc->read_domain & write_domain)) {
+                reloc->read_domain = 0;
+                reloc->write_domain = write_domain;
+            } else if (read_domain & reloc->write_domain) {
+                reloc->read_domain = 0;
+            } else {
+                if (write_domain != reloc->write_domain)
+                    return -EINVAL;
+                if (read_domain != reloc->read_domain)
+                    return -EINVAL;
             }
+
             reloc->read_domain |= read_domain;
             reloc->write_domain |= write_domain;
             /* update flags */