[igt-dev] [PATCH i-g-t 4/7] lib: Add aux surface state to igt_buf

Ville Syrjala ville.syrjala at linux.intel.com
Wed Jul 4 16:16:43 UTC 2018


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

Store a bit of aux surface state in igt_buf. This will be needed
for rendercopy AUX_CCS_E color compression.

We also have to sprinkle memset()s and whatnot all over to make
sure the current igt_buf users don't leave the aux stuff full
of stack garbage.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 lib/intel_batchbuffer.h         | 18 +++++++++++-------
 tests/gem_gpgpu_fill.c          |  2 ++
 tests/gem_media_fill.c          |  2 ++
 tests/gem_ppgtt.c               |  4 +++-
 tests/gem_render_copy.c         |  2 ++
 tests/gem_render_copy_redux.c   |  2 ++
 tests/gem_render_linear_blits.c |  6 +++---
 tests/gem_render_tiled_blits.c  |  2 +-
 tests/gem_ring_sync_copy.c      |  2 ++
 tests/gem_stress.c              |  2 ++
 tests/kms_psr_sink_crc.c        |  2 ++
 tests/perf.c                    |  2 ++
 tests/pm_sseu.c                 |  2 +-
 13 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 8acfdbbfc875..2dcb09ce8f08 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -223,13 +223,17 @@ void intel_copy_bo(struct intel_batchbuffer *batch,
  * fill functions.
  */
 struct igt_buf {
-    drm_intel_bo *bo;
-    uint32_t stride;
-    uint32_t tiling;
-    uint32_t *data;
-    uint32_t size;
-    /*< private >*/
-    unsigned num_tiles;
+	drm_intel_bo *bo;
+	uint32_t stride;
+	uint32_t tiling;
+	uint32_t *data;
+	uint32_t size;
+	struct {
+		uint32_t offset;
+		uint32_t stride;
+	} aux;
+	/*< private >*/
+	unsigned num_tiles;
 };
 
 unsigned igt_buf_width(const struct igt_buf *buf);
diff --git a/tests/gem_gpgpu_fill.c b/tests/gem_gpgpu_fill.c
index df9e86f6c912..8ef05a3f0727 100644
--- a/tests/gem_gpgpu_fill.c
+++ b/tests/gem_gpgpu_fill.c
@@ -72,6 +72,8 @@ static void scratch_buf_init(data_t *data, struct igt_buf *buf,
 	gem_write(data->drm_fd, bo->handle, 0, data->linear,
 		sizeof(data->linear));
 
+	memset(buf, 0, sizeof(*buf));
+
 	buf->bo = bo;
 	buf->stride = stride;
 	buf->tiling = I915_TILING_NONE;
diff --git a/tests/gem_media_fill.c b/tests/gem_media_fill.c
index e3564e8b5d0e..109af12933f6 100644
--- a/tests/gem_media_fill.c
+++ b/tests/gem_media_fill.c
@@ -75,6 +75,8 @@ static void scratch_buf_init(data_t *data, struct igt_buf *buf,
 	gem_write(data->drm_fd, bo->handle, 0, data->linear,
 		sizeof(data->linear));
 
+	memset(buf, 0, sizeof(*buf));
+
 	buf->bo = bo;
 	buf->stride = stride;
 	buf->tiling = I915_TILING_NONE;
diff --git a/tests/gem_ppgtt.c b/tests/gem_ppgtt.c
index 575b0e9d3168..af5e3e073de7 100644
--- a/tests/gem_ppgtt.c
+++ b/tests/gem_ppgtt.c
@@ -66,6 +66,8 @@ static void scratch_buf_init(struct igt_buf *buf,
 			     drm_intel_bufmgr *bufmgr,
 			     uint32_t pixel)
 {
+	memset(buf, 0, sizeof(*buf));
+
 	buf->bo = create_bo(bufmgr, pixel);
 	buf->stride = STRIDE;
 	buf->tiling = I915_TILING_NONE;
@@ -109,7 +111,7 @@ static void fork_rcs_copy(int target, drm_intel_bo **dst, int count, unsigned fl
 
 	igt_fork(child, count) {
 		struct intel_batchbuffer *batch;
-		struct igt_buf buf;
+		struct igt_buf buf = {};
 
 		batch = intel_batchbuffer_alloc(dst[child]->bufmgr,
 						devid);
diff --git a/tests/gem_render_copy.c b/tests/gem_render_copy.c
index 2efec0783585..956f83f4b3a5 100644
--- a/tests/gem_render_copy.c
+++ b/tests/gem_render_copy.c
@@ -206,6 +206,8 @@ static void scratch_buf_init(data_t *data, struct igt_buf *buf,
 
 	bo = drm_intel_bo_alloc(data->bufmgr, "", size, 4096);
 
+	memset(buf, 0, sizeof(*buf));
+
 	buf->bo = bo;
 	buf->stride = stride;
 	buf->tiling = I915_TILING_NONE;
diff --git a/tests/gem_render_copy_redux.c b/tests/gem_render_copy_redux.c
index 95d1f975763e..27098ea6dcc7 100644
--- a/tests/gem_render_copy_redux.c
+++ b/tests/gem_render_copy_redux.c
@@ -103,6 +103,8 @@ static void scratch_buf_init(data_t *data, struct igt_buf *buf,
 	gem_write(data->fd, bo->handle, 0, data->linear,
 		  sizeof(data->linear));
 
+	memset(buf, 0, sizeof(*buf));
+
 	buf->bo = bo;
 	buf->stride = stride;
 	buf->tiling = I915_TILING_NONE;
diff --git a/tests/gem_render_linear_blits.c b/tests/gem_render_linear_blits.c
index db34d427385a..a1a7e0338235 100644
--- a/tests/gem_render_linear_blits.c
+++ b/tests/gem_render_linear_blits.c
@@ -105,7 +105,7 @@ static void run_test (int fd, int count)
 
 	igt_info("Cyclic blits, forward...\n");
 	for (i = 0; i < count * 4; i++) {
-		struct igt_buf src, dst;
+		struct igt_buf src = {}, dst = {};
 
 		src.bo = bo[i % count];
 		src.stride = STRIDE;
@@ -128,7 +128,7 @@ static void run_test (int fd, int count)
 
 	igt_info("Cyclic blits, backward...\n");
 	for (i = 0; i < count * 4; i++) {
-		struct igt_buf src, dst;
+		struct igt_buf src = {}, dst = {};
 
 		src.bo = bo[(i + 1) % count];
 		src.stride = STRIDE;
@@ -148,7 +148,7 @@ static void run_test (int fd, int count)
 
 	igt_info("Random blits...\n");
 	for (i = 0; i < count * 4; i++) {
-		struct igt_buf src, dst;
+		struct igt_buf src = {}, dst = {};
 		int s = random() % count;
 		int d = random() % count;
 
diff --git a/tests/gem_render_tiled_blits.c b/tests/gem_render_tiled_blits.c
index b2cc7a0c8ea5..3484d561a4b1 100644
--- a/tests/gem_render_tiled_blits.c
+++ b/tests/gem_render_tiled_blits.c
@@ -61,7 +61,7 @@ static int snoop;
 static void
 check_bo(struct intel_batchbuffer *batch, struct igt_buf *buf, uint32_t val)
 {
-	struct igt_buf tmp;
+	struct igt_buf tmp = {};
 	uint32_t *ptr;
 	int i;
 
diff --git a/tests/gem_ring_sync_copy.c b/tests/gem_ring_sync_copy.c
index a949753decff..8d3723559f76 100644
--- a/tests/gem_ring_sync_copy.c
+++ b/tests/gem_ring_sync_copy.c
@@ -131,6 +131,8 @@ static void bo_check(data_t *data, drm_intel_bo *bo, uint32_t val)
 
 static void scratch_buf_init_from_bo(struct igt_buf *buf, drm_intel_bo *bo)
 {
+	memset(buf, 0, sizeof(*buf));
+
 	buf->bo = bo;
 	buf->stride = 4 * WIDTH;
 	buf->tiling = I915_TILING_NONE;
diff --git a/tests/gem_stress.c b/tests/gem_stress.c
index 4d0de5c4eee4..225f283e4256 100644
--- a/tests/gem_stress.c
+++ b/tests/gem_stress.c
@@ -478,6 +478,8 @@ static void sanitize_stride(struct igt_buf *buf)
 
 static void init_buffer(struct igt_buf *buf, unsigned size)
 {
+	memset(buf, 0, sizeof(*buf));
+
 	buf->bo = drm_intel_bo_alloc(bufmgr, "tiled bo", size, 4096);
 	buf->size = size;
 	igt_assert(buf->bo);
diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c
index 28818e25f202..3115a5de68f0 100644
--- a/tests/kms_psr_sink_crc.c
+++ b/tests/kms_psr_sink_crc.c
@@ -150,6 +150,8 @@ static void fill_blt(data_t *data, uint32_t handle, unsigned char color)
 static void scratch_buf_init(struct igt_buf *buf, drm_intel_bo *bo,
 			     int size, int stride)
 {
+	memset(buf, 0, sizeof(*buf));
+
 	buf->bo = bo;
 	buf->stride = stride;
 	buf->tiling = I915_TILING_X;
diff --git a/tests/perf.c b/tests/perf.c
index 95048bfa5e31..f2bfb507ea63 100644
--- a/tests/perf.c
+++ b/tests/perf.c
@@ -495,6 +495,8 @@ scratch_buf_init(drm_intel_bufmgr *bufmgr,
 
 	scratch_buf_memset(bo, width, height, color);
 
+	memset(buf, 0, sizeof(*buf));
+
 	buf->bo = bo;
 	buf->stride = stride;
 	buf->tiling = I915_TILING_NONE;
diff --git a/tests/pm_sseu.c b/tests/pm_sseu.c
index 9a7daa5636f2..1274e1fa6856 100644
--- a/tests/pm_sseu.c
+++ b/tests/pm_sseu.c
@@ -35,7 +35,7 @@
 
 IGT_TEST_DESCRIPTION("Tests slice/subslice/EU power gating functionality.\n");
 
-struct {
+static struct {
 	int init;
 	int drm_fd;
 	int devid;
-- 
2.16.4



More information about the igt-dev mailing list