From patchwork Tue May 12 12:09:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Morton X-Patchwork-Id: 6387481 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0ABC09F32E for ; Tue, 12 May 2015 12:10:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3A459203E3 for ; Tue, 12 May 2015 12:10:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2F0A32035D for ; Tue, 12 May 2015 12:10:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A68B06E5DC; Tue, 12 May 2015 05:10:26 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTP id 9F6996E5DE for ; Tue, 12 May 2015 05:10:25 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 12 May 2015 05:10:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,414,1427785200"; d="scan'208";a="492557801" Received: from djmorton-linux.isw.intel.com ([10.102.226.153]) by FMSMGA003.fm.intel.com with ESMTP; 12 May 2015 05:10:24 -0700 From: Derek Morton To: intel-gfx@lists.freedesktop.org Date: Tue, 12 May 2015 13:09:37 +0100 Message-Id: <1431432577-13202-1-git-send-email-derek.j.morton@intel.com> X-Mailer: git-send-email 1.9.1 Cc: thomas.wood@intel.com Subject: [Intel-gfx] [PATCH i-g-t] tests/gem_cpu_reloc: Fix gem_cpu_reloc OOM failure 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 On android with small memory footprints gem_cpu_reloc can fail due to OOM. Refactor gem_cpu_reloc into 2 tests, a basic test which performs 10 relocations and a full test which skips if there is insufficient memory. Changed the memory required test to better estimate the actual RAM used. Signed-off-by: Derek Morton Reviewed-by: Tim Gore --- tests/gem_cpu_reloc.c | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/tests/gem_cpu_reloc.c b/tests/gem_cpu_reloc.c index 058089c..2f5fc60 100644 --- a/tests/gem_cpu_reloc.c +++ b/tests/gem_cpu_reloc.c @@ -159,16 +159,14 @@ uint32_t gen8_batch[] = { uint32_t *batch = gen6_batch; uint32_t batch_size = sizeof(gen6_batch); -igt_simple_main +void run_test(int fd, int count) { const uint32_t hang[] = {-1, -1, -1, -1}; const uint32_t end[] = {MI_BATCH_BUFFER_END, 0}; - uint64_t aper_size; uint32_t noop; uint32_t *handles; - int fd, i, count; + int i; - fd = drm_open_any(); noop = intel_get_drm_devid(fd); use_blt = 0; @@ -180,13 +178,6 @@ igt_simple_main batch_size += 2 * 4; } - aper_size = gem_mappable_aperture_size(); - count = aper_size / 4096 * 2; - if (igt_run_in_simulation()) - count = 10; - - intel_require_memory(1+count, 4096, CHECK_RAM); - handles = malloc (count * sizeof(uint32_t)); igt_assert(handles); @@ -246,6 +237,39 @@ igt_simple_main igt_progress("gem_cpu_reloc: ", 2*count+i, 3*count); } - igt_info("Test suceeded, cleanup up - this might take a while.\n"); + igt_info("Subtest suceeded, cleanup up - this might take a while.\n"); + for (i = 0; i < count; i++) { + gem_close(fd, handles[i]); + } + gem_close(fd, noop); + free(handles); +} + +igt_main +{ + uint64_t aper_size; + int fd, count; + + igt_fixture { + fd = drm_open_any(); + } + + igt_subtest("basic") { + run_test (fd, 10); + } + + igt_skip_on_simulation(); + + igt_subtest("full") { + aper_size = gem_mappable_aperture_size(); + count = aper_size / 4096 * 2; + + /* count + 2 (noop & bad) buffers. A gem object appears to + require about 2kb + buffer + kernel overhead */ + intel_require_memory(2+count, 2048+4096, CHECK_RAM); + + run_test (fd, count); + } + close(fd); }