From patchwork Tue Mar 3 10:43:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tim.gore@intel.com X-Patchwork-Id: 5921201 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 31E0ABF440 for ; Tue, 3 Mar 2015 10:43:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 51AD02026F for ; Tue, 3 Mar 2015 10:43:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 662742026C for ; Tue, 3 Mar 2015 10:43:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CADAB6E58A; Tue, 3 Mar 2015 02:43:48 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 4C8346E58A for ; Tue, 3 Mar 2015 02:43:47 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 03 Mar 2015 02:43:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,681,1418112000"; d="scan'208";a="461800409" Received: from tgore-linux.isw.intel.com ([10.102.226.47]) by FMSMGA003.fm.intel.com with ESMTP; 03 Mar 2015 02:37:34 -0800 From: tim.gore@intel.com To: intel-gfx@lists.freedesktop.org Date: Tue, 3 Mar 2015 10:43:43 +0000 Message-Id: <1425379423-1781-1-git-send-email-tim.gore@intel.com> X-Mailer: git-send-email 2.3.0 Cc: daniel.vetter@ffwll.ch, thomas.wood@intel.com Subject: [Intel-gfx] [PATCH i-g-t v2] tests/gem_render_tiled_blits: split into subtests 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: , MIME-Version: 1.0 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 From: Tim Gore The gem_render_tiled_blits test tends to get oom killed on low memory (< 4GB) Android systems. This is because the test tries to allocate (sysinfo.totalram * 9 / 10) in buffer objects and the remaining 10% of memory is not always enough for the Android system. A similar issue with gem_render_linear_blits was resolved by creating several subtests. A "basic" subtest that uses minimal memory buffers to test the basic operation, and two stress tests which are skipped if there is insufficient memory. The first stress test uses more memory than the graphics apperture and the second uses enough to ensure that swap space is used (if present). This patch makes the same changes to gem_render_tiled_blits. v2: Following comments from Daniel Vetter: a) Use igt_main macro instead of "open coding", and b) cull some leading spaces Signed-off-by: Tim Gore --- tests/gem_render_tiled_blits.c | 72 ++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/tests/gem_render_tiled_blits.c b/tests/gem_render_tiled_blits.c index dc22529..f669270 100644 --- a/tests/gem_render_tiled_blits.c +++ b/tests/gem_render_tiled_blits.c @@ -85,30 +85,25 @@ check_bo(struct intel_batchbuffer *batch, struct igt_buf *buf, uint32_t val) } for (i = 0; i < WIDTH*HEIGHT; i++) { igt_assert_f(ptr[i] == val, - "Expected 0x%08x, found 0x%08x " - "at offset 0x%08x\n", - val, ptr[i], i * 4); + "Expected 0x%08x, found 0x%08x " + "at offset 0x%08x\n", + val, ptr[i], i * 4); val++; } if (ptr != data) dri_bo_unmap(linear); } -int main(int argc, char **argv) +static void run_test (int fd, int count) { drm_intel_bufmgr *bufmgr; struct intel_batchbuffer *batch; uint32_t *start_val; struct igt_buf *buf; uint32_t start = 0; - int i, j, fd, count; + int i, j; uint32_t devid; - igt_simple_init(argc, argv); - - igt_skip_on_simulation(); - - fd = drm_open_any(); devid = intel_get_drm_devid(fd); render_copy = igt_get_render_copyfunc(devid); @@ -124,23 +119,6 @@ int main(int argc, char **argv) drm_intel_bufmgr_gem_set_vma_cache_size(bufmgr, 32); batch = intel_batchbuffer_alloc(bufmgr, devid); - count = 0; - if (argc > 1) - count = atoi(argv[1]); - if (count == 0) - count = 3 * gem_aperture_size(fd) / SIZE / 2; - else if (count < 2) { - igt_warn("count must be >= 2\n"); - return 1; - } - - if (count > intel_get_total_ram_mb() * 9 / 10) { - count = intel_get_total_ram_mb() * 9 / 10; - igt_info("not enough RAM to run test, reducing buffer count\n"); - } - - igt_info("Using %d 1MiB buffers\n", count); - linear = drm_intel_bo_alloc(bufmgr, "linear", WIDTH*HEIGHT*4, 0); if (snoop) { gem_set_caching(fd, linear->handle, 1); @@ -211,5 +189,45 @@ int main(int argc, char **argv) for (i = 0; i < count; i++) check_bo(batch, &buf[i], start_val[i]); + /* release resources */ + drm_intel_bo_unreference(linear); + for (i = 0; i < count; i++) { + drm_intel_bo_unreference(buf[i].bo); + } + intel_batchbuffer_free(batch); + drm_intel_bufmgr_destroy(bufmgr); +} + + +igt_main +{ + int fd = 0; + int count = 0; + + igt_fixture { + fd = drm_open_any(); + } + + igt_subtest("basic") { + run_test(fd, 2); + } + + /* the rest of the tests are too long for simulation */ + igt_skip_on_simulation(); + + igt_subtest("apperture-thrash") { + count = 3 * gem_aperture_size(fd) / SIZE / 2; + intel_require_memory(count, SIZE, CHECK_RAM); + run_test(fd, count); + } + + igt_subtest("swap-thrash") { + uint64_t swap_mb = intel_get_total_swap_mb(); + igt_require(swap_mb > 0); + count = ((intel_get_avail_ram_mb() + (swap_mb / 2)) * 1024*1024) / SIZE; + intel_require_memory(count, SIZE, CHECK_RAM | CHECK_SWAP); + run_test(fd, count); + } + igt_exit(); }