3737#include "generated/xe_wa_oob.h"
3838#include "xe_wa.h"
3939
40- #define TEST_VM_ASYNC_OPS_ERROR
41-
4240static struct drm_gem_object * xe_vm_obj (struct xe_vm * vm )
4341{
4442 return vm -> gpuvm .r_obj ;
@@ -114,11 +112,8 @@ int xe_vma_userptr_pin_pages(struct xe_userptr_vma *uvma)
114112 num_pages - pinned ,
115113 read_only ? 0 : FOLL_WRITE ,
116114 & pages [pinned ]);
117- if (ret < 0 ) {
118- if (in_kthread )
119- ret = 0 ;
115+ if (ret < 0 )
120116 break ;
121- }
122117
123118 pinned += ret ;
124119 ret = 0 ;
@@ -1984,6 +1979,7 @@ static int xe_vm_prefetch(struct xe_vm *vm, struct xe_vma *vma,
19841979 xe_exec_queue_last_fence_get (wait_exec_queue , vm );
19851980
19861981 xe_sync_entry_signal (& syncs [i ], NULL , fence );
1982+ dma_fence_put (fence );
19871983 }
19881984 }
19891985
@@ -2064,7 +2060,6 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_bo *bo,
20642060 struct drm_gem_object * obj = bo ? & bo -> ttm .base : NULL ;
20652061 struct drm_gpuva_ops * ops ;
20662062 struct drm_gpuva_op * __op ;
2067- struct xe_vma_op * op ;
20682063 struct drm_gpuvm_bo * vm_bo ;
20692064 int err ;
20702065
@@ -2111,15 +2106,6 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_bo *bo,
21112106 if (IS_ERR (ops ))
21122107 return ops ;
21132108
2114- #ifdef TEST_VM_ASYNC_OPS_ERROR
2115- if (operation & FORCE_ASYNC_OP_ERROR ) {
2116- op = list_first_entry_or_null (& ops -> list , struct xe_vma_op ,
2117- base .entry );
2118- if (op )
2119- op -> inject_error = true;
2120- }
2121- #endif
2122-
21232109 drm_gpuva_for_each_op (__op , ops ) {
21242110 struct xe_vma_op * op = gpuva_op_to_vma_op (__op );
21252111
@@ -2199,8 +2185,10 @@ static u64 xe_vma_max_pte_size(struct xe_vma *vma)
21992185 return SZ_1G ;
22002186 else if (vma -> gpuva .flags & XE_VMA_PTE_2M )
22012187 return SZ_2M ;
2188+ else if (vma -> gpuva .flags & XE_VMA_PTE_4K )
2189+ return SZ_4K ;
22022190
2203- return SZ_4K ;
2191+ return SZ_1G ; /* Uninitialized, used max size */
22042192}
22052193
22062194static u64 xe_vma_set_pte_size (struct xe_vma * vma , u64 size )
@@ -2530,13 +2518,25 @@ static int __xe_vma_op_execute(struct xe_vm *vm, struct xe_vma *vma,
25302518 }
25312519 drm_exec_fini (& exec );
25322520
2533- if (err == - EAGAIN && xe_vma_is_userptr ( vma ) ) {
2521+ if (err == - EAGAIN ) {
25342522 lockdep_assert_held_write (& vm -> lock );
2535- err = xe_vma_userptr_pin_pages (to_userptr_vma (vma ));
2536- if (!err )
2537- goto retry_userptr ;
25382523
2539- trace_xe_vma_fail (vma );
2524+ if (op -> base .op == DRM_GPUVA_OP_REMAP ) {
2525+ if (!op -> remap .unmap_done )
2526+ vma = gpuva_to_vma (op -> base .remap .unmap -> va );
2527+ else if (op -> remap .prev )
2528+ vma = op -> remap .prev ;
2529+ else
2530+ vma = op -> remap .next ;
2531+ }
2532+
2533+ if (xe_vma_is_userptr (vma )) {
2534+ err = xe_vma_userptr_pin_pages (to_userptr_vma (vma ));
2535+ if (!err )
2536+ goto retry_userptr ;
2537+
2538+ trace_xe_vma_fail (vma );
2539+ }
25402540 }
25412541
25422542 return err ;
@@ -2548,13 +2548,6 @@ static int xe_vma_op_execute(struct xe_vm *vm, struct xe_vma_op *op)
25482548
25492549 lockdep_assert_held_write (& vm -> lock );
25502550
2551- #ifdef TEST_VM_ASYNC_OPS_ERROR
2552- if (op -> inject_error ) {
2553- op -> inject_error = false;
2554- return - ENOMEM ;
2555- }
2556- #endif
2557-
25582551 switch (op -> base .op ) {
25592552 case DRM_GPUVA_OP_MAP :
25602553 ret = __xe_vma_op_execute (vm , op -> map .vma , op );
@@ -2669,7 +2662,7 @@ static void vm_bind_ioctl_ops_unwind(struct xe_vm *vm,
26692662{
26702663 int i ;
26712664
2672- for (i = num_ops_list - 1 ; i ; ++ i ) {
2665+ for (i = num_ops_list - 1 ; i >= 0 ; -- i ) {
26732666 struct drm_gpuva_ops * __ops = ops [i ];
26742667 struct drm_gpuva_op * __op ;
26752668
@@ -2714,16 +2707,9 @@ static int vm_bind_ioctl_ops_execute(struct xe_vm *vm,
27142707 return 0 ;
27152708}
27162709
2717- #ifdef TEST_VM_ASYNC_OPS_ERROR
2718- #define SUPPORTED_FLAGS \
2719- (FORCE_ASYNC_OP_ERROR | DRM_XE_VM_BIND_FLAG_READONLY | \
2720- DRM_XE_VM_BIND_FLAG_IMMEDIATE | DRM_XE_VM_BIND_FLAG_NULL | 0xffff)
2721- #else
27222710#define SUPPORTED_FLAGS \
27232711 (DRM_XE_VM_BIND_FLAG_READONLY | \
2724- DRM_XE_VM_BIND_FLAG_IMMEDIATE | DRM_XE_VM_BIND_FLAG_NULL | \
2725- 0xffff)
2726- #endif
2712+ DRM_XE_VM_BIND_FLAG_IMMEDIATE | DRM_XE_VM_BIND_FLAG_NULL)
27272713#define XE_64K_PAGE_MASK 0xffffull
27282714#define ALL_DRM_XE_SYNCS_FLAGS (DRM_XE_SYNCS_FLAG_WAIT_FOR_OP)
27292715
0 commit comments