mirror of
				https://github.com/tiagovignatti/intel-gpu-tools.git
				synced 2025-10-31 18:17:13 +00:00 
			
		
		
		
	lib: Share common __gem_execbuf()
An oft-repeated function to check EXECBUFFER2 for a particular fail condition. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
		
							parent
							
								
									711398e82a
								
							
						
					
					
						commit
						e3b68bb666
					
				| @ -178,14 +178,6 @@ static int gem_linear_blt(int fd, | ||||
| 	return (b+2 - batch) * sizeof(uint32_t); | ||||
| } | ||||
| 
 | ||||
| static int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf) | ||||
| { | ||||
| 	int err = 0; | ||||
| 	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf)) | ||||
| 		err = -errno; | ||||
| 	return err; | ||||
| } | ||||
| 
 | ||||
| static int run(int object, int batch, int time, int reps) | ||||
| { | ||||
| 	struct drm_i915_gem_execbuffer2 execbuf; | ||||
|  | ||||
| @ -49,15 +49,6 @@ | ||||
| #define LOCAL_I915_EXEC_NO_RELOC (1<<11) | ||||
| #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12) | ||||
| 
 | ||||
| static int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf) | ||||
| { | ||||
| 	int err = 0; | ||||
| 	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf)) | ||||
| 		err = -errno; | ||||
| 	return err; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| static double elapsed(const struct timespec *start, | ||||
|                         const struct timespec *end) | ||||
| { | ||||
|  | ||||
| @ -56,14 +56,6 @@ static double elapsed(const struct timespec *start, | ||||
| 	return (end->tv_sec - start->tv_sec) + 1e-9*(end->tv_nsec - start->tv_nsec); | ||||
| } | ||||
| 
 | ||||
| static int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf) | ||||
| { | ||||
| 	int err = 0; | ||||
| 	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf)) | ||||
| 		err = -errno; | ||||
| 	return err; | ||||
| } | ||||
| 
 | ||||
| static uint32_t batch(int fd) | ||||
| { | ||||
| 	const uint32_t buf[] = {MI_BATCH_BUFFER_END}; | ||||
|  | ||||
| @ -55,14 +55,6 @@ static double elapsed(const struct timespec *start, | ||||
| 	return (end->tv_sec - start->tv_sec) + 1e-9*(end->tv_nsec - start->tv_nsec); | ||||
| } | ||||
| 
 | ||||
| static int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf) | ||||
| { | ||||
| 	int err = 0; | ||||
| 	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf)) | ||||
| 		err = -errno; | ||||
| 	return err; | ||||
| } | ||||
| 
 | ||||
| static uint32_t batch(int fd) | ||||
| { | ||||
| 	const uint32_t buf[] = {MI_BATCH_BUFFER_END}; | ||||
|  | ||||
| @ -502,6 +502,22 @@ uint32_t gem_create(int fd, uint64_t size) | ||||
| 	return create.handle; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|  * __gem_execbuf: | ||||
|  * @fd: open i915 drm file descriptor | ||||
|  * @execbuf: execbuffer data structure | ||||
|  * | ||||
|  * This wraps the EXECBUFFER2 ioctl, which submits a batchbuffer for the gpu to | ||||
|  * run. This is allowed to fail, with -errno returned. | ||||
|  */ | ||||
| int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf) | ||||
| { | ||||
| 	int err = 0; | ||||
| 	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf)) | ||||
| 		err = -errno; | ||||
| 	return err; | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|  * gem_execbuf: | ||||
|  * @fd: open i915 drm file descriptor | ||||
| @ -512,10 +528,7 @@ uint32_t gem_create(int fd, uint64_t size) | ||||
|  */ | ||||
| void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf) | ||||
| { | ||||
| 	int result; | ||||
| 
 | ||||
| 	result = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf); | ||||
| 	igt_assert(result == 0); | ||||
| 	igt_assert_eq(__gem_execbuf(fd, execbuf), 0); | ||||
| 	errno = 0; | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -62,6 +62,7 @@ uint32_t gem_create_stolen(int fd, uint64_t size); | ||||
| uint32_t __gem_create(int fd, int size); | ||||
| uint32_t gem_create(int fd, uint64_t size); | ||||
| void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf); | ||||
| int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf); | ||||
| 
 | ||||
| void *gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot); | ||||
| void *gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot); | ||||
|  | ||||
| @ -122,14 +122,6 @@ static uint32_t busy_blt(int fd) | ||||
| 	return object[0].handle; | ||||
| } | ||||
| 
 | ||||
| static int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *eb) | ||||
| { | ||||
| 	int err = 0; | ||||
| 	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, eb)) | ||||
| 		err = -errno; | ||||
| 	return err; | ||||
| } | ||||
| 
 | ||||
| static bool exec_noop(int fd, | ||||
| 		      uint32_t *handles, | ||||
| 		      unsigned ring, | ||||
|  | ||||
| @ -112,14 +112,6 @@ static void test_throttle(int fd) | ||||
| 	trigger_reset(fd); | ||||
| } | ||||
| 
 | ||||
| static int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *eb) | ||||
| { | ||||
| 	int err = 0; | ||||
| 	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, eb)) | ||||
| 		err = -errno; | ||||
| 	return err; | ||||
| } | ||||
| 
 | ||||
| static void test_execbuf(int fd) | ||||
| { | ||||
| 	struct drm_i915_gem_execbuffer2 execbuf; | ||||
|  | ||||
| @ -40,11 +40,6 @@ | ||||
| 
 | ||||
| IGT_TEST_DESCRIPTION("Exercises the basic execbuffer using object alignments"); | ||||
| 
 | ||||
| static int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *eb) | ||||
| { | ||||
| 	return drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, eb); | ||||
| } | ||||
| 
 | ||||
| static uint32_t find_last_bit(uint64_t x) | ||||
| { | ||||
| 	uint32_t i = 0; | ||||
| @ -163,8 +158,8 @@ static void single(int fd) | ||||
| 	if (__gem_execbuf(fd, &execbuf)) { | ||||
| 		execobj.flags = 0; | ||||
| 		gtt_size = 1ull << 32; | ||||
| 		gem_execbuf(fd, &execbuf); | ||||
| 	} | ||||
| 	gem_execbuf(fd, &execbuf); | ||||
| 
 | ||||
| 	execobj.alignment = 3*4096; | ||||
| 	non_pot = __gem_execbuf(fd, &execbuf) == 0; | ||||
|  | ||||
| @ -35,14 +35,6 @@ | ||||
| #define I915_PARAM_CMD_PARSER_VERSION       28 | ||||
| #endif | ||||
| 
 | ||||
| static int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf) | ||||
| { | ||||
| 	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf)) | ||||
| 		return -errno; | ||||
| 
 | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| static void exec_batch_patched(int fd, uint32_t cmd_bo, uint32_t *cmds, | ||||
| 			       int size, int patch_offset, uint64_t expected_value) | ||||
| { | ||||
|  | ||||
| @ -141,14 +141,6 @@ static void fill_reloc(struct drm_i915_gem_relocation_entry *reloc, uint32_t han | ||||
| 	reloc->write_domain = 0; | ||||
| } | ||||
| 
 | ||||
| static int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *eb) | ||||
| { | ||||
| 	int err = 0; | ||||
| 	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, eb)) | ||||
| 		err = errno; | ||||
| 	return err; | ||||
| } | ||||
| 
 | ||||
| #define BUSY_LOAD (1 << 0) | ||||
| #define INTERRUPTIBLE (1 << 1) | ||||
| 
 | ||||
| @ -200,8 +192,8 @@ static void run_test(int fd, int num_fences, int expected_errno, | ||||
| 		if (flags & BUSY_LOAD) | ||||
| 			emit_dummy_load(); | ||||
| 
 | ||||
| 		igt_assert_eq(__gem_execbuf(fd, &execbuf[0]), expected_errno); | ||||
| 		igt_assert_eq(__gem_execbuf(fd, &execbuf[1]), expected_errno); | ||||
| 		igt_assert_eq(__gem_execbuf(fd, &execbuf[0]), -expected_errno); | ||||
| 		igt_assert_eq(__gem_execbuf(fd, &execbuf[1]), -expected_errno); | ||||
| 	} while (--loop); | ||||
| 
 | ||||
| 	if (flags & INTERRUPTIBLE) | ||||
|  | ||||
| @ -136,20 +136,6 @@ static int gem_reset_status(int fd, int ctx_id) | ||||
| 	return RS_NO_ERROR; | ||||
| } | ||||
| 
 | ||||
| static int gem_exec(int fd, struct drm_i915_gem_execbuffer2 *execbuf) | ||||
| { | ||||
| 	int ret; | ||||
| 
 | ||||
| 	ret = ioctl(fd, | ||||
| 		    DRM_IOCTL_I915_GEM_EXECBUFFER2, | ||||
| 		    execbuf); | ||||
| 
 | ||||
| 	if (ret < 0) | ||||
| 		return -errno; | ||||
| 
 | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| static int exec_valid_ring(int fd, int ctx, int ring) | ||||
| { | ||||
| 	struct drm_i915_gem_execbuffer2 execbuf; | ||||
| @ -180,7 +166,7 @@ static int exec_valid_ring(int fd, int ctx, int ring) | ||||
| 	i915_execbuffer2_set_context_id(execbuf, ctx); | ||||
| 	execbuf.rsvd2 = 0; | ||||
| 
 | ||||
| 	ret = gem_exec(fd, &execbuf); | ||||
| 	ret = __gem_execbuf(fd, &execbuf); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
| 
 | ||||
|  | ||||
| @ -35,14 +35,6 @@ IGT_TEST_DESCRIPTION("Basic check of ring<->ring write synchronisation."); | ||||
|  * Extremely efficient at catching missed irqs with semaphores=0 ... | ||||
|  */ | ||||
| 
 | ||||
| static int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *eb) | ||||
| { | ||||
| 	int err = 0; | ||||
| 	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, eb)) | ||||
| 		err = -errno; | ||||
| 	return err; | ||||
| } | ||||
| 
 | ||||
| static void | ||||
| sync_loop(int fd) | ||||
| { | ||||
|  | ||||
| @ -71,14 +71,6 @@ static void fill_ring(int fd, struct drm_i915_gem_execbuffer2 *execbuf) | ||||
| 		gem_execbuf(fd, execbuf); | ||||
| } | ||||
| 
 | ||||
| static int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf) | ||||
| { | ||||
| 	int err = 0; | ||||
| 	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf)) | ||||
| 		err = -errno; | ||||
| 	return err; | ||||
| } | ||||
| 
 | ||||
| #define INTERRUPTIBLE 0x1 | ||||
| #define HANG 0x2 | ||||
| #define CHILD 0x8 | ||||
|  | ||||
| @ -43,14 +43,6 @@ static uint64_t gen8_canonical_addr(uint64_t address) | ||||
| 	return (__s64)(address << shift) >> shift; | ||||
| } | ||||
| 
 | ||||
| static int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *eb) | ||||
| { | ||||
| 	int err = 0; | ||||
| 	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, eb)) | ||||
| 		err = -errno; | ||||
| 	return err; | ||||
| } | ||||
| 
 | ||||
| static void test_invalid(int fd) | ||||
| { | ||||
| 	const uint32_t bbe = MI_BATCH_BUFFER_END; | ||||
|  | ||||
| @ -51,11 +51,6 @@ | ||||
| 
 | ||||
| IGT_TEST_DESCRIPTION("Test of streaming writes into active GPU sources"); | ||||
| 
 | ||||
| static bool __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *eb) | ||||
| { | ||||
| 	return drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, eb) == 0; | ||||
| } | ||||
| 
 | ||||
| #define SRC 0 | ||||
| #define DST 1 | ||||
| #define BATCH 2 | ||||
| @ -109,9 +104,9 @@ static void test_streaming(int fd, int mode, int sync) | ||||
| 	execbuf.buffers_ptr = (uintptr_t)exec; | ||||
| 	execbuf.buffer_count = 2; | ||||
| 	execbuf.flags = LOCAL_I915_EXEC_HANDLE_LUT; | ||||
| 	if (!__gem_execbuf(fd, &execbuf)) { | ||||
| 	if (__gem_execbuf(fd, &execbuf)) { | ||||
| 		execbuf.flags = 0; | ||||
| 		igt_require(__gem_execbuf(fd, &execbuf)); | ||||
| 		igt_require(__gem_execbuf(fd, &execbuf) == 0); | ||||
| 	} | ||||
| 	/* We assume that the active objects are fixed to avoid relocations */ | ||||
| 	__src_offset = src_offset; | ||||
| @ -135,7 +130,7 @@ static void test_streaming(int fd, int mode, int sync) | ||||
| 		reloc[2*i+1].read_domains = I915_GEM_DOMAIN_RENDER; | ||||
| 		reloc[2*i+1].write_domain = 0; | ||||
| 	} | ||||
| 	igt_assert(__gem_execbuf(fd, &execbuf)); | ||||
| 	gem_execbuf(fd, &execbuf); | ||||
| 	igt_assert_eq_u64(__src_offset, src_offset); | ||||
| 	igt_assert_eq_u64(__dst_offset, dst_offset); | ||||
| 
 | ||||
| @ -304,7 +299,7 @@ static void test_batch(int fd, int mode, int reverse) | ||||
| 	execbuf.flags = LOCAL_I915_EXEC_HANDLE_LUT; | ||||
| 	if (gem_has_blt(fd)) | ||||
| 		execbuf.flags |= I915_EXEC_BLT; | ||||
| 	if (!__gem_execbuf(fd, &execbuf)) { | ||||
| 	if (__gem_execbuf(fd, &execbuf)) { | ||||
| 		execbuf.flags &= ~LOCAL_I915_EXEC_HANDLE_LUT; | ||||
| 		gem_execbuf(fd, &execbuf); | ||||
| 	} | ||||
|  | ||||
| @ -65,14 +65,6 @@ out: | ||||
| 	return ts.tv_sec + 1e-9*ts.tv_nsec; | ||||
| } | ||||
| 
 | ||||
| static int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *eb) | ||||
| { | ||||
| 	int err = 0; | ||||
| 	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, eb)) | ||||
| 		err = -errno; | ||||
| 	return err; | ||||
| } | ||||
| 
 | ||||
| static void | ||||
| sync_ring(int fd, int ring, unsigned flags) | ||||
| { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user