1
1
/*
2
- * fence-array: aggregate fences to be waited together
2
+ * dma- fence-array: aggregate fences to be waited together
3
3
*
4
4
* Copyright (C) 2016 Collabora Ltd
5
5
* Copyright (C) 2016 Advanced Micro Devices, Inc.
19
19
20
20
#include <linux/export.h>
21
21
#include <linux/slab.h>
22
- #include <linux/fence-array.h>
22
+ #include <linux/dma- fence-array.h>
23
23
24
- static void fence_array_cb_func (struct fence * f , struct fence_cb * cb );
25
-
26
- static const char * fence_array_get_driver_name (struct fence * fence )
24
+ static const char * dma_fence_array_get_driver_name (struct dma_fence * fence )
27
25
{
28
- return "fence_array " ;
26
+ return "dma_fence_array " ;
29
27
}
30
28
31
- static const char * fence_array_get_timeline_name (struct fence * fence )
29
+ static const char * dma_fence_array_get_timeline_name (struct dma_fence * fence )
32
30
{
33
31
return "unbound" ;
34
32
}
35
33
36
- static void fence_array_cb_func (struct fence * f , struct fence_cb * cb )
34
+ static void dma_fence_array_cb_func (struct dma_fence * f ,
35
+ struct dma_fence_cb * cb )
37
36
{
38
- struct fence_array_cb * array_cb =
39
- container_of (cb , struct fence_array_cb , cb );
40
- struct fence_array * array = array_cb -> array ;
37
+ struct dma_fence_array_cb * array_cb =
38
+ container_of (cb , struct dma_fence_array_cb , cb );
39
+ struct dma_fence_array * array = array_cb -> array ;
41
40
42
41
if (atomic_dec_and_test (& array -> num_pending ))
43
- fence_signal (& array -> base );
44
- fence_put (& array -> base );
42
+ dma_fence_signal (& array -> base );
43
+ dma_fence_put (& array -> base );
45
44
}
46
45
47
- static bool fence_array_enable_signaling (struct fence * fence )
46
+ static bool dma_fence_array_enable_signaling (struct dma_fence * fence )
48
47
{
49
- struct fence_array * array = to_fence_array (fence );
50
- struct fence_array_cb * cb = (void * )(& array [1 ]);
48
+ struct dma_fence_array * array = to_dma_fence_array (fence );
49
+ struct dma_fence_array_cb * cb = (void * )(& array [1 ]);
51
50
unsigned i ;
52
51
53
52
for (i = 0 ; i < array -> num_fences ; ++ i ) {
@@ -60,10 +59,10 @@ static bool fence_array_enable_signaling(struct fence *fence)
60
59
* until we signal the array as complete (but that is now
61
60
* insufficient).
62
61
*/
63
- fence_get (& array -> base );
64
- if (fence_add_callback (array -> fences [i ], & cb [i ].cb ,
65
- fence_array_cb_func )) {
66
- fence_put (& array -> base );
62
+ dma_fence_get (& array -> base );
63
+ if (dma_fence_add_callback (array -> fences [i ], & cb [i ].cb ,
64
+ dma_fence_array_cb_func )) {
65
+ dma_fence_put (& array -> base );
67
66
if (atomic_dec_and_test (& array -> num_pending ))
68
67
return false;
69
68
}
@@ -72,74 +71,76 @@ static bool fence_array_enable_signaling(struct fence *fence)
72
71
return true;
73
72
}
74
73
75
- static bool fence_array_signaled (struct fence * fence )
74
+ static bool dma_fence_array_signaled (struct dma_fence * fence )
76
75
{
77
- struct fence_array * array = to_fence_array (fence );
76
+ struct dma_fence_array * array = to_dma_fence_array (fence );
78
77
79
78
return atomic_read (& array -> num_pending ) <= 0 ;
80
79
}
81
80
82
- static void fence_array_release (struct fence * fence )
81
+ static void dma_fence_array_release (struct dma_fence * fence )
83
82
{
84
- struct fence_array * array = to_fence_array (fence );
83
+ struct dma_fence_array * array = to_dma_fence_array (fence );
85
84
unsigned i ;
86
85
87
86
for (i = 0 ; i < array -> num_fences ; ++ i )
88
- fence_put (array -> fences [i ]);
87
+ dma_fence_put (array -> fences [i ]);
89
88
90
89
kfree (array -> fences );
91
- fence_free (fence );
90
+ dma_fence_free (fence );
92
91
}
93
92
94
- const struct fence_ops fence_array_ops = {
95
- .get_driver_name = fence_array_get_driver_name ,
96
- .get_timeline_name = fence_array_get_timeline_name ,
97
- .enable_signaling = fence_array_enable_signaling ,
98
- .signaled = fence_array_signaled ,
99
- .wait = fence_default_wait ,
100
- .release = fence_array_release ,
93
+ const struct dma_fence_ops dma_fence_array_ops = {
94
+ .get_driver_name = dma_fence_array_get_driver_name ,
95
+ .get_timeline_name = dma_fence_array_get_timeline_name ,
96
+ .enable_signaling = dma_fence_array_enable_signaling ,
97
+ .signaled = dma_fence_array_signaled ,
98
+ .wait = dma_fence_default_wait ,
99
+ .release = dma_fence_array_release ,
101
100
};
102
- EXPORT_SYMBOL (fence_array_ops );
101
+ EXPORT_SYMBOL (dma_fence_array_ops );
103
102
104
103
/**
105
- * fence_array_create - Create a custom fence array
104
+ * dma_fence_array_create - Create a custom fence array
106
105
* @num_fences: [in] number of fences to add in the array
107
106
* @fences: [in] array containing the fences
108
107
* @context: [in] fence context to use
109
108
* @seqno: [in] sequence number to use
110
109
* @signal_on_any: [in] signal on any fence in the array
111
110
*
112
- * Allocate a fence_array object and initialize the base fence with fence_init().
111
+ * Allocate a dma_fence_array object and initialize the base fence with
112
+ * dma_fence_init().
113
113
* In case of error it returns NULL.
114
114
*
115
115
* The caller should allocate the fences array with num_fences size
116
116
* and fill it with the fences it wants to add to the object. Ownership of this
117
- * array is taken and fence_put () is used on each fence on release.
117
+ * array is taken and dma_fence_put () is used on each fence on release.
118
118
*
119
119
* If @signal_on_any is true the fence array signals if any fence in the array
120
120
* signals, otherwise it signals when all fences in the array signal.
121
121
*/
122
- struct fence_array * fence_array_create (int num_fences , struct fence * * fences ,
123
- u64 context , unsigned seqno ,
124
- bool signal_on_any )
122
+ struct dma_fence_array * dma_fence_array_create (int num_fences ,
123
+ struct dma_fence * * fences ,
124
+ u64 context , unsigned seqno ,
125
+ bool signal_on_any )
125
126
{
126
- struct fence_array * array ;
127
+ struct dma_fence_array * array ;
127
128
size_t size = sizeof (* array );
128
129
129
130
/* Allocate the callback structures behind the array. */
130
- size += num_fences * sizeof (struct fence_array_cb );
131
+ size += num_fences * sizeof (struct dma_fence_array_cb );
131
132
array = kzalloc (size , GFP_KERNEL );
132
133
if (!array )
133
134
return NULL ;
134
135
135
136
spin_lock_init (& array -> lock );
136
- fence_init (& array -> base , & fence_array_ops , & array -> lock ,
137
- context , seqno );
137
+ dma_fence_init (& array -> base , & dma_fence_array_ops , & array -> lock ,
138
+ context , seqno );
138
139
139
140
array -> num_fences = num_fences ;
140
141
atomic_set (& array -> num_pending , signal_on_any ? 1 : num_fences );
141
142
array -> fences = fences ;
142
143
143
144
return array ;
144
145
}
145
- EXPORT_SYMBOL (fence_array_create );
146
+ EXPORT_SYMBOL (dma_fence_array_create );
0 commit comments