]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: host: ioctl to set fence name
authorDeepak Nibade <dnibade@nvidia.com>
Tue, 1 Apr 2014 10:53:19 +0000 (16:23 +0530)
committerTerje Bergstrom <tbergstrom@nvidia.com>
Thu, 10 Apr 2014 07:59:40 +0000 (00:59 -0700)
Add ioctl NVHOST_IOCTL_CTRL_SYNC_FENCE_SET_NAME to set
name for a sync fence

Bug 1473041

Change-Id: Iabc1c472f6fddc87dac75d3a37b75a83a834dc1e
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/391271
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>
drivers/video/tegra/host/host1x/host1x.c
drivers/video/tegra/host/nvhost_sync.c
include/linux/nvhost.h
include/linux/nvhost_ioctl.h

index 3f7920512d972ccfb32a63416fac22be13910862..f13200a06e5b755fa2b44c86e4a004dcf3cd0310 100644 (file)
@@ -235,6 +235,31 @@ out:
 #endif
 }
 
+static int nvhost_ioctl_ctrl_sync_fence_set_name(
+       struct nvhost_ctrl_userctx *ctx,
+       struct nvhost_ctrl_sync_fence_name_args *args)
+{
+#ifdef CONFIG_TEGRA_GRHOST_SYNC
+       int err;
+       char name[32];
+       const char __user *args_name =
+               (const char __user *)(uintptr_t)args->name;
+
+       if (args_name) {
+               if (strncpy_from_user(name, args_name, sizeof(name)) < 0)
+                       return -EFAULT;
+               name[sizeof(name) - 1] = '\0';
+       } else {
+               name[0] = '\0';
+       }
+
+       err = nvhost_sync_fence_set_name(args->fence_fd, name);
+       return err;
+#else
+       return -EINVAL;
+#endif
+}
+
 static int nvhost_ioctl_ctrl_module_mutex(struct nvhost_ctrl_userctx *ctx,
        struct nvhost_ctrl_module_mutex_args *args)
 {
@@ -402,6 +427,9 @@ static long nvhost_ctrlctl(struct file *filp,
        case NVHOST_IOCTL_CTRL_SYNC_FENCE_CREATE:
                err = nvhost_ioctl_ctrl_sync_fence_create(priv, (void *)buf);
                break;
+       case NVHOST_IOCTL_CTRL_SYNC_FENCE_SET_NAME:
+               err = nvhost_ioctl_ctrl_sync_fence_set_name(priv, (void *)buf);
+               break;
        case NVHOST_IOCTL_CTRL_MODULE_MUTEX:
                err = nvhost_ioctl_ctrl_module_mutex(priv, (void *)buf);
                break;
index aa0139229dd71c6a0d721f49362694ad3e5d111a..4bb4bd58be669188cb51e4ff305c4bbf9d9bdf5e 100644 (file)
@@ -349,6 +349,17 @@ void nvhost_sync_pt_signal(struct nvhost_sync_pt *pt)
        sync_timeline_signal(&obj->obj);
 }
 
+int nvhost_sync_fence_set_name(int fence_fd, const char *name)
+{
+       struct sync_fence *fence = nvhost_sync_fdget(fence_fd);
+       if (!fence)
+               return -EINVAL;
+       strlcpy(fence->name, name, sizeof(fence->name));
+       sync_fence_put(fence);
+       return 0;
+}
+EXPORT_SYMBOL(nvhost_sync_fence_set_name);
+
 int nvhost_sync_create_fence_fd(struct platform_device *pdev,
                struct nvhost_ctrl_sync_fence_info *pts,
                u32 num_pts, const char *name, int *fence_fd)
index 82d9eb0a0a5f9058037aadb85072a48fe67b6a6b..785192623104fe3b690c3723095e4756e57c8d9a 100644 (file)
@@ -314,6 +314,7 @@ struct sync_fence *nvhost_sync_fdget(int fd);
 int nvhost_sync_num_pts(struct sync_fence *fence);
 u32 nvhost_sync_pt_id(struct sync_pt *pt);
 u32 nvhost_sync_pt_thresh(struct sync_pt *pt);
+int nvhost_sync_fence_set_name(int fence_fd, const char *name);
 
 #else
 static inline struct sync_fence *nvhost_sync_create_fence(
@@ -355,6 +356,11 @@ static inline u32 nvhost_sync_pt_thresh(struct sync_pt *pt)
        return 0;
 }
 
+static inline int nvhost_sync_fence_set_name(int fence_fd, const char *name)
+{
+       return -EINVAL;
+}
+
 #endif
 
 /* Hacky way to get access to struct nvhost_device_data for VI device. */
index 372df5426b03208a7a20a06d44c046312912ec6e..91f3b7a08bd1ddce0cb7eed9341bfca2fd5372c6 100644 (file)
@@ -438,6 +438,11 @@ struct nvhost_ctrl_sync_fence_create_args {
        __u64 name; /* const char* */
 };
 
+struct nvhost_ctrl_sync_fence_name_args {
+       __u64 name; /* const char* for name */
+       __s32 fence_fd; /* fd of fence */
+};
+
 struct nvhost_ctrl_module_mutex_args {
        __u32 id;
        __u32 lock;
@@ -486,9 +491,11 @@ enum nvhost_module_id {
        _IOWR(NVHOST_IOCTL_MAGIC, 11, struct nvhost_ctrl_sync_fence_create_args)
 #define NVHOST_IOCTL_CTRL_MODULE_REGRDWR       \
        _IOWR(NVHOST_IOCTL_MAGIC, 12, struct nvhost_ctrl_module_regrdwr_args)
+#define NVHOST_IOCTL_CTRL_SYNC_FENCE_SET_NAME  \
+       _IOWR(NVHOST_IOCTL_MAGIC, 13, struct nvhost_ctrl_sync_fence_name_args)
 
 #define NVHOST_IOCTL_CTRL_LAST                 \
-       _IOC_NR(NVHOST_IOCTL_CTRL_MODULE_REGRDWR)
+       _IOC_NR(NVHOST_IOCTL_CTRL_SYNC_FENCE_SET_NAME)
 #define NVHOST_IOCTL_CTRL_MAX_ARG_SIZE \
        sizeof(struct nvhost_ctrl_syncpt_waitmex_args)