video: tegra: nvmap: always initilize carveout's dma_dev
Sri Krishna chowdary [Tue, 19 May 2015 16:12:37 +0000 (21:12 +0530)]
If carveout's dma_dev is not initialized at compile time,
initialize it at runtime with the device present within.

This is needed to simplify the logic for reserved-memory handling.

Remove the redundant device from nvmap_heap.

Bug 200027296

Change-Id: Ib44fbc10f12370c012295f3954c29ee8ef627d3f
Signed-off-by: Sri Krishna chowdary <schowdary@nvidia.com>
Reviewed-on: http://git-master/r/744431
Reviewed-by: Sachin Nikam <snikam@nvidia.com>

drivers/video/tegra/nvmap/nvmap_heap.c
drivers/video/tegra/nvmap/nvmap_init.c
include/linux/nvmap.h

index 8398b65..2047cf9 100644 (file)
@@ -74,7 +74,6 @@ struct nvmap_heap {
        size_t len;
        struct device *cma_dev;
        struct device *dma_dev;
-       struct device dev;
        bool is_ivm;
        bool can_alloc; /* Used only if is_ivm == true */
        int peer; /* Used only if is_ivm == true */
@@ -324,6 +323,7 @@ struct nvmap_heap *nvmap_heap_create(struct device *parent,
                return NULL;
        }
 
+       h->dma_dev = co->dma_dev;
        if (co->cma_dev) {
 #ifdef CONFIG_CMA
                struct dma_contiguous_stats stats;
@@ -334,7 +334,6 @@ struct nvmap_heap *nvmap_heap_create(struct device *parent,
                base = stats.base;
                len = stats.size;
                h->cma_dev = co->cma_dev;
-               h->dma_dev = co->dma_dev;
 #else
                dev_err(parent, "invalid resize config for carveout %s\n",
                                co->name);
@@ -343,14 +342,6 @@ struct nvmap_heap *nvmap_heap_create(struct device *parent,
        } else {
                int err;
 
-               if (co->dma_dev)
-                       h->dma_dev = co->dma_dev;
-               else
-                       /* To continue working with bsp that doesn't
-                        * pass dma_dev ptr.
-                        */
-                       h->dma_dev = &h->dev;
-
                /* declare Non-CMA heap */
                err = dma_declare_coherent_memory(h->dma_dev, 0, base, len,
                                DMA_MEMORY_NOMAP | DMA_MEMORY_EXCLUSIVE);
index e8adae2..cce29f1 100644 (file)
@@ -87,8 +87,10 @@ static struct nvmap_platform_carveout *nvmap_get_carveout_pdata(const char *name
        for (co = nvmap_carveouts;
             co < nvmap_carveouts + ARRAY_SIZE(nvmap_carveouts); co++) {
                int i = strcspn(name, "_");
-               if (!strncmp("ivm", name, min(i, 3)) && !co->name)
+               if (!strncmp("ivm", name, min(i, 3)) && !co->name) {
+                       co->dma_dev = co->dma_dev ? co->dma_dev : &co->dev;
                        return co;
+               }
        }
        pr_err("not enough space for all nvmap carveouts\n");
        return NULL;
index 6eda225..b1801f1 100644 (file)
@@ -80,6 +80,7 @@ struct nvmap_platform_carveout {
        struct device *cma_dev;
        bool resize;
        struct device *dma_dev;
+       struct device dev;
        bool is_ivm;
        int peer;
        int vmid;