Skip to content

Commit

Permalink
[Media Common] [VP] Remove pat index hard-code and fix bo reuse policy
Browse files Browse the repository at this point in the history
Remove pat index hard-code in our driver because KMD issue was fixed.
Fix bo reuse policy for old KMD without pat index support.
  • Loading branch information
LhGu authored and intel-mediadev committed May 15, 2023
1 parent 3c59100 commit 08dd244
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
1 change: 0 additions & 1 deletion media_softlet/linux/common/os/i915/include/mos_bufmgr.h
Expand Up @@ -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);
Expand Down
22 changes: 10 additions & 12 deletions media_softlet/linux/common/os/i915/mos_bufmgr.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 08dd244

Please sign in to comment.