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>,
	"Matthew Auld" <matthew.auld@intel.com>,
	"Juha-Pekka Heikkila" <juhapekka.heikkila@gmail.com>
Subject: [PATCH i-g-t 1/2] lib/xe_query: Add display alignment helper
Date: Thu, 11 Jul 2024 13:02:09 +0200	[thread overview]
Message-ID: <20240711110210.207882-2-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20240711110210.207882-1-zbigniew.kempczynski@intel.com>

Battlemage supports 4K pages but display requires 64K physical page
alignment for Tile4 + compression. Lets add helper which returns
necessary bo alignment. This is temporary solution as kernel change
which exposes 64K as configuration for display alignment needs to
be merged first. This chicken-and-egg problem is workarounded here
and it will be replaced in next step after kernel change will land.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
---
 lib/xe/xe_query.c | 27 +++++++++++++++++++++++++++
 lib/xe/xe_query.h |  4 ++++
 2 files changed, 31 insertions(+)

diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
index 84eaaac967..1f277500a5 100644
--- a/lib/xe/xe_query.c
+++ b/lib/xe/xe_query.c
@@ -12,6 +12,7 @@
 #include "drmtest.h"
 #include "ioctl_wrappers.h"
 #include "igt_map.h"
+#include "intel_chipset.h"
 
 #include "xe_query.h"
 #include "xe_ioctl.h"
@@ -188,6 +189,23 @@ static uint32_t __mem_default_alignment(struct drm_xe_query_mem_regions *mem_reg
 	return alignment;
 }
 
+/*
+ * FIXME:
+ *
+ * This function is temporary and will be replaced by config->display_alignment
+ * exposed in the kernel configuration. Before kernel change will land it mimics
+ * its behavior.
+ */
+static uint32_t __display_alignment(uint16_t devid)
+{
+	uint32_t display_alignment = XE_DEFAULT_ALIGNMENT;
+
+	if (IS_BATTLEMAGE(devid))
+		display_alignment = XE_DEFAULT_ALIGNMENT_64K;
+
+	return display_alignment;
+}
+
 /**
  * xe_engine_class_string:
  * @engine_class: engine class
@@ -268,6 +286,7 @@ struct xe_device *xe_device_get(int fd)
 	xe_dev->config = xe_query_config_new(fd);
 	xe_dev->va_bits = xe_dev->config->info[DRM_XE_QUERY_CONFIG_VA_BITS];
 	xe_dev->dev_id = xe_dev->config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] & 0xffff;
+	xe_dev->display_alignment = __display_alignment(xe_dev->dev_id);
 	xe_dev->gt_list = xe_query_gt_list_new(fd);
 	xe_dev->memory_regions = __memory_regions(xe_dev->gt_list);
 	xe_dev->engines = xe_query_engines(fd);
@@ -691,6 +710,14 @@ uint64_t xe_visible_available_vram_size(int fd, int gt)
  */
 xe_dev_FN(xe_get_default_alignment, default_alignment, uint32_t);
 
+/**
+ * xe_get_display_alignment:
+ * @fd: xe device fd
+ *
+ * Returns alignment for allocating bo for display on xe device @fd.
+ */
+xe_dev_FN(xe_get_display_alignment, display_alignment, uint32_t);
+
 /**
  * xe_va_bits:
  * @fd: xe device fd
diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
index c33f91ca11..4f46d397e3 100644
--- a/lib/xe/xe_query.h
+++ b/lib/xe/xe_query.h
@@ -50,6 +50,9 @@ struct xe_device {
 	/** @default_alignment: safe alignment regardless region location */
 	uint32_t default_alignment;
 
+	/** @display_alignment: required alignment for display */
+	uint32_t display_alignment;
+
 	/** @has_vram: true if gpu has vram, false if system memory only */
 	bool has_vram;
 
@@ -97,6 +100,7 @@ uint64_t xe_visible_vram_size(int fd, int gt);
 uint64_t xe_available_vram_size(int fd, int gt);
 uint64_t xe_visible_available_vram_size(int fd, int gt);
 uint32_t xe_get_default_alignment(int fd);
+uint32_t xe_get_display_alignment(int fd);
 uint32_t xe_va_bits(int fd);
 uint16_t xe_dev_id(int fd);
 int xe_supports_faults(int fd);
-- 
2.34.1


  reply	other threads:[~2024-07-11 11:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-11 11:02 [PATCH i-g-t 0/2] Use display alignment for fb size calculation Zbigniew Kempczyński
2024-07-11 11:02 ` Zbigniew Kempczyński [this message]
2024-07-11 11:02 ` [PATCH i-g-t 2/2] lib/igt_fb: Calculate fb size according to display requirement Zbigniew Kempczyński
2024-07-11 13:01 ` ✓ CI.xeBAT: success for Use display alignment for fb size calculation Patchwork
2024-07-11 13:14 ` ✓ Fi.CI.BAT: " Patchwork
2024-07-11 15:37 ` ✗ CI.xeFULL: failure " Patchwork
2024-07-11 22:19 ` ✗ Fi.CI.IGT: " 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=20240711110210.207882-2-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=juhapekka.heikkila@gmail.com \
    --cc=matthew.auld@intel.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