1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3 * Copyright (c) 2017, Linaro Limited
4 * All rights reserved.
5 */
6
7 #ifndef XTEST_SDP_BASIC_H
8 #define XTEST_SDP_BASIC_H
9
10 #include <linux/dma-buf.h>
11 #include <linux/version.h>
12 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
13 #include <linux/dma-heap.h>
14 #define DEFAULT_HEAP_TYPE 0
15 #define DEFAULT_HEAP_NAME "/dev/dma_heap/sdp"
16 #else
17 #include "include/uapi/linux/ion.h"
18 #include "include/uapi/linux/ion_old.h"
19 #define DEFAULT_HEAP_TYPE ION_HEAP_TYPE_UNMAPPED
20 #define DEFAULT_HEAP_NAME "unmapped"
21 #endif
22
23 #include "ta_sdp_basic.h"
24
25 enum test_target_ta {
26 TEST_NS_TO_TA,
27 TEST_NS_TO_PTA,
28 TEST_TA_TO_TA,
29 TEST_TA_TO_PTA,
30 };
31
32 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
33 int allocate_dma_buffer(size_t size, const char *heap_name, int verbosity);
allocate_buffer(size_t size,const char * heap_name,int heap_id,int verbosity)34 static inline int allocate_buffer(size_t size, const char *heap_name, int heap_id, int verbosity)
35 {
36 (void)heap_id;
37
38 return allocate_dma_buffer(size, heap_name, verbosity);
39 }
40 #else
41 int allocate_ion_buffer(size_t size, const char *heap_name, int heap_id, int verbosity);
allocate_buffer(size_t size,const char * heap_name,int heap_id,int verbosity)42 static inline int allocate_buffer(size_t size, const char *heap_name, int heap_id, int verbosity)
43 {
44 return allocate_ion_buffer(size, heap_name, heap_id, verbosity);
45 }
46 #endif
47 int sdp_basic_test(enum test_target_ta ta,
48 size_t size, size_t loop, const char *heap_name, int ion_heap,
49 int rnd_offset, int verbosity);
50
51 int sdp_out_of_bounds_memref_test(size_t size, const char *heap_name, int ion_heap, int verbosity);
52
53 #endif /* XTEST_SDP_BASIC_H */
54