From patchwork Wed Feb 11 14:46:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Weinehall X-Patchwork-Id: 5812801 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 3642C9F37F for ; Wed, 11 Feb 2015 14:46:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1FA8820219 for ; Wed, 11 Feb 2015 14:46:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id ED0EC20211 for ; Wed, 11 Feb 2015 14:46:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 16D9B6E300; Wed, 11 Feb 2015 06:46:45 -0800 (PST) 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 366D06E300 for ; Wed, 11 Feb 2015 06:46:43 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 11 Feb 2015 06:42:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,559,1418112000"; d="scan'208";a="650676136" Received: from dweineha-mobl3.fi.intel.com (HELO [10.237.72.159]) ([10.237.72.159]) by orsmga001.jf.intel.com with ESMTP; 11 Feb 2015 06:46:08 -0800 Message-ID: <54DB6B2A.3040503@intel.com> Date: Wed, 11 Feb 2015 16:46:02 +0200 From: David Weinehall User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.4.0 MIME-Version: 1.0 To: "intel-gf >> Intel Graphics Development" Subject: [Intel-gfx] Hibernation test 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 intel-gpu-tools currently has a bunch of tests for suspend, but currently none (that I could find) for hibernate. Attached is a rudimentary patch to add said test. It does so by repurposing the drv_suspend driver to handle both suspend and hibernate, since the difference is miniscule. I decided to split the suspend/autoresume functions in igt_aux.c though, to be able to leave the igt_system_uspend_autoresume() function unchanged (the other option would be to introduce a boolean function argument and have that decide what parameters to pass to rtcwake). The timeout passed to rtcwake probably needs tuning (it might even need to be dynamically adjusted, since the time hibernation takes varies wildly depending on the amount of non-cache memory in use). Kind regards, David Weinehall PS: Go easy on me, mkay -- first patch to intel-gfx :P (meh, who am I kidding, I should be flame tolerant enough, bring it on). --------------------------------------------------------------------- Intel Finland Oy Registered Address: PL 281, 00181 Helsinki Business Identity Code: 0357606 - 4 Domiciled in Helsinki This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. Reviewed-by: Imre Deak diff --git a/lib/igt_aux.c b/lib/igt_aux.c index aefa0863e9e9..c39ccd86db63 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -1,5 +1,5 @@ /* - * Copyright © 2007, 2011, 2013, 2014 Intel Corporation + * Copyright © 2007, 2011, 2013, 2014, 2015 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -411,7 +411,7 @@ void igt_cleanup_aperture_trashers(void) * igt_system_suspend_autoresume: * * Execute a system suspend-to-mem cycle and automatically wake up again using - * the firmwares resume timer. + * the firmware's resume timer. * * This is very handy for implementing any kind of suspend/resume test. */ @@ -430,6 +430,34 @@ void igt_system_suspend_autoresume(void) } /** + * igt_system_hibernate_autoresume: + * + * Execute a system suspend-to-disk cycle and automatically wake up again using + * the firmware's resume timer. + * + * This is very handy for implementing any kind of hibernate/resume test. + */ +void igt_system_hibernate_autoresume(void) +{ + int ret; + + /* FIXME: I'm guessing simulation behaves the same way as with + * suspend/resume, but it might be prudent to make sure + */ + /* FIXME: Simulation doesn't like suspend/resume, and not even a lighter + * approach using /sys/power/pm_test to just test our driver's callbacks + * seems to fare better. We need to investigate what's going on. */ + igt_skip_on_simulation(); + + /* The timeout might need to be adjusted if hibernation takes too long + * or if we have to wait excessively long before resume + */ + ret = system("rtcwake -s 90 -m disk"); + igt_assert_f(ret == 0, "This failure means that something is wrong with the rtcwake tool " + "or how your distro is set up. This is not a i915.ko or i-g-t bug."); +} + +/** * igt_drop_root: * * Drop root privileges and make sure it actually worked. Useful for tests diff --git a/lib/igt_aux.h b/lib/igt_aux.h index 798a5b45fcb9..636ab3dc06fc 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -1,5 +1,5 @@ /* - * Copyright © 2014 Intel Corporation + * Copyright © 2014, 2015 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -58,8 +58,9 @@ void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr); void igt_trash_aperture(void); void igt_cleanup_aperture_trashers(void); -/* suspend and auto-resume system */ +/* suspend/hibernate and auto-resume system */ void igt_system_suspend_autoresume(void); +void igt_system_hibernate_autoresume(void); /* dropping priviledges */ void igt_drop_root(void); diff --git a/tests/drv_suspend.c b/tests/drv_suspend.c index 80f6a2254b75..8165cef9b333 100644 --- a/tests/drv_suspend.c +++ b/tests/drv_suspend.c @@ -1,5 +1,5 @@ /* - * Copyright © 2013 Intel Corporation + * Copyright © 2013, 2015 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -22,6 +22,7 @@ * * Authors: * Daniel Vetter + * David Weinehall * */ @@ -45,7 +46,7 @@ #define OBJECT_SIZE (16*1024*1024) static void -test_fence_restore(int fd, bool tiled2untiled) +test_fence_restore(int fd, bool tiled2untiled, bool hibernate) { uint32_t handle1, handle2, handle_tiled; uint32_t *ptr1, *ptr2, *ptr_tiled; @@ -80,7 +81,10 @@ test_fence_restore(int fd, bool tiled2untiled) else gem_set_tiling(fd, handle_tiled, I915_TILING_X, 2048); - igt_system_suspend_autoresume(); + if (hibernate) + igt_system_hibernate_autoresume(); + else + igt_system_suspend_autoresume(); igt_info("checking the first canary object\n"); for (i = 0; i < OBJECT_SIZE/sizeof(uint32_t); i++) @@ -100,7 +104,7 @@ test_fence_restore(int fd, bool tiled2untiled) } static void -test_debugfs_reader(void) +test_debugfs_reader(bool hibernate) { struct igt_helper_process reader = {}; reader.use_SIGKILL = true; @@ -117,7 +121,10 @@ test_debugfs_reader(void) sleep(1); - igt_system_suspend_autoresume(); + if (hibernate) + igt_system_hibernate_autoresume(); + else + igt_system_suspend_autoresume(); sleep(1); @@ -125,7 +132,7 @@ test_debugfs_reader(void) } static void -test_sysfs_reader(void) +test_sysfs_reader(bool hibernate) { struct igt_helper_process reader = {}; reader.use_SIGKILL = true; @@ -142,7 +149,10 @@ test_sysfs_reader(void) sleep(1); - igt_system_suspend_autoresume(); + if (hibernate) + igt_system_hibernate_autoresume(); + else + igt_system_suspend_autoresume(); sleep(1); @@ -150,13 +160,18 @@ test_sysfs_reader(void) } static void -test_forcewake(void) +test_forcewake(bool hibernate) { int fw_fd; fw_fd = igt_open_forcewake_handle(); igt_assert(fw_fd >= 0); - igt_system_suspend_autoresume(); + + if (hibernate) + igt_system_hibernate_autoresume(); + else + igt_system_suspend_autoresume(); + close (fw_fd); } @@ -169,20 +184,35 @@ igt_main igt_fixture fd = drm_open_any(); - igt_subtest("fence-restore-tiled2untiled") - test_fence_restore(fd, true); + igt_subtest("fence-restore-tiled2untiled-suspend") + test_fence_restore(fd, true, false); + + igt_subtest("fence-restore-untiled-suspend") + test_fence_restore(fd, false, false); + + igt_subtest("debugfs-reader-suspend") + test_debugfs_reader(false); + + igt_subtest("sysfs-reader-suspend") + test_sysfs_reader(false); + + igt_subtest("forcewake-suspend") + test_forcewake(false); + + igt_subtest("fence-restore-tiled2untiled-hibernate") + test_fence_restore(fd, true, true); - igt_subtest("fence-restore-untiled") - test_fence_restore(fd, false); + igt_subtest("fence-restore-untiled-hibernate") + test_fence_restore(fd, false, true); - igt_subtest("debugfs-reader") - test_debugfs_reader(); + igt_subtest("debugfs-reader-hibernate") + test_debugfs_reader(true); - igt_subtest("sysfs-reader") - test_sysfs_reader(); + igt_subtest("sysfs-reader-hibernate") + test_sysfs_reader(true); - igt_subtest("forcewake") - test_forcewake(); + igt_subtest("forcewake-hibernate") + test_forcewake(true); igt_fixture close(fd);