xref: /linux/drivers/gpu/drm/i915/gem/selftests/igt_gem_utils.h (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
110be98a7SChris Wilson /*
210be98a7SChris Wilson  * SPDX-License-Identifier: MIT
310be98a7SChris Wilson  *
410be98a7SChris Wilson  * Copyright © 2018 Intel Corporation
510be98a7SChris Wilson  */
610be98a7SChris Wilson 
710be98a7SChris Wilson #ifndef __IGT_GEM_UTILS_H__
810be98a7SChris Wilson #define __IGT_GEM_UTILS_H__
910be98a7SChris Wilson 
1018851edfSMatthew Auld #include <linux/types.h>
1118851edfSMatthew Auld 
1256d7bd74SAndrzej Hajda #include "i915_vma.h"
1356d7bd74SAndrzej Hajda 
1410be98a7SChris Wilson struct i915_request;
1510be98a7SChris Wilson struct i915_gem_context;
1618851edfSMatthew Auld struct i915_vma;
1710be98a7SChris Wilson 
1875b974a8SChris Wilson struct intel_context;
1975b974a8SChris Wilson struct intel_engine_cs;
2075b974a8SChris Wilson 
2110be98a7SChris Wilson struct i915_request *
2210be98a7SChris Wilson igt_request_alloc(struct i915_gem_context *ctx, struct intel_engine_cs *engine);
2310be98a7SChris Wilson 
2418851edfSMatthew Auld struct i915_vma *
2518851edfSMatthew Auld igt_emit_store_dw(struct i915_vma *vma,
2618851edfSMatthew Auld 		  u64 offset,
2718851edfSMatthew Auld 		  unsigned long count,
2818851edfSMatthew Auld 		  u32 val);
2918851edfSMatthew Auld 
3075b974a8SChris Wilson int igt_gpu_fill_dw(struct intel_context *ce,
3175b974a8SChris Wilson 		    struct i915_vma *vma, u64 offset,
3275b974a8SChris Wilson 		    unsigned long count, u32 val);
3318851edfSMatthew Auld 
3456d7bd74SAndrzej Hajda static inline int __must_check
igt_vma_move_to_active_unlocked(struct i915_vma * vma,struct i915_request * rq,unsigned int flags)3556d7bd74SAndrzej Hajda igt_vma_move_to_active_unlocked(struct i915_vma *vma, struct i915_request *rq,
3656d7bd74SAndrzej Hajda 				unsigned int flags)
3756d7bd74SAndrzej Hajda {
3856d7bd74SAndrzej Hajda 	int err;
3956d7bd74SAndrzej Hajda 
4056d7bd74SAndrzej Hajda 	i915_vma_lock(vma);
41*f350c74fSAndrzej Hajda 	err = i915_vma_move_to_active(vma, rq, flags);
4256d7bd74SAndrzej Hajda 	i915_vma_unlock(vma);
4356d7bd74SAndrzej Hajda 	return err;
4456d7bd74SAndrzej Hajda }
4556d7bd74SAndrzej Hajda 
4610be98a7SChris Wilson #endif /* __IGT_GEM_UTILS_H__ */
47