From 5775bc0c53c9b31651fd92e0639ad17e1e65f8ca Mon Sep 17 00:00:00 2001 From: Sagar Ghuge Date: Thu, 29 Feb 2024 10:52:30 -0800 Subject: [PATCH] anv/xe: Consider pat_index while unbinding the bo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Xe KMD also checks if cpu_caching caching set during bo creationg matches with caching of the PAT index set in the VM unbind. This was being unnoticed until now by luck and lack of testing in MTL. So here always setting PAT index for all VM operations that has a bo associated. v2: (Jose) - Move pat_index little bit up - Copy commit message from iris patch Fixes: 19439624d9f ("anv: Use DRM_XE_VM_BIND_OP_UNMAP_ALL to unbind whole bos") Signed-off-by: Sagar Ghuge Reviewed-by: José Roberto de Souza Part-of: --- src/intel/vulkan/xe/anv_kmd_backend.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/intel/vulkan/xe/anv_kmd_backend.c b/src/intel/vulkan/xe/anv_kmd_backend.c index 6056f1193d3..4eca33b06fe 100644 --- a/src/intel/vulkan/xe/anv_kmd_backend.c +++ b/src/intel/vulkan/xe/anv_kmd_backend.c @@ -155,6 +155,10 @@ xe_vm_bind_op(struct anv_device *device, for (int i = 0; i < submit->binds_len; i++) { struct anv_vm_bind *bind = &submit->binds[i]; struct anv_bo *bo = bind->bo; + uint16_t pat_index = 0; + + if (bo) + pat_index = anv_device_get_pat_entry(device, bo->alloc_flags)->index; struct drm_xe_vm_bind_op *xe_bind = &xe_binds[i]; *xe_bind = (struct drm_xe_vm_bind_op) { @@ -165,12 +169,10 @@ xe_vm_bind_op(struct anv_device *device, .op = DRM_XE_VM_BIND_OP_UNMAP, .flags = capture_vm_in_error_dump(device, bo), .prefetch_mem_region_instance = 0, + .pat_index = pat_index, }; if (bind->op == ANV_VM_BIND) { - const enum anv_bo_alloc_flags alloc_flags = bo ? bo->alloc_flags : 0; - - xe_bind->pat_index = anv_device_get_pat_entry(device, alloc_flags)->index; if (!bo) { xe_bind->op = DRM_XE_VM_BIND_OP_MAP; xe_bind->flags |= DRM_XE_VM_BIND_FLAG_NULL;