From 08dd244b22484770a33464c2c8ae85430e548000 Mon Sep 17 00:00:00 2001 From: LhGu Date: Mon, 15 May 2023 14:34:08 +0800 Subject: [PATCH] [Media Common] [VP] Remove pat index hard-code and fix bo reuse policy Remove pat index hard-code in our driver because KMD issue was fixed. Fix bo reuse policy for old KMD without pat index support. --- .../linux/common/os/i915/include/mos_bufmgr.h | 1 - .../linux/common/os/i915/mos_bufmgr.c | 22 +++++++++---------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/media_softlet/linux/common/os/i915/include/mos_bufmgr.h b/media_softlet/linux/common/os/i915/include/mos_bufmgr.h index ca1d364118..5fcc70413f 100644 --- a/media_softlet/linux/common/os/i915/include/mos_bufmgr.h +++ b/media_softlet/linux/common/os/i915/include/mos_bufmgr.h @@ -171,7 +171,6 @@ struct mos_aub_annotation { #define BO_ALLOC_FOR_RENDER (1<<0) #define PAT_INDEX_INVALID ((uint32_t)-1) -#define PAT_INDEX_NON_COHERENT_UC 2 struct mos_linux_bo *mos_bo_alloc(struct mos_bufmgr *bufmgr, const char *name, unsigned long size, unsigned int alignment, int mem_type, unsigned int pat_index = PAT_INDEX_INVALID, bool cpu_cacheable = true); diff --git a/media_softlet/linux/common/os/i915/mos_bufmgr.c b/media_softlet/linux/common/os/i915/mos_bufmgr.c index 19d66d0279..a5d587a36d 100644 --- a/media_softlet/linux/common/os/i915/mos_bufmgr.c +++ b/media_softlet/linux/common/os/i915/mos_bufmgr.c @@ -1047,17 +1047,12 @@ mos_gem_bo_alloc_internal(struct mos_bufmgr *bufmgr, } else { bo_size = bucket->size; } - /* For specific platform with no L4 cache, - * pat_index which is less than PAT_INDEX_NON_COHERENT_UC is the same as PAT_INDEX_NON_COHERENT_UC. - * However, from our tests, less than PAT_INDEX_NON_COHERENT_UC has some unexpected issues. - * Gmm or i915 may need to handle this issue when doing bo allocation. - * Temporarily, hard-code PAT_INDEX_NON_COHERENT_UC when pat index is less than PAT_INDEX_NON_COHERENT_UC for the specific platform. - * If new platform open source is enabled and the meaning of pat_index is changed, - * this quick enable code may cause issue. - */ - if (pat_index < PAT_INDEX_NON_COHERENT_UC) + if (!support_pat_index) { - pat_index = PAT_INDEX_NON_COHERENT_UC; + /* For old kernel without pat index support, + * We need to reset pat_index for bo reuse policy + */ + pat_index = PAT_INDEX_INVALID; } pthread_mutex_lock(&bufmgr_gem->lock); /* Get a buffer out of the cache if available */ @@ -1174,7 +1169,6 @@ mos_gem_bo_alloc_internal(struct mos_bufmgr *bufmgr, bo_gem->gem_handle = create.handle; bo_gem->bo.handle = bo_gem->gem_handle; bo_gem->pat_index = pat_index; - bo_gem->cpu_cacheable = cpu_cacheable; if (ret != 0) { /* For old kernel without pat_index support, @@ -1196,7 +1190,6 @@ mos_gem_bo_alloc_internal(struct mos_bufmgr *bufmgr, bo_gem->gem_handle = create.handle; bo_gem->bo.handle = bo_gem->gem_handle; bo_gem->pat_index = PAT_INDEX_INVALID; - bo_gem->cpu_cacheable = true; } } if (ret != 0) { @@ -1239,6 +1232,11 @@ mos_gem_bo_alloc_internal(struct mos_bufmgr *bufmgr, bo_gem->reusable = true; bo_gem->use_48b_address_range = bufmgr_gem->bufmgr.bo_use_48b_address_range ? true : false; + if (bo_gem->pat_index != PAT_INDEX_INVALID) + { + bo_gem->cpu_cacheable = cpu_cacheable; + } + mos_bo_gem_set_in_aperture_size(bufmgr_gem, bo_gem, alignment); if (bufmgr_gem->use_softpin)