]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: host: gk20a: Support extended map
authorArto Merilainen <amerilainen@nvidia.com>
Tue, 4 Feb 2014 14:13:15 +0000 (16:13 +0200)
committerTerje Bergstrom <tbergstrom@nvidia.com>
Wed, 12 Feb 2014 08:01:20 +0000 (00:01 -0800)
This patch adds support for extended map buffer ioctl. The ioctl
currently supports giving also kind but padding is reserved for
future extensions.

Bug 1445482

Change-Id: I9498f00fd48b4452b37fa88d79dee952380d1d13
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/363321
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Lauri Peltonen <lpeltonen@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
drivers/video/tegra/host/gk20a/mm_gk20a.c
drivers/video/tegra/host/nvhost_as.c
drivers/video/tegra/host/nvhost_as.h
include/linux/nvhost_as_ioctl.h

index 060a58bb79e80463e31ff7138c09140d224a7c22..0b3dd36c61701ea025b77acf9072c7f214364a0d 100644 (file)
@@ -2225,7 +2225,8 @@ static int gk20a_as_map_buffer(struct nvhost_as_share *as_share,
                               int memmgr_fd,
                               ulong mem_id,
                               u64 *offset_align,
-                              u32 flags /*NVHOST_AS_MAP_BUFFER_FLAGS_*/)
+                              u32 flags, /*NVHOST_AS_MAP_BUFFER_FLAGS_*/
+                              u32 kind)
 {
        int err = 0;
        struct vm_gk20a *vm = (struct vm_gk20a *)as_share->priv;
@@ -2249,7 +2250,7 @@ static int gk20a_as_map_buffer(struct nvhost_as_share *as_share,
        }
 
        ret_va = gk20a_vm_map(vm, memmgr, r, *offset_align,
-                       flags, NV_KIND_DEFAULT, NULL, true,
+                       flags, kind, NULL, true,
                        mem_flag_none);
        *offset_align = ret_va;
        if (!ret_va) {
index b7651ae4f0a598d6c03ed6c3e68a7c9af0e6ba7e..6b9be495f515c72f1f5d5175746f5b80033b80a2 100644 (file)
@@ -149,6 +149,11 @@ long nvhost_as_dev_ctl(struct file *filp, unsigned int cmd, unsigned long arg)
                err = nvhost_as_ioctl_map_buffer(as_share,
                                       (struct nvhost_as_map_buffer_args *)buf);
                break;
+       case NVHOST_AS_IOCTL_MAP_BUFFER_EX:
+               trace_nvhost_as_ioctl_map_buffer(dev_name(&ch->dev->dev));
+               err = nvhost_as_ioctl_map_buffer_ex(as_share,
+                              (struct nvhost_as_map_buffer_ex_args *)buf);
+               break;
        case NVHOST_AS_IOCTL_UNMAP_BUFFER:
                trace_nvhost_as_ioctl_unmap_buffer(dev_name(&ch->dev->dev));
                err = nvhost_as_ioctl_unmap_buffer(as_share,
@@ -375,6 +380,26 @@ int nvhost_as_ioctl_free_space(struct nvhost_as_share *as_share,
        return pdata->as_ops->free_space(as_share, args);
 }
 
+int nvhost_as_ioctl_map_buffer_ex(struct nvhost_as_share *as_share,
+                                 struct nvhost_as_map_buffer_ex_args *args)
+{
+       struct nvhost_device_data *pdata =
+               nvhost_get_devdata(as_share->ch->dev);
+       int i;
+
+       nvhost_dbg_fn("");
+
+       /* ensure that padding is not set. this is required for ensuring that
+        * we can safely use these fields later */
+       for (i = 0; i < ARRAY_SIZE(args->padding); i++)
+               if (args->padding[i])
+                       return -EINVAL;
+
+       return pdata->as_ops->map_buffer(as_share, 0, args->dmabuf_fd,
+                                        &args->offset, args->flags,
+                                        args->kind);
+}
+
 int nvhost_as_ioctl_map_buffer(struct nvhost_as_share *as_share,
                               struct nvhost_as_map_buffer_args *args)
 {
@@ -382,9 +407,9 @@ int nvhost_as_ioctl_map_buffer(struct nvhost_as_share *as_share,
                nvhost_get_devdata(as_share->ch->dev);
        nvhost_dbg_fn("");
 
-       return pdata->as_ops->map_buffer(as_share,
-                                            args->nvmap_fd, args->nvmap_handle,
-                                            &args->o_a.align, args->flags);
+       return pdata->as_ops->map_buffer(as_share, args->nvmap_fd,
+                                        args->nvmap_handle, &args->o_a.align,
+                                        args->flags, NV_KIND_DEFAULT);
        /* args->o_a.offset will be set if !err */
 }
 
index 26153f6b10fec975b1b48968bcb5f95dd9046ffc..6947c7c62c019b8eb5a7662a999d802c52208e37 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Tegra Host Address Space
  *
- * Copyright (c) 2011-2013, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2011-2014, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -44,7 +44,8 @@ struct nvhost_as_moduleops {
                          int memmgr_fd,
                          ulong mem_id,
                          u64 *offset_align,
-                         u32 flags /*NVHOST_AS_MAP_BUFFER_FLAGS_*/);
+                         u32 flags, /*NVHOST_AS_MAP_BUFFER_FLAGS_*/
+                         u32 kind);
        int (*unmap_buffer)(struct nvhost_as_share *, u64 offset);
 };
 
@@ -87,6 +88,8 @@ int nvhost_as_ioctl_bind_channel(struct nvhost_as_share *as_share,
                                 struct nvhost_as_bind_channel_args *args);
 int nvhost_as_ioctl_map_buffer(struct nvhost_as_share *as_share,
                               struct nvhost_as_map_buffer_args *args);
+int nvhost_as_ioctl_map_buffer_ex(struct nvhost_as_share *as_share,
+                                 struct nvhost_as_map_buffer_ex_args *args);
 int nvhost_as_ioctl_unmap_buffer(struct nvhost_as_share *as_share,
                                 struct nvhost_as_unmap_buffer_args *args);
 
index 9ea4a12a95f5b5e95c4a3dac661457a8d2eb91d2..cb6e8fd3813c25319728f72029ed4e6e87ee7172 100644 (file)
@@ -130,6 +130,31 @@ struct nvhost_as_map_buffer_args {
        } o_a;
 };
 
+ /*
+ * Mapping dmabuf fds into an address space:
+ *
+ * The caller requests a mapping to a particular page 'kind'.
+ *
+ * If 'page_size' is set to 0 the dmabuf's alignment/sizing will be used to
+ * determine the page size (largest possible).  The page size chosen will be
+ * returned back to the caller in the 'page_size' parameter in that case.
+ */
+struct nvhost_as_map_buffer_ex_args {
+       __u32 flags;            /* in/out */
+#define NV_KIND_DEFAULT -1
+       __s32 kind;             /* in (-1 represents default) */
+       __u32 dmabuf_fd;        /* in */
+       __u32 page_size;        /* inout, 0:= best fit to buffer */
+
+       __u32 padding[4];       /* reserved for future usage */
+
+       __u64 offset;           /* in/out, we use this address if flag
+                                * FIXED_OFFSET is set. This will fail
+                                * if space is not properly allocated. The
+                                * actual virtual address to which we mapped
+                                * the buffer is returned in this field. */
+};
+
 /*
  * Unmapping a buffer:
  *
@@ -153,11 +178,13 @@ struct nvhost_as_unmap_buffer_args {
        _IOWR(NVHOST_AS_IOCTL_MAGIC, 5, struct nvhost_as_unmap_buffer_args)
 #define NVHOST_AS_IOCTL_ALLOC_SPACE \
        _IOWR(NVHOST_AS_IOCTL_MAGIC, 6, struct nvhost_as_alloc_space_args)
+#define NVHOST_AS_IOCTL_MAP_BUFFER_EX \
+       _IOWR(NVHOST_AS_IOCTL_MAGIC, 7, struct nvhost_as_map_buffer_ex_args)
 
 #define NVHOST_AS_IOCTL_LAST           \
-       _IOC_NR(NVHOST_AS_IOCTL_ALLOC_SPACE)
+       _IOC_NR(NVHOST_AS_IOCTL_MAP_BUFFER_EX)
 #define NVHOST_AS_IOCTL_MAX_ARG_SIZE   \
-       sizeof(struct nvhost_as_map_buffer_args)
+       sizeof(struct nvhost_as_map_buffer_ex_args)
 
 
 #endif