gpu: nvgpu: remove use of DEFINE_MUTEX()

API DEFINE_MUTEX() is defined in Linux and might
not be available in other OSs.
Hence remove its usage from nvgpu

Declare and explicitly initialize below mutexes
for both nvgpu and vgpu
g->mm.priv_lock
g->mm.tlb_lock

Jira NVGPU-13

Change-Id: If72885a6da0227a1552303206172f1f2b751471d
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1298042
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Deepak Nibade
2017-02-02 15:16:33 +05:30
committed by mobile promotions
parent 8ee3aa4b31
commit 8cdb91c527
4 changed files with 13 additions and 7 deletions

View File

@@ -110,6 +110,9 @@ static void nvgpu_init_mm_vars(struct gk20a *g)
g->mm.bypass_smmu = platform->bypass_smmu; g->mm.bypass_smmu = platform->bypass_smmu;
g->mm.disable_bigpage = platform->disable_bigpage; g->mm.disable_bigpage = platform->disable_bigpage;
g->mm.vidmem_is_vidmem = platform->vidmem_is_vidmem; g->mm.vidmem_is_vidmem = platform->vidmem_is_vidmem;
nvgpu_mutex_init(&g->mm.tlb_lock);
nvgpu_mutex_init(&g->mm.priv_lock);
} }
int nvgpu_probe(struct gk20a *g, int nvgpu_probe(struct gk20a *g,

View File

@@ -4811,15 +4811,15 @@ int gk20a_vm_bind_channel(struct gk20a_as_share *as_share,
int gk20a_dmabuf_alloc_drvdata(struct dma_buf *dmabuf, struct device *dev) int gk20a_dmabuf_alloc_drvdata(struct dma_buf *dmabuf, struct device *dev)
{ {
struct gk20a *g = gk20a_get_platform(dev)->g;
struct gk20a_dmabuf_priv *priv; struct gk20a_dmabuf_priv *priv;
static DEFINE_MUTEX(priv_lock);
static u64 priv_count = 0; static u64 priv_count = 0;
priv = dma_buf_get_drvdata(dmabuf, dev); priv = dma_buf_get_drvdata(dmabuf, dev);
if (likely(priv)) if (likely(priv))
return 0; return 0;
nvgpu_mutex_acquire(&priv_lock); nvgpu_mutex_acquire(&g->mm.priv_lock);
priv = dma_buf_get_drvdata(dmabuf, dev); priv = dma_buf_get_drvdata(dmabuf, dev);
if (priv) if (priv)
goto priv_exist_or_err; goto priv_exist_or_err;
@@ -4833,7 +4833,7 @@ int gk20a_dmabuf_alloc_drvdata(struct dma_buf *dmabuf, struct device *dev)
priv->buffer_id = ++priv_count; priv->buffer_id = ++priv_count;
dma_buf_set_drvdata(dmabuf, dev, priv, gk20a_mm_delete_priv); dma_buf_set_drvdata(dmabuf, dev, priv, gk20a_mm_delete_priv);
priv_exist_or_err: priv_exist_or_err:
nvgpu_mutex_release(&priv_lock); nvgpu_mutex_release(&g->mm.priv_lock);
if (IS_ERR(priv)) if (IS_ERR(priv))
return -ENOMEM; return -ENOMEM;
@@ -5358,8 +5358,6 @@ void gk20a_mm_tlb_invalidate(struct vm_gk20a *vm)
u32 addr_lo; u32 addr_lo;
u32 data; u32 data;
static DEFINE_MUTEX(tlb_lock);
gk20a_dbg_fn(""); gk20a_dbg_fn("");
/* pagetables are considered sw states which are preserved after /* pagetables are considered sw states which are preserved after
@@ -5373,7 +5371,7 @@ void gk20a_mm_tlb_invalidate(struct vm_gk20a *vm)
addr_lo = u64_lo32(gk20a_mem_get_base_addr(g, &vm->pdb.mem, 0) >> 12); addr_lo = u64_lo32(gk20a_mem_get_base_addr(g, &vm->pdb.mem, 0) >> 12);
nvgpu_mutex_acquire(&tlb_lock); nvgpu_mutex_acquire(&g->mm.tlb_lock);
trace_gk20a_mm_tlb_invalidate(dev_name(g->dev)); trace_gk20a_mm_tlb_invalidate(dev_name(g->dev));
@@ -5414,7 +5412,7 @@ void gk20a_mm_tlb_invalidate(struct vm_gk20a *vm)
trace_gk20a_mm_tlb_invalidate_done(dev_name(g->dev)); trace_gk20a_mm_tlb_invalidate_done(dev_name(g->dev));
out: out:
nvgpu_mutex_release(&tlb_lock); nvgpu_mutex_release(&g->mm.tlb_lock);
} }
int gk20a_mm_suspend(struct gk20a *g) int gk20a_mm_suspend(struct gk20a *g)

View File

@@ -361,6 +361,8 @@ struct mm_gk20a {
} ce; } ce;
struct nvgpu_mutex l2_op_lock; struct nvgpu_mutex l2_op_lock;
struct nvgpu_mutex tlb_lock;
struct nvgpu_mutex priv_lock;
#ifdef CONFIG_ARCH_TEGRA_18x_SOC #ifdef CONFIG_ARCH_TEGRA_18x_SOC
struct mem_desc bar2_desc; struct mem_desc bar2_desc;
#endif #endif

View File

@@ -30,6 +30,9 @@ static int vgpu_init_mm_setup_sw(struct gk20a *g)
return 0; return 0;
} }
nvgpu_mutex_init(&mm->tlb_lock);
nvgpu_mutex_init(&mm->priv_lock);
mm->g = g; mm->g = g;
/*TBD: make channel vm size configurable */ /*TBD: make channel vm size configurable */