]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: host: use dma apis for host1x_cdma.c
authorDeepak Nibade <dnibade@nvidia.com>
Wed, 9 Oct 2013 07:01:19 +0000 (12:31 +0530)
committerTerje Bergstrom <tbergstrom@nvidia.com>
Mon, 14 Oct 2013 10:55:01 +0000 (03:55 -0700)
- use dma_alloc_writecombine()/dma_free_writecombine() apis to
  allocate/free memory instead of nvhost_memmgr apis

Bug 1380150

Change-Id: Icee0154886217c4c348c25896cf27e80cb1461ed
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/288994
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
drivers/video/tegra/host/host1x/host1x_cdma.c
drivers/video/tegra/host/nvhost_cdma.h

index aa2fb27b139e3497e06040dc546dd7f3f97757fc..0433f67cfa3c255af218193efe59f035b3fbd5f4 100644 (file)
@@ -27,7 +27,6 @@
 #include "dev.h"
 #include "class_ids.h"
 #include "chip_support.h"
-#include "nvhost_memmgr.h"
 #include "nvhost_job.h"
 
 #include "host1x_cdma.h"
@@ -66,40 +65,24 @@ static void push_buffer_destroy(struct push_buffer *pb);
 static int push_buffer_init(struct push_buffer *pb)
 {
        struct nvhost_cdma *cdma = pb_to_cdma(pb);
-       struct mem_mgr *mgr = cdma_to_memmgr(cdma);
        int err = 0;
-       pb->mem = NULL;
        pb->mapped = NULL;
-       pb->phys = 0;
+       pb->dma_addr = 0;
        pb->client_handle = NULL;
 
        cdma_pb_op().reset(pb);
 
-       /* allocate and map pushbuffer memory */
-       pb->mem = nvhost_memmgr_alloc(mgr, PUSH_BUFFER_SIZE + 4, 32,
-                             mem_mgr_flag_write_combine, 0);
-       if (IS_ERR(pb->mem)) {
-               err = PTR_ERR(pb->mem);
-               pb->mem = NULL;
-               goto fail;
-       }
-       pb->mapped = nvhost_memmgr_mmap(pb->mem);
+       /* allocate the pushbuffer memory */
+       pb->mapped = dma_alloc_writecombine(&cdma_to_dev(cdma)->dev->dev,
+                                       PUSH_BUFFER_SIZE + 4,
+                                       &pb->dma_addr,
+                                       GFP_KERNEL);
        if (!pb->mapped) {
                err = -ENOMEM;
                pb->mapped = NULL;
                goto fail;
        }
 
-       /* pin pushbuffer and get physical address */
-       pb->sgt = nvhost_memmgr_pin(mgr, pb->mem,
-                       &cdma_to_dev(cdma)->dev->dev, mem_flag_none);
-       if (IS_ERR(pb->sgt)) {
-               err = PTR_ERR(pb->sgt);
-               pb->sgt = 0;
-               goto fail;
-       }
-       pb->phys = nvhost_memmgr_dma_addr(pb->sgt);
-
        /* memory for storing nvmap client and handles for each opcode pair */
        pb->client_handle = kzalloc(NVHOST_GATHER_QUEUE_SIZE *
                                sizeof(struct mem_mgr_handle),
@@ -111,7 +94,7 @@ static int push_buffer_init(struct push_buffer *pb)
 
        /* put the restart at the end of pushbuffer memory */
        *(pb->mapped + (PUSH_BUFFER_SIZE >> 2)) =
-               nvhost_opcode_restart(pb->phys);
+               nvhost_opcode_restart(pb->dma_addr);
 
        return 0;
 
@@ -126,22 +109,16 @@ fail:
 static void push_buffer_destroy(struct push_buffer *pb)
 {
        struct nvhost_cdma *cdma = pb_to_cdma(pb);
-       struct mem_mgr *mgr = cdma_to_memmgr(cdma);
        if (pb->mapped)
-               nvhost_memmgr_munmap(pb->mem, pb->mapped);
-
-       if (pb->phys != 0)
-               nvhost_memmgr_unpin(mgr, pb->mem,
-                               &cdma_to_dev(cdma)->dev->dev, pb->sgt);
-
-       if (pb->mem)
-               nvhost_memmgr_put(mgr, pb->mem);
+               dma_free_writecombine(&cdma_to_dev(cdma)->dev->dev,
+                                       PUSH_BUFFER_SIZE + 4,
+                                       pb->mapped,
+                                       pb->dma_addr);
 
        kfree(pb->client_handle);
 
-       pb->mem = NULL;
        pb->mapped = NULL;
-       pb->phys = 0;
+       pb->dma_addr = 0;
        pb->client_handle = 0;
 }
 
@@ -195,7 +172,7 @@ static u32 push_buffer_space(struct push_buffer *pb)
 
 static u32 push_buffer_putptr(struct push_buffer *pb)
 {
-       return pb->phys + pb->cur;
+       return pb->dma_addr + pb->cur;
 }
 
 /*
@@ -241,13 +218,13 @@ static void cdma_timeout_pb_cleanup(struct nvhost_cdma *cdma, u32 getptr,
        u32 getidx;
 
        /* NOP all the PB slots */
-       getidx = getptr - pb->phys;
+       getidx = getptr - pb->dma_addr;
        while (nr_slots--) {
                u32 *p = (u32 *)((uintptr_t)pb->mapped + getidx);
                *(p++) = NVHOST_OPCODE_NOOP;
                *(p++) = NVHOST_OPCODE_NOOP;
                dev_dbg(&dev->dev->dev, "%s: NOP at 0x%llx\n",
-                       __func__, (u64)(pb->phys + getidx));
+                       __func__, (u64)(pb->dma_addr + getidx));
                getidx = (getidx + 8) & (PUSH_BUFFER_SIZE - 1);
        }
        wmb();
index 4b6dca2bb8604a03604ee6b7b066c3ff4c9b645f..19061f0135e1d81b0968fb55a79c7b38bc4729e4 100644 (file)
@@ -53,10 +53,8 @@ struct mem_mgr_handle {
 };
 
 struct push_buffer {
-       struct mem_handle *mem;         /* handle to pushbuffer memory */
        u32 *mapped;                    /* mapped pushbuffer memory */
-       struct sg_table *sgt;
-       dma_addr_t phys;                /* physical address of pushbuffer */
+       dma_addr_t dma_addr;            /* dma address of pushbuffer */
        u32 fence;                      /* index we've written */
        u32 cur;                        /* index to write to */
        struct mem_mgr_handle *client_handle; /* handle for each opcode pair */