From patchwork Thu Nov 22 14:46:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 1783841 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 195233FC64 for ; Thu, 22 Nov 2012 14:47:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6C226E6550 for ; Thu, 22 Nov 2012 06:47:01 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by gabe.freedesktop.org (Postfix) with ESMTP id 01CF4E64F4 for ; Thu, 22 Nov 2012 06:46:49 -0800 (PST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 22 Nov 2012 06:46:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.83,301,1352102400"; d="scan'208";a="221110567" Received: from ideak-desk.fi.intel.com (HELO localhost) ([10.237.72.159]) by azsmga001.ch.intel.com with ESMTP; 22 Nov 2012 06:46:37 -0800 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Thu, 22 Nov 2012 16:46:36 +0200 Message-Id: <1353595596-11993-1-git-send-email-imre.deak@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1353590706-1366-5-git-send-email-imre.deak@intel.com> References: <1353590706-1366-5-git-send-email-imre.deak@intel.com> Subject: [Intel-gfx] [i-g-t PATCH 4/4] flip_test: switch to using monotonic timestamps (v2) 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. v2: drop the tests for the compatibilty mode (Daniel) Signed-off-by: Imre Deak --- tests/flip_test.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/tests/flip_test.c b/tests/flip_test.c index d88f81c..5214da9 100644 --- a/tests/flip_test.c +++ b/tests/flip_test.c @@ -57,12 +57,17 @@ #define EVENT_FLIP (1 << 0) #define EVENT_VBLANK (1 << 1) +#ifndef DRM_CAP_TIMESTAMP_MONOTONIC +#define DRM_CAP_TIMESTAMP_MONOTONIC 6 +#endif + drmModeRes *resources; int drm_fd; 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 +301,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; @@ -933,6 +950,18 @@ static int run_test(int duration, int flags, const char *test_name) return 1; } +static void get_timestamp_format(void) +{ + uint64_t cap_mono; + int ret; + + ret = drmGetCap(drm_fd, DRM_CAP_TIMESTAMP_MONOTONIC, &cap_mono); + assert(ret == 0 || errno == EINVAL); + monotonic_timestamp = ret == 0 && cap_mono == 1; + printf("Using %s timestamps\n", + monotonic_timestamp ? "monotonic" : "real"); +} + int main(int argc, char **argv) { struct { @@ -975,6 +1004,8 @@ int main(int argc, char **argv) drm_fd = drm_open_any(); + get_timestamp_format(); + bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096); devid = intel_get_drm_devid(drm_fd); batch = intel_batchbuffer_alloc(bufmgr, devid);