Skip to content

Commit

Permalink
drm/ttm: Restore ttm prefaulting
Browse files Browse the repository at this point in the history
Commit 4daa4fb ("gpu: drm: ttm: Adding new return type vm_fault_t")
broke TTM prefaulting. Since vmf_insert_mixed() typically always returns
VM_FAULT_NOPAGE, prefaulting stops after the second PTE.

Restore (almost) the original behaviour. Unfortunately we can no longer
with the new vm_fault_t return type determine whether a prefaulting
PTE insertion hit an already populated PTE, and terminate the insertion
loop. Instead we continue with the pre-determined number of prefaults.

Fixes: 4daa4fb ("gpu: drm: ttm: Adding new return type vm_fault_t")
Cc: Souptick Joarder <[email protected]>
Cc: Christian König <[email protected]>
Signed-off-by: Thomas Hellstrom <[email protected]>
Reviewed-by: Christian König <[email protected]>
Cc: [email protected] # v4.19+
Signed-off-by: Christian König <[email protected]>
Link: https://patchwork.freedesktop.org/patch/330387/
  • Loading branch information
thomashvmw authored and ChristianKoenigAMD committed Oct 14, 2019
1 parent 73a88e4 commit 941f2f7
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions drivers/gpu/drm/ttm/ttm_bo_vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,13 @@ static vm_fault_t ttm_bo_vm_fault(struct vm_fault *vmf)
else
ret = vmf_insert_pfn(&cvma, address, pfn);

/*
* Somebody beat us to this PTE or prefaulting to
* an already populated PTE, or prefaulting error.
*/

if (unlikely((ret == VM_FAULT_NOPAGE && i > 0)))
break;
else if (unlikely(ret & VM_FAULT_ERROR))
goto out_io_unlock;
/* Never error on prefaulted PTEs */
if (unlikely((ret & VM_FAULT_ERROR))) {
if (i == 0)
goto out_io_unlock;
else
break;
}

address += PAGE_SIZE;
if (unlikely(++page_offset >= page_last))
Expand Down

0 comments on commit 941f2f7

Please sign in to comment.