[04/21] drm/i915: Refresh the errno to vmf_fault translations

Submitted by Chris Wilson on Sept. 2, 2019, 4:02 a.m.

Details

Message ID 20190902040303.14195-4-chris@chris-wilson.co.uk
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Intel GFX

Not browsing as part of any series.

Commit Message

Chris Wilson Sept. 2, 2019, 4:02 a.m.
It's been a long time since we accidentally reported -EIO upon wedging,
it can now only be generated by failure to swap in a page.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 39 +++++++++---------------
 1 file changed, 15 insertions(+), 24 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
index 261c9bd83f51..82db2b783123 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
@@ -287,6 +287,9 @@  vm_fault_t i915_gem_fault(struct vm_fault *vmf)
 			view.type = I915_GGTT_VIEW_PARTIAL;
 			vma = i915_gem_object_ggtt_pin(obj, &view, 0, 0, flags);
 		}
+
+		/* The entire mappable GGTT is pinned? Unexpected! */
+		GEM_BUG_ON(vma == ERR_PTR(-ENOSPC));
 	}
 	if (IS_ERR(vma)) {
 		ret = PTR_ERR(vma);
@@ -333,23 +336,19 @@  vm_fault_t i915_gem_fault(struct vm_fault *vmf)
 	i915_gem_object_unpin_pages(obj);
 err:
 	switch (ret) {
-	case -EIO:
-		/*
-		 * We eat errors when the gpu is terminally wedged to avoid
-		 * userspace unduly crashing (gl has no provisions for mmaps to
-		 * fail). But any other -EIO isn't ours (e.g. swap in failure)
-		 * and so needs to be reported.
-		 */
-		if (!intel_gt_is_wedged(ggtt->vm.gt))
-			return VM_FAULT_SIGBUS;
-		/* else, fall through */
-	case -EAGAIN:
-		/*
-		 * EAGAIN means the gpu is hung and we'll wait for the error
-		 * handler to reset everything when re-faulting in
-		 * i915_mutex_lock_interruptible.
-		 */
+	default:
+		WARN_ONCE(ret, "unhandled error in %s: %i\n", __func__, ret);
+		/* fallthrough */
+	case -EIO: /* shmemfs failure from swap device */
+	case -EFAULT: /* purged object */
+		return VM_FAULT_SIGBUS;
+
+	case -ENOSPC: /* shmemfs allocation failure */
+	case -ENOMEM: /* our allocation failure */
+		return VM_FAULT_OOM;
+
 	case 0:
+	case -EAGAIN:
 	case -ERESTARTSYS:
 	case -EINTR:
 	case -EBUSY:
@@ -358,14 +357,6 @@  vm_fault_t i915_gem_fault(struct vm_fault *vmf)
 		 * already did the job.
 		 */
 		return VM_FAULT_NOPAGE;
-	case -ENOMEM:
-		return VM_FAULT_OOM;
-	case -ENOSPC:
-	case -EFAULT:
-		return VM_FAULT_SIGBUS;
-	default:
-		WARN_ONCE(ret, "unhandled error in %s: %i\n", __func__, ret);
-		return VM_FAULT_SIGBUS;
 	}
 }
 

Comments

On 02/09/2019 7.02, Chris Wilson wrote:
> It's been a long time since we accidentally reported -EIO upon wedging,
> it can now only be generated by failure to swap in a page.
> 

Reviewed-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>

> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_mman.c | 39 +++++++++---------------
>  1 file changed, 15 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> index 261c9bd83f51..82db2b783123 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> @@ -287,6 +287,9 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
>  			view.type = I915_GGTT_VIEW_PARTIAL;
>  			vma = i915_gem_object_ggtt_pin(obj, &view, 0, 0, flags);
>  		}
> +
> +		/* The entire mappable GGTT is pinned? Unexpected! */
> +		GEM_BUG_ON(vma == ERR_PTR(-ENOSPC));
>  	}
>  	if (IS_ERR(vma)) {
>  		ret = PTR_ERR(vma);
> @@ -333,23 +336,19 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
>  	i915_gem_object_unpin_pages(obj);
>  err:
>  	switch (ret) {
> -	case -EIO:
> -		/*
> -		 * We eat errors when the gpu is terminally wedged to avoid
> -		 * userspace unduly crashing (gl has no provisions for mmaps to
> -		 * fail). But any other -EIO isn't ours (e.g. swap in failure)
> -		 * and so needs to be reported.
> -		 */
> -		if (!intel_gt_is_wedged(ggtt->vm.gt))
> -			return VM_FAULT_SIGBUS;
> -		/* else, fall through */
> -	case -EAGAIN:
> -		/*
> -		 * EAGAIN means the gpu is hung and we'll wait for the error
> -		 * handler to reset everything when re-faulting in
> -		 * i915_mutex_lock_interruptible.
> -		 */
> +	default:
> +		WARN_ONCE(ret, "unhandled error in %s: %i\n", __func__, ret);
> +		/* fallthrough */
> +	case -EIO: /* shmemfs failure from swap device */
> +	case -EFAULT: /* purged object */
> +		return VM_FAULT_SIGBUS;
> +
> +	case -ENOSPC: /* shmemfs allocation failure */
> +	case -ENOMEM: /* our allocation failure */
> +		return VM_FAULT_OOM;
> +
>  	case 0:
> +	case -EAGAIN:
>  	case -ERESTARTSYS:
>  	case -EINTR:
>  	case -EBUSY:
> @@ -358,14 +357,6 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
>  		 * already did the job.
>  		 */
>  		return VM_FAULT_NOPAGE;
> -	case -ENOMEM:
> -		return VM_FAULT_OOM;
> -	case -ENOSPC:
> -	case -EFAULT:
> -		return VM_FAULT_SIGBUS;
> -	default:
> -		WARN_ONCE(ret, "unhandled error in %s: %i\n", __func__, ret);
> -		return VM_FAULT_SIGBUS;
>  	}
>  }
>  
>