Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/xe: Include hardware prefetch buffer in batchbuffer allocations

The hardware prefetches several cachelines of data from batchbuffers
before they are parsed. This prefetching only stops when the parser
encounters an MI_BATCH_BUFFER_END instruction (or a nested
MI_BATCH_BUFFER_START), so we must ensure that there is enough padding
at the end of the batchbuffer to prevent the prefetcher from running
past the end of the allocation and potentially faulting.

Bspec: 45717
Link: https://lore.kernel.org/r/20230329173334.4015124-2-matthew.d.roper@intel.com
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

authored by

Matt Roper and committed by
Rodrigo Vivi
681818fd 3d4451d3

+23 -2
+23 -2
drivers/gpu/drm/xe/xe_bb.c
··· 8 8 #include "regs/xe_gpu_commands.h" 9 9 #include "xe_device.h" 10 10 #include "xe_engine_types.h" 11 + #include "xe_gt.h" 11 12 #include "xe_hw_fence.h" 12 13 #include "xe_sa.h" 13 14 #include "xe_sched_job.h" 14 15 #include "xe_vm_types.h" 16 + 17 + static int bb_prefetch(struct xe_gt *gt) 18 + { 19 + struct xe_device *xe = gt->xe; 20 + 21 + if (GRAPHICS_VERx100(xe) >= 1250 && !xe_gt_is_media_type(gt)) 22 + /* 23 + * RCS and CCS require 1K, although other engines would be 24 + * okay with 512. 25 + */ 26 + return SZ_1K; 27 + else 28 + return SZ_512; 29 + } 15 30 16 31 struct xe_bb *xe_bb_new(struct xe_gt *gt, u32 dwords, bool usm) 17 32 { ··· 36 21 if (!bb) 37 22 return ERR_PTR(-ENOMEM); 38 23 39 - bb->bo = xe_sa_bo_new(!usm ? &gt->kernel_bb_pool : 40 - &gt->usm.bb_pool, 4 * dwords + 4); 24 + /* 25 + * We need to allocate space for the requested number of dwords, 26 + * one additional MI_BATCH_BUFFER_END dword, and additional buffer 27 + * space to accomodate the platform-specific hardware prefetch 28 + * requirements. 29 + */ 30 + bb->bo = xe_sa_bo_new(!usm ? &gt->kernel_bb_pool : &gt->usm.bb_pool, 31 + 4 * (dwords + 1) + bb_prefetch(gt)); 41 32 if (IS_ERR(bb->bo)) { 42 33 err = PTR_ERR(bb->bo); 43 34 goto err;