mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
drm/xe: Allow compressible surfaces to be 1-way coherent
Previously, compressible surfaces were required to be non-coherent (allocated as WC) because compression and coherency were mutually exclusive. Starting with Xe3, hardware supports combining compression with 1-way coherency, allowing compressible surfaces to be allocated as WB memory. This provides applications with more efficient memory allocation by avoiding WC allocation overhead that can cause system stuttering and memory management challenges. The implementation adds support for compressed+coherent PAT entry for the xe3_lpg devices and updates the driver logic to handle the new compression capabilities. v2: (Matthew Auld) - Improved error handling with XE_IOCTL_DBG() - Enhanced documentation and comments - Fixed xe_bo_needs_ccs_pages() outdated compression assumptions v3: - Improve WB compression support detection by checking PAT table instead of version check v4: - Add XE_CACHE_WB_COMPRESSION, which simplifies the logic. v5: - Use U16_MAX for the invalid PAT index. (Matthew Auld) Bspec: 71582, 59361, 59399 Cc: Matthew Auld <matthew.auld@intel.com> Cc: Matt Roper <matthew.d.roper@intel.com> Signed-off-by: Xin Wang <x.wang@intel.com> Reviewed-by: Matthew Auld <matthew.auld@intel.com> Link: https://patch.msgid.link/20260109093007.546784-1-x.wang@intel.com Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
This commit is contained in:
@@ -3405,6 +3405,7 @@ static int vm_bind_ioctl_check_args(struct xe_device *xe, struct xe_vm *vm,
|
||||
DRM_XE_VM_BIND_FLAG_CPU_ADDR_MIRROR;
|
||||
u16 pat_index = (*bind_ops)[i].pat_index;
|
||||
u16 coh_mode;
|
||||
bool comp_en;
|
||||
|
||||
if (XE_IOCTL_DBG(xe, is_cpu_addr_mirror &&
|
||||
(!xe_vm_in_fault_mode(vm) ||
|
||||
@@ -3421,6 +3422,7 @@ static int vm_bind_ioctl_check_args(struct xe_device *xe, struct xe_vm *vm,
|
||||
pat_index = array_index_nospec(pat_index, xe->pat.n_entries);
|
||||
(*bind_ops)[i].pat_index = pat_index;
|
||||
coh_mode = xe_pat_index_get_coh_mode(xe, pat_index);
|
||||
comp_en = xe_pat_index_get_comp_en(xe, pat_index);
|
||||
if (XE_IOCTL_DBG(xe, !coh_mode)) { /* hw reserved */
|
||||
err = -EINVAL;
|
||||
goto free_bind_ops;
|
||||
@@ -3451,6 +3453,8 @@ static int vm_bind_ioctl_check_args(struct xe_device *xe, struct xe_vm *vm,
|
||||
op == DRM_XE_VM_BIND_OP_MAP_USERPTR) ||
|
||||
XE_IOCTL_DBG(xe, coh_mode == XE_COH_NONE &&
|
||||
op == DRM_XE_VM_BIND_OP_MAP_USERPTR) ||
|
||||
XE_IOCTL_DBG(xe, comp_en &&
|
||||
op == DRM_XE_VM_BIND_OP_MAP_USERPTR) ||
|
||||
XE_IOCTL_DBG(xe, op == DRM_XE_VM_BIND_OP_MAP_USERPTR &&
|
||||
!IS_ENABLED(CONFIG_DRM_GPUSVM)) ||
|
||||
XE_IOCTL_DBG(xe, obj &&
|
||||
@@ -3529,6 +3533,7 @@ static int xe_vm_bind_ioctl_validate_bo(struct xe_device *xe, struct xe_bo *bo,
|
||||
u16 pat_index, u32 op, u32 bind_flags)
|
||||
{
|
||||
u16 coh_mode;
|
||||
bool comp_en;
|
||||
|
||||
if (XE_IOCTL_DBG(xe, (bo->flags & XE_BO_FLAG_NO_COMPRESSION) &&
|
||||
xe_pat_index_get_comp_en(xe, pat_index)))
|
||||
@@ -3574,6 +3579,14 @@ static int xe_vm_bind_ioctl_validate_bo(struct xe_device *xe, struct xe_bo *bo,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ensures that imported buffer objects (dma-bufs) are not mapped
|
||||
* with a PAT index that enables compression.
|
||||
*/
|
||||
comp_en = xe_pat_index_get_comp_en(xe, pat_index);
|
||||
if (XE_IOCTL_DBG(xe, bo->ttm.base.import_attach && comp_en))
|
||||
return -EINVAL;
|
||||
|
||||
/* If a BO is protected it can only be mapped if the key is still valid */
|
||||
if ((bind_flags & DRM_XE_VM_BIND_FLAG_CHECK_PXP) && xe_bo_is_protected(bo) &&
|
||||
op != DRM_XE_VM_BIND_OP_UNMAP && op != DRM_XE_VM_BIND_OP_UNMAP_ALL)
|
||||
|
||||
Reference in New Issue
Block a user