1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 3 * 4 * (C) COPYRIGHT 2010-2018, 2020-2021 ARM Limited. All rights reserved. 5 * 6 * This program is free software and is provided to you under the terms of the 7 * GNU General Public License version 2 as published by the Free Software 8 * Foundation, and any use by you of this program is subject to the terms 9 * of such GNU license. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, you can access it online at 18 * http://www.gnu.org/licenses/gpl-2.0.html. 19 * 20 */ 21 22 #ifndef _KBASE_FENCE_DEFS_H_ 23 #define _KBASE_FENCE_DEFS_H_ 24 25 /* 26 * There was a big rename in the 4.10 kernel (fence* -> dma_fence*) 27 * This file hides the compatibility issues with this for the rest the driver 28 */ 29 30 #include <linux/version.h> 31 32 #if (KERNEL_VERSION(4, 10, 0) > LINUX_VERSION_CODE) 33 34 #include <linux/fence.h> 35 36 #define dma_fence_context_alloc(a) fence_context_alloc(a) 37 #define dma_fence_init(a, b, c, d, e) fence_init(a, b, c, d, e) 38 #define dma_fence_get(a) fence_get(a) 39 #define dma_fence_put(a) fence_put(a) 40 #define dma_fence_signal(a) fence_signal(a) 41 #define dma_fence_is_signaled(a) fence_is_signaled(a) 42 #define dma_fence_add_callback(a, b, c) fence_add_callback(a, b, c) 43 #define dma_fence_remove_callback(a, b) fence_remove_callback(a, b) 44 45 #if (KERNEL_VERSION(4, 9, 68) <= LINUX_VERSION_CODE) 46 #define dma_fence_get_status(a) (fence_is_signaled(a) ? (a)->error ?: 1 : 0) 47 #else 48 #define dma_fence_get_status(a) (fence_is_signaled(a) ? (a)->status ?: 1 : 0) 49 #endif 50 51 #else 52 53 #include <linux/dma-fence.h> 54 55 #if (KERNEL_VERSION(4, 11, 0) > LINUX_VERSION_CODE) 56 #define dma_fence_get_status(a) (dma_fence_is_signaled(a) ? \ 57 (a)->status ?: 1 \ 58 : 0) 59 #endif 60 61 #endif /* < 4.10.0 */ 62 63 #endif /* _KBASE_FENCE_DEFS_H_ */ 64