blob: 81c137755ffb7ec16a65adbcc95ef7ff221a0aff [file] [log] [blame]
Chris Wilson07d59b32011-01-20 22:10:10 +00001/*
2 * Copyright © 2011 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 * Chris Wilson <chris@chris-wilson.co.uk>
25 *
26 */
27
Thomas Wood804e11f2015-08-17 17:57:43 +010028#include "igt.h"
Chris Wilson07d59b32011-01-20 22:10:10 +000029#include <unistd.h>
30#include <stdlib.h>
31#include <stdint.h>
32#include <stdio.h>
33#include <string.h>
Chris Wilson07d59b32011-01-20 22:10:10 +000034#include <fcntl.h>
35#include <inttypes.h>
36#include <errno.h>
37#include <sys/stat.h>
38#include <sys/ioctl.h>
Chris Wilson07d59b32011-01-20 22:10:10 +000039#include <sys/time.h>
Chris Wilsonb4307092015-07-01 13:53:07 +010040#include <time.h>
Chris Wilson07d59b32011-01-20 22:10:10 +000041#include "drm.h"
Chris Wilson07d59b32011-01-20 22:10:10 +000042
Chris Wilsoncd8d3802015-03-24 09:15:12 +000043#define LOCAL_I915_EXEC_NO_RELOC (1<<11)
44#define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
45
Zhong Libafbbf12013-04-23 15:06:45 +080046#define LOCAL_I915_EXEC_VEBOX (4<<0)
Daniel Vetter51f08302012-12-05 19:29:11 +010047
Chris Wilson2659cbb2015-03-26 12:09:57 +000048const uint32_t batch[2] = {MI_BATCH_BUFFER_END};
49int device;
50
Chris Wilsoncd8d3802015-03-24 09:15:12 +000051static void loop(int fd, uint32_t handle, unsigned ring_id, const char *ring_name)
Chris Wilson07d59b32011-01-20 22:10:10 +000052{
53 struct drm_i915_gem_execbuffer2 execbuf;
Daniel Vettera7a80c22012-01-10 15:50:20 +010054 struct drm_i915_gem_exec_object2 gem_exec[1];
Chris Wilson07d59b32011-01-20 22:10:10 +000055 int count;
Chris Wilson07d59b32011-01-20 22:10:10 +000056
Daniel Vetter8f5387e2013-08-13 13:20:58 +020057 gem_require_ring(fd, ring_id);
58
Chris Wilsoncd8d3802015-03-24 09:15:12 +000059 memset(&gem_exec, 0, sizeof(gem_exec));
60 gem_exec[0].handle = handle;
Chris Wilson07d59b32011-01-20 22:10:10 +000061
Chris Wilsoncd8d3802015-03-24 09:15:12 +000062 memset(&execbuf, 0, sizeof(execbuf));
63 execbuf.buffers_ptr = (uintptr_t)gem_exec;
64 execbuf.buffer_count = 1;
65 execbuf.flags = ring_id;
66 execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT;
67 execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC;
68 if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf)) {
69 execbuf.flags = ring_id;
70 do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
71 }
72 gem_sync(fd, handle);
73
Chris Wilson04bd9642015-12-16 19:51:08 +000074 for (count = 1; count <= SLOW_QUICK(1<<17, 1<<4); count <<= 1) {
Chris Wilson89bcdb92015-12-08 13:42:50 +000075 int loops = count;
76 gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, 0);
77 while (loops--)
78 do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
79 gem_sync(fd, handle);
Chris Wilson07d59b32011-01-20 22:10:10 +000080 }
Daniel Vetterd9d95782012-12-04 17:13:05 +010081}
Daniel Vetter8f5387e2013-08-13 13:20:58 +020082
Daniel Vetter071e9ca2013-10-31 16:23:26 +010083igt_main
Daniel Vetterd9d95782012-12-04 17:13:05 +010084{
Chris Wilson7e0853c2016-01-27 14:17:53 +000085 const struct intel_execution_engine *e;
Chris Wilson2659cbb2015-03-26 12:09:57 +000086 uint32_t handle = 0;
Daniel Vetterd9d95782012-12-04 17:13:05 +010087
Chris Wilson2659cbb2015-03-26 12:09:57 +000088 igt_fixture {
Micah Fedkec81d2932015-07-22 21:54:02 +000089 device = drm_open_driver(DRIVER_INTEL);
Chris Wilson2659cbb2015-03-26 12:09:57 +000090 handle = gem_create(device, 4096);
91 gem_write(device, handle, 0, batch, sizeof(batch));
Daniel Vetterb3880d32013-08-14 18:02:46 +020092 }
Daniel Vetterd9d95782012-12-04 17:13:05 +010093
Chris Wilson7e0853c2016-01-27 14:17:53 +000094 for (e = intel_execution_engines; e->name; e++)
95 igt_subtest_f("%s", e->name)
96 loop(device, handle, e->exec_id | e->flags, e->name);
Daniel Vetterd9d95782012-12-04 17:13:05 +010097
Daniel Vetterb3880d32013-08-14 18:02:46 +020098 igt_fixture {
Chris Wilson2659cbb2015-03-26 12:09:57 +000099 gem_close(device, handle);
Chris Wilson2659cbb2015-03-26 12:09:57 +0000100 close(device);
Daniel Vetterb3880d32013-08-14 18:02:46 +0200101 }
Chris Wilson07d59b32011-01-20 22:10:10 +0000102}