video: tegra: nvmap: convert some of NvMap API to private
Krishna Reddy [Thu, 26 Sep 2013 19:11:55 +0000 (12:11 -0700)]
convert nvmap_create_client/_dmabuf_export_from_ref/_ref_to_id,
nvmap_pin/_unpin into private API.
remove obsolete API nvmap_ref_to_user_id/_get_addr_from_user_id
as well.

Change-Id: I18025307d9d819d6c19df6dc558a03febd6fef14
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
(cherry picked from commit 0d0c64fc93436c0671672d2a6b55d64b55db8b50)
Signed-off-by: Ajay Nandakumar <anandakumarm@nvidia.com>

drivers/video/tegra/nvmap/nvmap.c
drivers/video/tegra/nvmap/nvmap_dev.c
drivers/video/tegra/nvmap/nvmap_dmabuf.c
drivers/video/tegra/nvmap/nvmap_handle.c
drivers/video/tegra/nvmap/nvmap_ioctl.c
drivers/video/tegra/nvmap/nvmap_priv.h
include/linux/nvmap.h

index 1ed54e2..190b689 100644 (file)
@@ -60,21 +60,9 @@ static phys_addr_t handle_phys(struct nvmap_handle *h)
 }
 
 /*
- * Get physical address of the handle. Handle should be
- * already validated and pinned.
- */
-phys_addr_t nvmap_get_addr_from_user_id(ulong user_id)
-{
-       struct nvmap_handle *h;
-
-       h = (struct nvmap_handle *)unmarshal_user_id(user_id);
-       return handle_phys(h);
-}
-
-/*
  * Do the actual pin. Just calls to the dma_buf code.
  */
-static int __nvmap_pin(struct nvmap_handle_ref *ref, phys_addr_t *phys)
+int __nvmap_pin(struct nvmap_handle_ref *ref, phys_addr_t *phys)
 {
        struct nvmap_handle *h = ref->handle;
        struct sg_table *sgt = NULL;
@@ -97,22 +85,7 @@ err:
        return PTR_ERR(sgt);
 }
 
-/*
- * Map a handle's memory into the IO virtual address space. This function
- * should be called on a handle before its memory is used by a device.
- */
-int nvmap_pin(struct nvmap_client *c, struct nvmap_handle_ref *ref,
-             phys_addr_t *phys)
-{
-       if (!virt_addr_valid(ref) ||
-           !virt_addr_valid(ref->handle))
-               return -EINVAL;
-
-       return __nvmap_pin(ref, phys);
-}
-EXPORT_SYMBOL(nvmap_pin);
-
-void nvmap_unpin(struct nvmap_client *client, struct nvmap_handle_ref *ref)
+void __nvmap_unpin(struct nvmap_handle_ref *ref)
 {
        struct nvmap_handle *h = ref->handle;
 
@@ -126,7 +99,6 @@ void nvmap_unpin(struct nvmap_client *client, struct nvmap_handle_ref *ref)
        dma_buf_unmap_attachment(h->attachment,
                h->attachment->priv, DMA_BIDIRECTIONAL);
 }
-EXPORT_SYMBOL(nvmap_unpin);
 
 int nvmap_pin_ids(struct nvmap_client *client, unsigned int nr,
                  const unsigned long *ids)
@@ -170,7 +142,7 @@ err_cleanup:
                 * up so if this worked the first time it will work again.
                 */
                ref = __nvmap_validate_id_locked(client, ids[i]);
-               nvmap_unpin(client, ref);
+               __nvmap_unpin(ref);
        }
        nvmap_ref_unlock(client);
        return err;
@@ -201,7 +173,7 @@ void nvmap_unpin_ids(struct nvmap_client *client, unsigned int nr,
                        continue;
                }
 
-               nvmap_unpin(client, ref);
+               __nvmap_unpin(ref);
        }
        nvmap_ref_unlock(client);
 }
@@ -414,7 +386,7 @@ static struct nvmap_client *nvmap_get_dmabuf_client(void)
        if (!client) {
                struct nvmap_client *temp;
 
-               temp = nvmap_create_client(nvmap_dev, "dmabuf_client");
+               temp = __nvmap_create_client(nvmap_dev, "dmabuf_client");
                if (!temp)
                        return NULL;
                if (cmpxchg(&client, NULL, temp))
@@ -443,14 +415,14 @@ static struct nvmap_handle_ref *__nvmap_alloc(struct nvmap_client *client,
        if (IS_ERR(r))
                return r;
 
-       err = nvmap_alloc_handle_id(client, nvmap_ref_to_id(r),
+       err = nvmap_alloc_handle_id(client, __nvmap_ref_to_id(r),
                                    heap_mask, align,
                                    0, /* kind n/a */
                                    flags & ~(NVMAP_HANDLE_KIND_SPECIFIED |
                                              NVMAP_HANDLE_COMPR_SPECIFIED));
 
        if (err) {
-               nvmap_free_handle_id(client, nvmap_ref_to_id(r));
+               nvmap_free_handle_id(client, __nvmap_ref_to_id(r));
                return ERR_PTR(err);
        }
 
@@ -460,7 +432,7 @@ static struct nvmap_handle_ref *__nvmap_alloc(struct nvmap_client *client,
 static void __nvmap_free(struct nvmap_client *client,
                         struct nvmap_handle_ref *r)
 {
-       unsigned long ref_id = nvmap_ref_to_id(r);
+       unsigned long ref_id = __nvmap_ref_to_id(r);
 
        if (!r ||
            WARN_ON(!virt_addr_valid(client)) ||
@@ -483,7 +455,7 @@ struct dma_buf *nvmap_alloc_dmabuf(size_t size, size_t align,
        if (!ref)
                return ERR_PTR(-ENOMEM);
 
-       dmabuf = nvmap_dmabuf_export_from_ref(ref);
+       dmabuf = __nvmap_dmabuf_export_from_ref(ref);
        __nvmap_free(client, ref);
        return dmabuf;
 }
index 202f787..f50d851 100644 (file)
@@ -518,8 +518,8 @@ struct nvmap_handle *nvmap_validate_get(struct nvmap_client *client,
        return NULL;
 }
 
-struct nvmap_client *nvmap_create_client(struct nvmap_device *dev,
-                                        const char *name)
+struct nvmap_client *__nvmap_create_client(struct nvmap_device *dev,
+                                          const char *name)
 {
        struct nvmap_client *client;
        struct task_struct *task;
@@ -566,7 +566,6 @@ struct nvmap_client *nvmap_create_client(struct nvmap_device *dev,
        spin_unlock(&dev->clients_lock);
        return client;
 }
-EXPORT_SYMBOL(nvmap_create_client);
 
 static void destroy_client(struct nvmap_client *client)
 {
@@ -586,7 +585,7 @@ static void destroy_client(struct nvmap_client *client)
                pins = atomic_read(&ref->pin);
 
                while (pins--)
-                       nvmap_unpin(client, ref);
+                       __nvmap_unpin(ref);
 
                if (ref->handle->owner == client) {
                        ref->handle->owner = NULL;
@@ -665,7 +664,7 @@ static int nvmap_open(struct inode *inode, struct file *filp)
                return ret;
 
        BUG_ON(dev != nvmap_dev);
-       priv = nvmap_create_client(dev, "user");
+       priv = __nvmap_create_client(dev, "user");
        if (!priv)
                return -ENOMEM;
        trace_nvmap_open(priv, priv->name);
index e89f241..fbdedb8 100644 (file)
@@ -609,7 +609,7 @@ struct dma_buf *nvmap_dmabuf_export(struct nvmap_client *client,
  * user_id. You must dma_buf_put() the dma_buf object when you are done with
  * it.
  */
-struct dma_buf *nvmap_dmabuf_export_from_ref(struct nvmap_handle_ref *ref)
+struct dma_buf *__nvmap_dmabuf_export_from_ref(struct nvmap_handle_ref *ref)
 {
        if (!virt_addr_valid(ref))
                return ERR_PTR(-EINVAL);
@@ -617,7 +617,6 @@ struct dma_buf *nvmap_dmabuf_export_from_ref(struct nvmap_handle_ref *ref)
        get_dma_buf(ref->handle->dmabuf);
        return ref->handle->dmabuf;
 }
-EXPORT_SYMBOL(nvmap_dmabuf_export_from_ref);
 
 /*
  * Returns the nvmap handle ID associated with the passed dma_buf's fd. This
index 8f5882d..f4a3ca9 100644 (file)
@@ -899,7 +899,7 @@ void nvmap_free_handle_id(struct nvmap_client *client, unsigned long id)
                            current->group_leader->comm, h);
 
        while (atomic_read(&ref->pin))
-               nvmap_unpin(client, ref);
+               __nvmap_unpin(ref);
 
        if (h->owner == client) {
                h->owner = NULL;
@@ -1167,7 +1167,7 @@ unsigned long nvmap_duplicate_handle_id_ex(struct nvmap_client *client,
        if (IS_ERR(ref))
                return 0;
 
-       return nvmap_ref_to_id(ref);
+       return __nvmap_ref_to_id(ref);
 }
 EXPORT_SYMBOL(nvmap_duplicate_handle_id_ex);
 
@@ -1242,7 +1242,7 @@ int nvmap_acquire_page_list(struct nvmap_client *client,
        nvmap_ref_lock(client);
        ref = __nvmap_validate_id_locked(client, id);
        if (ref)
-               nvmap_pin(client, ref, &dummy);
+               __nvmap_pin(ref, &dummy);
        nvmap_ref_unlock(client);
 
        return 0;
@@ -1260,7 +1260,7 @@ int nvmap_release_page_list(struct nvmap_client *client, unsigned long id)
 
        ref = __nvmap_validate_id_locked(client, id);
        if (ref)
-               nvmap_unpin(client, ref);
+               __nvmap_unpin(ref);
 
        nvmap_ref_unlock(client);
 
index 0264acc..c710548 100644 (file)
@@ -157,25 +157,16 @@ ulong unmarshal_id(ulong id)
 struct nvmap_handle *marshal_kernel_ref(struct nvmap_handle_ref *ref)
 {
        if (ref->fd == -1)
-               return marshal_kernel_handle(nvmap_ref_to_id(ref));
+               return marshal_kernel_handle(__nvmap_ref_to_id(ref));
        return (struct nvmap_handle *)ref->fd;
 }
 
-ulong nvmap_ref_to_user_id(struct nvmap_handle_ref *ref)
-{
-       if (!virt_addr_valid(ref))
-               return 0;
-       return (ulong)marshal_kernel_handle(nvmap_ref_to_id(ref));
-}
-EXPORT_SYMBOL(nvmap_ref_to_user_id);
-
-ulong nvmap_ref_to_id(struct nvmap_handle_ref *ref)
+ulong __nvmap_ref_to_id(struct nvmap_handle_ref *ref)
 {
        if (!virt_addr_valid(ref))
                return 0;
        return (unsigned long)ref->handle;
 }
-EXPORT_SYMBOL(nvmap_ref_to_id);
 
 int nvmap_ioctl_pinop(struct file *filp, bool is_pin, void __user *arg)
 {
@@ -437,7 +428,7 @@ int nvmap_ioctl_create(struct file *filp, unsigned int cmd, void __user *arg)
        op.handle = marshal_kernel_ref(ref);
        if (copy_to_user(arg, &op, sizeof(op))) {
                err = -EFAULT;
-               nvmap_free_handle_id(client, nvmap_ref_to_id(ref));
+               nvmap_free_handle_id(client, __nvmap_ref_to_id(ref));
        }
 
        return err;
index cbe56b6..b0eda63 100644 (file)
@@ -332,6 +332,9 @@ int is_nvmap_vma(struct vm_area_struct *vma);
 int nvmap_get_dmabuf_fd(struct nvmap_client *client, ulong id);
 ulong nvmap_get_id_from_dmabuf_fd(struct nvmap_client *client, int fd);
 
+int nvmap_get_handle_param(struct nvmap_client *client,
+               struct nvmap_handle_ref *ref, u32 param, u64 *result);
+
 #ifdef CONFIG_COMPAT
 ulong unmarshal_user_handle(__u32 handle);
 __u32 marshal_kernel_handle(ulong handle);
@@ -394,6 +397,12 @@ int __nvmap_get_handle_param(struct nvmap_client *client,
 int __nvmap_cache_maint(struct nvmap_client *client, struct nvmap_handle *h,
                        unsigned long start, unsigned long end,
                        unsigned int op, unsigned int allow_deferred);
+struct nvmap_client *__nvmap_create_client(struct nvmap_device *dev,
+                                          const char *name);
+struct dma_buf *__nvmap_dmabuf_export_from_ref(struct nvmap_handle_ref *ref);
+ulong __nvmap_ref_to_id(struct nvmap_handle_ref *ref);
+int __nvmap_pin(struct nvmap_handle_ref *ref, phys_addr_t *phys);
+void __nvmap_unpin(struct nvmap_handle_ref *ref);
 
 void nvmap_dmabuf_debugfs_init(struct dentry *nvmap_root);
 int nvmap_dmabuf_stash_init(void);
index f72e743..371466a 100644 (file)
@@ -60,48 +60,31 @@ struct nvmap_handle_ref;
 struct nvmap_client;
 struct nvmap_device;
 
-struct nvmap_client *nvmap_create_client(struct nvmap_device *dev,
-                                        const char *name);
-
 struct dma_buf *nvmap_alloc_dmabuf(size_t size, size_t align,
                                   unsigned int flags,
                                   unsigned int heap_mask);
 
 struct dma_buf *nvmap_dmabuf_export(struct nvmap_client *client, ulong user_id);
 
-struct dma_buf *nvmap_dmabuf_export_from_ref(struct nvmap_handle_ref *ref);
-
-ulong nvmap_ref_to_id(struct nvmap_handle_ref *ref);
-
-ulong nvmap_ref_to_user_id(struct nvmap_handle_ref *ref);
-
 ulong nvmap_dmabuf_to_user_id(struct dma_buf *dmabuf);
 
-phys_addr_t nvmap_get_addr_from_user_id(ulong user_id);
-
 struct nvmap_client *nvmap_client_get_file(int fd);
 
 struct nvmap_client *nvmap_client_get(struct nvmap_client *client);
 
 void nvmap_client_put(struct nvmap_client *c);
 
-int nvmap_pin(struct nvmap_client *c, struct nvmap_handle_ref *r,
-             phys_addr_t *phys);
-
 phys_addr_t nvmap_handle_address_user_id(struct nvmap_client *c,
                                         unsigned long user_id);
 
-void nvmap_unpin(struct nvmap_client *client, struct nvmap_handle_ref *r);
-
 struct sg_table *nvmap_dmabuf_sg_table(struct dma_buf *dmabuf);
+
 void nvmap_dmabuf_free_sg_table(struct dma_buf *dmabuf, struct sg_table *sgt);
 
 void nvmap_set_dmabuf_private(struct dma_buf *dmabuf, void *priv,
                              void (*delete)(void *priv));
-void *nvmap_get_dmabuf_private(struct dma_buf *dmabuf);
 
-int nvmap_get_handle_param(struct nvmap_client *client,
-               struct nvmap_handle_ref *ref, u32 param, u64 *result);
+void *nvmap_get_dmabuf_private(struct dma_buf *dmabuf);
 
 int nvmap_get_dmabuf_param(struct dma_buf *dmabuf, u32 param, u64 *result);