1/* 2 * Copyright (C) 2013, 2015 ARM Limited. All rights reserved. 3 * 4 * This program is free software and is provided to you under the terms of the GNU General Public License version 2 5 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence. 6 * 7 * A copy of the licence is included with the program, and can also be obtained from Free Software 8 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 9 */ 10 11/** 12 * @file mali_timeline_fence_wait.h 13 * 14 * This file contains functions used to wait until a Timeline fence is signaled. 15 */ 16 17#ifndef __MALI_TIMELINE_FENCE_WAIT_H__ 18#define __MALI_TIMELINE_FENCE_WAIT_H__ 19 20#include "mali_osk.h" 21#include "mali_timeline.h" 22 23/** 24 * If used as the timeout argument in @ref mali_timeline_fence_wait, a timer is not used and the 25 * function only returns when the fence is signaled. 26 */ 27#define MALI_TIMELINE_FENCE_WAIT_TIMEOUT_NEVER ((u32) -1) 28 29/** 30 * If used as the timeout argument in @ref mali_timeline_fence_wait, the function will return 31 * immediately with the current state of the fence. 32 */ 33#define MALI_TIMELINE_FENCE_WAIT_TIMEOUT_IMMEDIATELY 0 34 35/** 36 * Fence wait tracker. 37 * 38 * The fence wait tracker is added to the Timeline system with the fence we are waiting on as a 39 * dependency. We will then perform a blocking wait, possibly with a timeout, until the tracker is 40 * activated, which happens when the fence is signaled. 41 */ 42struct mali_timeline_fence_wait_tracker { 43 mali_bool activated; /**< MALI_TRUE if the tracker has been activated, MALI_FALSE if not. */ 44 _mali_osk_atomic_t refcount; /**< Reference count. */ 45 struct mali_timeline_system *system; /**< Timeline system. */ 46 struct mali_timeline_tracker tracker; /**< Timeline tracker. */ 47}; 48 49/** 50 * Wait for a fence to be signaled, or timeout is reached. 51 * 52 * @param system Timeline system. 53 * @param fence Fence to wait on. 54 * @param timeout Timeout in ms, or MALI_TIMELINE_FENCE_WAIT_TIMEOUT_NEVER or 55 * MALI_TIMELINE_FENCE_WAIT_TIMEOUT_IMMEDIATELY. 56 * @return MALI_TRUE if signaled, MALI_FALSE if timed out. 57 */ 58mali_bool mali_timeline_fence_wait(struct mali_timeline_system *system, struct mali_timeline_fence *fence, u32 timeout); 59 60/** 61 * Used by the Timeline system to activate a fence wait tracker. 62 * 63 * @param fence_wait_tracker Fence waiter tracker. 64 */ 65void mali_timeline_fence_wait_activate(struct mali_timeline_fence_wait_tracker *fence_wait_tracker); 66 67#endif /* __MALI_TIMELINE_FENCE_WAIT_H__ */ 68