From patchwork Thu Nov 22 13:25:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 1783821 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 84AE4DF230 for ; Thu, 22 Nov 2012 13:29:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6D68EE5ED9 for ; Thu, 22 Nov 2012 05:29:09 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [143.182.124.37]) by gabe.freedesktop.org (Postfix) with ESMTP id 4DACCE5EDD for ; Thu, 22 Nov 2012 05:25:16 -0800 (PST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 22 Nov 2012 05:25:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.83,300,1352102400"; d="scan'208";a="221085854" Received: from ideak-desk.fi.intel.com (HELO localhost) ([10.237.72.159]) by azsmga001.ch.intel.com with ESMTP; 22 Nov 2012 05:25:14 -0800 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 22 Nov 2012 15:25:06 +0200 Message-Id: <1353590706-1366-5-git-send-email-imre.deak@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1353590706-1366-1-git-send-email-imre.deak@intel.com> References: <1353590706-1366-1-git-send-email-imre.deak@intel.com> Subject: [Intel-gfx] [i-g-t PATCH 4/4] flip_test: switch to using monotonic timestamps X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Since monotonic timestamps are now the preferred time format, change timestamps checks to compare against monotonic instead of real time. Also add two tests for DRM's compatibility mode where it returns real timestamps. Signed-off-by: Imre Deak --- tests/flip_test.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/tests/flip_test.c b/tests/flip_test.c index d88f81c..258d727 100644 --- a/tests/flip_test.c +++ b/tests/flip_test.c @@ -53,6 +53,7 @@ #define TEST_VBLANK_BLOCK (1 << 9) #define TEST_VBLANK_ABSOLUTE (1 << 10) #define TEST_VBLANK_EXPIRED_SEQ (1 << 11) +#define TEST_TIMESTAMP_REAL (1 << 12) #define EVENT_FLIP (1 << 0) #define EVENT_VBLANK (1 << 1) @@ -63,6 +64,7 @@ static drm_intel_bufmgr *bufmgr; struct intel_batchbuffer *batch; uint32_t devid; int test_time = 3; +static bool monotonic_timestamp; uint32_t *fb_ptr; @@ -296,7 +298,19 @@ analog_tv_connector(struct test_output *o) static void event_handler(struct event_state *es, unsigned int frame, unsigned int sec, unsigned int usec) { - gettimeofday(&es->current_received_ts, NULL); + struct timeval now; + + if (monotonic_timestamp) { + struct timespec ts; + + clock_gettime(CLOCK_MONOTONIC, &ts); + now.tv_sec = ts.tv_sec; + now.tv_usec = ts.tv_nsec / 1000; + } else { + gettimeofday(&now, NULL); + } + es->current_received_ts = now; + es->current_ts.tv_sec = sec; es->current_ts.tv_usec = usec; es->current_seq = frame; @@ -899,6 +913,28 @@ static int get_pipe_from_crtc_id(int crtc_id) return pfci.pipe; } +static void enable_monotonic_timestamp(bool enable) +{ + static const char *sysfs_mono_path = + "/sys/module/drm/parameters/timestamp_monotonic"; + int mono_ts_enabled; + int scanned; + FILE *f; + + f = fopen(sysfs_mono_path, "r+"); + assert(f); + + scanned = fscanf(f, "%d", &mono_ts_enabled); + assert(scanned == 1 && (mono_ts_enabled == 1 || mono_ts_enabled == 0)); + + if (mono_ts_enabled != enable) + fprintf(f, "%d", enable); + + fclose(f); + + monotonic_timestamp = enable; +} + static int run_test(int duration, int flags, const char *test_name) { struct test_output o; @@ -911,6 +947,8 @@ static int run_test(int duration, int flags, const char *test_name) exit(5); } + enable_monotonic_timestamp(!(flags & TEST_TIMESTAMP_REAL)); + /* Find any connected displays */ for (c = 0; c < resources->count_connectors; c++) { for (i = 0; i < resources->count_crtcs; i++) { @@ -941,6 +979,8 @@ int main(int argc, char **argv) const char *name; } tests[] = { { 15, TEST_VBLANK | TEST_CHECK_TS, "wf-vblank" }, + { 15, TEST_VBLANK | TEST_TIMESTAMP_REAL | TEST_CHECK_TS, + "wf-vblank with real timestamps" }, { 15, TEST_VBLANK | TEST_VBLANK_BLOCK | TEST_CHECK_TS, "blocking wf-vblank" }, { 5, TEST_VBLANK | TEST_VBLANK_ABSOLUTE, @@ -955,6 +995,8 @@ int main(int argc, char **argv) "delayed wf-vblank vs modeset" }, { 15, TEST_FLIP | TEST_CHECK_TS | TEST_EBUSY , "plain flip" }, + { 5, TEST_FLIP | TEST_TIMESTAMP_REAL | TEST_CHECK_TS, + "flip with real timestamps" }, { 30, TEST_FLIP | TEST_DPMS | TEST_EINVAL, "flip vs dpms" }, { 30, TEST_FLIP | TEST_DPMS | TEST_WITH_DUMMY_LOAD, "delayed flip vs dpms" }, { 5, TEST_FLIP | TEST_PAN, "flip vs panning" }, @@ -973,6 +1015,11 @@ int main(int argc, char **argv) }; int i; + if (geteuid() != 0) { + fprintf(stderr, "you must run this as root\n"); + exit(EXIT_FAILURE); + } + drm_fd = drm_open_any(); bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096);