]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - include/linux/fence-array.h
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[mirror_ubuntu-zesty-kernel.git] / include / linux / fence-array.h
CommitLineData
b3dfbdf2
GP
1/*
2 * fence-array: aggregates fence to be waited together
3 *
4 * Copyright (C) 2016 Collabora Ltd
5 * Copyright (C) 2016 Advanced Micro Devices, Inc.
6 * Authors:
7 * Gustavo Padovan <gustavo@padovan.org>
8 * Christian König <christian.koenig@amd.com>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published by
12 * the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 */
19
20#ifndef __LINUX_FENCE_ARRAY_H
21#define __LINUX_FENCE_ARRAY_H
22
23#include <linux/fence.h>
24
25/**
26 * struct fence_array_cb - callback helper for fence array
27 * @cb: fence callback structure for signaling
28 * @array: reference to the parent fence array object
29 */
30struct fence_array_cb {
31 struct fence_cb cb;
32 struct fence_array *array;
33};
34
35/**
36 * struct fence_array - fence to represent an array of fences
37 * @base: fence base class
38 * @lock: spinlock for fence handling
39 * @num_fences: number of fences in the array
40 * @num_pending: fences in the array still pending
41 * @fences: array of the fences
42 */
43struct fence_array {
44 struct fence base;
45
46 spinlock_t lock;
47 unsigned num_fences;
48 atomic_t num_pending;
49 struct fence **fences;
50};
51
52extern const struct fence_ops fence_array_ops;
53
54/**
55 * to_fence_array - cast a fence to a fence_array
56 * @fence: fence to cast to a fence_array
57 *
58 * Returns NULL if the fence is not a fence_array,
59 * or the fence_array otherwise.
60 */
61static inline struct fence_array *to_fence_array(struct fence *fence)
62{
63 if (fence->ops != &fence_array_ops)
64 return NULL;
65
66 return container_of(fence, struct fence_array, base);
67}
68
69struct fence_array *fence_array_create(int num_fences, struct fence **fences,
f7104568
CK
70 u64 context, unsigned seqno,
71 bool signal_on_any);
b3dfbdf2
GP
72
73#endif /* __LINUX_FENCE_ARRAY_H */