summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Kempczyński <zbigniew.kempczynski@intel.com>2020-09-11 10:07:23 +0200
committerChris Wilson <chris@chris-wilson.co.uk>2020-09-16 14:15:19 +0100
commita13282d661bb5af9e6aa61317924b340b0a650e8 (patch)
tree1af5addc3f1664bf1fe33f971bf11c315c8835db
parent92c0e2375c6b1e17598da29aac61af09e880af07 (diff)
lib/intel_batchbuffer: dump bb to base64
Code for dumping bb to log as base64 which can be used when something wrong happened. Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Cc: Dominik Grzegorzek <dominik.grzegorzek@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--lib/intel_batchbuffer.c41
-rw-r--r--lib/intel_batchbuffer.h2
2 files changed, 43 insertions, 0 deletions
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 88307076..29932e1b 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -52,6 +52,7 @@
#include "igt_rand.h"
#include "i830_reg.h"
#include "huc_copy.h"
+#include <glib.h>
#include <i915_drm.h>
@@ -1481,6 +1482,18 @@ void intel_bb_set_debug(struct intel_bb *ibb, bool debug)
ibb->debug = debug;
}
+/**
+ * intel_bb_set_dump_base64:
+ * @ibb: pointer to intel_bb
+ * @dump: true / false
+ *
+ * Do bb dump as base64 string before execbuf call.
+ */
+void intel_bb_set_dump_base64(struct intel_bb *ibb, bool dump)
+{
+ ibb->dump_base64 = dump;
+}
+
static int __compare_objects(const void *p1, const void *p2)
{
const struct drm_i915_gem_exec_object2 *o1 = p1, *o2 = p2;
@@ -1883,6 +1896,31 @@ static void intel_bb_dump_execbuf(struct intel_bb *ibb,
}
}
+#define LINELEN 76
+static void intel_bb_dump_base64(struct intel_bb *ibb)
+{
+ int outsize;
+ gchar *str, *pos;
+
+ igt_info("--- bb ---\n");
+ pos = str = g_base64_encode((const guchar *) ibb->batch, ibb->size);
+ outsize = strlen(str);
+
+ while (pos) {
+ char line[LINELEN + 1];
+ int to_copy = min(LINELEN, outsize);
+
+ memcpy(line, pos, to_copy);
+ line[to_copy] = 0;
+ igt_info("%s\n", line);
+ pos += LINELEN;
+ outsize -= to_copy;
+ if (outsize == 0)
+ break;
+ }
+ free(str);
+}
+
static void print_node(const void *node, VISIT which, int depth)
{
const struct drm_i915_gem_exec_object2 *object =
@@ -1938,6 +1976,9 @@ int __intel_bb_exec(struct intel_bb *ibb, uint32_t end_offset,
execbuf.flags &= ~I915_EXEC_NO_RELOC;
execbuf.rsvd2 = 0;
+ if (ibb->dump_base64)
+ intel_bb_dump_base64(ibb);
+
ret = __gem_execbuf_wr(ibb->i915, &execbuf);
if (ret) {
intel_bb_dump_execbuf(ibb, &execbuf);
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index c80eb97d..caa89dc6 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -433,6 +433,7 @@ struct intel_bb {
int i915;
int gen;
bool debug;
+ bool dump_base64;
bool enforce_relocs;
uint32_t devid;
uint32_t handle;
@@ -486,6 +487,7 @@ int intel_bb_sync(struct intel_bb *ibb);
void intel_bb_print(struct intel_bb *ibb);
void intel_bb_dump(struct intel_bb *ibb, const char *filename);
void intel_bb_set_debug(struct intel_bb *ibb, bool debug);
+void intel_bb_set_dump_base64(struct intel_bb *ibb, bool dump);
static inline uint64_t
intel_bb_set_default_object_alignment(struct intel_bb *ibb, uint64_t alignment)