summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nouveau_fence.c
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2012-05-04 16:25:47 +1000
committerBen Skeggs <bskeggs@redhat.com>2012-05-24 16:55:58 +1000
commit906c033e276877c1374c9159976b05746af3c86d (patch)
treef7e03b7148cf9f5caad6ac72b33e0354e94aad41 /drivers/gpu/drm/nouveau/nouveau_fence.c
parent299bee10fb228fce4a3fc5dd89f32787a6e58fe5 (diff)
downloadblackbird-op-linux-906c033e276877c1374c9159976b05746af3c86d.tar.gz
blackbird-op-linux-906c033e276877c1374c9159976b05746af3c86d.zip
drm/nouveau/fence: fix a race where fence->channel can disappear
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.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index 4ba41a45114f..3c180493dab8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -147,15 +147,19 @@ nouveau_fence_wait(struct nouveau_fence *fence, bool lazy, bool intr)
int
nouveau_fence_sync(struct nouveau_fence *fence, struct nouveau_channel *chan)
{
- struct nouveau_channel *prev = fence ? fence->channel : NULL;
struct drm_device *dev = chan->dev;
struct nouveau_fence_priv *priv = nv_engine(dev, NVOBJ_ENGINE_FENCE);
+ struct nouveau_channel *prev;
int ret = 0;
- if (unlikely(prev && prev != chan && !nouveau_fence_done(fence))) {
- ret = priv->sync(fence, chan);
- if (unlikely(ret))
- ret = nouveau_fence_wait(fence, true, false);
+ prev = fence ? nouveau_channel_get_unlocked(fence->channel) : NULL;
+ if (prev) {
+ if (unlikely(prev != chan && !nouveau_fence_done(fence))) {
+ ret = priv->sync(fence, prev, chan);
+ if (unlikely(ret))
+ ret = nouveau_fence_wait(fence, true, false);
+ }
+ nouveau_channel_put_unlocked(&prev);
}
return ret;
OpenPOWER on IntegriCloud