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 v23 02/18] lib/intel_bufops: change in hw/sw tiling detection
Date: Sun,  2 Aug 2020 18:29:46 +0200	[thread overview]
Message-ID: <20200802163002.5815-3-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20200802163002.5815-1-zbigniew.kempczynski@intel.com>

Not all swizzling can be handled by the software (bit17) so detect
it properly during bufops creation time and disable if necessary.

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_bufops.c | 45 ++++++++++++++++++++++++++++++++++++---------
 1 file changed, 36 insertions(+), 9 deletions(-)

diff --git a/lib/intel_bufops.c b/lib/intel_bufops.c
index 09433bed..2ba4dbf6 100644
--- a/lib/intel_bufops.c
+++ b/lib/intel_bufops.c
@@ -157,7 +157,7 @@ static int __gem_get_tiling(int fd, struct drm_i915_gem_get_tiling *arg)
 }
 
 static bool __get_tiling(int fd, uint32_t handle, uint32_t *tiling,
-			 uint32_t *swizzle)
+			 uint32_t *swizzle, uint32_t *phys_swizzle)
 {
 	struct drm_i915_gem_get_tiling get_tiling = { .handle = handle };
 
@@ -166,12 +166,13 @@ static bool __get_tiling(int fd, uint32_t handle, uint32_t *tiling,
 
 	*tiling = get_tiling.tiling_mode;
 	*swizzle = get_tiling.swizzle_mode;
+	*phys_swizzle = get_tiling.phys_swizzle_mode;
 	igt_debug("buf tiling: %s, swizzle: %x, phys_swizzle: %x\n",
 		  tiling_str(get_tiling.tiling_mode),
 		  get_tiling.swizzle_mode,
 		  get_tiling.phys_swizzle_mode);
 
-	return get_tiling.phys_swizzle_mode == get_tiling.swizzle_mode;
+	return true;
 }
 
 static int __set_tiling(int fd, uint32_t handle, uint32_t tiling,
@@ -212,8 +213,10 @@ static void set_hw_tiled(struct buf_ops *bops, struct intel_buf *buf)
 	if (buf->tiling != I915_TILING_X && buf->tiling != I915_TILING_Y)
 		return;
 
-	if (!buf_ops_has_hw_fence(bops, buf->tiling))
+	if (!buf_ops_has_hw_fence(bops, buf->tiling)) {
+		igt_warn("No HW fence for tiling: %d\n", buf->tiling);
 		return;
+	}
 
 	igt_assert_eq(__set_tiling(bops->fd,
 				   buf->handle, buf->tiling,
@@ -1029,10 +1032,11 @@ struct buf_ops buf_ops_arr[] = {
 	},
 };
 
-static bool probe_hw_tiling(struct buf_ops *bops, uint32_t tiling)
+static bool probe_hw_tiling(struct buf_ops *bops, uint32_t tiling,
+			    bool *swizzling_supported)
 {
 	uint64_t size = 256 * 256;
-	uint32_t handle, buf_tiling, buf_swizzle;
+	uint32_t handle, buf_tiling, buf_swizzle, phys_swizzle;
 	uint32_t stride;
 	int ret;
 	bool is_set = false;
@@ -1051,12 +1055,15 @@ static bool probe_hw_tiling(struct buf_ops *bops, uint32_t tiling)
 	if (ret)
 		goto end;
 
-	is_set = __get_tiling(bops->fd, handle, &buf_tiling, &buf_swizzle);
+	is_set = __get_tiling(bops->fd, handle, &buf_tiling, &buf_swizzle,
+			      &phys_swizzle);
 	if (is_set) {
 		if (tiling == I915_TILING_X)
 			bops->swizzle_x = buf_swizzle;
 		else if (tiling == I915_TILING_Y)
 			bops->swizzle_y = buf_swizzle;
+
+		*swizzling_supported = buf_swizzle == phys_swizzle;
 	}
 end:
 	gem_close(bops->fd, handle);
@@ -1172,14 +1179,21 @@ static struct buf_ops *__buf_ops_create(int fd, bool check_idempotency)
 	 *
 	 * Ok, you have been warned.
 	 */
-	if (bops->intel_gen == 2) {
+	if (bops->intel_gen == 2 ) {
 		igt_warn("Gen2 detected. HW (de)tiling support only.");
 		return bops;
 	}
 
 	/* Let's probe X and Y hw tiling support */
 	if (is_hw_tiling_supported(bops, I915_TILING_X)) {
-		bool supported = probe_hw_tiling(bops, I915_TILING_X);
+		bool swizzling_supported;
+		bool supported = probe_hw_tiling(bops, I915_TILING_X,
+						 &swizzling_supported);
+
+		if (!swizzling_supported) {
+			igt_debug("Swizzling for X is not supported\n");
+			bops->supported_tiles &= ~TILE_X;
+		}
 
 		igt_debug("X fence support: %s\n", bool_str(supported));
 		if (!supported) {
@@ -1190,7 +1204,14 @@ static struct buf_ops *__buf_ops_create(int fd, bool check_idempotency)
 	}
 
 	if (is_hw_tiling_supported(bops, I915_TILING_Y)) {
-		bool supported = probe_hw_tiling(bops, I915_TILING_Y);
+		bool swizzling_supported;
+		bool supported = probe_hw_tiling(bops, I915_TILING_Y,
+						 &swizzling_supported);
+
+		if (!swizzling_supported) {
+			igt_debug("Swizzling for Y is not supported\n");
+			bops->supported_tiles &= ~TILE_Y;
+		}
 
 		igt_debug("Y fence support: %s\n", bool_str(supported));
 		if (!supported) {
@@ -1307,6 +1328,9 @@ bool buf_ops_set_software_tiling(struct buf_ops *bops,
 	switch (tiling) {
 	case I915_TILING_X:
 		if (use_software_tiling) {
+			bool supported = buf_ops_has_tiling_support(bops, tiling);
+			igt_assert_f(supported, "Cannot switch to X software tiling\n");
+
 			igt_debug("-> change X to SW\n");
 			bops->linear_to_x = copy_linear_to_x;
 			bops->x_to_linear = copy_x_to_linear;
@@ -1324,6 +1348,9 @@ bool buf_ops_set_software_tiling(struct buf_ops *bops,
 
 	case I915_TILING_Y:
 		if (use_software_tiling) {
+			bool supported = buf_ops_has_tiling_support(bops, tiling);
+			igt_assert_f(supported, "Cannot switch to Y software tiling\n");
+
 			igt_debug("-> change Y to SW\n");
 			bops->linear_to_y = copy_linear_to_y;
 			bops->y_to_linear = copy_y_to_linear;
-- 
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 16:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-02 16:29 [igt-dev] [PATCH i-g-t v23 00/18] Remove libdrm in rendercopy Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 01/18] lib/intel_bufops: add mapping on cpu / device Zbigniew Kempczyński
2020-08-02 16:29 ` Zbigniew Kempczyński [this message]
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 03/18] lib/intel_bufops: change stride requirements for Grantsdale Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 04/18] lib/intel_batchbuffer: add new functions to support rendercopy Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 05/18] lib/intel_batchbuffer: dump bb to base64 Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 06/18] lib/intel_batchbuffer: use canonical addresses for 48bit ppgtt Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 07/18] tests/api_intel_bb: test flags are cleared on bb reset Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 08/18] tests/gem_caching|partial: adopt to batch flush function cleanup Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 09/18] lib/rendercopy: remove libdrm dependency Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 10/18] tests/api_intel_bb: add render tests Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 11/18] lib/igt_draw: remove libdrm dependency Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 12/18] lib/igt_fb: Removal of " Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 13/18] tests/gem|kms: remove libdrm dependency (batch 1) Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 14/18] tests/gem|kms: remove libdrm dependency (batch 2) Zbigniew Kempczyński
2020-08-02 16:29 ` [igt-dev] [PATCH i-g-t v23 15/18] tools/intel_residency: adopt intel_residency to use bufops Zbigniew Kempczyński
2020-08-02 16:30 ` [igt-dev] [PATCH i-g-t v23 16/18] tests/perf: remove libdrm dependency for rendercopy Zbigniew Kempczyński
2020-08-02 16:30 ` [igt-dev] [PATCH i-g-t v23 17/18] fix: lib/intel_bufops: add 64bit bpp Zbigniew Kempczyński
2020-08-02 16:30 ` [igt-dev] [PATCH i-g-t v23 18/18] tests/kms_psr: trying to fix blt Zbigniew Kempczyński
2020-08-02 17:09 ` [igt-dev] ✓ Fi.CI.BAT: success for Remove libdrm in rendercopy (rev22) Patchwork
2020-08-02 20:36 ` [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=20200802163002.5815-3-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.