Skip to content

Commit 338ec84

Browse files
committed
drm/xe/bo: optimise CCS case for WB pages
Dealing with CCS state is significant on LNL+, where we end up clearing the compression state on every page alloc using the blitter for user buffers, including also saving and restoring it when moving between domains, plus we need to alloc extra pages to hold the raw CCS state for the save step. However all compression PAT modes, on platforms like LNL, also require coh_none, meaning that only WC memory can use compression in the first place. With this we can be sneaky and completely ignore CCS for WB buffers, which is likely the common case anyway. This would then skip all blitter moves/clears between sys <-> tt and then also means we can drop the extra CCS pages. This should be safe since there is no way to interact with the compression state (potentially uncleared) without using a PAT enabled index (which is rejected at bind), including if trying to be malicious and copy the raw CCS state from userpace, which should give back all zeroes if the src surface (indirect) is lacking compressed PAT index. Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Satyanarayana K V P <satyanarayana.k.v.p@intel.com> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> Cc: Matthew Brost <matthew.brost@intel.com> Reviewed-by: José Roberto de Souza <jose.souza@intel.com> Reviewed-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com> Link: https://lore.kernel.org/r/20250516153810.223530-2-matthew.auld@intel.com
1 parent 2cb38bb commit 338ec84

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2982,6 +2982,14 @@ bool xe_bo_needs_ccs_pages(struct xe_bo *bo)
29822982
if (IS_DGFX(xe) && (bo->flags & XE_BO_FLAG_SYSTEM))
29832983
return false;
29842984

2985+
/*
2986+
* Compression implies coh_none, therefore we know for sure that WB
2987+
* memory can't currently use compression, which is likely one of the
2988+
* common cases.
2989+
*/
2990+
if (bo->cpu_caching == DRM_XE_GEM_CPU_CACHING_WB)
2991+
return false;
2992+
29852993
return true;
29862994
}
29872995

drivers/gpu/drm/xe/xe_pat.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ static const struct xe_pat_table_entry xelpg_pat_table[] = {
103103
*
104104
* Note: There is an implicit assumption in the driver that compression and
105105
* coh_1way+ are mutually exclusive. If this is ever not true then userptr
106-
* and imported dma-buf from external device will have uncleared ccs state.
106+
* and imported dma-buf from external device will have uncleared ccs state. See
107+
* also xe_bo_needs_ccs_pages().
107108
*/
108109
#define XE2_PAT(no_promote, comp_en, l3clos, l3_policy, l4_policy, __coh_mode) \
109110
{ \

0 commit comments

Comments
 (0)