drm/xe: Use kvmalloc for the VMA ops page-table update array
Subsystems (3)
PATCH 1/1 drm/xe: Use kvmalloc for the VMA ops page-table update array
From: Karim Sabar <[email protected]>
Big games die after every s2idle resume on flat-CCS iGPUs. The exec ioctl keeps returning -ENOMEM even with 11-16 GB of RAM free.
On suspend xe_bo_evict_all_user() evicts every user BO in XE_PL_TT on these parts. On resume the first exec rebinds every VMA in one go and xe_vma_ops_alloc() kmallocs one 384-byte op per VMA as a single array. Final Fantasy VII Rebirth has about 33,500 VMAs which means a 12.9 MB array. It's over the 4 MB KMALLOC_MAX_SIZE and can never succeed. __GFP_NOWARN keeps it out of dmesg.
Data from a Panther Lake handheld (SteamOS kernel 7.2.7), kretprobes after resume:
xe_vma_ops_alloc -ENOMEM on 63 of 63 attempts
xe_vm_rebind -ENOMEM on 63 of 63 attempts
BO validate, TTM populate, PT prepare never failed
The array is only used by the CPU and doesn't need to be contiguous. This switches it to kvmalloc and kvfree.
With the same change applied as a module on that kernel, the game survives every sleep I tried with zero ENOMEM. The biggest array was 30,753 ops (11.8 MB).
drm-xe-next already does this through commit 0e33330f1238 ("drm/xe: Add struct xe_pt_job_ops"), but that's part of a big series that won't go to stable.
I tracked this down and tested it on my own device. I used an AI assistant to help with the debugging, i.e the kprobe tracing and reading through the xe code. I ran every test, picked the fix and reviewed the change myself.
What I couldn't do: this is build-tested on drm-xe-fixes but only run-tested on the SteamOS 7.2.7 kernel through an equivalent module, not on a mainline kernel.
---
Downstream SteamOS report with the same data: https://github.com/ValveSoftware/SteamOS/issues/2962
--- drivers/gpu/drm/xe/xe_vm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_vm.c +4 -4
@@ -703,9 +703,9 @@ static int xe_vma_ops_alloc(struct xe_vma_ops *vops, bool array_of_binds)continue ; vops->pt_update_ops[i].ops = -kmalloc_objs (*vops->pt_update_ops[i].ops, - vops->pt_update_ops[i].num_ops, -GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_NOWARN); +kvmalloc_objs (*vops->pt_update_ops[i].ops, + vops->pt_update_ops[i].num_ops, +GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_NOWARN);if (!vops->pt_update_ops[i].ops)return array_of_binds ? -ENOBUFS : -ENOMEM ; }
@@ -742,7 +742,7 @@ static void xe_vma_ops_fini(struct xe_vma_ops *vops)xe_vma_svm_prefetch_ops_fini (vops);for (i =0 ; i <XE_MAX_TILES_PER_DEVICE ; ++i) -kfree (vops->pt_update_ops[i].ops); +kvfree (vops->pt_update_ops[i].ops); }static void xe_vma_ops_incr_pt_update_ops (struct xe_vma_ops *vops,u8 tile_mask,int inc_val)
---
base-commit: d2ce8fcd778ee6d92748c92d23a56d4416c29d86
change-id: 20261020-xe-kvmalloc-vma-ops-2637ebf81cfd
Best regards,
Signature · 1 line
Karim Sabar <[email protected]>
Patchwork
CI✗ LGCI.VerificationFailed: failure for drm/xe: Use kvmalloc for the VMA ops page-table update array
== Series Details ==
== Series Details ==
Series: drm/xe: Use kvmalloc for the VMA ops page-table update array
URL : https://patchwork.freedesktop.org/series/176556/
State : failure
== Summary ==
Series author address '[email protected]' is not on the allowlist, which prevents CI from being automatically triggered. If you want CI to run for this series, ask Patchwork project owners to click 'retest' on the series in Patchwork. Exception occurred during validation, bailing out!
Build URL: http://intel-gfx-ci-public.igk.intel.com:8080/job/xe_pw_trigger/1318717/ (on master)
Matthew Brost
maintainerQuoted 2 lines · On Tue, Oct 20, 2026 at 07:08:27PM -0500, [email protected] wrote:
From: Karim Sabar <[email protected]>
Thanks for the patch. I do see the problem in the old code. Unfortunately, we will not be able to pull this into drm-xe-next or drm-xe-fixes, as 7.3 is already out and 0e33330f1238 is included in our 7.4 PR. As a result, this would need to go directly to stable.
There is also a risk that predates the series containing 0e33330f1238. If the bind has to run on the GPU, you can still get -ENOBUFS later in the bind pipeline if the bind is too large to fit into the migration-layer BB. If that occurs, the proper fix may actually be in xe_vm_validate_rebind(). If xe_vm_rebind() fails with -ENOBUFS or -ENOMEM, we could call a new function, such as xe_vm_rebind_iterative(), which would run each VMA requiring a rebind in its own job. This is effectively what Mesa does in userspace when a bind operation returns -ENOBUFS.
We could probably still pull that approach into drm-xe-fixes + have naturally backport to stable, and it may ultimately be the better solution.
Let me know what you think. I can give this an RB, but I'd like to hold off until we've settled on the solution we want to pursue here.
Matt
Quoted 81 lines
Big games die after every s2idle resume on flat-CCS iGPUs. The exec ioctl keeps returning
-ENOMEMeven with 11-16 GB of RAM free.On suspend
xe_bo_evict_all_user()evicts every user BO inXE_PL_TTon these parts. On resume the first exec rebinds every VMA in one go andxe_vma_ops_alloc()kmallocs one 384-byte op per VMA as a single array. Final Fantasy VII Rebirth has about 33,500 VMAs which means a 12.9 MB array. It's over the 4 MBKMALLOC_MAX_SIZEand can never succeed.__GFP_NOWARNkeeps it out of dmesg.Data from a Panther Lake handheld (SteamOS kernel 7.2.7), kretprobes after resume:
xe_vma_ops_alloc-ENOMEMon 63 of 63 attempts
xe_vm_rebind-ENOMEMon 63 of 63 attempts
BO validate, TTM populate, PT prepare never failedThe array is only used by the CPU and doesn't need to be contiguous. This switches it to kvmalloc and kvfree.
With the same change applied as a module on that kernel, the game survives every sleep I tried with zero ENOMEM. The biggest array was 30,753 ops (11.8 MB).
drm-xe-next already does this through commit
0e33330f1238("drm/xe: Add structxe_pt_job_ops"), but that's part of a big series that won't go to stable.I tracked this down and tested it on my own device. I used an AI assistant to help with the debugging, i.e the kprobe tracing and reading through the xe code. I ran every test, picked the fix and reviewed the change myself.
What I couldn't do: this is build-tested on drm-xe-fixes but only run-tested on the SteamOS 7.2.7 kernel through an equivalent module, not on a mainline kernel.
Fixes 2e524668c440 ("drm/xe: Add xe_vm_pgtable_update_op to xe_vma_ops")Cc [email protected] # v6.11+Assisted-by Claude:claude-opus-5-5Signed-off-by Karim Sabar <[email protected]>---
Downstream SteamOS report with the same data: https://github.com/ValveSoftware/SteamOS/issues/2962--- drivers/gpu/drm/xe/xe_vm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/xe/xe_vm.c +4
-5@@ -703,9 +703,9 @@ static int xe_vma_ops_alloc(struct xe_vma_ops *vops, bool array_of_binds)continue ; vops->pt_update_ops[i].ops = -kmalloc_objs (*vops->pt_update_ops[i].ops, - vops->pt_update_ops[i].num_ops, -GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_NOWARN); +kvmalloc_objs (*vops->pt_update_ops[i].ops, + vops->pt_update_ops[i].num_ops, +GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_NOWARN);if (!vops->pt_update_ops[i].ops)return array_of_binds ? -ENOBUFS : -ENOMEM ; }@@ -742,7 +742,7 @@ static void xe_vma_ops_fini(struct xe_vma_ops *vops)xe_vma_svm_prefetch_ops_fini (vops);for (i =0 ; i <XE_MAX_TILES_PER_DEVICE ; ++i) -kfree (vops->pt_update_ops[i].ops); +kvfree (vops->pt_update_ops[i].ops); }static void xe_vma_ops_incr_pt_update_ops (struct xe_vma_ops *vops,u8 tile_mask,int inc_val) ---base-commit:
d2ce8fcd778ee6d92748c92d23a56d4416c29d86
change-id: 20261020-xe-kvmalloc-vma-ops-2637ebf81cfdBest regards,
Signature · 1 line
Karim Sabar <[email protected]>
Hey Matthew!
Sounds good to me, the fallback of trying to bind the vma one at a time sounds good to me. And it is actually a bit broader than my patch since it covers the -ENOBUFS case as well. It should also be easy to get through drm-xe-fixes and then backported the normal way.
I can write it as a v2 & test it on my Panther Lake device, I have a small repro that does about 20,000 mappings and fails after suspend (every time without the fix). If you'd prefer to write it, I can test your patch as well.
Thanks,
Karim
Quoted 109 lines · Matthew Brost
Quoted 2 lines · On Tue, Oct 20, 2026 at 07:08:27PM -0500, [email protected] wrote:
From: Karim Sabar <[email protected]>
Thanks for the patch. I do see the problem in the old code. Unfortunately, we will not be able to pull this into drm-xe-next or drm-xe-fixes, as 7.3 is already out and
0e33330f1238is included in our 7.4 PR. As a result, this would need to go directly to stable.There is also a risk that predates the series containing
0e33330f1238. If the bind has to run on the GPU, you can still get-ENOBUFSlater in the bind pipeline if the bind is too large to fit into the migration-layer BB. If that occurs, the proper fix may actually be inxe_vm_validate_rebind(). Ifxe_vm_rebind()fails with-ENOBUFSor-ENOMEM, we could call a new function, such asxe_vm_rebind_iterative(), which would run each VMA requiring a rebind in its own job. This is effectively what Mesa does in userspace when a bind operation returns-ENOBUFS.We could probably still pull that approach into drm-xe-fixes + have naturally backport to stable, and it may ultimately be the better solution.
Let me know what you think. I can give this an RB, but I'd like to hold off until we've settled on the solution we want to pursue here.
Matt
Quoted 81 lines
Big games die after every s2idle resume on flat-CCS iGPUs. The exec ioctl keeps returning
-ENOMEMeven with 11-16 GB of RAM free.On suspend
xe_bo_evict_all_user()evicts every user BO inXE_PL_TTon these parts. On resume the first exec rebinds every VMA in one go andxe_vma_ops_alloc()kmallocs one 384-byte op per VMA as a single array. Final Fantasy VII Rebirth has about 33,500 VMAs which means a 12.9 MB array. It's over the 4 MBKMALLOC_MAX_SIZEand can never succeed.__GFP_NOWARNkeeps it out of dmesg.Data from a Panther Lake handheld (SteamOS kernel 7.2.7), kretprobes after resume:
xe_vma_ops_alloc-ENOMEMon 63 of 63 attempts
xe_vm_rebind-ENOMEMon 63 of 63 attempts
BO validate, TTM populate, PT prepare never failedThe array is only used by the CPU and doesn't need to be contiguous. This switches it to kvmalloc and kvfree.
With the same change applied as a module on that kernel, the game survives every sleep I tried with zero ENOMEM. The biggest array was 30,753 ops (11.8 MB).
drm-xe-next already does this through commit
0e33330f1238("drm/xe: Add structxe_pt_job_ops"), but that's part of a big series that won't go to stable.I tracked this down and tested it on my own device. I used an AI assistant to help with the debugging, i.e the kprobe tracing and reading through the xe code. I ran every test, picked the fix and reviewed the change myself.
What I couldn't do: this is build-tested on drm-xe-fixes but only run-tested on the SteamOS 7.2.7 kernel through an equivalent module, not on a mainline kernel.
Fixes 2e524668c440 ("drm/xe: Add xe_vm_pgtable_update_op to xe_vma_ops")Cc [email protected] # v6.11+Assisted-by Claude:claude-opus-5-5Signed-off-by Karim Sabar <[email protected]>---
Downstream SteamOS report with the same data: https://github.com/ValveSoftware/SteamOS/issues/2962--- drivers/gpu/drm/xe/xe_vm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/xe/xe_vm.c +4
-5@@ -703,9 +703,9 @@ static int xe_vma_ops_alloc(struct xe_vma_ops *vops, bool array_of_binds)continue ; vops->pt_update_ops[i].ops = -kmalloc_objs (*vops->pt_update_ops[i].ops, - vops->pt_update_ops[i].num_ops, -GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_NOWARN); +kvmalloc_objs (*vops->pt_update_ops[i].ops, + vops->pt_update_ops[i].num_ops, +GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_NOWARN);if (!vops->pt_update_ops[i].ops)return array_of_binds ? -ENOBUFS : -ENOMEM ; }@@ -742,7 +742,7 @@ static void xe_vma_ops_fini(struct xe_vma_ops *vops)xe_vma_svm_prefetch_ops_fini (vops);for (i =0 ; i <XE_MAX_TILES_PER_DEVICE ; ++i) -kfree (vops->pt_update_ops[i].ops); +kvfree (vops->pt_update_ops[i].ops); }static void xe_vma_ops_incr_pt_update_ops (struct xe_vma_ops *vops,u8 tile_mask,int inc_val) ---base-commit:
d2ce8fcd778ee6d92748c92d23a56d4416c29d86
change-id: 20261020-xe-kvmalloc-vma-ops-2637ebf81cfdBest regards,
Signature · 1 line
Karim Sabar <[email protected]>
Matthew Brost
maintainerQuoted 6 lines · On Wed, Oct 21, 2026 at 09:28:08PM -0500, [email protected] wrote:
Hey Matthew!
Sounds good to me, the fallback of trying to bind the vma one at a time sounds good to me. And it is actually a bit broader than my patch since it covers the
-ENOBUFScase as well. It should also be easy to get through drm-xe-fixes and then backported the normal way.I can write it as a v2 & test it on my Panther Lake device, I have a small repro that does about 20,000 mappings and fails after suspend (every time without the fix). If you'd prefer to write it, I can test your patch as well.
Since you have a repro, I'd say go ahead and code it up. This is on my radar, so I can review and pull it quickly. It should be a relatively simple function, and something like Claude can help you code it with a concise query if needed.
One follow-up we'd probably want to add is error injection and an IGT test to ensure long-term functionality, but we (Intel) can take care of that part as an AR.
Matt
Quoted 113 lines
Thanks,
KarimQuoted 109 lines · Matthew Brost
Quoted 2 lines · On Tue, Oct 20, 2026 at 07:08:27PM -0500, [email protected] wrote:
From: Karim Sabar <[email protected]>
Thanks for the patch. I do see the problem in the old code. Unfortunately, we will not be able to pull this into drm-xe-next or drm-xe-fixes, as 7.3 is already out and
0e33330f1238is included in our 7.4 PR. As a result, this would need to go directly to stable.There is also a risk that predates the series containing
0e33330f1238. If the bind has to run on the GPU, you can still get-ENOBUFSlater in the bind pipeline if the bind is too large to fit into the migration-layer BB. If that occurs, the proper fix may actually be inxe_vm_validate_rebind(). Ifxe_vm_rebind()fails with-ENOBUFSor-ENOMEM, we could call a new function, such asxe_vm_rebind_iterative(), which would run each VMA requiring a rebind in its own job. This is effectively what Mesa does in userspace when a bind operation returns-ENOBUFS.We could probably still pull that approach into drm-xe-fixes + have naturally backport to stable, and it may ultimately be the better solution.
Let me know what you think. I can give this an RB, but I'd like to hold off until we've settled on the solution we want to pursue here.
Matt
Quoted 81 lines
Big games die after every s2idle resume on flat-CCS iGPUs. The exec ioctl keeps returning
-ENOMEMeven with 11-16 GB of RAM free.On suspend
xe_bo_evict_all_user()evicts every user BO inXE_PL_TTon these parts. On resume the first exec rebinds every VMA in one go andxe_vma_ops_alloc()kmallocs one 384-byte op per VMA as a single array. Final Fantasy VII Rebirth has about 33,500 VMAs which means a 12.9 MB array. It's over the 4 MBKMALLOC_MAX_SIZEand can never succeed.__GFP_NOWARNkeeps it out of dmesg.Data from a Panther Lake handheld (SteamOS kernel 7.2.7), kretprobes after resume:
xe_vma_ops_alloc-ENOMEMon 63 of 63 attempts
xe_vm_rebind-ENOMEMon 63 of 63 attempts
BO validate, TTM populate, PT prepare never failedThe array is only used by the CPU and doesn't need to be contiguous. This switches it to kvmalloc and kvfree.
With the same change applied as a module on that kernel, the game survives every sleep I tried with zero ENOMEM. The biggest array was 30,753 ops (11.8 MB).
drm-xe-next already does this through commit
0e33330f1238("drm/xe: Add structxe_pt_job_ops"), but that's part of a big series that won't go to stable.I tracked this down and tested it on my own device. I used an AI assistant to help with the debugging, i.e the kprobe tracing and reading through the xe code. I ran every test, picked the fix and reviewed the change myself.
What I couldn't do: this is build-tested on drm-xe-fixes but only run-tested on the SteamOS 7.2.7 kernel through an equivalent module, not on a mainline kernel.
Fixes 2e524668c440 ("drm/xe: Add xe_vm_pgtable_update_op to xe_vma_ops")Cc [email protected] # v6.11+Assisted-by Claude:claude-opus-5-5Signed-off-by Karim Sabar <[email protected]>---
Downstream SteamOS report with the same data: https://github.com/ValveSoftware/SteamOS/issues/2962--- drivers/gpu/drm/xe/xe_vm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/xe/xe_vm.c +4
-5@@ -703,9 +703,9 @@ static int xe_vma_ops_alloc(struct xe_vma_ops *vops, bool array_of_binds)continue ; vops->pt_update_ops[i].ops = -kmalloc_objs (*vops->pt_update_ops[i].ops, - vops->pt_update_ops[i].num_ops, -GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_NOWARN); +kvmalloc_objs (*vops->pt_update_ops[i].ops, + vops->pt_update_ops[i].num_ops, +GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_NOWARN);if (!vops->pt_update_ops[i].ops)return array_of_binds ? -ENOBUFS : -ENOMEM ; }@@ -742,7 +742,7 @@ static void xe_vma_ops_fini(struct xe_vma_ops *vops)xe_vma_svm_prefetch_ops_fini (vops);for (i =0 ; i <XE_MAX_TILES_PER_DEVICE ; ++i) -kfree (vops->pt_update_ops[i].ops); +kvfree (vops->pt_update_ops[i].ops); }static void xe_vma_ops_incr_pt_update_ops (struct xe_vma_ops *vops,u8 tile_mask,int inc_val) ---base-commit:
d2ce8fcd778ee6d92748c92d23a56d4416c29d86
change-id: 20261020-xe-kvmalloc-vma-ops-2637ebf81cfdBest regards,
Signature · 1 line
Karim Sabar <[email protected]>
PATCH v2 1/1 drm/xe: Rebind VMAs one at a time when a bulk rebind fails
From: Karim Sabar <[email protected]>
Big games die after every s2idle resume on flat-CCS iGPUs. The exec ioctl keeps returning -ENOMEM even with 11-16 GB of RAM free.
On suspend xe_bo_evict_all_user() evicts every user BO in XE_PL_TT on these parts. On resume the first exec rebinds every VMA in one job and xe_vma_ops_alloc() kmallocs one 384-byte op per VMA as a single array. Final Fantasy VII Rebirth has about 33,500 VMAs which means a 12.9 MB array. It's over the 4 MB KMALLOC_MAX_SIZE and can never succeed. A bind that big can also fail later with -ENOBUFS when it doesn't fit in the migrate layer's vm_update_sa.
When xe_vm_rebind() fails with -ENOMEM or -ENOBUFS, fall back to xe_vm_rebind_iterative(). It rebinds each VMA on the rebind list in its own job, the same thing Mesa does from userspace when a bind returns -ENOBUFS. Each VMA comes off the list once its job is queued which means a failure part way through leaves the rest for the next attempt.
I tested this on a OneXPlayer 3 (Panther Lake) running SteamOS's 7.2.7 kernel. A small Vulkan program fills a VM with 20,000 or 35,000 64 KiB buffers, suspends with rtcwake and submits again after resume. Without the fix the first exec after resume returns -ENOMEM over and over and Mesa reports the device as lost. With the same fallback loaded into xe_vm_validate_rebind() through a test module, the bulk rebind failed with -ENOMEM on all four resumes and the fallback rebound 20,024 VMAs three times and 35,027 VMAs once with no errors. The program kept submitting after every resume and the kernel log stayed clean. The patch itself is build tested on drm-xe-fixes with W=1.
I tracked this down and tested it on my own device. I used an AI assistant to help with the debugging and with writing the fallback. I ran every test and reviewed the change myself.
---
Hey Matt,
Sorry for the slow turnaround on this one. I said I'd write it and then it sat for a week. Here's the iterative rebind you suggested. When xe_vm_rebind() fails with -ENOMEM or -ENOBUFS, xe_vm_validate_rebind() now falls back to rebinding one VMA per job.
I only hooked it into xe_vm_validate_rebind() like you said. The preempt rebind worker for LR VMs still calls xe_vm_rebind() directly. I left that alone since it's not the path I can reproduce but I'm happy to add it there too if you want it covered.
Thanks for offering to take the error injection and IGT test on your side. Also I'm not on the Intel CI allowlist which means CI won't run on this one until someone hits retest. Would you mind kicking it off?
Changes in v2:
- Fall back to per-VMA rebinds in xe_vm_validate_rebind() instead of switching the op array to kvmalloc (Matt)
- Link to v1: https://lore.kernel.org/r/[email protected]
drivers/gpu/drm/xe/xe_vm.c | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
drivers/gpu/drm/xe/xe_vm.c +49 -0
@@ -370,6 +370,8 @@ static int xe_gpuvm_validate(struct drm_gpuvm_bo *vm_bo, struct drm_exec *exec)return 0 ; } +static int xe_vm_rebind_iterative (struct xe_vm *vm); +/** * xe_vm_validate_rebind() - Validate buffer objects and rebind vmas * @vm: The vm for which we are rebinding.
@@ -397,6 +399,8 @@ int xe_vm_validate_rebind(struct xe_vm *vm, struct drm_exec *exec,return ret; ret =xe_vm_rebind (vm, false); +if (ret == -ENOBUFS || ret == -ENOMEM ) + ret =xe_vm_rebind_iterative (vm);if (ret)return ret; }while (!list_empty (&vm->gpuvm.evict.list));
@@ -856,6 +860,51 @@ int xe_vm_rebind(struct xe_vm *vm, bool rebind_worker)return err; } +static int xe_vm_rebind_iterative (struct xe_vm *vm) +{ +struct dma_fence *fence; +struct xe_vma *vma, *next; +struct xe_vma_ops vops; +struct xe_vma_op *op, *next_op; +int err =0 , i; + +lockdep_assert_held (&vm->lock); +xe_vm_assert_held (vm); + +list_for_each_entry_safe (vma, next, &vm->rebind_list, + combined_links.rebind) { +xe_vma_ops_init (&vops, vm,NULL ,NULL ,0 ); +for (i =0 ; i <XE_MAX_TILES_PER_DEVICE ; ++i) + vops.pt_update_ops[i].wait_vm_bookkeep = true; + +trace_xe_vma_rebind_exec (vma); + + err =xe_vm_ops_add_rebind (&vops, vma, vma->tile_present); +if (!err) + err =xe_vma_ops_alloc (&vops, false); +if (!err) { + fence =ops_execute (vm, &vops); +if (IS_ERR (fence)) { + err =PTR_ERR (fence); + }else { +dma_fence_put (fence); +list_del_init (&vma->combined_links.rebind); + } + } + +list_for_each_entry_safe (op, next_op, &vops.list, link) { +list_del (&op->link); +kfree (op); + } +xe_vma_ops_fini (&vops); + +if (err) +break ; + } + +return err; +} +struct dma_fence *xe_vma_rebind (struct xe_vm *vm,struct xe_vma *vma,u8 tile_mask) {struct dma_fence *fence =NULL ;
base-commit: d2ce8fcd778ee6d92748c92d23a56d4416c29d86
Re: [PATCH v2] drm/xe: Rebind VMAs one at a time when a bulk rebind fails
Quoted 13 lines · On Wed, Oct 28, 2026 at 01:35:29AM -0500, [email protected] wrote:
From: Karim Sabar <[email protected]>
Big games die after every s2idle resume on flat-CCS iGPUs. The exec ioctl keeps returning
-ENOMEMeven with 11-16 GB of RAM free.On suspend
xe_bo_evict_all_user()evicts every user BO inXE_PL_TTon these parts. On resume the first exec rebinds every VMA in one job andxe_vma_ops_alloc()kmallocs one 384-byte op per VMA as a single array. Final Fantasy VII Rebirth has about 33,500 VMAs which means a 12.9 MB array. It's over the 4 MBKMALLOC_MAX_SIZEand can never succeed. A bind that big can also fail later with-ENOBUFSwhen it doesn't fit in the migrate layer'svm_update_sa.
Quoted 7 lines
When
xe_vm_rebind()fails with-ENOMEMor-ENOBUFS, fall back toxe_vm_rebind_iterative(). It rebinds each VMA on the rebind list in its own job, the same thing Mesa does from userspace when a bind returns-ENOBUFS. Each VMA comes off the list once its job is queued which means a failure part way through leaves the rest for the next attempt.I tested this on a OneXPlayer 3 (Panther Lake) running SteamOS's 7.2.7
Generally don't use I statements in commit messages, I can adjust your commit message when I merge this (after our CI comes back).
Thanks for the patch:
Quoted 120 lines
kernel. A small Vulkan program fills a VM with 20,000 or 35,000 64 KiB buffers, suspends with rtcwake and submits again after resume. Without the fix the first exec after resume returns
-ENOMEMover and over and Mesa reports the device as lost. With the same fallback loaded intoxe_vm_validate_rebind()through a test module, the bulk rebind failed with-ENOMEMon all four resumes and the fallback rebound 20,024 VMAs three times and 35,027 VMAs once with no errors. The program kept submitting after every resume and the kernel log stayed clean. The patch itself is build tested on drm-xe-fixes with W=1.I tracked this down and tested it on my own device. I used an AI assistant to help with the debugging and with writing the fallback. I ran every test and reviewed the change myself.
Fixes 2e524668c440 ("drm/xe: Add xe_vm_pgtable_update_op to xe_vma_ops")Suggested-by Matthew Brost <[email protected]>Cc [email protected] # v6.11+Assisted-by Claude:claude-opus-5-5Signed-off-by Karim Sabar <[email protected]>---
Hey Matt,Sorry for the slow turnaround on this one. I said I'd write it and then it sat for a week. Here's the iterative rebind you suggested. When
xe_vm_rebind()fails with-ENOMEMor-ENOBUFS,xe_vm_validate_rebind()now falls back to rebinding one VMA per job.I only hooked it into
xe_vm_validate_rebind()like you said. The preempt rebind worker for LR VMs still callsxe_vm_rebind()directly. I left that alone since it's not the path I can reproduce but I'm happy to add it there too if you want it covered.Thanks for offering to take the error injection and IGT test on your side. Also I'm not on the Intel CI allowlist which means CI won't run on this one until someone hits retest. Would you mind kicking it off?
Changes in v2:
- Fall back to per-VMA rebinds inxe_vm_validate_rebind()instead of switching the op array to kvmalloc (Matt)
- Link to v1: https://lore.kernel.org/r/[email protected]drivers/gpu/drm/xe/xe_vm.c | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)drivers/gpu/drm/xe/xe_vm.c +49
-0@@ -370,6 +370,8 @@ static int xe_gpuvm_validate(struct drm_gpuvm_bo *vm_bo, struct drm_exec *exec)return 0 ; } +static int xe_vm_rebind_iterative (struct xe_vm *vm); +/** * xe_vm_validate_rebind() - Validate buffer objects and rebind vmas * @vm: The vm for which we are rebinding. @@ -397,6 +399,8 @@ int xe_vm_validate_rebind(struct xe_vm *vm, struct drm_exec *exec,return ret; ret =xe_vm_rebind (vm, false); +if (ret == -ENOBUFS || ret == -ENOMEM ) + ret =xe_vm_rebind_iterative (vm);if (ret)return ret; }while (!list_empty (&vm->gpuvm.evict.list));@@ -856,6 +860,51 @@ int xe_vm_rebind(struct xe_vm *vm, bool rebind_worker)return err; } +static int xe_vm_rebind_iterative (struct xe_vm *vm) +{ +struct dma_fence *fence; +struct xe_vma *vma, *next; +struct xe_vma_ops vops; +struct xe_vma_op *op, *next_op; +int err =0 , i; + +lockdep_assert_held (&vm->lock); +xe_vm_assert_held (vm); + +list_for_each_entry_safe (vma, next, &vm->rebind_list, + combined_links.rebind) { +xe_vma_ops_init (&vops, vm,NULL ,NULL ,0 ); +for (i =0 ; i <XE_MAX_TILES_PER_DEVICE ; ++i) + vops.pt_update_ops[i].wait_vm_bookkeep = true; + +trace_xe_vma_rebind_exec (vma); + + err =xe_vm_ops_add_rebind (&vops, vma, vma->tile_present); +if (!err) + err =xe_vma_ops_alloc (&vops, false); +if (!err) { + fence =ops_execute (vm, &vops); +if (IS_ERR (fence)) { + err =PTR_ERR (fence); + }else { +dma_fence_put (fence); +list_del_init (&vma->combined_links.rebind); + } + } + +list_for_each_entry_safe (op, next_op, &vops.list, link) { +list_del (&op->link); +kfree (op); + } +xe_vma_ops_fini (&vops); + +if (err) +break ; + } + +return err; +} +struct dma_fence *xe_vma_rebind (struct xe_vm *vm,struct xe_vma *vma,u8 tile_mask) {struct dma_fence *fence =NULL ;base-commit:
d2ce8fcd778ee6d92748c92d23a56d4416c29d86
Patchwork
CI✗ LGCI.VerificationFailed: failure for drm/xe: Use kvmalloc for the VMA ops page-table update array (rev2)
In reply to [email protected]== Series Details ==
== Series Details ==
Series: drm/xe: Use kvmalloc for the VMA ops page-table update array (rev2)
URL : https://patchwork.freedesktop.org/series/176556/
State : failure
== Summary ==
Series author address '[email protected]' is not on the allowlist, which prevents CI from being automatically triggered. If you want CI to run for this series, ask Patchwork project owners to click 'retest' on the series in Patchwork. Exception occurred during validation, bailing out!
Build URL: http://intel-gfx-ci-public.igk.intel.com:8080/job/xe_pw_trigger/1325559/ (on master)