anv/xe: Consider pat_index while unbinding the bo

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: 19439624d9 ("anv: Use DRM_XE_VM_BIND_OP_UNMAP_ALL to unbind whole bos")
Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com>
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27893>
This commit is contained in:
Sagar Ghuge 2024-02-29 10:52:30 -08:00 committed by Marge Bot
parent 963c08b623
commit 5775bc0c53

View file

@ -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;