summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/nouveau/nouveau_fence.c
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@canonical.com>2014-04-09 18:19:30 +0400
committerMaarten Lankhorst <maarten.lankhorst@canonical.com>2014-09-02 19:28:48 +0400
commit809e9447b92ffe1346b2d6ec390e212d5307f61c (patch)
tree11d04d4ef34cd681cf63efa11a90992c7865eb27 /drivers/gpu/drm/nouveau/nouveau_fence.c
parent9242829a87e970773628f30522d2278dd91890ec (diff)
downloadlinux-809e9447b92ffe1346b2d6ec390e212d5307f61c.tar.xz
drm/nouveau: use shared fences for readable objects
nouveau keeps track in userspace whether a buffer is being written to or being read, but it doesn't use that information. Change this to allow multiple readers on the same bo. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Acked-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.c55
1 files changed, 31 insertions, 24 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index 5e7fa68bc438..decfe6c4ac07 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -342,41 +342,56 @@ nouveau_fence_wait(struct nouveau_fence *fence, bool lazy, bool intr)
}
int
-nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan)
+nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool exclusive)
{
struct nouveau_fence_chan *fctx = chan->fence;
- struct fence *fence = NULL;
+ struct fence *fence;
struct reservation_object *resv = nvbo->bo.resv;
struct reservation_object_list *fobj;
+ struct nouveau_fence *f;
int ret = 0, i;
+ if (!exclusive) {
+ ret = reservation_object_reserve_shared(resv);
+
+ if (ret)
+ return ret;
+ }
+
+ fobj = reservation_object_get_list(resv);
fence = reservation_object_get_excl(resv);
- if (fence && !fence_is_signaled(fence)) {
- struct nouveau_fence *f = from_fence(fence);
- struct nouveau_channel *prev = f->channel;
+ if (fence && (!exclusive || !fobj || !fobj->shared_count)) {
+ struct nouveau_channel *prev = NULL;
- if (prev != chan) {
- ret = fctx->sync(f, prev, chan);
- if (unlikely(ret))
- ret = nouveau_fence_wait(f, true, true);
- }
- }
+ f = nouveau_local_fence(fence, chan->drm);
+ if (f)
+ prev = f->channel;
+
+ if (!prev || (prev != chan && (ret = fctx->sync(f, prev, chan))))
+ ret = fence_wait(fence, true);
- if (ret)
return ret;
+ }
- fobj = reservation_object_get_list(resv);
- if (!fobj)
+ if (!exclusive || !fobj)
return ret;
for (i = 0; i < fobj->shared_count && !ret; ++i) {
+ struct nouveau_channel *prev = NULL;
+
fence = rcu_dereference_protected(fobj->shared[i],
reservation_object_held(resv));
- /* should always be true, for now */
- if (!nouveau_local_fence(fence, chan->drm))
+ f = nouveau_local_fence(fence, chan->drm);
+ if (f)
+ prev = f->channel;
+
+ if (!prev || (ret = fctx->sync(f, prev, chan)))
ret = fence_wait(fence, true);
+
+ if (ret)
+ break;
}
return ret;
@@ -390,14 +405,6 @@ nouveau_fence_unref(struct nouveau_fence **pfence)
*pfence = NULL;
}
-struct nouveau_fence *
-nouveau_fence_ref(struct nouveau_fence *fence)
-{
- if (fence)
- fence_get(&fence->base);
- return fence;
-}
-
int
nouveau_fence_new(struct nouveau_channel *chan, bool sysmem,
struct nouveau_fence **pfence)