Skip to content

Commit

Permalink
Add code for old kernel compatibility
Browse files Browse the repository at this point in the history
Fixed intel#1651
Signed-off-by: Gu, Lihao <lihao.gu@intel.com>
  • Loading branch information
LhGu committed May 4, 2023
1 parent 64e4fad commit 3376475
Showing 1 changed file with 39 additions and 26 deletions.
65 changes: 39 additions & 26 deletions media_softlet/linux/common/os/i915/mos_bufmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ mos_gem_bo_alloc_internal(struct mos_bufmgr *bufmgr,

bo_gem->bo.size = bo_size;
bo_gem->mem_region = I915_MEMORY_CLASS_SYSTEM;
bo_gem->pat_index = pat_index;
bo_gem->pat_index = PAT_INDEX_INVALID;
bo_gem->cpu_cacheable = true;

if (bufmgr_gem->has_lmem &&
Expand Down Expand Up @@ -1146,33 +1146,46 @@ mos_gem_bo_alloc_internal(struct mos_bufmgr *bufmgr,
bo_gem->bo.handle = bo_gem->gem_handle;
bo_gem->mem_region = I915_MEMORY_CLASS_DEVICE;
}
else if (pat_index != PAT_INDEX_INVALID)
else
{
struct drm_i915_gem_create_ext_set_pat set_pat_ext;
memclear(set_pat_ext);
set_pat_ext.base.name = I915_GEM_CREATE_EXT_SET_PAT;
set_pat_ext.pat_index = pat_index;

struct drm_i915_gem_create_ext create;
memclear(create);
create.size = bo_size;
create.extensions = (uintptr_t)(&set_pat_ext);
ret = drmIoctl(bufmgr_gem->fd,
DRM_IOCTL_I915_GEM_CREATE_EXT,
ret = -EINVAL;
if (pat_index != PAT_INDEX_INVALID)
{
struct drm_i915_gem_create_ext_set_pat set_pat_ext;
memclear(set_pat_ext);
set_pat_ext.base.name = I915_GEM_CREATE_EXT_SET_PAT;
set_pat_ext.pat_index = pat_index;

struct drm_i915_gem_create_ext create;
memclear(create);
create.size = bo_size;
create.extensions = (uintptr_t)(&set_pat_ext);
ret = drmIoctl(bufmgr_gem->fd,
DRM_IOCTL_I915_GEM_CREATE_EXT,
&create);
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;
}
/* For old kernel without pat_index support,
* DRM_IOCTL_I915_GEM_CREATE_EXT with unknown
* set_pat_ext extension will return error
* Add below code for old kernel compatibility
*/
if (ret != 0)
{
struct drm_i915_gem_create create;
memclear(create);
create.size = bo_size;
ret = drmIoctl(bufmgr_gem->fd,
DRM_IOCTL_I915_GEM_CREATE,
&create);
bo_gem->gem_handle = create.handle;
bo_gem->bo.handle = bo_gem->gem_handle;
bo_gem->cpu_cacheable = cpu_cacheable;
}
else {
struct drm_i915_gem_create create;
memclear(create);
create.size = bo_size;
ret = drmIoctl(bufmgr_gem->fd,
DRM_IOCTL_I915_GEM_CREATE,
&create);
bo_gem->gem_handle = create.handle;
bo_gem->bo.handle = bo_gem->gem_handle;
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) {
free(bo_gem);
Expand Down

0 comments on commit 3376475

Please sign in to comment.