[Intel-gfx] [PATCH 2/5] drm/i915/gtt: Read-only pages for insert_entries on bdw+
Joonas Lahtinen
joonas.lahtinen at linux.intel.com
Fri Jun 15 08:06:20 UTC 2018
Quoting Chris Wilson (2018-06-14 22:24:01)
> From: Jon Bloomfield <jon.bloomfield at intel.com>
>
> 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 at intel.com>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
> Cc: Matthew Auld <matthew.william.auld at gmail.com>
> Reviewed-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com> #v1
> Reviewed-by: Matthew Auld <matthew.william.auld at gmail.com> #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 at linux.intel.com>
Regards, Joonas
More information about the Intel-gfx
mailing list