[PATCH i-g-t v2] intel_aubdump: Default to 48-bit AUBs when the gen is unknown

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



v2:
 * Use 48-bit rather than 64-bit (Ken)
 * Use 'addr_bits' rather than 'use_64bit'

Cc: Kenneth Graunke <kenneth@xxxxxxxxxxxxx>
Signed-off-by: Jordan Justen <jordan.l.justen@xxxxxxxxx>
---
 tools/aubdump.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/tools/aubdump.c b/tools/aubdump.c
index f3efb451..ee378a76 100644
--- a/tools/aubdump.c
+++ b/tools/aubdump.c
@@ -59,6 +59,7 @@ static int gen = 0;
 static int verbose = 0;
 static bool device_override;
 static uint32_t device;
+static int addr_bits = 0;
 
 static const struct {
 	const char *name;
@@ -190,7 +191,7 @@ data_out(const void *data, size_t size)
 static uint32_t
 gtt_entry_size(void)
 {
-	return gen >= 8 ? 8 : 4;
+	return addr_bits > 32 ? 8 : 4;
 }
 
 static uint32_t
@@ -229,17 +230,17 @@ write_header(void)
 	data_out(comment, comment_dwords * 4);
 
 	/* Set up the GTT. The max we can handle is 64M */
-	dword_out(CMD_AUB_TRACE_HEADER_BLOCK | ((gen >= 8 ? 6 : 5) - 2));
+	dword_out(CMD_AUB_TRACE_HEADER_BLOCK | ((addr_bits > 32 ? 6 : 5) - 2));
 	dword_out(AUB_TRACE_MEMTYPE_GTT_ENTRY |
 		  AUB_TRACE_TYPE_NOTYPE | AUB_TRACE_OP_DATA_WRITE);
 	dword_out(0); /* subtype */
 	dword_out(0); /* offset */
 	dword_out(gtt_size()); /* size */
-	if (gen >= 8)
+	if (addr_bits > 32)
 		dword_out(0);
 	for (uint32_t i = 0; i * gtt_entry_size() < gtt_size(); i++) {
 		dword_out(entry + 0x1000 * i);
-		if (gen >= 8)
+		if (addr_bits > 32)
 			dword_out(0);
 	}
 }
@@ -263,13 +264,13 @@ aub_write_trace_block(uint32_t type, void *virtual, uint32_t size, uint64_t gtt_
 			block_size = 8 * 4096;
 
 		dword_out(CMD_AUB_TRACE_HEADER_BLOCK |
-			  ((gen >= 8 ? 6 : 5) - 2));
+			  ((addr_bits > 32 ? 6 : 5) - 2));
 		dword_out(AUB_TRACE_MEMTYPE_GTT |
 			  type | AUB_TRACE_OP_DATA_WRITE);
 		dword_out(subtype);
 		dword_out(gtt_offset + offset);
 		dword_out(align_u32(block_size, 4));
-		if (gen >= 8)
+		if (addr_bits > 32)
 			dword_out((gtt_offset + offset) >> 32);
 
 		if (virtual)
@@ -285,7 +286,7 @@ aub_write_trace_block(uint32_t type, void *virtual, uint32_t size, uint64_t gtt_
 static void
 write_reloc(void *p, uint64_t v)
 {
-	if (gen >= 8) {
+	if (addr_bits > 32) {
 		/* From the Broadwell PRM Vol. 2a,
 		 * MI_LOAD_REGISTER_MEM::MemoryAddress:
 		 *
@@ -324,7 +325,7 @@ aub_dump_ringbuffer(uint64_t batch_offset, uint64_t offset, int ring_flag)
 	/* Make a ring buffer to execute our batchbuffer. */
 	memset(ringbuffer, 0, sizeof(ringbuffer));
 
-	aub_mi_bbs_len = gen >= 8 ? 3 : 2;
+	aub_mi_bbs_len = addr_bits > 32 ? 3 : 2;
 	ringbuffer[ring_count] = AUB_MI_BATCH_BUFFER_START | (aub_mi_bbs_len - 2);
 	write_reloc(&ringbuffer[ring_count + 1], batch_offset);
 	ring_count += aub_mi_bbs_len;
@@ -333,12 +334,12 @@ aub_dump_ringbuffer(uint64_t batch_offset, uint64_t offset, int ring_flag)
 	 * the ring in the simulator.
 	 */
 	dword_out(CMD_AUB_TRACE_HEADER_BLOCK |
-		  ((gen >= 8 ? 6 : 5) - 2));
+		  ((addr_bits > 32 ? 6 : 5) - 2));
 	dword_out(AUB_TRACE_MEMTYPE_GTT | ring | AUB_TRACE_OP_COMMAND_WRITE);
 	dword_out(0); /* general/surface subtype */
 	dword_out(offset);
 	dword_out(ring_count * 4);
-	if (gen >= 8)
+	if (addr_bits > 32)
 		dword_out(offset >> 32);
 
 	data_out(ringbuffer, ring_count * 4);
@@ -441,6 +442,11 @@ dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)
 			       filename, device, gen);
 	}
 
+	/* If we don't know the device gen, then it probably is a
+	 * newer device which uses 48-bit addresses.
+	 */
+	addr_bits = (gen >= 8 || gen == 0) ? 48 : 32;
+
 	if (verbose)
 		printf("Dumping execbuffer2:\n");
 
-- 
2.14.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux