[PATCH i-g-t 1/2] lib/xe_query: Add display alignment helper
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Thu Jul 11 11:02:09 UTC 2024
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 at intel.com>
Cc: Matthew Auld <matthew.auld at intel.com>
Cc: Juha-Pekka Heikkila <juhapekka.heikkila at 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
More information about the igt-dev
mailing list