From 88d9d2bab07325c6649f1e227466c8974af64fb7 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Wed, 30 Sep 2026 18:00:04 +0300 Subject: [PATCH] drm/i915/selftests: use intel_gtt_view_is_*() helpers more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prefer using the intel_gtt_view_is_*() helpers instead of comparing the view type directly. v3: Use view, not vma->gtt_view even more (Ville) v2: Use view, not vma->gtt_view at the end (Sashiko) Reviewed-by: Maarten Lankhorst Reviewed-by: Ville Syrjälä Link: https://patch.msgid.link/350f0be2c56ae4ac7b7bb97186f4d501faa7bb4e.1790780340.git.jani.nikula@intel.com Signed-off-by: Jani Nikula --- drivers/gpu/drm/i915/selftests/i915_vma.c | 34 +++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c b/drivers/gpu/drm/i915/selftests/i915_vma.c index b16297a6a4e8..182c9f860628 100644 --- a/drivers/gpu/drm/i915/selftests/i915_vma.c +++ b/drivers/gpu/drm/i915/selftests/i915_vma.c @@ -51,7 +51,7 @@ static bool assert_vma(struct i915_vma *vma, ok = false; } - if (vma->gtt_view.type != I915_GTT_VIEW_NORMAL) { + if (!intel_gtt_view_is_normal(&vma->gtt_view)) { pr_err("VMA created with wrong type [%d]\n", vma->gtt_view.type); ok = false; @@ -533,12 +533,12 @@ assert_remapped(struct drm_i915_gem_object *obj, return sg; } -static unsigned int remapped_size(enum intel_gtt_view_type view_type, +static unsigned int remapped_size(const struct intel_gtt_view *view, const struct intel_remapped_plane_info *a, const struct intel_remapped_plane_info *b) { - if (view_type == I915_GTT_VIEW_ROTATED) + if (intel_gtt_view_is_rotated(view)) return a->dst_stride * a->width + b->dst_stride * b->width; else return a->dst_stride * a->height + b->dst_stride * b->height; @@ -606,11 +606,11 @@ static int igt_vma_rotate_remap(void *arg) max_offset = max_pages - max_offset; if (!plane_info[0].dst_stride) - plane_info[0].dst_stride = view.type == I915_GTT_VIEW_ROTATED ? + plane_info[0].dst_stride = intel_gtt_view_is_rotated(&view) ? plane_info[0].height : plane_info[0].width; if (!plane_info[1].dst_stride) - plane_info[1].dst_stride = view.type == I915_GTT_VIEW_ROTATED ? + plane_info[1].dst_stride = intel_gtt_view_is_rotated(&view) ? plane_info[1].height : plane_info[1].width; @@ -632,9 +632,9 @@ static int igt_vma_rotate_remap(void *arg) goto out_object; } - expected_pages = remapped_size(view.type, &plane_info[0], &plane_info[1]); + expected_pages = remapped_size(&view, &plane_info[0], &plane_info[1]); - if (view.type == I915_GTT_VIEW_ROTATED && + if (intel_gtt_view_is_rotated(&view) && vma->size != expected_pages * PAGE_SIZE) { pr_err("VMA is wrong size, expected %lu, found %llu\n", PAGE_SIZE * expected_pages, vma->size); @@ -642,7 +642,7 @@ static int igt_vma_rotate_remap(void *arg) goto out_object; } - if (view.type == I915_GTT_VIEW_REMAPPED && + if (intel_gtt_view_is_remapped(&view) && vma->size > expected_pages * PAGE_SIZE) { pr_err("VMA is wrong size, expected %lu, found %llu\n", PAGE_SIZE * expected_pages, vma->size); @@ -672,13 +672,13 @@ static int igt_vma_rotate_remap(void *arg) sg = vma->pages->sgl; for (n = 0; n < ARRAY_SIZE(view.rotated.plane); n++) { - if (view.type == I915_GTT_VIEW_ROTATED) + if (intel_gtt_view_is_rotated(&view)) sg = assert_rotated(obj, &view.rotated, n, sg); else sg = assert_remapped(obj, &view.remapped, n, sg); if (IS_ERR(sg)) { pr_err("Inconsistent %s VMA pages for plane %d: [(%d, %d, %d, %d, %d), (%d, %d, %d, %d, %d)]\n", - view.type == I915_GTT_VIEW_ROTATED ? + intel_gtt_view_is_rotated(&view) ? "rotated" : "remapped", n, plane_info[0].width, plane_info[0].height, @@ -763,7 +763,7 @@ static bool assert_pin(struct i915_vma *vma, ok = false; } - if (view && view->type != I915_GTT_VIEW_NORMAL) { + if (view && !intel_gtt_view_is_normal(view)) { if (memcmp(&vma->gtt_view, view, sizeof(*view))) { pr_err("(%s) VMA mismatch upon creation!\n", name); @@ -776,7 +776,7 @@ static bool assert_pin(struct i915_vma *vma, ok = false; } } else { - if (vma->gtt_view.type != I915_GTT_VIEW_NORMAL) { + if (!intel_gtt_view_is_normal(&vma->gtt_view)) { pr_err("Not the normal ggtt view! Found %d\n", vma->gtt_view.type); ok = false; @@ -1017,7 +1017,7 @@ static int igt_vma_remapped_gtt(void *arg) goto out; if (!plane_info[0].dst_stride) - plane_info[0].dst_stride = *t == I915_GTT_VIEW_ROTATED ? + plane_info[0].dst_stride = intel_gtt_view_is_rotated(&view) ? p->height : p->width; vma = i915_gem_object_ggtt_pin(obj, &view, 0, 0, PIN_MAPPABLE); @@ -1040,7 +1040,7 @@ static int igt_vma_remapped_gtt(void *arg) unsigned int offset; u32 val = y << 16 | x; - if (*t == I915_GTT_VIEW_ROTATED) + if (intel_gtt_view_is_rotated(&view)) offset = (x * plane_info[0].dst_stride + y) * PAGE_SIZE; else offset = (y * plane_info[0].dst_stride + x) * PAGE_SIZE; @@ -1057,7 +1057,7 @@ static int igt_vma_remapped_gtt(void *arg) goto out; } - GEM_BUG_ON(vma->gtt_view.type != I915_GTT_VIEW_NORMAL); + GEM_BUG_ON(!intel_gtt_view_is_normal(&vma->gtt_view)); map = i915_vma_pin_iomap(vma); i915_vma_unpin(vma); @@ -1072,7 +1072,7 @@ static int igt_vma_remapped_gtt(void *arg) u32 exp = y << 16 | x; u32 val; - if (*t == I915_GTT_VIEW_ROTATED) + if (intel_gtt_view_is_rotated(&view)) src_idx = rotated_index(&view.rotated, 0, x, y); else src_idx = remapped_index(&view.remapped, 0, x, y); @@ -1081,7 +1081,7 @@ static int igt_vma_remapped_gtt(void *arg) val = ioread32(&map[offset / sizeof(*map)]); if (val != exp) { pr_err("%s VMA write test failed, expected 0x%x, found 0x%x\n", - *t == I915_GTT_VIEW_ROTATED ? "Rotated" : "Remapped", + intel_gtt_view_is_rotated(&view) ? "Rotated" : "Remapped", exp, val); i915_vma_unpin_iomap(vma); err = -EINVAL;