aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nouveau_fence.c
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2012-04-29 22:51:48 -0400
committerBen Skeggs <bskeggs@redhat.com>2012-05-24 02:55:44 -0400
commit875ac34aad49bb875833aed2b4f2deb7a28df9f0 (patch)
tree254aedbbc3c838471090154a9d14d29ad86211de /drivers/gpu/drm/nouveau/nouveau_fence.c
parent35bcf5d55540e47091a67e5962f12b88d51d7131 (diff)
drm/nouveau/fence: make ttm interfaces wrap ours, not the other way around
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_fence.c')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_fence.c36
1 files changed, 13 insertions, 23 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index aca4719c287f..f26177ac27e7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -199,28 +199,23 @@ nouveau_fence_work(struct nouveau_fence *fence,
199} 199}
200 200
201void 201void
202__nouveau_fence_unref(void **sync_obj) 202nouveau_fence_unref(struct nouveau_fence **pfence)
203{ 203{
204 struct nouveau_fence *fence = nouveau_fence(*sync_obj); 204 if (*pfence)
205 205 kref_put(&(*pfence)->refcount, nouveau_fence_del);
206 if (fence) 206 *pfence = NULL;
207 kref_put(&fence->refcount, nouveau_fence_del);
208 *sync_obj = NULL;
209} 207}
210 208
211void * 209struct nouveau_fence *
212__nouveau_fence_ref(void *sync_obj) 210nouveau_fence_ref(struct nouveau_fence *fence)
213{ 211{
214 struct nouveau_fence *fence = nouveau_fence(sync_obj);
215
216 kref_get(&fence->refcount); 212 kref_get(&fence->refcount);
217 return sync_obj; 213 return fence;
218} 214}
219 215
220bool 216bool
221__nouveau_fence_signalled(void *sync_obj, void *sync_arg) 217nouveau_fence_signalled(struct nouveau_fence *fence)
222{ 218{
223 struct nouveau_fence *fence = nouveau_fence(sync_obj);
224 struct nouveau_channel *chan = fence->channel; 219 struct nouveau_channel *chan = fence->channel;
225 220
226 if (fence->signalled) 221 if (fence->signalled)
@@ -231,25 +226,20 @@ __nouveau_fence_signalled(void *sync_obj, void *sync_arg)
231} 226}
232 227
233int 228int
234__nouveau_fence_wait(void *sync_obj, void *sync_arg, bool lazy, bool intr) 229nouveau_fence_wait(struct nouveau_fence *fence, bool lazy, bool intr)
235{ 230{
236 struct nouveau_fence *fence = nouveau_fence(sync_obj);
237 unsigned long timeout = fence->timeout;
238 unsigned long sleep_time = NSEC_PER_MSEC / 1000; 231 unsigned long sleep_time = NSEC_PER_MSEC / 1000;
239 ktime_t t; 232 ktime_t t;
240 int ret = 0; 233 int ret = 0;
241 234
242 while (1) { 235 while (!nouveau_fence_signalled(fence)) {
243 if (__nouveau_fence_signalled(sync_obj, sync_arg)) 236 if (time_after_eq(jiffies, fence->timeout)) {
244 break;
245
246 if (time_after_eq(jiffies, timeout)) {
247 ret = -EBUSY; 237 ret = -EBUSY;
248 break; 238 break;
249 } 239 }
250 240
251 __set_current_state(intr ? TASK_INTERRUPTIBLE 241 __set_current_state(intr ? TASK_INTERRUPTIBLE :
252 : TASK_UNINTERRUPTIBLE); 242 TASK_UNINTERRUPTIBLE);
253 if (lazy) { 243 if (lazy) {
254 t = ktime_set(0, sleep_time); 244 t = ktime_set(0, sleep_time);
255 schedule_hrtimeout(&t, HRTIMER_MODE_REL); 245 schedule_hrtimeout(&t, HRTIMER_MODE_REL);