aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma-buf/dma-buf.c
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@canonical.com>2014-07-01 06:57:54 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-07-08 16:37:35 -0400
commit04a5faa8cbe5a8eaf152cb88959ba6360c26e702 (patch)
treefee24a356ead0c38b98d8c3d3b671cd0dd981714 /drivers/dma-buf/dma-buf.c
parent9b495a5887994a6d74d5c261d012083a92b94738 (diff)
reservation: update api and add some helpers
Move the list of shared fences to a struct, and return it in reservation_object_get_list(). Add reservation_object_get_excl to get the exclusive fence. Add reservation_object_reserve_shared(), which reserves space in the reservation_object for 1 more shared fence. reservation_object_add_shared_fence() and reservation_object_add_excl_fence() are used to assign a new fence to a reservation_object pointer, to complete a reservation. Changes since v1: - Add reservation_object_get_excl, reorder code a bit. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Acked-by: Sumit Semwal <sumit.semwal@linaro.org> Acked-by: Daniel Vetter <daniel@ffwll.ch> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/dma-buf/dma-buf.c')
-rw-r--r--drivers/dma-buf/dma-buf.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 25e8c4165936..cb8379dfeed5 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -134,7 +134,10 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll)
134{ 134{
135 struct dma_buf *dmabuf; 135 struct dma_buf *dmabuf;
136 struct reservation_object *resv; 136 struct reservation_object *resv;
137 struct reservation_object_list *fobj;
138 struct fence *fence_excl;
137 unsigned long events; 139 unsigned long events;
140 unsigned shared_count;
138 141
139 dmabuf = file->private_data; 142 dmabuf = file->private_data;
140 if (!dmabuf || !dmabuf->resv) 143 if (!dmabuf || !dmabuf->resv)
@@ -150,12 +153,18 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll)
150 153
151 ww_mutex_lock(&resv->lock, NULL); 154 ww_mutex_lock(&resv->lock, NULL);
152 155
153 if (resv->fence_excl && (!(events & POLLOUT) || 156 fobj = resv->fence;
154 resv->fence_shared_count == 0)) { 157 if (!fobj)
158 goto out;
159
160 shared_count = fobj->shared_count;
161 fence_excl = resv->fence_excl;
162
163 if (fence_excl && (!(events & POLLOUT) || shared_count == 0)) {
155 struct dma_buf_poll_cb_t *dcb = &dmabuf->cb_excl; 164 struct dma_buf_poll_cb_t *dcb = &dmabuf->cb_excl;
156 unsigned long pevents = POLLIN; 165 unsigned long pevents = POLLIN;
157 166
158 if (resv->fence_shared_count == 0) 167 if (shared_count == 0)
159 pevents |= POLLOUT; 168 pevents |= POLLOUT;
160 169
161 spin_lock_irq(&dmabuf->poll.lock); 170 spin_lock_irq(&dmabuf->poll.lock);
@@ -167,19 +176,20 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll)
167 spin_unlock_irq(&dmabuf->poll.lock); 176 spin_unlock_irq(&dmabuf->poll.lock);
168 177
169 if (events & pevents) { 178 if (events & pevents) {
170 if (!fence_add_callback(resv->fence_excl, 179 if (!fence_add_callback(fence_excl, &dcb->cb,
171 &dcb->cb, dma_buf_poll_cb)) 180 dma_buf_poll_cb)) {
172 events &= ~pevents; 181 events &= ~pevents;
173 else 182 } else {
174 /* 183 /*
175 * No callback queued, wake up any additional 184 * No callback queued, wake up any additional
176 * waiters. 185 * waiters.
177 */ 186 */
178 dma_buf_poll_cb(NULL, &dcb->cb); 187 dma_buf_poll_cb(NULL, &dcb->cb);
188 }
179 } 189 }
180 } 190 }
181 191
182 if ((events & POLLOUT) && resv->fence_shared_count > 0) { 192 if ((events & POLLOUT) && shared_count > 0) {
183 struct dma_buf_poll_cb_t *dcb = &dmabuf->cb_shared; 193 struct dma_buf_poll_cb_t *dcb = &dmabuf->cb_shared;
184 int i; 194 int i;
185 195
@@ -194,15 +204,18 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll)
194 if (!(events & POLLOUT)) 204 if (!(events & POLLOUT))
195 goto out; 205 goto out;
196 206
197 for (i = 0; i < resv->fence_shared_count; ++i) 207 for (i = 0; i < shared_count; ++i) {
198 if (!fence_add_callback(resv->fence_shared[i], 208 struct fence *fence = fobj->shared[i];
199 &dcb->cb, dma_buf_poll_cb)) { 209
210 if (!fence_add_callback(fence, &dcb->cb,
211 dma_buf_poll_cb)) {
200 events &= ~POLLOUT; 212 events &= ~POLLOUT;
201 break; 213 break;
202 } 214 }
215 }
203 216
204 /* No callback queued, wake up any additional waiters. */ 217 /* No callback queued, wake up any additional waiters. */
205 if (i == resv->fence_shared_count) 218 if (i == shared_count)
206 dma_buf_poll_cb(NULL, &dcb->cb); 219 dma_buf_poll_cb(NULL, &dcb->cb);
207 } 220 }
208 221