iris: canonicalize addresses.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 7 Apr 2018 06:08:52 +0000 (23:08 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:05 +0000 (10:26 -0800)
Back to working!  Woo!

src/gallium/drivers/iris/iris_bufmgr.c

index c1a4fa5d5f3250aae2d16cc54bdf1ee681dfc8d0..a81a2561fe2169e2ae4be57246dc2cf0ae68030c 100644 (file)
@@ -344,12 +344,30 @@ vma_alloc(struct iris_bufmgr *bufmgr,
       return 1ull << 32;
 
    struct bo_cache_bucket *bucket = get_bucket_allocator(bufmgr, size);
+   uint64_t addr;
 
-   if (bucket)
-      return bucket_vma_alloc(bufmgr, bucket, memzone);
+   if (bucket) {
+      addr = bucket_vma_alloc(bufmgr, bucket, memzone);
+   } else {
+      addr = util_vma_heap_alloc(&bufmgr->vma_allocator[memzone], size,
+                                 alignment);
+   }
+
+   /* Canonicalize the address.
+    *
+    * The Broadwell PRM Vol. 2a, MI_LOAD_REGISTER_MEM::MemoryAddress says:
+    *
+    *    "This field specifies the address of the memory location where the
+    *     register value specified in the DWord above will read from. The
+    *     address specifies the DWord location of the data. Range =
+    *     GraphicsVirtualAddress[63:2] for a DWord register GraphicsAddress
+    *     [63:48] are ignored by the HW and assumed to be in correct
+    *     canonical form [63:48] == [47]."
+    */
+   const int shift = 63 - 47;
+   addr = (((int64_t) addr) << shift) >> shift;
 
-   return util_vma_heap_alloc(&bufmgr->vma_allocator[memzone], size,
-                              alignment);
+   return addr;
 }
 
 static void