diff options
author | Sally Qi <feng.qi@intel.com> | 2020-07-14 13:33:44 -0700 |
---|---|---|
committer | Antonio Argenziano <antonio.argenziano@intel.com> | 2020-07-15 11:00:20 -0700 |
commit | 32f8759b75ba5a06520f220d5d982b12d0cebd9f (patch) | |
tree | 0b2d19fed41f63cdb1e21ec29da267dbcac9677b /lib | |
parent | 21f8204e54c122e4a0f8ca4b59e4b2db8d1ba687 (diff) |
tests/i915/gem_huc_copy: Enable a HuC copy test
This test case loads the HuC copy firmware to copy the content of
the source buffer to the destination buffer.
v2: (Tony Ye)
* Restructured some functions and files.
* Defined the copy buffer size as 4K explicitly as the HuC Copy kernel
always copy 4K bytes from src buffer to dst buffer.
v3: (Feng Qi, Antonio Argenziano, Tony Ye)
* Restructured some functions as igt requested, exclude libdrm function call.
* Remove huc function wrappers
* Random initialize source input buffer
v4: (Robert Fosha)
* Fix autotools build failure.
v5: (Feng Qi, Tony Ye)
* Released all bo buffer after huc copying.
* Restructured huc_copy() function.
v6: (Feng Qi)
* Fixed the function of huc enabling and status check
* Added huc_copy to fast feedback testlist
v7: (Tony Ye, Feng Qi, Robert Fosha, Chris Wilson, Michal Wajdeczko)
* Check error with HUC_STATUS ioctl instead of debugfs
v8: (Antonio Argenziano)
* Remove unnecessary variable.
* Add huc_load subtest.
* Move failure checks out of igt_fixture.
* get_huc_status() returns errno and then status as a parameter
v9: (Antonio Argenziano)
* Remove huc_load subtest - to be added later.
v10:
* Rebase
* Remove huc_load subtest from fast-feedback.testlist.
Signed-off-by: Feng Qi <feng.qi@intel.com>
Signed-off-by: Tony Ye <tony.ye@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Antonio Argenziano <antonio.argenziano@intel.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile.sources | 2 | ||||
-rw-r--r-- | lib/huc_copy.c | 106 | ||||
-rw-r--r-- | lib/huc_copy.h | 49 | ||||
-rw-r--r-- | lib/intel_batchbuffer.c | 20 | ||||
-rw-r--r-- | lib/intel_batchbuffer.h | 19 | ||||
-rw-r--r-- | lib/meson.build | 1 |
6 files changed, 197 insertions, 0 deletions
diff --git a/lib/Makefile.sources b/lib/Makefile.sources index 00374c97b..464f5be2a 100644 --- a/lib/Makefile.sources +++ b/lib/Makefile.sources @@ -90,6 +90,8 @@ lib_source_list = \ ioctl_wrappers.h \ media_fill.c \ media_fill.h \ + huc_copy.c \ + huc_copy.h \ media_spin.h \ media_spin.c \ gpgpu_fill.h \ diff --git a/lib/huc_copy.c b/lib/huc_copy.c new file mode 100644 index 000000000..bc98b1f9f --- /dev/null +++ b/lib/huc_copy.c @@ -0,0 +1,106 @@ +/* + * Copyright © 2019 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#include <i915_drm.h> +#include "huc_copy.h" + +static void +gen9_emit_huc_virtual_addr_state(struct drm_i915_gem_exec_object2 *src, + struct drm_i915_gem_exec_object2 *dst, + struct drm_i915_gem_relocation_entry *reloc_src, + struct drm_i915_gem_relocation_entry *reloc_dst, + uint32_t *buf, + int *i) +{ + buf[(*i)++] = HUC_VIRTUAL_ADDR_STATE; + + for (int j = 0; j < HUC_VIRTUAL_ADDR_REGION_NUM; j++) { + if (j == HUC_VIRTUAL_ADDR_REGION_SRC) { + buf[(*i)++] = src->offset; + + reloc_src->target_handle = src->handle; + reloc_src->delta = 0; + reloc_src->offset = (*i - 1) * sizeof(buf[0]); + reloc_src->read_domains = 0; + reloc_src->write_domain = 0; + } else if (j == HUC_VIRTUAL_ADDR_REGION_DST) { + buf[(*i)++] = dst->offset; + + reloc_dst->target_handle = dst->handle; + reloc_dst->delta = 0; + reloc_dst->offset = (*i - 1) * sizeof(buf[0]); + reloc_dst->read_domains = 0; + reloc_dst->write_domain = I915_GEM_DOMAIN_RENDER; + } else { + buf[(*i)++] = 0; + } + buf[(*i)++] = 0; + buf[(*i)++] = 0; + } +} + +void +gen9_huc_copyfunc(int fd, + struct drm_i915_gem_exec_object2 *obj) +{ + struct drm_i915_gem_relocation_entry reloc[2]; + struct drm_i915_gem_execbuffer2 execbuf; + int i = 0; + uint32_t buf[63]; + + /* load huc kernel */ + buf[i++] = HUC_IMEM_STATE; + buf[i++] = 0; + buf[i++] = 0; + buf[i++] = 0; + buf[i++] = 0x3; + + buf[i++] = MFX_WAIT; + buf[i++] = MFX_WAIT; + + buf[i++] = HUC_PIPE_MODE_SELECT; + buf[i++] = 0; + buf[i++] = 0; + + buf[i++] = MFX_WAIT; + + memset(reloc, 0, sizeof(reloc)); + gen9_emit_huc_virtual_addr_state(&obj[0], &obj[1], &reloc[0], &reloc[1], buf, &i); + + buf[i++] = HUC_START; + buf[i++] = 1; + + buf[i++] = MI_BATCH_BUFFER_END; + + gem_write(fd, obj[2].handle, 0, buf, sizeof(buf)); + obj[2].relocation_count = 2; + obj[2].relocs_ptr = to_user_pointer(reloc); + + memset(&execbuf, 0, sizeof(execbuf)); + execbuf.buffers_ptr = to_user_pointer(obj); + execbuf.buffer_count = 3; + execbuf.flags = I915_EXEC_BSD; + + gem_execbuf(fd, &execbuf); +} diff --git a/lib/huc_copy.h b/lib/huc_copy.h new file mode 100644 index 000000000..ac31d8009 --- /dev/null +++ b/lib/huc_copy.h @@ -0,0 +1,49 @@ +/* + * Copyright © 2019 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#ifndef HUC_COPY_H +#define HUC_COPY_H + +#include <stdint.h> +#include <string.h> +#include "ioctl_wrappers.h" +#include "intel_reg.h" + +#define PARALLEL_VIDEO_PIPE (0x3<<29) +#define MFX_WAIT (PARALLEL_VIDEO_PIPE|(0x1<<27)|(0x1<<8)) + +#define HUC_IMEM_STATE (PARALLEL_VIDEO_PIPE|(0x2<<27)|(0xb<<23)|(0x1<<16)|0x3) +#define HUC_PIPE_MODE_SELECT (PARALLEL_VIDEO_PIPE|(0x2<<27)|(0xb<<23)|0x1) +#define HUC_START (PARALLEL_VIDEO_PIPE|(0x2<<27)|(0xb<<23)|(0x21<<16)) +#define HUC_VIRTUAL_ADDR_STATE (PARALLEL_VIDEO_PIPE|(0x2<<27)|(0xb<<23)|(0x4<<16)|0x2f) + +#define HUC_VIRTUAL_ADDR_REGION_NUM 16 +#define HUC_VIRTUAL_ADDR_REGION_SRC 0 +#define HUC_VIRTUAL_ADDR_REGION_DST 14 + +void +gen9_huc_copyfunc(int fd, + struct drm_i915_gem_exec_object2 *obj); + +#endif /* HUC_COPY_H */ diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c index 57fdbbbc5..99c2e1489 100644 --- a/lib/intel_batchbuffer.c +++ b/lib/intel_batchbuffer.c @@ -50,6 +50,7 @@ #include "igt_aux.h" #include "igt_rand.h" #include "i830_reg.h" +#include "huc_copy.h" #include <i915_drm.h> @@ -2125,3 +2126,22 @@ void intel_bb_blt_copy(struct intel_bb *ibb, intel_bb_emit_bbe(ibb); intel_bb_flush_blit(ibb); } + +/** + * igt_get_huc_copyfunc: + * @devid: pci device id + * + * Returns: + * + * The platform-specific huc copy function pointer for the device specified + * with @devid. Will return NULL when no media spin function is implemented. + */ +igt_huc_copyfunc_t igt_get_huc_copyfunc(int devid) +{ + igt_huc_copyfunc_t copy = NULL; + + if (IS_GEN12(devid) || IS_GEN11(devid) || IS_GEN9(devid)) + copy = gen9_huc_copyfunc; + + return copy; +} diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h index 02168b9d5..a69fffd8d 100644 --- a/lib/intel_batchbuffer.h +++ b/lib/intel_batchbuffer.h @@ -601,4 +601,23 @@ void intel_bb_blt_copy(struct intel_bb *ibb, struct intel_buf *dst, int dst_x1, int dst_y1, int dst_pitch, int width, int height, int bpp); + +/** + * igt_huc_copyfunc_t: + * @fd: drm fd + * @obj: drm_i915_gem_exec_object2 buffer array + * obj[0] is source buffer + * obj[1] is destination buffer + * obj[2] is execution buffer + * + * This is the type of the per-platform huc copy functions. + * + * The huc copy function emits a batchbuffer to the VDBOX engine to + * invoke the HuC Copy kernel to copy 4K bytes from the source buffer + * to the destination buffer. + */ +typedef void (*igt_huc_copyfunc_t)(int fd, + struct drm_i915_gem_exec_object2 *obj); + +igt_huc_copyfunc_t igt_get_huc_copyfunc(int devid); #endif diff --git a/lib/meson.build b/lib/meson.build index 6c71ae3d8..341696e5b 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -1,5 +1,6 @@ lib_sources = [ 'drmtest.c', + 'huc_copy.c', 'i915/gem.c', 'i915/gem_context.c', 'i915/gem_engine_topology.c', |