Skip to content

Commit e44f18c

Browse files
author
Thomas Hellström
committed
drm/ttm: Make the call to ttm_tt_populate() interruptible when faulting
When swapping in, or under memory pressure ttm_tt_populate() may sleep for a substantiable amount of time. Allow interrupts during the sleep. This will also allow us to inject -EINTR errors during swapin in upcoming patches. Also avoid returning VM_FAULT_OOM, since that will confuse the core mm, making it print out a confused message and retrying the fault. Return VM_FAULT_SIGBUS also under OOM conditions. Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Reviewed-by: Christian König <christian.koenig@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230404200650.11043-4-thomas.hellstrom@linux.intel.com
1 parent 322458c commit e44f18c

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

drivers/gpu/drm/ttm/ttm_bo_vm.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,21 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
218218
prot = ttm_io_prot(bo, bo->resource, prot);
219219
if (!bo->resource->bus.is_iomem) {
220220
struct ttm_operation_ctx ctx = {
221-
.interruptible = false,
221+
.interruptible = true,
222222
.no_wait_gpu = false,
223223
.force_alloc = true
224224
};
225225

226226
ttm = bo->ttm;
227-
if (ttm_tt_populate(bdev, bo->ttm, &ctx))
228-
return VM_FAULT_OOM;
227+
err = ttm_tt_populate(bdev, bo->ttm, &ctx);
228+
if (err) {
229+
if (err == -EINTR || err == -ERESTARTSYS ||
230+
err == -EAGAIN)
231+
return VM_FAULT_NOPAGE;
232+
233+
pr_debug("TTM fault hit %pe.\n", ERR_PTR(err));
234+
return VM_FAULT_SIGBUS;
235+
}
229236
} else {
230237
/* Iomem should not be marked encrypted */
231238
prot = pgprot_decrypted(prot);

0 commit comments

Comments
 (0)