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>
This commit is contained in:
parent
9c7a11e6f9
commit
6f0a81edb9
2 changed files with 7 additions and 0 deletions
|
@ -99,6 +99,7 @@ struct nv84_fence_priv {
|
||||||
struct nouveau_bo *bo;
|
struct nouveau_bo *bo;
|
||||||
struct nouveau_bo *bo_gart;
|
struct nouveau_bo *bo_gart;
|
||||||
u32 *suspend;
|
u32 *suspend;
|
||||||
|
struct mutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
u64 nv84_fence_crtc(struct nouveau_channel *, int);
|
u64 nv84_fence_crtc(struct nouveau_channel *, int);
|
||||||
|
|
|
@ -121,8 +121,10 @@ nv84_fence_context_del(struct nouveau_channel *chan)
|
||||||
}
|
}
|
||||||
|
|
||||||
nouveau_bo_wr32(priv->bo, chan->chid * 16 / 4, fctx->base.sequence);
|
nouveau_bo_wr32(priv->bo, chan->chid * 16 / 4, fctx->base.sequence);
|
||||||
|
mutex_lock(&priv->mutex);
|
||||||
nouveau_bo_vma_del(priv->bo, &fctx->vma_gart);
|
nouveau_bo_vma_del(priv->bo, &fctx->vma_gart);
|
||||||
nouveau_bo_vma_del(priv->bo, &fctx->vma);
|
nouveau_bo_vma_del(priv->bo, &fctx->vma);
|
||||||
|
mutex_unlock(&priv->mutex);
|
||||||
nouveau_fence_context_del(&fctx->base);
|
nouveau_fence_context_del(&fctx->base);
|
||||||
chan->fence = NULL;
|
chan->fence = NULL;
|
||||||
nouveau_fence_context_free(&fctx->base);
|
nouveau_fence_context_free(&fctx->base);
|
||||||
|
@ -148,11 +150,13 @@ nv84_fence_context_new(struct nouveau_channel *chan)
|
||||||
fctx->base.sync32 = nv84_fence_sync32;
|
fctx->base.sync32 = nv84_fence_sync32;
|
||||||
fctx->base.sequence = nv84_fence_read(chan);
|
fctx->base.sequence = nv84_fence_read(chan);
|
||||||
|
|
||||||
|
mutex_lock(&priv->mutex);
|
||||||
ret = nouveau_bo_vma_add(priv->bo, cli->vm, &fctx->vma);
|
ret = nouveau_bo_vma_add(priv->bo, cli->vm, &fctx->vma);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = nouveau_bo_vma_add(priv->bo_gart, cli->vm,
|
ret = nouveau_bo_vma_add(priv->bo_gart, cli->vm,
|
||||||
&fctx->vma_gart);
|
&fctx->vma_gart);
|
||||||
}
|
}
|
||||||
|
mutex_unlock(&priv->mutex);
|
||||||
|
|
||||||
/* map display semaphore buffers into channel's vm */
|
/* map display semaphore buffers into channel's vm */
|
||||||
for (i = 0; !ret && i < chan->drm->dev->mode_config.num_crtc; i++) {
|
for (i = 0; !ret && i < chan->drm->dev->mode_config.num_crtc; i++) {
|
||||||
|
@ -232,6 +236,8 @@ nv84_fence_create(struct nouveau_drm *drm)
|
||||||
priv->base.context_base = fence_context_alloc(priv->base.contexts);
|
priv->base.context_base = fence_context_alloc(priv->base.contexts);
|
||||||
priv->base.uevent = true;
|
priv->base.uevent = true;
|
||||||
|
|
||||||
|
mutex_init(&priv->mutex);
|
||||||
|
|
||||||
/* Use VRAM if there is any ; otherwise fallback to system memory */
|
/* Use VRAM if there is any ; otherwise fallback to system memory */
|
||||||
domain = drm->device.info.ram_size != 0 ? TTM_PL_FLAG_VRAM :
|
domain = drm->device.info.ram_size != 0 ? TTM_PL_FLAG_VRAM :
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue