radeonsi: properly extract a buffer address from a descriptor
authorMarek Olšák <marek.olsak@amd.com>
Wed, 21 Feb 2018 23:28:39 +0000 (00:28 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 7 Mar 2018 18:55:40 +0000 (13:55 -0500)
src/gallium/drivers/radeonsi/si_descriptors.c

index e6c58ffca78cd05f291dd637c48af3822c038bc5..b6e767c2546ee31995ffa60dfbe2ba306808bbc3 100644 (file)
@@ -96,7 +96,13 @@ static uint32_t null_image_descriptor[8] = {
 
 static uint64_t si_desc_extract_buffer_address(uint32_t *desc)
 {
-       return desc[0] | ((uint64_t)G_008F04_BASE_ADDRESS_HI(desc[1]) << 32);
+       uint64_t va = desc[0] |
+                     ((uint64_t)G_008F04_BASE_ADDRESS_HI(desc[1]) << 32);
+
+       /* Sign-extend the 48-bit address. */
+       if (va & (1ull << 47))
+               va |= 0xffffull << 48;
+       return va;
 }
 
 static void si_init_descriptor_list(uint32_t *desc_list,