[Intel-gfx] [PATCH 3/5] drm/i915: Add cpu fault handler for mmap_offset
Chris Wilson
chris at chris-wilson.co.uk
Mon Aug 26 12:44:38 UTC 2019
Quoting Abdiel Janulgue (2019-08-26 13:21:00)
> Fault handler to handle missing pages for shmem-backed objects. Handle also
> logic needed to refault pages depending on fault handler usage.
>
> Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
> Signed-off-by: Matthew Auld <matthew.auld at intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
> ---
> drivers/gpu/drm/i915/gem/i915_gem_domain.c | 2 +-
> drivers/gpu/drm/i915/gem/i915_gem_mman.c | 189 ++++++++++++++++-----
> drivers/gpu/drm/i915/gem/i915_gem_object.h | 2 +-
> drivers/gpu/drm/i915/i915_gem.c | 2 +-
> 4 files changed, 149 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_domain.c b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
> index 9c58e8fac1d9..517e73c3aa31 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_domain.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_domain.c
> @@ -254,7 +254,7 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,
> }
>
> if (obj->userfault_count)
> - __i915_gem_object_release_mmap(obj);
> + __i915_gem_object_release_mmap_gtt(obj);
>
> /*
> * As we no longer need a fence for GTT access,
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> index 87690aa64814..d0a653a9a4cc 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> @@ -5,6 +5,7 @@
> */
>
> #include <linux/mman.h>
> +#include <linux/pfn_t.h>
> #include <linux/sizes.h>
>
> #include "gt/intel_gt.h"
> @@ -199,6 +200,45 @@ compute_partial_view(const struct drm_i915_gem_object *obj,
> return view;
> }
>
> +static vm_fault_t i915_error_to_vmf_fault(int err, struct intel_gt *gt)
> +{
> + switch (err) {
> + 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(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.
> + */
These errors don't exist anymore and should not be cargo-culted onto
paths that could not possibly generate them.
-Chris
More information about the Intel-gfx
mailing list