summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Courbot <acourbot@nvidia.com>2015-09-25 10:29:50 +0900
committerAlexandre Courbot <acourbot@nvidia.com>2015-09-25 10:29:50 +0900
commitb4db5569f487cb772e601460055c6ca521d64d3a (patch)
treea99181c03d051756ebf8c5d3dcdc26f569ca5296
parent12ec2505e949a1a35bf7a3c1977da1bf7978c368 (diff)
downloadnouveau-gk20a.tar.gz
instmem/gk20a: exclusively acquire instobjsgk20a
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
-rw-r--r--drm/nouveau/nvkm/subdev/instmem/gk20a.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/drm/nouveau/nvkm/subdev/instmem/gk20a.c b/drm/nouveau/nvkm/subdev/instmem/gk20a.c
index fc419bb8e..d015633b8 100644
--- a/drm/nouveau/nvkm/subdev/instmem/gk20a.c
+++ b/drm/nouveau/nvkm/subdev/instmem/gk20a.c
@@ -92,6 +92,7 @@ struct gk20a_instmem {
/* protects vaddr_* and gk20a_instobj::vaddr* */
spinlock_t lock;
+ unsigned long flags;
/* CPU mappings LRU */
unsigned int vaddr_use;
@@ -188,12 +189,11 @@ gk20a_instobj_acquire(struct nvkm_memory *memory)
struct gk20a_instobj *node = gk20a_instobj(memory);
struct gk20a_instmem *imem = node->imem;
struct nvkm_ltc *ltc = imem->base.subdev.device->ltc;
- const u64 size = nvkm_memory_size(memory);
- unsigned long flags;
+ u64 size;
nvkm_ltc_flush(ltc);
- spin_lock_irqsave(&imem->lock, flags);
+ spin_lock_irqsave(&imem->lock, imem->flags);
if (node->vaddr) {
/* remove us from the LRU list since we cannot be unmapped */
@@ -202,6 +202,8 @@ gk20a_instobj_acquire(struct nvkm_memory *memory)
goto out;
}
+ size = nvkm_memory_size(memory);
+
/* try to free some address space if we reached the limit */
gk20a_instmem_vaddr_gc(imem, size);
@@ -218,8 +220,6 @@ gk20a_instobj_acquire(struct nvkm_memory *memory)
imem->vaddr_use, imem->vaddr_max);
out:
- spin_unlock_irqrestore(&imem->lock, flags);
-
return node->vaddr;
}
@@ -229,14 +229,11 @@ gk20a_instobj_release(struct nvkm_memory *memory)
struct gk20a_instobj *node = gk20a_instobj(memory);
struct gk20a_instmem *imem = node->imem;
struct nvkm_ltc *ltc = imem->base.subdev.device->ltc;
- unsigned long flags;
-
- spin_lock_irqsave(&imem->lock, flags);
/* add ourselves to the LRU list so our CPU mapping can be freed */
list_add_tail(&node->vaddr_node, &imem->vaddr_lru);
- spin_unlock_irqrestore(&imem->lock, flags);
+ spin_unlock_irqrestore(&imem->lock, imem->flags);
wmb();
nvkm_ltc_invalidate(ltc);