[Intel-gfx] [PATCH 2/2] drm/i915/selftests: exercise cache domain eviction
Chris Wilson
chris at chris-wilson.co.uk
Fri Mar 3 18:28:28 UTC 2017
On Fri, Mar 03, 2017 at 06:03:35PM +0000, Matthew Auld wrote:
> Signed-off-by: Matthew Auld <matthew.auld at intel.com>
> ---
> drivers/gpu/drm/i915/selftests/i915_gem_evict.c | 80 +++++++++++++++++++++++++
> 1 file changed, 80 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c
> index 97af353db218..e92c235d0200 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c
> @@ -202,6 +202,85 @@ static int igt_evict_for_vma(void *arg)
> return err;
> }
>
> +static void mock_color_adjust(const struct drm_mm_node *node,
> + unsigned long color,
> + u64 *start,
> + u64 *end)
> +{
Ah. I see, this is because evict_for_node makes the assumption that any
color_adjust is i915_ggtt_color_adjust. I was wondering. Please add a
note here about the magic.
> +}
> +
> +static int igt_evict_for_cache_color(void *arg)
> +{
> + struct drm_i915_private *i915 = arg;
> + struct i915_ggtt *ggtt = &i915->ggtt;
> + const unsigned long flags = PIN_OFFSET_FIXED;
> + struct drm_mm_node target = {
> + .start = I915_GTT_PAGE_SIZE * 2,
> + .size = I915_GTT_PAGE_SIZE,
> + .color = I915_CACHE_LLC,
> + };
> + struct drm_i915_gem_object *obj;
> + struct i915_vma *vma;
> + int err;
> +
> + ggtt->base.mm.color_adjust = mock_color_adjust;
> +
> + obj = i915_gem_object_create_internal(i915, I915_GTT_PAGE_SIZE);
> + if (IS_ERR(obj)) {
> + err = PTR_ERR(obj);
> + goto cleanup;
> + }
> + i915_gem_object_set_cache_level(obj, I915_CACHE_LLC);
> +
> + vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0,
> + I915_GTT_PAGE_SIZE | flags);
> + if (IS_ERR(vma)) {
> + pr_err("[0]i915_gem_object_ggtt_pin failed\n");
> + err = PTR_ERR(vma);
> + goto cleanup;
> + }
> +
> + obj = i915_gem_object_create_internal(i915, I915_GTT_PAGE_SIZE);
> + if (IS_ERR(obj)) {
> + err = PTR_ERR(obj);
> + goto cleanup;
> + }
> + i915_gem_object_set_cache_level(obj, I915_CACHE_LLC);
> +
/* Neighbouring; same colour - should fit */
> + vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0,
> + (I915_GTT_PAGE_SIZE * 2) | flags);
> + if (IS_ERR(vma)) {
> + pr_err("[1]i915_gem_object_ggtt_pin failed\n");
> + err = PTR_ERR(vma);
> + goto cleanup;
> + }
> +
> + i915_vma_unpin(vma);
> +
/* Remove just the second vma */
> + err = i915_gem_evict_for_node(&ggtt->base, &target, 0);
> + if (err) {
> + pr_err("[0]i915_gem_evict_for_node returned err=%d\n", err);
> + goto cleanup;
> + }
> +
/* Attempt to remove the first *pinned* vma, by removing the (empty) neighbour */
> + target.color = I915_CACHE_L3_LLC;
> +
> + err = i915_gem_evict_for_node(&ggtt->base, &target, 0);
> + if (!err) {
> + pr_err("[1]i915_gem_evict_for_node returned err=%d\n", err);
> + err = -EINVAL;
> + goto cleanup;
Your pr_err("[]") are as bad as mine ;)
I see what you're testing, looks ok. So just a couple of comments for
the next reader.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the Intel-gfx
mailing list