Skip to contentSkip to conversation

drm/ttm: fix handling of errors on prefaulted pages

PATCH New Paolo Bonzini 1 participant 1 message Aug 4

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/ttm: fix handling of errors on prefaulted pages

Commit fe662d846c95 ("drm/ttm: remove io_reserve_lru handling v3") mechanically converted the goto out_io_unlock exits into return statements, but it broke the promise that errors in speculative fault would not be reported.

The old code was

		if (unlikely((ret & VM_FAULT_ERROR))) {
			if (i == 0)
				goto out_io_unlock;     /* return ret, i.e. the error */
			else
				break;                  /* return NOPAGE */
		}
		...
	}
	ret = VM_FAULT_NOPAGE;
out_io_unlock:
	...
	return ret;

while the new one does the opposite: it returns ret if i > 0 (previously it would return VM_FAULT_NOPAGE), and VM_FAULT_NOPAGE if i == 0 (previously it would return ret).

Fix the condition of the "if".

Fixes fe662d846c95 ("drm/ttm: remove io_reserve_lru handling v3", 2020-09-03)
Cc Christian Koenig <[email protected]> (maintainer:DRM TTM SUBSYSTEM)
Cc Huang Rui <[email protected]> (maintainer:DRM TTM SUBSYSTEM)
Cc Matthew Auld <[email protected]> (reviewer:DRM TTM SUBSYSTEM)
Cc Matthew Brost <[email protected]> (reviewer:DRM TTM SUBSYSTEM)
Cc Thomas Zimmermann <[email protected]> (maintainer:DRM DRIVERS AND MISC GPU PATCHES)
Cc [email protected] (open list:DRM TTM SUBSYSTEM)
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +1 -1
index a80510489c45..6d59f3c0696c 100644
@@ -267,7 +267,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
 
 		/* Never error on prefaulted PTEs */
 		if (unlikely((ret & VM_FAULT_ERROR))) {
-			if (i == 0)
+			if (i > 0)
 				return VM_FAULT_NOPAGE;
 			else
 				break;
Signature · 1 line
2.55.0