From patchwork Wed Dec 21 10:15:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foss X-Patchwork-Id: 9482805 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 C1F1760772 for ; Wed, 21 Dec 2016 10:15:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A0912846A for ; Wed, 21 Dec 2016 10:15:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E35F28474; Wed, 21 Dec 2016 10:15:23 +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, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 036732846A for ; Wed, 21 Dec 2016 10:15:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F1156EFD2; Wed, 21 Dec 2016 10:15:18 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by gabe.freedesktop.org (Postfix) with ESMTPS id 641D46EFD2 for ; Wed, 21 Dec 2016 10:15:16 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: robertfoss) with ESMTPSA id F13C0269312 From: Robert Foss To: intel-gfx@lists.freedesktop.org, Tomeu Vizoso , Robert Bragg , Chris Wilson Date: Wed, 21 Dec 2016 05:15:09 -0500 Message-Id: <20161221101509.17656-1-robert.foss@collabora.com> X-Mailer: git-send-email 2.11.0 Subject: [Intel-gfx] [PATCH i-g-t v3] tests/perf: Fix pointer length compilation errors on 32-bit systems 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 Fix pointer length compilations errors on 32-bit systems. Signed-off-by: Robert Foss Reviewed-by: Chris Wilson --- tests/perf.c | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/tests/perf.c b/tests/perf.c index 87df9f00..27681368 100644 --- a/tests/perf.c +++ b/tests/perf.c @@ -205,6 +205,11 @@ static uint64_t timestamp_frequency = 12500000; static igt_render_copyfunc_t render_copy = NULL; +static inline uint64_t to_user_pointer(void *ptr) +{ + return (uint64_t)(uintptr_t)ptr; +} + static int __perf_open(int fd, struct drm_i915_perf_open_param *param) { @@ -432,7 +437,7 @@ test_system_wide_paranoid(void) .flags = I915_PERF_FLAG_FD_CLOEXEC | I915_PERF_FLAG_FD_NONBLOCK, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; write_u64_file("/proc/sys/dev/i915/perf_stream_paranoid", 1); @@ -458,7 +463,7 @@ test_system_wide_paranoid(void) .flags = I915_PERF_FLAG_FD_CLOEXEC | I915_PERF_FLAG_FD_NONBLOCK, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; int stream_fd; @@ -491,7 +496,7 @@ test_invalid_open_flags(void) struct drm_i915_perf_open_param param = { .flags = ~0, /* Undefined flag bits set! */ .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; do_ioctl_err(drm_fd, DRM_IOCTL_I915_PERF_OPEN, ¶m, EINVAL); @@ -513,7 +518,7 @@ test_invalid_oa_metric_set_id(void) .flags = I915_PERF_FLAG_FD_CLOEXEC | I915_PERF_FLAG_FD_NONBLOCK, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; int stream_fd; @@ -548,7 +553,7 @@ test_invalid_oa_format_id(void) .flags = I915_PERF_FLAG_FD_CLOEXEC | I915_PERF_FLAG_FD_NONBLOCK, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; int stream_fd; @@ -581,7 +586,7 @@ test_missing_sample_flags(void) struct drm_i915_perf_open_param param = { .flags = I915_PERF_FLAG_FD_CLOEXEC, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; do_ioctl_err(drm_fd, DRM_IOCTL_I915_PERF_OPEN, ¶m, EINVAL); @@ -735,7 +740,7 @@ open_and_read_2_oa_reports(int format_id, struct drm_i915_perf_open_param param = { .flags = I915_PERF_FLAG_FD_CLOEXEC, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; int stream_fd = __perf_open(drm_fd, ¶m); @@ -1047,7 +1052,7 @@ test_invalid_oa_exponent(void) struct drm_i915_perf_open_param param = { .flags = I915_PERF_FLAG_FD_CLOEXEC, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; int stream_fd = __perf_open(drm_fd, ¶m); @@ -1103,7 +1108,7 @@ test_low_oa_exponent_permissions(void) struct drm_i915_perf_open_param param = { .flags = I915_PERF_FLAG_FD_CLOEXEC, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; uint64_t oa_period, oa_freq; @@ -1168,7 +1173,7 @@ test_per_context_mode_unprivileged(void) struct drm_i915_perf_open_param param = { .flags = I915_PERF_FLAG_FD_CLOEXEC, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; /* should be default, but just to be sure... */ @@ -1255,7 +1260,7 @@ test_blocking(void) struct drm_i915_perf_open_param param = { .flags = I915_PERF_FLAG_FD_CLOEXEC, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; int stream_fd = __perf_open(drm_fd, ¶m); uint8_t buf[1024 * 1024]; @@ -1348,7 +1353,7 @@ test_polling(void) .flags = I915_PERF_FLAG_FD_CLOEXEC | I915_PERF_FLAG_FD_NONBLOCK, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; int stream_fd = __perf_open(drm_fd, ¶m); uint8_t buf[1024 * 1024]; @@ -1465,7 +1470,7 @@ test_buffer_fill(void) struct drm_i915_perf_open_param param = { .flags = I915_PERF_FLAG_FD_CLOEXEC, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; int stream_fd = __perf_open(drm_fd, ¶m); int buf_size = 65536 * (256 + sizeof(struct drm_i915_perf_record_header)); @@ -1540,7 +1545,7 @@ test_enable_disable(void) .flags = I915_PERF_FLAG_FD_CLOEXEC | I915_PERF_FLAG_DISABLED, /* Verify we start disabled */ .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; int stream_fd = __perf_open(drm_fd, ¶m); int buf_size = 65536 * (256 + sizeof(struct drm_i915_perf_record_header)); @@ -1610,7 +1615,7 @@ test_short_reads(void) struct drm_i915_perf_open_param param = { .flags = I915_PERF_FLAG_FD_CLOEXEC, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; size_t record_size = 256 + sizeof(struct drm_i915_perf_record_header); size_t page_size = sysconf(_SC_PAGE_SIZE); @@ -1698,7 +1703,7 @@ test_non_sampling_read_error(void) struct drm_i915_perf_open_param param = { .flags = I915_PERF_FLAG_FD_CLOEXEC, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; int stream_fd = __perf_open(drm_fd, ¶m); uint8_t buf[1024]; @@ -1732,7 +1737,7 @@ test_disabled_read_error(void) .flags = I915_PERF_FLAG_FD_CLOEXEC | I915_PERF_FLAG_DISABLED, /* XXX: open disabled */ .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; int stream_fd = __perf_open(drm_fd, ¶m); uint32_t oa_report0[64]; @@ -1794,7 +1799,7 @@ test_mi_rpc(void) struct drm_i915_perf_open_param param = { .flags = I915_PERF_FLAG_FD_CLOEXEC, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; int stream_fd = __perf_open(drm_fd, ¶m); drm_intel_bufmgr *bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096); @@ -1924,7 +1929,7 @@ test_per_ctx_mi_rpc(void) struct drm_i915_perf_open_param param = { .flags = I915_PERF_FLAG_FD_CLOEXEC, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; /* should be default, but just to be sure... */ @@ -2134,7 +2139,7 @@ test_rc6_disable(void) struct drm_i915_perf_open_param param = { .flags = I915_PERF_FLAG_FD_CLOEXEC, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; int stream_fd = __perf_open(drm_fd, ¶m); uint64_t n_events_start = read_debugfs_u64_record("i915_drpc_info", @@ -2208,7 +2213,7 @@ test_i915_ref_count(void) struct drm_i915_perf_open_param param = { .flags = I915_PERF_FLAG_FD_CLOEXEC, .num_properties = sizeof(properties) / 16, - .properties_ptr = (uint64_t)properties, + .properties_ptr = to_user_pointer(properties), }; unsigned baseline, ref_count0, ref_count1; int stream_fd;