]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: host: use dma APIs in gr3d.c
authorDeepak Nibade <dnibade@nvidia.com>
Thu, 24 Oct 2013 09:04:38 +0000 (14:34 +0530)
committerTerje Bergstrom <tbergstrom@nvidia.com>
Fri, 1 Nov 2013 09:51:25 +0000 (02:51 -0700)
Use dma_alloc_*/dma_free_* APIs in gr3d.c for
function nvhost_3dctx_alloc_common()

Bug 1380147

Change-Id: I99efb1ef98dec71929175e6b3b188879c6e99de5
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/323894
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
drivers/video/tegra/host/gr3d/gr3d.c
drivers/video/tegra/host/gr3d/gr3d_t114.c
drivers/video/tegra/host/host1x/host1x_hwctx.h

index 9b4386820ed5a7d44d2d2bf35849935e27695dd2..eda26d9e8c8845c86f7321f393a3338f2d249512 100644 (file)
@@ -224,32 +224,29 @@ void nvhost_3dctx_restore_end(struct host1x_hwctx_handler *p, u32 *ptr)
 
 /*** ctx3d ***/
 struct host1x_hwctx *nvhost_3dctx_alloc_common(struct host1x_hwctx_handler *p,
-               struct nvhost_channel *ch, bool map_restore)
+               struct nvhost_channel *ch, bool mem_flag)
 {
-       struct mem_mgr *memmgr = nvhost_get_host(ch->dev)->memmgr;
        struct host1x_hwctx *ctx;
 
        ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
        if (!ctx)
                return NULL;
-       ctx->restore = nvhost_memmgr_alloc(memmgr, p->restore_size * 4, 32,
-               map_restore ? mem_mgr_flag_write_combine
-                           : mem_mgr_flag_uncacheable, 0);
-       if (IS_ERR(ctx->restore))
-               goto fail_alloc;
-
-       if (map_restore) {
-               ctx->restore_virt = nvhost_memmgr_mmap(ctx->restore);
-               if (!ctx->restore_virt)
-                       goto fail_mmap;
-       } else
-               ctx->restore_virt = NULL;
 
-       ctx->restore_sgt = nvhost_memmgr_pin(memmgr, ctx->restore,
-                       &ch->dev->dev, mem_flag_none);
-       if (IS_ERR(ctx->restore_sgt))
-               goto fail_pin;
-       ctx->restore_phys = nvhost_memmgr_dma_addr(ctx->restore_sgt);
+       if (mem_flag)
+               ctx->cpuva = dma_alloc_writecombine(&ch->dev->dev,
+                                               p->restore_size * 4,
+                                               &ctx->iova,
+                                               GFP_KERNEL);
+       else
+               ctx->cpuva = dma_alloc_coherent(&ch->dev->dev,
+                                               p->restore_size * 4,
+                                               &ctx->iova,
+                                               GFP_KERNEL);
+
+       if (!ctx->cpuva) {
+               dev_err(&ch->dev->dev, "memory allocation failed\n");
+               goto fail;
+       }
 
        kref_init(&ctx->hwctx.ref);
        ctx->hwctx.h = &p->h;
@@ -261,14 +258,10 @@ struct host1x_hwctx *nvhost_3dctx_alloc_common(struct host1x_hwctx_handler *p,
 
        ctx->restore_size = p->restore_size;
        ctx->hwctx.restore_incrs = p->restore_incrs;
+       ctx->mem_flag = mem_flag;
        return ctx;
 
-fail_pin:
-       if (map_restore)
-               nvhost_memmgr_munmap(ctx->restore, ctx->restore_virt);
-fail_mmap:
-       nvhost_memmgr_put(memmgr, ctx->restore);
-fail_alloc:
+fail:
        kfree(ctx);
        return NULL;
 }
@@ -277,12 +270,12 @@ void nvhost_3dctx_restore_push(struct nvhost_hwctx *nctx,
                struct nvhost_cdma *cdma)
 {
        struct host1x_hwctx *ctx = to_host1x_hwctx(nctx);
-       nvhost_cdma_push_gather(cdma,
-               ctx->hwctx.memmgr,
-               ctx->restore,
+       _nvhost_cdma_push_gather(cdma,
+               ctx->cpuva,
+               ctx->iova,
                0,
                nvhost_opcode_gather(ctx->restore_size),
-               ctx->restore_phys);
+               ctx->iova);
 }
 
 void nvhost_3dctx_get(struct nvhost_hwctx *ctx)
@@ -294,14 +287,23 @@ void nvhost_3dctx_free(struct kref *ref)
 {
        struct nvhost_hwctx *nctx = container_of(ref, struct nvhost_hwctx, ref);
        struct host1x_hwctx *ctx = to_host1x_hwctx(nctx);
-       struct mem_mgr *memmgr = nvhost_get_host(nctx->channel->dev)->memmgr;
 
-       if (ctx->restore_virt)
-               nvhost_memmgr_munmap(ctx->restore, ctx->restore_virt);
+       if (ctx->cpuva) {
+               if (ctx->mem_flag)
+                       dma_free_writecombine(&nctx->channel->dev->dev,
+                                       ctx->restore_size * 4,
+                                       ctx->cpuva,
+                                       ctx->iova);
+               else
+                       dma_free_coherent(&nctx->channel->dev->dev,
+                                       ctx->restore_size * 4,
+                                       ctx->cpuva,
+                                       ctx->iova);
+
+               ctx->cpuva = NULL;
+               ctx->iova = 0;
+       }
 
-       nvhost_memmgr_unpin(memmgr, ctx->restore, &nctx->channel->dev->dev,
-                       ctx->restore_sgt);
-       nvhost_memmgr_put(memmgr, ctx->restore);
        kfree(ctx);
 }
 
index 70d6163fbeca2a7c15d2464ca6ad07d9d2bc84ba..18e5ca0be19eb727d19949cf2d2825d3c075a431 100644 (file)
@@ -170,7 +170,7 @@ static void save_push_v1(struct nvhost_hwctx *nctx, struct nvhost_cdma *cdma)
                nvhost_opcode_imm(0x403, 0));
        nvhost_cdma_push(cdma,
                nvhost_opcode_nonincr(AR3D_DW_MEMORY_OUTPUT_ADDRESS, 1),
-               ctx->restore_phys);
+               ctx->iova);
        /* gather the save buffer */
        _nvhost_cdma_push_gather(cdma,
                        p->cpuva,
index 3d2d62dadf9a30ba131c0d578f00c49935f8e6be..587b8f18dfe5cad54fd979cc59d55ec32706f866 100644 (file)
@@ -38,13 +38,10 @@ struct sg_table;
 struct host1x_hwctx {
        struct nvhost_hwctx hwctx;
 
-       struct mem_handle *restore;
-       u32 *restore_virt;
-       struct sg_table *restore_sgt;
-       dma_addr_t restore_phys;
        u32 restore_size;
        u32 *cpuva;
        dma_addr_t iova;
+       bool mem_flag;
 };
 
 struct host1x_hwctx_handler {