Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>,
	"Juha-Pekka Heikkila" <juhapekka.heikkila@gmail.com>
Subject: [PATCH i-g-t v2 02/12] lib/intel_bufops: Fix mapping/unmapping for i915 and xe
Date: Tue, 18 Jun 2024 07:23:25 +0200	[thread overview]
Message-ID: <20240618052335.152588-3-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20240618052335.152588-1-zbigniew.kempczynski@intel.com>

It looks previously there was no user of intel-buf mapping code so
missing xe path wasn't notice. Lets add xe path along with correct
buffer size mapping.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
---
 lib/intel_bufops.c | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/lib/intel_bufops.c b/lib/intel_bufops.c
index 313c2665ae..b4ccf4c093 100644
--- a/lib/intel_bufops.c
+++ b/lib/intel_bufops.c
@@ -1232,37 +1232,46 @@ void intel_buf_destroy(struct intel_buf *buf)
 
 void *intel_buf_cpu_map(struct intel_buf *buf, bool write)
 {
-	int i915 = buf_ops_get_fd(buf->bops);
+	int fd = buf_ops_get_fd(buf->bops);
 
 	igt_assert(buf);
 	igt_assert(buf->ptr == NULL); /* already mapped */
 
 	buf->cpu_write = write;
-	buf->ptr = gem_mmap__cpu_coherent(i915, buf->handle, 0,
-					  buf->surface[0].size,
-					  write ? PROT_WRITE : PROT_READ);
 
-	gem_set_domain(i915, buf->handle,
-		       I915_GEM_DOMAIN_CPU,
-		       write ? I915_GEM_DOMAIN_CPU : 0);
+	if (is_xe_device(fd)) {
+		buf->ptr = xe_bo_map(fd, buf->handle, buf->bo_size);
+	} else {
+		buf->ptr = gem_mmap__cpu_coherent(fd, buf->handle, 0,
+						  buf->bo_size,
+						  write ? PROT_WRITE : PROT_READ);
+
+		gem_set_domain(fd, buf->handle,
+			       I915_GEM_DOMAIN_CPU,
+			       write ? I915_GEM_DOMAIN_CPU : 0);
+	}
 
 	return buf->ptr;
 }
 
 void *intel_buf_device_map(struct intel_buf *buf, bool write)
 {
-	int i915 = buf_ops_get_fd(buf->bops);
+	int fd = buf_ops_get_fd(buf->bops);
 
 	igt_assert(buf);
 	igt_assert(buf->ptr == NULL); /* already mapped */
 
-	buf->ptr = gem_mmap__device_coherent(i915, buf->handle, 0,
-					     buf->surface[0].size,
-					     write ? PROT_WRITE : PROT_READ);
+	if (is_xe_device(fd)) {
+		buf->ptr = xe_bo_map(fd, buf->handle, buf->bo_size);
+	} else {
+		buf->ptr = gem_mmap__device_coherent(fd, buf->handle, 0,
+						     buf->bo_size,
+						     write ? PROT_WRITE : PROT_READ);
 
-	gem_set_domain(i915, buf->handle,
-		       I915_GEM_DOMAIN_WC,
-		       write ? I915_GEM_DOMAIN_WC : 0);
+		gem_set_domain(fd, buf->handle,
+			       I915_GEM_DOMAIN_WC,
+			       write ? I915_GEM_DOMAIN_WC : 0);
+	}
 
 	return buf->ptr;
 }
@@ -1272,7 +1281,7 @@ void intel_buf_unmap(struct intel_buf *buf)
 	igt_assert(buf);
 	igt_assert(buf->ptr);
 
-	munmap(buf->ptr, buf->surface[0].size);
+	munmap(buf->ptr, buf->bo_size);
 	buf->ptr = NULL;
 }
 
-- 
2.34.1


  parent reply	other threads:[~2024-06-18  5:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-18  5:23 [PATCH i-g-t v2 00/12] Introduce intel_tiling_detect tool Zbigniew Kempczyński
2024-06-18  5:23 ` [PATCH i-g-t v2 01/12] lib/intel_bufops: Fix offset returned for Tile4 Zbigniew Kempczyński
2024-06-18  5:23 ` Zbigniew Kempczyński [this message]
2024-06-18  5:23 ` [PATCH i-g-t v2 03/12] lib/intel_bufops: Add linear-to-none copy path Zbigniew Kempczyński
2024-06-18  5:23 ` [PATCH i-g-t v2 04/12] lib/intel_bufops: Add Tile4 in linear_to and to_linear helpers Zbigniew Kempczyński
2024-06-18  5:23 ` [PATCH i-g-t v2 05/12] lib/intel_bufops: Add Yf tiling Zbigniew Kempczyński
2024-06-18  5:23 ` [PATCH i-g-t v2 06/12] lib/intel_blt: Add Yf tiling in block-copy Zbigniew Kempczyński
2024-06-18  5:23 ` [PATCH i-g-t v2 07/12] lib/intel_bufops: Add Ys tiling in linear_to and to_linear path Zbigniew Kempczyński
2024-06-18  5:23 ` [PATCH i-g-t v2 08/12] lib/intel_bufops: Drop unnecessary Tile4 function assignment Zbigniew Kempczyński
2024-06-18  5:23 ` [PATCH i-g-t v2 09/12] lib/intel_bufops: Preparation for adding software tiling for Tile64 Zbigniew Kempczyński
2024-06-18  5:23 ` [PATCH i-g-t v2 10/12] lib/intel_bufops: Drop Tile4 swizzling Zbigniew Kempczyński
2024-06-18  5:23 ` [PATCH i-g-t v2 11/12] lib/intel_bufops: Don't disable x and y on platforms without swizzling Zbigniew Kempczyński
2024-06-18  5:23 ` [PATCH i-g-t v2 12/12] tools/intel_tiling_detect: Introduce tiling detection tool Zbigniew Kempczyński
2024-06-19 11:41   ` Juha-Pekka Heikkila
2024-06-19 12:23     ` Zbigniew Kempczyński
2024-06-18  8:34 ` ✓ CI.xeBAT: success for Introduce intel_tiling_detect tool (rev2) Patchwork
2024-06-18  8:36 ` ✓ Fi.CI.BAT: " Patchwork
2024-06-18 11:46 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-06-19  5:54   ` Zbigniew Kempczyński
2024-06-18 20:12 ` ✓ CI.xeFULL: success " 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=20240618052335.152588-3-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=juhapekka.heikkila@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox