Re: [PATCH 2/5] drm/i915/gtt: Read-only pages for insert_entries on bdw+

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

 



Quoting Chris Wilson (2018-06-14 22:24:01)
> From: Jon Bloomfield <jon.bloomfield@xxxxxxxxx>
> 
> Hook up the flags to allow read-only ppGTT mappings for gen8+
> 
> v2: Include a selftest to check that writes to a readonly PTE are
> dropped
> 
> Signed-off-by: Jon Bloomfield <jon.bloomfield@xxxxxxxxx>
> Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
> Cc: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>
> Cc: Matthew Auld <matthew.william.auld@xxxxxxxxx>
> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx> #v1
> Reviewed-by: Matthew Auld <matthew.william.auld@xxxxxxxxx> #v1

<SNIP>

> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_context.c
> @@ -23,6 +23,7 @@
>   */
>  
>  #include "../i915_selftest.h"
> +#include "i915_random.h"
>  #include "igt_flush_test.h"
>  
>  #include "mock_drm.h"
> @@ -266,6 +267,41 @@ static int cpu_check(struct drm_i915_gem_object *obj, unsigned int max)
>         return err;
>  }
>  
> +static int ro_check(struct drm_i915_gem_object *obj, unsigned int max)
> +{
> +       unsigned int n, m, needs_flush;
> +       int err;
> +
> +       err = i915_gem_obj_prepare_shmem_read(obj, &needs_flush);
> +       if (err)
> +               return err;
> +
> +       for (n = 0; n < real_page_count(obj); n++) {
> +               u32 *map;
> +
> +               map = kmap_atomic(i915_gem_object_get_page(obj, n));
> +               if (needs_flush & CLFLUSH_BEFORE)
> +                       drm_clflush_virt_range(map, PAGE_SIZE);
> +
> +               for (m = 0; m < DW_PER_PAGE; m++) {
> +                       if (map[m] != 0xdeadbeef) {

One could have #define MAGIC 0xdeadbeef

> +                               pr_err("Invalid value (overwritten) at page %d, offset %d: found %08x expected %08x\n",
> +                                      n, m, map[m], 0xdeadbeef);
> +                               err = -EINVAL;
> +                               goto out_unmap;
> +                       }
> +               }
> +
> +out_unmap:
> +               kunmap_atomic(map);
> +               if (err)
> +                       break;
> +       }
> +
> +       i915_gem_obj_finish_shmem_access(obj);
> +       return err;
> +}

<SNIP>

> +static int igt_ctx_readonly(void *arg)
> +{
> +       struct drm_i915_private *i915 = arg;
> +       struct drm_i915_gem_object *obj = NULL;
> +       struct drm_file *file;
> +       I915_RND_STATE(prng);
> +       IGT_TIMEOUT(end_time);
> +       LIST_HEAD(objects);
> +       struct i915_gem_context *ctx;
> +       struct i915_hw_ppgtt *ppgtt;
> +       unsigned long ndwords, dw;
> +       int err = -ENODEV;
> +
> +       /* Create a few different contexts (with different mm) and write

As noted by Matt.

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>

Regards, Joonas
_______________________________________________
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