arm: tegra: nvmap: Update nvmap_alloc api.
Krishna Reddy [Fri, 16 Mar 2012 02:14:53 +0000 (19:14 -0700)]
Update nvmap_alloc api to take heap_mask as arg.
This is to let clients specify the specific heap needed.

Change-Id: I9950b3e60e6dac0301b6dc66be3e9d0bab8e0fee
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/90471
Reviewed-by: Scott Williams <scwilliams@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User

arch/arm/mach-tegra/include/mach/nvmap.h
drivers/gpu/ion/tegra/tegra_ion.c
drivers/media/video/tegra/avp/avp.c
drivers/media/video/tegra/nvavp/nvavp_dev.c
drivers/video/tegra/host/gr3d/gr3d.c
drivers/video/tegra/host/gr3d/gr3d_t20.c
drivers/video/tegra/host/gr3d/gr3d_t30.c
drivers/video/tegra/host/host1x/host1x_cdma.c
drivers/video/tegra/host/mpe/mpe.c
drivers/video/tegra/host/nvhost_job.c
drivers/video/tegra/nvmap/nvmap.c

index fb2eda1..88f913f 100644 (file)
@@ -106,7 +106,8 @@ struct nvmap_client *nvmap_create_client(struct nvmap_device *dev,
                                         const char *name);
 
 struct nvmap_handle_ref *nvmap_alloc(struct nvmap_client *client, size_t size,
-                                    size_t align, unsigned int flags);
+                                    size_t align, unsigned int flags,
+                                    unsigned int heap_mask);
 
 void nvmap_free(struct nvmap_client *client, struct nvmap_handle_ref *r);
 
index f686269..2252079 100644 (file)
@@ -373,7 +373,8 @@ struct nvmap_client *nvmap_create_client(struct nvmap_device *dev,
 }
 
 struct nvmap_handle_ref *nvmap_alloc(struct nvmap_client *client, size_t size,
-                                    size_t align, unsigned int flags)
+                                    size_t align, unsigned int flags,
+                                    unsigned int heap_mask)
 {
        return ion_alloc(client, size, align, HEAP_FLAGS);
 }
index b287073..074a42f 100644 (file)
@@ -1158,7 +1158,7 @@ static int _load_lib(struct tegra_avp_info *avp, struct tegra_avp_lib *lib,
        }
 
        lib_handle = nvmap_alloc(avp->nvmap_libs, fw->size, L1_CACHE_BYTES,
-                                NVMAP_HANDLE_UNCACHEABLE);
+                                NVMAP_HANDLE_UNCACHEABLE, 0);
        if (IS_ERR_OR_NULL(lib_handle)) {
                pr_err("avp_lib: can't nvmap alloc for lib '%s'\n", lib->name);
                ret = PTR_ERR(lib_handle);
@@ -1649,7 +1649,7 @@ static int tegra_avp_probe(struct platform_device *pdev)
 
        if (heap_mask == NVMAP_HEAP_CARVEOUT_GENERIC) {
                avp->kernel_handle = nvmap_alloc(avp->nvmap_drv, SZ_1M, SZ_1M,
-                                               NVMAP_HANDLE_UNCACHEABLE);
+                                               NVMAP_HANDLE_UNCACHEABLE, 0);
                if (IS_ERR_OR_NULL(avp->kernel_handle)) {
                        pr_err("%s: cannot create handle\n", __func__);
                        ret = PTR_ERR(avp->kernel_handle);
@@ -1680,7 +1680,7 @@ static int tegra_avp_probe(struct platform_device *pdev)
         */
        avp->iram_backup_handle =
                nvmap_alloc(avp->nvmap_drv, TEGRA_IRAM_SIZE + 4,
-                               L1_CACHE_BYTES, NVMAP_HANDLE_UNCACHEABLE);
+                               L1_CACHE_BYTES, NVMAP_HANDLE_UNCACHEABLE, 0);
        if (IS_ERR_OR_NULL(avp->iram_backup_handle)) {
                pr_err("%s: cannot create handle for iram backup\n", __func__);
                ret = PTR_ERR(avp->iram_backup_handle);
index 0490bfc..63ddcde 100644 (file)
@@ -328,7 +328,7 @@ static int nvavp_pushbuffer_alloc(struct nvavp_info *nvavp)
        int ret = 0;
 
        nvavp->pushbuf_handle = nvmap_alloc(nvavp->nvmap, NVAVP_PUSHBUFFER_SIZE,
-                               SZ_1M, NVMAP_HANDLE_UNCACHEABLE);
+                               SZ_1M, NVMAP_HANDLE_UNCACHEABLE, 0);
        if (IS_ERR(nvavp->pushbuf_handle)) {
                dev_err(&nvavp->nvhost_dev->dev,
                        "cannot create pushbuffer handle\n");
@@ -571,7 +571,7 @@ static int nvavp_load_ucode(struct nvavp_info *nvavp)
 
                ucode_info->handle = nvmap_alloc(nvavp->nvmap,
                                                nvavp->ucode_info.size,
-                                       SZ_1M, NVMAP_HANDLE_UNCACHEABLE);
+                                       SZ_1M, NVMAP_HANDLE_UNCACHEABLE, 0);
                if (IS_ERR(ucode_info->handle)) {
                        dev_err(&nvavp->nvhost_dev->dev,
                                "cannot create ucode handle\n");
@@ -1205,7 +1205,7 @@ static int tegra_nvavp_probe(struct nvhost_device *ndev)
                break;
        case NVMAP_HEAP_CARVEOUT_GENERIC:
                nvavp->os_info.handle = nvmap_alloc(nvavp->nvmap, SZ_1M, SZ_1M,
-                                               NVMAP_HANDLE_UNCACHEABLE);
+                                               NVMAP_HANDLE_UNCACHEABLE, 0);
                if (IS_ERR_OR_NULL(nvavp->os_info.handle)) {
                        dev_err(&ndev->dev, "cannot create AVP os handle\n");
                        ret = PTR_ERR(nvavp->os_info.handle);
index 6e7f87e..2dca9ef 100644 (file)
@@ -76,7 +76,7 @@ struct host1x_hwctx *nvhost_3dctx_alloc_common(struct host1x_hwctx_handler *p,
                return NULL;
        ctx->restore = nvmap_alloc(nvmap, p->restore_size * 4, 32,
                map_restore ? NVMAP_HANDLE_WRITE_COMBINE
-                           : NVMAP_HANDLE_UNCACHEABLE);
+                           : NVMAP_HANDLE_UNCACHEABLE, 0);
        if (IS_ERR_OR_NULL(ctx->restore))
                goto fail;
 
index 90892aa..3604142 100644 (file)
@@ -366,7 +366,7 @@ struct nvhost_hwctx_handler * __init nvhost_gr3d_t20_ctxhandler_init(
        setup_save(p, NULL);
 
        p->save_buf = nvmap_alloc(nvmap, p->save_size * sizeof(u32), 32,
-                               NVMAP_HANDLE_WRITE_COMBINE);
+                               NVMAP_HANDLE_WRITE_COMBINE, 0);
        if (IS_ERR(p->save_buf)) {
                p->save_buf = NULL;
                return NULL;
index 6a7c147..e7329e5 100644 (file)
@@ -404,7 +404,7 @@ struct nvhost_hwctx_handler *__init nvhost_gr3d_t30_ctxhandler_init(
        setup_save(p, NULL);
 
        p->save_buf = nvmap_alloc(nvmap, p->save_size * 4, 32,
-                               NVMAP_HANDLE_WRITE_COMBINE);
+                               NVMAP_HANDLE_WRITE_COMBINE, 0);
        if (IS_ERR(p->save_buf)) {
                p->save_buf = NULL;
                return NULL;
index 0955275..064368a 100644 (file)
@@ -72,7 +72,7 @@ static int push_buffer_init(struct push_buffer *pb)
 
        /* allocate and map pushbuffer memory */
        pb->mem = nvmap_alloc(nvmap, PUSH_BUFFER_SIZE + 4, 32,
-                             NVMAP_HANDLE_WRITE_COMBINE);
+                             NVMAP_HANDLE_WRITE_COMBINE, 0);
        if (IS_ERR_OR_NULL(pb->mem)) {
                pb->mem = NULL;
                goto fail;
@@ -209,7 +209,7 @@ static int cdma_timeout_init(struct nvhost_cdma *cdma,
        /* allocate and map syncpt incr memory */
        sb->mem = nvmap_alloc(nvmap,
                        (SYNCPT_INCR_BUFFER_SIZE_WORDS * sizeof(u32)), 32,
-                       NVMAP_HANDLE_WRITE_COMBINE);
+                       NVMAP_HANDLE_WRITE_COMBINE, 0);
        if (IS_ERR_OR_NULL(sb->mem)) {
                sb->mem = NULL;
                goto fail;
index a5459e8..e1fef69 100644 (file)
@@ -437,7 +437,7 @@ static struct nvhost_hwctx *ctxmpe_alloc(struct nvhost_hwctx_handler *h,
        if (!ctx)
                return NULL;
        ctx->restore = nvmap_alloc(nvmap, restore_size * 4, 32,
-                               NVMAP_HANDLE_WRITE_COMBINE);
+                               NVMAP_HANDLE_WRITE_COMBINE, 0);
        if (IS_ERR_OR_NULL(ctx->restore)) {
                kfree(ctx);
                return NULL;
@@ -545,7 +545,7 @@ struct nvhost_hwctx_handler * __init nvhost_mpe_ctxhandler_init(
        setup_save(p, NULL);
 
        p->save_buf = nvmap_alloc(nvmap, p->save_size * 4, 32,
-                               NVMAP_HANDLE_WRITE_COMBINE);
+                               NVMAP_HANDLE_WRITE_COMBINE, 0);
        if (IS_ERR(p->save_buf)) {
                p->save_buf = NULL;
                return NULL;
index 1f774ed..e0baea5 100644 (file)
@@ -71,7 +71,7 @@ static int alloc_gathers(struct nvhost_job *job,
                /* Allocate memory */
                job->gather_mem = nvmap_alloc(job->nvmap,
                                gather_size(num_cmdbufs),
-                               32, NVMAP_HANDLE_CACHEABLE);
+                               32, NVMAP_HANDLE_CACHEABLE, 0);
                if (IS_ERR_OR_NULL(job->gather_mem)) {
                        err = PTR_ERR(job->gather_mem);
                        job->gather_mem = NULL;
index 5fcdee6..b4b6241 100644 (file)
@@ -740,19 +740,23 @@ void nvmap_munmap(struct nvmap_handle_ref *ref, void *addr)
 }
 
 struct nvmap_handle_ref *nvmap_alloc(struct nvmap_client *client, size_t size,
-                                    size_t align, unsigned int flags)
+                                    size_t align, unsigned int flags,
+                                    unsigned int heap_mask)
 {
        const unsigned int default_heap = (NVMAP_HEAP_SYSMEM |
                                           NVMAP_HEAP_CARVEOUT_GENERIC);
        struct nvmap_handle_ref *r = NULL;
        int err;
 
+       if (heap_mask == 0)
+               heap_mask = default_heap;
+
        r = nvmap_create_handle(client, size);
        if (IS_ERR(r))
                return r;
 
        err = nvmap_alloc_handle_id(client, nvmap_ref_to_id(r),
-                                   default_heap, align, flags);
+                                   heap_mask, align, flags);
 
        if (err) {
                nvmap_free_handle_id(client, nvmap_ref_to_id(r));