[Mesa-dev] [PATCH 3/8] radeonsi: properly extract a buffer address from a descriptor

Marek Olšák maraeo at gmail.com
Sun Feb 25 01:02:28 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

Cc: 17.3 18.0 <mesa-stable at lists.freedesktop.org>
---
 src/gallium/drivers/radeonsi/si_descriptors.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index 89fb614..49b5a2c 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -89,21 +89,27 @@ static uint32_t null_image_descriptor[8] = {
 	0,
 	0,
 	0,
 	S_008F1C_TYPE(V_008F1C_SQ_RSRC_IMG_1D)
 	/* the rest must contain zeros, which is also used by the buffer
 	 * descriptor */
 };
 
 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,
 				    unsigned element_dw_size,
 				    unsigned num_elements,
 				    const uint32_t *null_descriptor)
 {
 	int i;
 
 	/* Initialize the array to NULL descriptors if the element size is 8. */
-- 
2.7.4



More information about the mesa-dev mailing list