Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 1 | /* |
| 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 Wood | 804e11f | 2015-08-17 17:57:43 +0100 | [diff] [blame] | 28 | #include "igt.h" |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 29 | #include <unistd.h> |
| 30 | #include <stdlib.h> |
| 31 | #include <stdint.h> |
| 32 | #include <stdio.h> |
| 33 | #include <string.h> |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 34 | #include <fcntl.h> |
| 35 | #include <inttypes.h> |
| 36 | #include <errno.h> |
| 37 | #include <sys/stat.h> |
| 38 | #include <sys/ioctl.h> |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 39 | #include <sys/time.h> |
Chris Wilson | b430709 | 2015-07-01 13:53:07 +0100 | [diff] [blame] | 40 | #include <time.h> |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 41 | #include "drm.h" |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 42 | |
Chris Wilson | cd8d380 | 2015-03-24 09:15:12 +0000 | [diff] [blame] | 43 | #define LOCAL_I915_EXEC_NO_RELOC (1<<11) |
| 44 | #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12) |
| 45 | |
Zhong Li | bafbbf1 | 2013-04-23 15:06:45 +0800 | [diff] [blame] | 46 | #define LOCAL_I915_EXEC_VEBOX (4<<0) |
Daniel Vetter | 51f0830 | 2012-12-05 19:29:11 +0100 | [diff] [blame] | 47 | |
Chris Wilson | 2659cbb | 2015-03-26 12:09:57 +0000 | [diff] [blame] | 48 | const uint32_t batch[2] = {MI_BATCH_BUFFER_END}; |
| 49 | int device; |
| 50 | |
Chris Wilson | cd8d380 | 2015-03-24 09:15:12 +0000 | [diff] [blame] | 51 | static void loop(int fd, uint32_t handle, unsigned ring_id, const char *ring_name) |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 52 | { |
| 53 | struct drm_i915_gem_execbuffer2 execbuf; |
Daniel Vetter | a7a80c2 | 2012-01-10 15:50:20 +0100 | [diff] [blame] | 54 | struct drm_i915_gem_exec_object2 gem_exec[1]; |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 55 | int count; |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 56 | |
Daniel Vetter | 8f5387e | 2013-08-13 13:20:58 +0200 | [diff] [blame] | 57 | gem_require_ring(fd, ring_id); |
| 58 | |
Chris Wilson | cd8d380 | 2015-03-24 09:15:12 +0000 | [diff] [blame] | 59 | memset(&gem_exec, 0, sizeof(gem_exec)); |
| 60 | gem_exec[0].handle = handle; |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 61 | |
Chris Wilson | cd8d380 | 2015-03-24 09:15:12 +0000 | [diff] [blame] | 62 | 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 Wilson | 04bd964 | 2015-12-16 19:51:08 +0000 | [diff] [blame] | 74 | for (count = 1; count <= SLOW_QUICK(1<<17, 1<<4); count <<= 1) { |
Chris Wilson | 89bcdb9 | 2015-12-08 13:42:50 +0000 | [diff] [blame] | 75 | 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 Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 80 | } |
Daniel Vetter | d9d9578 | 2012-12-04 17:13:05 +0100 | [diff] [blame] | 81 | } |
Daniel Vetter | 8f5387e | 2013-08-13 13:20:58 +0200 | [diff] [blame] | 82 | |
Daniel Vetter | 071e9ca | 2013-10-31 16:23:26 +0100 | [diff] [blame] | 83 | igt_main |
Daniel Vetter | d9d9578 | 2012-12-04 17:13:05 +0100 | [diff] [blame] | 84 | { |
Chris Wilson | 7e0853c | 2016-01-27 14:17:53 +0000 | [diff] [blame^] | 85 | const struct intel_execution_engine *e; |
Chris Wilson | 2659cbb | 2015-03-26 12:09:57 +0000 | [diff] [blame] | 86 | uint32_t handle = 0; |
Daniel Vetter | d9d9578 | 2012-12-04 17:13:05 +0100 | [diff] [blame] | 87 | |
Chris Wilson | 2659cbb | 2015-03-26 12:09:57 +0000 | [diff] [blame] | 88 | igt_fixture { |
Micah Fedke | c81d293 | 2015-07-22 21:54:02 +0000 | [diff] [blame] | 89 | device = drm_open_driver(DRIVER_INTEL); |
Chris Wilson | 2659cbb | 2015-03-26 12:09:57 +0000 | [diff] [blame] | 90 | handle = gem_create(device, 4096); |
| 91 | gem_write(device, handle, 0, batch, sizeof(batch)); |
Daniel Vetter | b3880d3 | 2013-08-14 18:02:46 +0200 | [diff] [blame] | 92 | } |
Daniel Vetter | d9d9578 | 2012-12-04 17:13:05 +0100 | [diff] [blame] | 93 | |
Chris Wilson | 7e0853c | 2016-01-27 14:17:53 +0000 | [diff] [blame^] | 94 | 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 Vetter | d9d9578 | 2012-12-04 17:13:05 +0100 | [diff] [blame] | 97 | |
Daniel Vetter | b3880d3 | 2013-08-14 18:02:46 +0200 | [diff] [blame] | 98 | igt_fixture { |
Chris Wilson | 2659cbb | 2015-03-26 12:09:57 +0000 | [diff] [blame] | 99 | gem_close(device, handle); |
Chris Wilson | 2659cbb | 2015-03-26 12:09:57 +0000 | [diff] [blame] | 100 | close(device); |
Daniel Vetter | b3880d3 | 2013-08-14 18:02:46 +0200 | [diff] [blame] | 101 | } |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 102 | } |