Re: [PATCH 18/37] drm/i915: Test exhaustion of the mmap space

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11 January 2017 at 21:09, Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> wrote:
> An unlikely error condition that we can simulate by stealing the most of
s/the most/most/

> the range before trying to insert new objects.
>
> Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
> ---
>  drivers/gpu/drm/i915/selftests/i915_gem_object.c | 137 +++++++++++++++++++++++
>  1 file changed, 137 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_object.c b/drivers/gpu/drm/i915/selftests/i915_gem_object.c
> index df3625f551aa..46512a67877d 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_gem_object.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_object.c
> @@ -25,6 +25,7 @@
>  #include "i915_selftest.h"
>
>  #include "mock_gem_device.h"
> +#include "huge_gem_object.h"
>
>  static int igt_gem_object(void *arg)
>  {
> @@ -383,6 +384,141 @@ static int igt_partial_tiling(void *arg)
>         return err;
>  }
>
> +static int make_obj_busy(struct drm_i915_gem_object *obj)
> +{
> +       struct drm_i915_private *i915 = to_i915(obj->base.dev);
> +       struct drm_i915_gem_request *rq;
> +       struct i915_vma *vma;
> +       int err;
> +
> +       vma = i915_gem_obj_lookup_or_create_vma(obj, &i915->ggtt.base, NULL);
> +       if (IS_ERR(vma))
> +               return PTR_ERR(vma);
> +
> +       err = i915_vma_pin(vma, 0, 0, PIN_USER);
> +       if (err)
> +               return err;
> +
> +       rq = i915_gem_request_alloc(i915->engine[RCS], i915->kernel_context);
> +       if (IS_ERR(rq)) {
> +               i915_vma_unpin(vma);
> +               return PTR_ERR(rq);
> +       }
> +
> +       i915_vma_move_to_active(vma, rq, 0);
> +       i915_add_request(rq);
> +
> +       i915_gem_object_set_active_reference(obj);
> +       i915_vma_unpin(vma);
> +       return 0;
> +}
> +
> +static bool assert_mmap_offset(struct drm_i915_private *i915,
> +                              unsigned long size,
> +                              int expected)
> +{
> +       struct drm_i915_gem_object *obj;
> +       int err;
> +
> +       obj = i915_gem_object_create_internal(i915, size);
> +       if (IS_ERR(obj))
> +               return PTR_ERR(obj);
> +
> +       err = i915_gem_object_create_mmap_offset(obj);
> +       i915_gem_object_put(obj);
> +
> +       return err == expected;
> +}
> +
> +static int igt_mmap_offset_exhaustion(void *arg)
> +{
> +       struct drm_i915_private *i915 = arg;
> +       struct drm_mm *mm = &i915->drm.vma_offset_manager->vm_addr_space_mm;
> +       struct drm_i915_gem_object *obj;
> +       struct drm_mm_node resv, *hole;
> +       u64 hole_start, hole_end;
> +       int loop, err;
> +
> +       /* Trim the VMA mmap space to only a page */
> +       memset(&resv, 0, sizeof(resv));
> +       drm_mm_for_each_hole(hole, mm, hole_start, hole_end) {
> +               resv.start = hole_start;
> +               resv.size = hole_end - hole_start - 1; /* PAGE_SIZE units */
> +               err = drm_mm_reserve_node(mm, &resv);
> +               if (err) {
> +                       pr_err("Failed to trim VMA manager, err=%d\n", err);
> +                       return err;
> +               }
> +               break;
> +       }
> +
> +       /* Just fits! */
> +       if (!assert_mmap_offset(i915, PAGE_SIZE, 0)) {
> +               pr_err("Unable to insert object into single page hole\n");
> +               err = -EINVAL;
> +               goto err;
> +       }
> +
> +       /* Too large */
> +       if (!assert_mmap_offset(i915, 2*PAGE_SIZE, -ENOSPC)) {
> +               pr_err("Unexpectedly succeded in inserting too large object into single page hole\n");
s/succeded/succeeded

> +               err = -EINVAL;
> +               goto err;
> +       }
> +
> +       /* Fill the hole, should then fail */
Fill the hole, further attempts should then fail; less confusing imo.

Reviewed-by: Matthew Auld <matthew.auld@xxxxxxxxx>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux