From patchwork Mon Jun 6 09:21:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ankitprasad.r.sharma@intel.com X-Patchwork-Id: 9157669 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 11E4360572 for ; Mon, 6 Jun 2016 09:47:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 014E226E5D for ; Mon, 6 Jun 2016 09:47:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA2DE2780C; Mon, 6 Jun 2016 09:47:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FCC726E5D for ; Mon, 6 Jun 2016 09:47:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 521726E3BB; Mon, 6 Jun 2016 09:47:41 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id A104C6E3BB for ; Mon, 6 Jun 2016 09:47:39 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP; 06 Jun 2016 02:47:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,426,1459839600"; d="scan'208";a="116762207" Received: from ankitprasad-desktop.iind.intel.com ([10.223.82.74]) by fmsmga004.fm.intel.com with ESMTP; 06 Jun 2016 02:47:37 -0700 From: ankitprasad.r.sharma@intel.com To: intel-gfx@lists.freedesktop.org Date: Mon, 6 Jun 2016 14:51:57 +0530 Message-Id: <1465204917-6986-1-git-send-email-ankitprasad.r.sharma@intel.com> X-Mailer: git-send-email 1.9.1 Cc: akash.goel@intel.com, Ankitprasad Sharma Subject: [Intel-gfx] [PATCH 1/3] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation 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-Virus-Scanned: ClamAV using ClamSMTP From: Ankitprasad Sharma This patch verifies if the contents of the stolen backed object were preserved across hibernation. This is to validate kernel changes related to moving stolen-backed objects to shmem on hibernation. v2: Added comment, Use igt_assert_eq() instead of igt_assert(), Made loops more readable (Tvrtko) v3: Corrected assertion (Tvrtko) Signed-off-by: Ankitprasad Sharma Reviewed-by: Tvrtko Ursulin --- tests/gem_stolen.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/tests/gem_stolen.c b/tests/gem_stolen.c index 07fdd39..3a3cf81 100644 --- a/tests/gem_stolen.c +++ b/tests/gem_stolen.c @@ -290,6 +290,98 @@ static void stolen_fill_purge_test(int fd) gem_close(fd, handle[i]); } +static void stolen_hibernate(int fd) +{ + drm_intel_bo *bo; + drm_intel_bo *src, *dest; + int obj_count = 0, i = 0; + int ret, j; + uint32_t handle[MAX_OBJECTS], src_handle; + uint32_t *virt; + + gem_require_stolen_support(fd); + + src_handle = gem_create(fd, SIZE); + src = gem_handle_to_libdrm_bo(bufmgr, fd, + "bo", src_handle); + igt_assert(src != NULL); + + ret = drm_intel_gem_bo_map_gtt(src); + igt_assert_eq(ret, 0); + + virt = src->virtual; + for (j = 0; j < SIZE/DWORD_SIZE; j++) { + igt_assert_eq(virt[j], 0); + virt[j] = j; + } + + drm_intel_bo_unmap(src); + /* Exhaust Stolen space */ + for (i = 0; i < MAX_OBJECTS; i++) { + handle[i] = __gem_create_stolen(fd, SIZE); + if (!handle[i]) + break; + + bo = gem_handle_to_libdrm_bo(bufmgr, fd, + "verify_bo", handle[i]); + igt_assert(bo != NULL); + ret = drm_intel_gem_bo_map_gtt(bo); + igt_assert_eq(ret, 0); + + virt = bo->virtual; + for (j = 0; j < SIZE/DWORD_SIZE; j++) + igt_assert_eq(virt[j], 0); + + drm_intel_bo_unmap(bo); + drm_intel_bo_unreference(bo); + + obj_count++; + } + + /* Assert if atleast one object is allocated from stolen, that + * is good enough to verify the content preservation across + * hibernation. + */ + igt_assert(obj_count > 0); + + /* Copy data to all stolen backed objects */ + for (i = 0; i < obj_count; i++) { + dest = gem_handle_to_libdrm_bo(bufmgr, fd, + "dst_bo", handle[i]); + igt_assert(dest != NULL); + /* Copy contents to stolen backed objects via blt and + * verify post-hibernation, this also helps in identifying + * that the operation was completed before going to + * hibernation. + */ + intel_copy_bo(batch, dest, src, SIZE); + } + + drm_intel_bo_unreference(src); + + igt_system_hibernate_autoresume(); + /* Check if the object's memory contents are intact + * across hibernation. + */ + for (i = 0; i < obj_count; i++) { + bo = gem_handle_to_libdrm_bo(bufmgr, fd, + "verify_bo", handle[i]); + igt_assert(bo != NULL); + ret = drm_intel_gem_bo_map_gtt(bo); + igt_assert_eq(ret, 0); + virt = bo->virtual; + for (j = 0; j < SIZE/DWORD_SIZE; j++) + igt_assert_eq(virt[j], j); + + drm_intel_bo_unmap(bo); + drm_intel_bo_unreference(bo); + } + + gem_close(fd, src_handle); + for (i = 0; i < obj_count; i++) + gem_close(fd, handle[i]); +} + static void stolen_no_mmap(int fd) { @@ -353,6 +445,9 @@ igt_main igt_subtest("stolen-fill-purge") stolen_fill_purge_test(fd); + igt_subtest("stolen-hibernate") + stolen_hibernate(fd); + igt_fixture { intel_batchbuffer_free(batch); drm_intel_bufmgr_destroy(bufmgr);