Skip to content

Commit 6f0a81e

Browse files
Ben Skeggsgregkh
authored andcommitted
drm/nouveau/fence/g84-: protect against concurrent access to semaphore buffers
[ Upstream commit 96692b097ba76d0c637ae8af47b29c73da33c9d0 ] Signed-off-by: Ben Skeggs <bskeggs@redhat.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9c7a11e commit 6f0a81e

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

drivers/gpu/drm/nouveau/nouveau_fence.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ struct nv84_fence_priv {
9999
struct nouveau_bo *bo;
100100
struct nouveau_bo *bo_gart;
101101
u32 *suspend;
102+
struct mutex mutex;
102103
};
103104

104105
u64 nv84_fence_crtc(struct nouveau_channel *, int);

drivers/gpu/drm/nouveau/nv84_fence.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ nv84_fence_context_del(struct nouveau_channel *chan)
121121
}
122122

123123
nouveau_bo_wr32(priv->bo, chan->chid * 16 / 4, fctx->base.sequence);
124+
mutex_lock(&priv->mutex);
124125
nouveau_bo_vma_del(priv->bo, &fctx->vma_gart);
125126
nouveau_bo_vma_del(priv->bo, &fctx->vma);
127+
mutex_unlock(&priv->mutex);
126128
nouveau_fence_context_del(&fctx->base);
127129
chan->fence = NULL;
128130
nouveau_fence_context_free(&fctx->base);
@@ -148,11 +150,13 @@ nv84_fence_context_new(struct nouveau_channel *chan)
148150
fctx->base.sync32 = nv84_fence_sync32;
149151
fctx->base.sequence = nv84_fence_read(chan);
150152

153+
mutex_lock(&priv->mutex);
151154
ret = nouveau_bo_vma_add(priv->bo, cli->vm, &fctx->vma);
152155
if (ret == 0) {
153156
ret = nouveau_bo_vma_add(priv->bo_gart, cli->vm,
154157
&fctx->vma_gart);
155158
}
159+
mutex_unlock(&priv->mutex);
156160

157161
/* map display semaphore buffers into channel's vm */
158162
for (i = 0; !ret && i < chan->drm->dev->mode_config.num_crtc; i++) {
@@ -232,6 +236,8 @@ nv84_fence_create(struct nouveau_drm *drm)
232236
priv->base.context_base = fence_context_alloc(priv->base.contexts);
233237
priv->base.uevent = true;
234238

239+
mutex_init(&priv->mutex);
240+
235241
/* Use VRAM if there is any ; otherwise fallback to system memory */
236242
domain = drm->device.info.ram_size != 0 ? TTM_PL_FLAG_VRAM :
237243
/*

0 commit comments

Comments
 (0)