All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Subject: [igt-dev] [PATCH i-g-t v21 05/17] lib/intel_batchbuffer: dump bb to base64
Date: Sun,  2 Aug 2020 08:35:49 +0200	[thread overview]
Message-ID: <20200802063601.8259-6-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20200802063601.8259-1-zbigniew.kempczynski@intel.com>

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>
---
 lib/intel_batchbuffer.c | 41 +++++++++++++++++++++++++++++++++++++++++
 lib/intel_batchbuffer.h |  2 ++
 2 files changed, 43 insertions(+)

diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 36198d41..465c3271 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>
 
@@ -1480,6 +1481,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;
@@ -1882,6 +1895,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 =
@@ -1937,6 +1975,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)
-- 
2.26.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2020-08-02  6:36 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-02  6:35 [igt-dev] [PATCH i-g-t v21 00/17] Remove libdrm in rendercopy Zbigniew Kempczyński
2020-08-02  6:35 ` [igt-dev] [PATCH i-g-t v21 01/17] lib/intel_bufops: add mapping on cpu / device Zbigniew Kempczyński
2020-08-02  6:35 ` [igt-dev] [PATCH i-g-t v21 02/17] lib/intel_bufops: change in hw/sw tiling detection Zbigniew Kempczyński
2020-08-02  6:35 ` [igt-dev] [PATCH i-g-t v21 03/17] lib/intel_bufops: change stride requirements for Grantsdale Zbigniew Kempczyński
2020-08-02 12:04   ` Chris Wilson
2020-08-02  6:35 ` [igt-dev] [PATCH i-g-t v21 04/17] lib/intel_batchbuffer: add new functions to support rendercopy Zbigniew Kempczyński
2020-08-02  6:35 ` Zbigniew Kempczyński [this message]
2020-08-02  6:35 ` [igt-dev] [PATCH i-g-t v21 06/17] lib/intel_batchbuffer: use canonical addresses for 48bit ppgtt Zbigniew Kempczyński
2020-08-02  6:35 ` [igt-dev] [PATCH i-g-t v21 07/17] tests/api_intel_bb: test flags are cleared on bb reset Zbigniew Kempczyński
2020-08-02  6:35 ` [igt-dev] [PATCH i-g-t v21 08/17] tests/gem_caching|partial: adopt to batch flush function cleanup Zbigniew Kempczyński
2020-08-02  6:35 ` [igt-dev] [PATCH i-g-t v21 09/17] lib/rendercopy: remove libdrm dependency Zbigniew Kempczyński
2020-08-02  6:35 ` [igt-dev] [PATCH i-g-t v21 10/17] tests/api_intel_bb: add render tests Zbigniew Kempczyński
2020-08-02  6:35 ` [igt-dev] [PATCH i-g-t v21 11/17] lib/igt_draw: remove libdrm dependency Zbigniew Kempczyński
2020-08-02  6:35 ` [igt-dev] [PATCH i-g-t v21 12/17] lib/igt_fb: Removal of " Zbigniew Kempczyński
2020-08-02  6:35 ` [igt-dev] [PATCH i-g-t v21 13/17] tests/gem|kms: remove libdrm dependency (batch 1) Zbigniew Kempczyński
2020-08-02 12:09   ` Chris Wilson
2020-08-02  6:35 ` [igt-dev] [PATCH i-g-t v21 14/17] tests/gem|kms: remove libdrm dependency (batch 2) Zbigniew Kempczyński
2020-08-02  6:35 ` [igt-dev] [PATCH i-g-t v21 15/17] tools/intel_residency: adopt intel_residency to use bufops Zbigniew Kempczyński
2020-08-02  6:36 ` [igt-dev] [PATCH i-g-t v21 16/17] tests/perf: remove libdrm dependency for rendercopy Zbigniew Kempczyński
2020-08-02  6:36 ` [igt-dev] [PATCH i-g-t v21 17/17] fix: lib/intel_bufops: add 64bit bpp Zbigniew Kempczyński
2020-08-02  7:09 ` [igt-dev] ✓ Fi.CI.BAT: success for Remove libdrm in rendercopy (rev20) Patchwork
2020-08-02  8:23 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200802063601.8259-6-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.