aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-multimedia/libva/files/0008-Limit-INTEL-MEDIA-ALLOC-MODE-to-MTL-and-ARL-only.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-multimedia/libva/files/0008-Limit-INTEL-MEDIA-ALLOC-MODE-to-MTL-and-ARL-only.patch')
-rw-r--r--recipes-multimedia/libva/files/0008-Limit-INTEL-MEDIA-ALLOC-MODE-to-MTL-and-ARL-only.patch255
1 files changed, 255 insertions, 0 deletions
diff --git a/recipes-multimedia/libva/files/0008-Limit-INTEL-MEDIA-ALLOC-MODE-to-MTL-and-ARL-only.patch b/recipes-multimedia/libva/files/0008-Limit-INTEL-MEDIA-ALLOC-MODE-to-MTL-and-ARL-only.patch
new file mode 100644
index 00000000..ece5e00b
--- /dev/null
+++ b/recipes-multimedia/libva/files/0008-Limit-INTEL-MEDIA-ALLOC-MODE-to-MTL-and-ARL-only.patch
@@ -0,0 +1,255 @@
+From ac2ffac8d4aade216cc361c6c7120c13a8780719 Mon Sep 17 00:00:00 2001
+From: "Soon, Thean Siew" <thean.siew.soon@intel.com>
+Date: Thu, 28 Dec 2023 18:42:59 +0000
+Subject: [PATCH 08/12] Limit INTEL MEDIA ALLOC MODE to MTL and ARL only
+
+Upstream-Status: Submitted [https://github.com/intel/media-driver/pull/1754]
+
+Signed-off-by: Soon, Thean Siew <thean.siew.soon@intel.com>
+---
+ .../common/os/i915/include/mos_bufmgr_api.h | 1 +
+ .../common/os/i915/include/mos_bufmgr_priv.h | 2 +-
+ .../linux/common/os/i915/mos_bufmgr.c | 69 +++++++++++++++----
+ .../linux/common/os/i915/mos_bufmgr_api.c | 19 +++++
+ .../os/i915_production/mos_bufmgr_priv.h | 1 +
+ .../common/os/mos_context_specific_next.cpp | 36 +++++-----
+ 6 files changed, 94 insertions(+), 34 deletions(-)
+
+diff --git a/media_softlet/linux/common/os/i915/include/mos_bufmgr_api.h b/media_softlet/linux/common/os/i915/include/mos_bufmgr_api.h
+index 71cc01099..ab4f1ba89 100644
+--- a/media_softlet/linux/common/os/i915/include/mos_bufmgr_api.h
++++ b/media_softlet/linux/common/os/i915/include/mos_bufmgr_api.h
+@@ -299,6 +299,7 @@ void mos_bufmgr_enable_vmbind(struct mos_bufmgr *bufmgr);
+ void mos_bufmgr_disable_object_capture(struct mos_bufmgr *bufmgr);
+ int mos_bufmgr_get_memory_info(struct mos_bufmgr *bufmgr, char *info, uint32_t length);
+ int mos_bufmgr_get_devid(struct mos_bufmgr *bufmgr);
++void mos_bufmgr_realloc_cache(struct mos_bufmgr *bufmgr, uint8_t alloc_mode);
+
+ int mos_bo_map_unsynchronized(struct mos_linux_bo *bo);
+ int mos_bo_map_gtt(struct mos_linux_bo *bo);
+diff --git a/media_softlet/linux/common/os/i915/include/mos_bufmgr_priv.h b/media_softlet/linux/common/os/i915/include/mos_bufmgr_priv.h
+index 63f69f985..6fd58f827 100644
+--- a/media_softlet/linux/common/os/i915/include/mos_bufmgr_priv.h
++++ b/media_softlet/linux/common/os/i915/include/mos_bufmgr_priv.h
+@@ -358,9 +358,9 @@ struct mos_bufmgr {
+ void (*disable_object_capture)(struct mos_bufmgr *bufmgr) = nullptr;
+ int (*get_memory_info)(struct mos_bufmgr *bufmgr, char *info, uint32_t length) = nullptr;
+ int (*get_devid)(struct mos_bufmgr *bufmgr) = nullptr;
++ void (*realloc_cache)(struct mos_bufmgr *bufmgr, uint8_t alloc_mode) = nullptr;
+ int (*query_engines_count)(struct mos_bufmgr *bufmgr,
+ unsigned int *nengine) = nullptr;
+-
+ int (*query_engines)(struct mos_bufmgr *bufmgr,
+ __u16 engine_class,
+ __u64 caps,
+diff --git a/media_softlet/linux/common/os/i915/mos_bufmgr.c b/media_softlet/linux/common/os/i915/mos_bufmgr.c
+index b623d0129..2814ddbb7 100644
+--- a/media_softlet/linux/common/os/i915/mos_bufmgr.c
++++ b/media_softlet/linux/common/os/i915/mos_bufmgr.c
+@@ -2426,19 +2426,9 @@ mos_gem_bo_start_gtt_access(struct mos_linux_bo *bo, int write_enable)
+ }
+
+ static void
+-mos_bufmgr_gem_destroy(struct mos_bufmgr *bufmgr)
++mos_bufmgr_cleanup_cache(struct mos_bufmgr_gem *bufmgr_gem)
+ {
+- struct mos_bufmgr_gem *bufmgr_gem = (struct mos_bufmgr_gem *) bufmgr;
+- struct drm_gem_close close_bo;
+- int i, ret;
+-
+- free(bufmgr_gem->exec2_objects);
+- free(bufmgr_gem->exec_objects);
+- free(bufmgr_gem->exec_bos);
+- pthread_mutex_destroy(&bufmgr_gem->lock);
+-
+- /* Free any cached buffer objects we were going to reuse */
+- for (i = 0; i < bufmgr_gem->num_buckets; i++) {
++ for (int i = 0; i < bufmgr_gem->num_buckets; i++) {
+ struct mos_gem_bo_bucket *bucket =
+ &bufmgr_gem->cache_bucket[i];
+ struct mos_bo_gem *bo_gem;
+@@ -2450,7 +2440,25 @@ mos_bufmgr_gem_destroy(struct mos_bufmgr *bufmgr)
+
+ mos_gem_bo_free(&bo_gem->bo);
+ }
++ bufmgr_gem->cache_bucket[i].size = 0;
+ }
++ bufmgr_gem->num_buckets = 0;
++}
++
++static void
++mos_bufmgr_gem_destroy(struct mos_bufmgr *bufmgr)
++{
++ struct mos_bufmgr_gem *bufmgr_gem = (struct mos_bufmgr_gem *)bufmgr;
++ struct drm_gem_close close_bo;
++ int ret;
++
++ free(bufmgr_gem->exec2_objects);
++ free(bufmgr_gem->exec_objects);
++ free(bufmgr_gem->exec_bos);
++ pthread_mutex_destroy(&bufmgr_gem->lock);
++
++ /* Free any cached buffer objects we were going to reuse */
++ mos_bufmgr_cleanup_cache(bufmgr_gem);
+
+ /* Release userptr bo kept hanging around for optimisation. */
+ if (bufmgr_gem->userptr_active.ptr) {
+@@ -3852,9 +3860,41 @@ add_bucket(struct mos_bufmgr_gem *bufmgr_gem, int size)
+ }
+
+ static void
+-init_cache_buckets(struct mos_bufmgr_gem *bufmgr_gem, uint8_t alloc_mode)
++init_cache_buckets(struct mos_bufmgr_gem *bufmgr_gem)
++{
++ unsigned long size, cache_max_size = 64 * 1024 * 1024;
++
++ /* OK, so power of two buckets was too wasteful of memory.
++ * Give 3 other sizes between each power of two, to hopefully
++ * cover things accurately enough. (The alternative is
++ * probably to just go for exact matching of sizes, and assume
++ * that for things like composited window resize the tiled
++ * width/height alignment and rounding of sizes to pages will
++ * get us useful cache hit rates anyway)
++ */
++ add_bucket(bufmgr_gem, 4096);
++ add_bucket(bufmgr_gem, 4096 * 2);
++ add_bucket(bufmgr_gem, 4096 * 3);
++
++ /* Initialize the linked lists for BO reuse cache. */
++ for (size = 4 * 4096; size <= cache_max_size; size *= 2) {
++ add_bucket(bufmgr_gem, size);
++
++ add_bucket(bufmgr_gem, size + size * 1 / 4);
++ add_bucket(bufmgr_gem, size + size * 2 / 4);
++ add_bucket(bufmgr_gem, size + size * 3 / 4);
++ }
++}
++
++static void
++mos_gem_realloc_cache(struct mos_bufmgr *bufmgr, uint8_t alloc_mode)
+ {
+ unsigned long size, cache_max_size = 64 * 1024 * 1024, unit_size;
++ struct mos_bufmgr_gem *bufmgr_gem = (struct mos_bufmgr_gem *)bufmgr;
++
++ // Clean up the pre-allocated cache before re-allocating according
++ // to alloc_mode
++ mos_bufmgr_cleanup_cache(bufmgr_gem);
+
+ /* OK, so power of two buckets was too wasteful of memory.
+ * Give 3 other sizes between each power of two, to hopefully
+@@ -5218,6 +5258,7 @@ mos_bufmgr_gem_init_i915(int fd, int batch_size)
+ bufmgr_gem->bufmgr.disable_object_capture = mos_gem_disable_object_capture;
+ bufmgr_gem->bufmgr.get_memory_info = mos_gem_get_memory_info;
+ bufmgr_gem->bufmgr.get_devid = mos_gem_get_devid;
++ bufmgr_gem->bufmgr.realloc_cache = mos_gem_realloc_cache;
+ bufmgr_gem->bufmgr.set_context_param = mos_gem_set_context_param;
+ bufmgr_gem->bufmgr.set_context_param_parallel = mos_gem_set_context_param_parallel;
+ bufmgr_gem->bufmgr.set_context_param_load_balance = mos_gem_set_context_param_load_balance;
+@@ -5404,7 +5445,7 @@ mos_bufmgr_gem_init_i915(int fd, int batch_size)
+ bufmgr_gem->max_relocs = batch_size / sizeof(uint32_t) / 2 - 2;
+
+ DRMINITLISTHEAD(&bufmgr_gem->named);
+- init_cache_buckets(bufmgr_gem,alloc_mode);
++ init_cache_buckets(bufmgr_gem);
+
+ DRMLISTADD(&bufmgr_gem->managers, &bufmgr_list);
+
+diff --git a/media_softlet/linux/common/os/i915/mos_bufmgr_api.c b/media_softlet/linux/common/os/i915/mos_bufmgr_api.c
+index abe8ef96a..d0e02c267 100644
+--- a/media_softlet/linux/common/os/i915/mos_bufmgr_api.c
++++ b/media_softlet/linux/common/os/i915/mos_bufmgr_api.c
+@@ -1204,6 +1204,25 @@ mos_bufmgr_get_devid(struct mos_bufmgr *bufmgr)
+ }
+ }
+
++void
++mos_bufmgr_realloc_cache(struct mos_bufmgr *bufmgr, uint8_t alloc_mode)
++{
++ if(!bufmgr)
++ {
++ MOS_OS_CRITICALMESSAGE("Input null ptr\n");
++ return;
++ }
++
++ if (bufmgr->realloc_cache)
++ {
++ return bufmgr->realloc_cache(bufmgr, alloc_mode);
++ }
++ else
++ {
++ MOS_OS_CRITICALMESSAGE("Unsupported\n");
++ }
++}
++
+ int
+ mos_query_engines_count(struct mos_bufmgr *bufmgr,
+ unsigned int *nengine)
+diff --git a/media_softlet/linux/common/os/i915_production/mos_bufmgr_priv.h b/media_softlet/linux/common/os/i915_production/mos_bufmgr_priv.h
+index c3b765a4c..1d7f7edb0 100644
+--- a/media_softlet/linux/common/os/i915_production/mos_bufmgr_priv.h
++++ b/media_softlet/linux/common/os/i915_production/mos_bufmgr_priv.h
+@@ -358,6 +358,7 @@ struct mos_bufmgr {
+ void (*disable_object_capture)(struct mos_bufmgr *bufmgr) = nullptr;
+ int (*get_memory_info)(struct mos_bufmgr *bufmgr, char *info, uint32_t length) = nullptr;
+ int (*get_devid)(struct mos_bufmgr *bufmgr) = nullptr;
++ void (*realloc_cache)(struct mos_bufmgr *bufmgr, uint8_t alloc_mode) = nullptr;
+ int (*query_engines_count)(struct mos_bufmgr *bufmgr,
+ unsigned int *nengine) = nullptr;
+
+diff --git a/media_softlet/linux/common/os/mos_context_specific_next.cpp b/media_softlet/linux/common/os/mos_context_specific_next.cpp
+index 543e262d1..87059f538 100644
+--- a/media_softlet/linux/common/os/mos_context_specific_next.cpp
++++ b/media_softlet/linux/common/os/mos_context_specific_next.cpp
+@@ -90,25 +90,7 @@ MOS_STATUS OsContextSpecificNext::Init(DDI_DEVICE_CONTEXT ddiDriverContext)
+
+ userSettingPtr = MosInterface::MosGetUserSettingInstance(osDriverContext);
+
+- mode = BATCH_BUFFER_SIZE;
+- ReadUserSetting(
+- userSettingPtr,
+- value,
+- "INTEL MEDIA ALLOC MODE",
+- MediaUserSetting::Group::Device);
+-
+- if (value)
+- {
+- mode |= (value & 0x000000ff);
+- }
+- value = 0;
+- /* no need to set batch buffer size after switch to softpin
+- * keep it, just for test during relocation to softpin transition
+- * now , it could be a debug method , but is actually useless
+- * so it is safe to reuse the lowest 8bit to convey addtional information
+- * more suitable solution is deleting it , or add additional parameter*/
+-
+- m_bufmgr = mos_bufmgr_gem_init(m_fd, (int)mode, &m_deviceType);
++ m_bufmgr = mos_bufmgr_gem_init(m_fd, BATCH_BUFFER_SIZE, &m_deviceType);
+ if (nullptr == m_bufmgr)
+ {
+ MOS_OS_ASSERTMESSAGE("Not able to allocate buffer manager, fd=0x%d", m_fd);
+@@ -151,6 +133,22 @@ MOS_STATUS OsContextSpecificNext::Init(DDI_DEVICE_CONTEXT ddiDriverContext)
+ return eStatus;
+ }
+
++ if (m_platformInfo.eProductFamily == IGFX_METEORLAKE ||
++ m_platformInfo.eProductFamily == IGFX_ARROWLAKE)
++ {
++ ReadUserSetting(
++ userSettingPtr,
++ value,
++ "INTEL MEDIA ALLOC MODE",
++ MediaUserSetting::Group::Device);
++
++ if (value)
++ {
++ mode = (value & 0x000000ff);
++ }
++ mos_bufmgr_realloc_cache(m_bufmgr, mode);
++ }
++
+ ReadUserSetting(
+ userSettingPtr,
+ value,
+--
+2.40.1
+