From patchwork Thu Nov 5 00:10:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kasireddy, Vivek" X-Patchwork-Id: 7556101 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4C60ABEEA4 for ; Thu, 5 Nov 2015 00:13:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5D72E207F1 for ; Thu, 5 Nov 2015 00:13:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 14BED207F0 for ; Thu, 5 Nov 2015 00:13:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7BEA08932A; Wed, 4 Nov 2015 16:13:55 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 1A1E58932A for ; Wed, 4 Nov 2015 16:13:54 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 04 Nov 2015 16:13:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,245,1444719600"; d="scan'208";a="843378820" Received: from orsmsx104.amr.corp.intel.com ([10.22.225.131]) by fmsmga002.fm.intel.com with ESMTP; 04 Nov 2015 16:13:53 -0800 Received: from vkasired-desk2.fm.intel.com (10.22.254.139) by ORSMSX104.amr.corp.intel.com (10.22.225.131) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 4 Nov 2015 16:13:52 -0800 From: Vivek Kasireddy To: Date: Wed, 4 Nov 2015 16:10:15 -0800 Message-ID: <1446682215-4625-1-git-send-email-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <5639D8F3.40401@linux.intel.com> References: <5639D8F3.40401@linux.intel.com> MIME-Version: 1.0 X-Originating-IP: [10.22.254.139] Cc: Vivek Kasireddy Subject: [Intel-gfx] [PATCH] igt/kms_rotation_crc: Add a new subtest to exhaustively test for fence leaks (v3) X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In this subtest, as a first step, MAX_FENCES+1 number of framebuffers are created backed up by objects that have multiple GGTT views (normal and rotated). Next, we have the i915 driver instantiate a normal view followed by a rotated view. We continue doing the above MAX_FENCES + 1 times. v2: - Add a igt_require() to check if there is enough GTT space left for MAX_FENCES+1 framebuffers. (Tvrtko) - Make data2 local to test_plane_rotation_exhaust_fences(). (Tvrtko) - If there is a failure, deallocate all the previously allocated framebuffers before asserting. v3: Close the gem handle if set_tiling or addfb fails. (Tvrtko) Cc: Tvrtko Ursulin Signed-off-by: Vivek Kasireddy Reviewed-by: Tvrtko Ursulin --- tests/kms_rotation_crc.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c index ed6eeef..7e18b1e 100644 --- a/tests/kms_rotation_crc.c +++ b/tests/kms_rotation_crc.c @@ -25,6 +25,7 @@ #include "igt.h" #include +#define MAX_FENCES 32 typedef struct { int gfx_fd; @@ -376,6 +377,108 @@ static void test_plane_rotation_ytiled_obj(data_t *data, enum igt_plane plane_ty igt_assert(ret == 0); } +static void test_plane_rotation_exhaust_fences(data_t *data, enum igt_plane plane_type) +{ + igt_display_t *display = &data->display; + uint64_t tiling = LOCAL_I915_FORMAT_MOD_Y_TILED; + uint32_t format = DRM_FORMAT_XRGB8888; + int bpp = igt_drm_format_to_bpp(format); + enum igt_commit_style commit = COMMIT_LEGACY; + int fd = data->gfx_fd; + igt_output_t *output = &display->outputs[0]; + igt_plane_t *plane; + drmModeModeInfo *mode; + data_t data2[MAX_FENCES+1] = {}; + unsigned int stride, size, w, h; + uint32_t gem_handle; + uint64_t total_aperture_size, total_fbs_size; + int i, ret; + + igt_require(output != NULL && output->valid == true); + + plane = igt_output_get_plane(output, plane_type); + igt_require(igt_plane_supports_rotation(plane)); + + if (plane_type == IGT_PLANE_PRIMARY || plane_type == IGT_PLANE_CURSOR) { + igt_require(data->display.has_universal_planes); + commit = COMMIT_UNIVERSAL; + } + + mode = igt_output_get_mode(output); + w = mode->hdisplay; + h = mode->vdisplay; + + for (stride = 512; stride < (w * bpp / 8); stride *= 2) + ; + for (size = 1024*1024; size < stride * h; size *= 2) + ; + + /* + * Make sure there is atleast 90% of the available GTT space left + * for creating (MAX_FENCES+1) framebuffers. + */ + total_fbs_size = size * (MAX_FENCES + 1); + total_aperture_size = gem_available_aperture_size(fd); + igt_require(total_fbs_size < total_aperture_size * 0.9); + + igt_plane_set_fb(plane, NULL); + igt_display_commit(display); + + for (i = 0; i < MAX_FENCES + 1; i++) { + gem_handle = gem_create(fd, size); + ret = __gem_set_tiling(fd, gem_handle, I915_TILING_Y, stride); + if (ret) { + igt_warn("failed to set tiling\n"); + goto err_alloc; + } + + ret = (__kms_addfb(fd, gem_handle, w, h, stride, + format, tiling, LOCAL_DRM_MODE_FB_MODIFIERS, + &data2[i].fb.fb_id)); + if (ret) { + igt_warn("failed to create framebuffer\n"); + goto err_alloc; + } + + data2[i].fb.width = w; + data2[i].fb.height = h; + data2[i].fb.gem_handle = gem_handle; + + igt_plane_set_fb(plane, &data2[i].fb); + igt_plane_set_rotation(plane, IGT_ROTATION_0); + + ret = igt_display_try_commit2(display, commit); + if (ret) { + igt_warn("failed to commit unrotated fb\n"); + goto err_commit; + } + + igt_plane_set_rotation(plane, IGT_ROTATION_90); + + drmModeObjectSetProperty(fd, plane->drm_plane->plane_id, + DRM_MODE_OBJECT_PLANE, + plane->rotation_property, + plane->rotation); + ret = igt_display_try_commit2(display, commit); + if (ret) { + igt_warn("failed to commit hardware rotated fb\n"); + goto err_commit; + } + } + +err_alloc: + if (ret) + gem_close(fd, gem_handle); + + i--; +err_commit: + for (; i >= 0; i--) + igt_remove_fb(fd, &data2[i].fb); + + kmstest_restore_vt_mode(); + igt_assert(ret == 0); +} + igt_main { data_t data = {}; @@ -471,6 +574,11 @@ igt_main test_plane_rotation_ytiled_obj(&data, IGT_PLANE_PRIMARY); } + igt_subtest_f("exhaust-fences") { + igt_require(gen >= 9); + test_plane_rotation_exhaust_fences(&data, IGT_PLANE_PRIMARY); + } + igt_fixture { igt_display_fini(&data.display); }