]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: host: Use dmabuf for private data
authorArto Merilainen <amerilainen@nvidia.com>
Sun, 16 Feb 2014 14:06:26 +0000 (16:06 +0200)
committerTerje Bergstrom <tbergstrom@nvidia.com>
Thu, 27 Feb 2014 06:35:53 +0000 (22:35 -0800)
This far we have used direct nvmap calls to store/retrieve buffer
specific private data. This patch modifies nvhost to use the dmabuf
functionality for retrieving the private data.

Bug 1450489

Change-Id: I9611681c271f846a8d265ee08e3aa61c032e59e7
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/368140
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
drivers/video/tegra/host/gk20a/mm_gk20a.c
drivers/video/tegra/host/nvhost_memmgr.c
drivers/video/tegra/host/nvhost_memmgr.h
drivers/video/tegra/host/nvmap.c
drivers/video/tegra/host/nvmap.h

index 3dfbd223c137302ddc631fe1f6b47cc3851d9bf6..42664f4251ff74beee754ebb745041153337e31f 100644 (file)
@@ -1214,11 +1214,11 @@ u64 gk20a_vm_map(struct vm_gk20a *vm,
        if (!vm->enable_ctag)
                bfr.ctag_lines = 0;
 
-       nvhost_memmgr_get_comptags(r, &comptags);
+       nvhost_memmgr_get_comptags(d, r, &comptags);
 
        if (bfr.ctag_lines && !comptags.lines) {
                /* allocate compression resources if needed */
-               err = nvhost_memmgr_alloc_comptags(r,
+               err = nvhost_memmgr_alloc_comptags(d, r,
                                ctag_allocator, bfr.ctag_lines);
                if (err) {
                        /* ok to fall back here if we ran out */
@@ -1226,7 +1226,7 @@ u64 gk20a_vm_map(struct vm_gk20a *vm,
                        bfr.ctag_lines = bfr.ctag_offset = 0;
                        bfr.kind_v = bfr.uc_kind_v;
                } else {
-                       nvhost_memmgr_get_comptags(r, &comptags);
+                       nvhost_memmgr_get_comptags(d, r, &comptags);
 
                        /* init/clear the ctag buffer */
                        g->ops.ltc.clear_comptags(g,
index 39dae1958cf112f40d4b53e4c8d032fb078c76e9..0a7a1fd911c3342c2d9868bdd8d5b74128b07e65 100644 (file)
@@ -347,23 +347,25 @@ void nvhost_memmgr_free_sg_table(struct mem_mgr *mgr,
        return;
 }
 
-void nvhost_memmgr_get_comptags(struct mem_handle *mem,
+void nvhost_memmgr_get_comptags(struct device *dev,
+                               struct mem_handle *mem,
                                struct nvhost_comptags *comptags)
 {
 #ifdef CONFIG_TEGRA_GRHOST_USE_NVMAP
-       return nvhost_nvmap_get_comptags(mem, comptags);
+       return nvhost_nvmap_get_comptags(dev, mem, comptags);
 #endif
 #ifdef CONFIG_TEGRA_GRHOST_USE_DMABUF
        WARN_ON(1);
 #endif
 }
 
-int nvhost_memmgr_alloc_comptags(struct mem_handle *mem,
+int nvhost_memmgr_alloc_comptags(struct device *dev,
+                                struct mem_handle *mem,
                                 struct nvhost_allocator *allocator,
                                 int lines)
 {
 #ifdef CONFIG_TEGRA_GRHOST_USE_NVMAP
-       return nvhost_nvmap_alloc_comptags(mem, allocator, lines);
+       return nvhost_nvmap_alloc_comptags(dev, mem, allocator, lines);
 #endif
 #ifdef CONFIG_TEGRA_GRHOST_USE_DMABUF
        WARN_ON(1);
index b62b70ae49eba7e85761651c8774b3d01db48c1b..7a4d329404d8285856e89d2b422908a615d24815 100644 (file)
@@ -89,9 +89,11 @@ int nvhost_memmgr_get_param(struct mem_mgr *mem_mgr,
                            struct mem_handle *mem_handle,
                            u32 param, u64 *result);
 
-void nvhost_memmgr_get_comptags(struct mem_handle *mem,
+void nvhost_memmgr_get_comptags(struct device *dev,
+                               struct mem_handle *mem,
                                struct nvhost_comptags *comptags);
-int nvhost_memmgr_alloc_comptags(struct mem_handle *mem,
+int nvhost_memmgr_alloc_comptags(struct device *dev,
+                                struct mem_handle *mem,
                                 struct nvhost_allocator *allocator,
                                 int lines);
 size_t nvhost_memmgr_size(struct mem_handle *handle);
index 9894cb2815c9765be997fe69a0b74dbd8601a158..6f9b2611dde2b34fa05fbf70b4efa456fed6469b 100644 (file)
@@ -121,10 +121,10 @@ struct sg_table *nvhost_nvmap_pin(struct mem_mgr *mgr,
        static DEFINE_MUTEX(priv_lock);
 
        /* create the nvhost priv if needed */
-       priv = nvmap_get_dmabuf_private(dmabuf);
+       priv = dma_buf_get_drvdata(dmabuf, dev);
        if (!priv) {
                mutex_lock(&priv_lock);
-               priv = nvmap_get_dmabuf_private(dmabuf);
+               priv = dma_buf_get_drvdata(dmabuf, dev);
                if (priv)
                        goto priv_exist_or_err;
                priv = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -133,7 +133,7 @@ struct sg_table *nvhost_nvmap_pin(struct mem_mgr *mgr,
                        goto priv_exist_or_err;
                }
                mutex_init(&priv->lock);
-               nvmap_set_dmabuf_private(dmabuf, priv, delete_priv);
+               dma_buf_set_drvdata(dmabuf, dev, priv, delete_priv);
 priv_exist_or_err:
                mutex_unlock(&priv_lock);
        }
@@ -210,7 +210,8 @@ void nvhost_nvmap_unpin(struct mem_mgr *mgr, struct mem_handle *handle,
                struct device *dev, struct sg_table *sgt)
 {
        struct dma_buf *dmabuf = (struct dma_buf *)handle;
-       struct nvhost_nvmap_data *priv = nvmap_get_dmabuf_private(dmabuf);
+       struct nvhost_nvmap_data *priv =
+               dma_buf_get_drvdata(dmabuf, dev);
        struct nvhost_nvmap_as_data *as_priv;
        dma_addr_t dma_addr;
 
@@ -273,19 +274,27 @@ int nvhost_nvmap_get_param(struct mem_mgr *mgr, struct mem_handle *handle,
                        param, result);
 }
 
-void nvhost_nvmap_get_comptags(struct mem_handle *mem,
+void nvhost_nvmap_get_comptags(struct device *dev,
+                              struct mem_handle *mem,
                               struct nvhost_comptags *comptags)
 {
        struct nvhost_nvmap_data *priv;
 
-       priv = nvmap_get_dmabuf_private((struct dma_buf *)mem);
+       priv = dma_buf_get_drvdata((struct dma_buf *)mem, dev);
 
-       BUG_ON(!priv || !comptags);
+       BUG_ON(!comptags);
+
+       if (!priv) {
+               comptags->lines = 0;
+               comptags->offset = 0;
+               return;
+       }
 
        *comptags = priv->comptags;
 }
 
-int nvhost_nvmap_alloc_comptags(struct mem_handle *mem,
+int nvhost_nvmap_alloc_comptags(struct device *dev,
+                               struct mem_handle *mem,
                                struct nvhost_allocator *allocator,
                                int lines)
 {
@@ -293,9 +302,11 @@ int nvhost_nvmap_alloc_comptags(struct mem_handle *mem,
        u32 offset = 0;
        struct nvhost_nvmap_data *priv;
 
-       priv = nvmap_get_dmabuf_private((struct dma_buf *)mem);
+       priv = dma_buf_get_drvdata((struct dma_buf *)mem, dev);
+
+       if (!priv)
+               return -ENOSYS;
 
-       BUG_ON(!priv);
        BUG_ON(!lines);
 
        /* store the allocator so we can use it when we free the ctags */
index d9208e5e03a3cff0128b2066a9ac68edfbabc187..a11e7f24e7307a997ec483ee405d842fb3ec4374 100644 (file)
@@ -50,9 +50,9 @@ int nvhost_nvmap_get_param(struct mem_mgr *mgr, struct mem_handle *handle,
 phys_addr_t nvhost_nvmap_get_addr_from_id(ulong id);
 
 void nvhost_nvmap_unpin_id(struct mem_mgr *mgr, ulong id);
-void nvhost_nvmap_get_comptags(struct mem_handle *mem,
+void nvhost_nvmap_get_comptags(struct device *dev, struct mem_handle *mem,
                               struct nvhost_comptags *comptags);
-int nvhost_nvmap_alloc_comptags(struct mem_handle *mem,
+int nvhost_nvmap_alloc_comptags(struct device *dev, struct mem_handle *mem,
                                struct nvhost_allocator *allocator,
                                int lines);
 size_t nvhost_nvmap_size(struct mem_handle *handle);