video: tegra: host: add kernel sync_fence i/f
Rakesh Iyer [Fri, 25 Oct 2013 22:37:07 +0000 (15:37 -0700)]
Add support for sync_fence interface for kernel modules.

Bug 1356564.

Change-Id: I851ac2e8abcc29d512ce4caf52ece502832f8742
Signed-off-by: Rakesh Iyer <riyer@nvidia.com>
Reviewed-on: http://git-master/r/336298
Reviewed-by: Jon Mayo <jmayo@nvidia.com>
Tested-by: Jon Mayo <jmayo@nvidia.com>

drivers/video/tegra/host/nvhost_syncpt.c
include/linux/nvhost.h

index 9b5d0e6..8249ebb 100644 (file)
@@ -829,6 +829,35 @@ int nvhost_syncpt_wait_timeout_ext(struct platform_device *dev, u32 id,
 }
 EXPORT_SYMBOL(nvhost_syncpt_wait_timeout_ext);
 
+int nvhost_syncpt_create_fence_single_ext(struct platform_device *dev,
+       u32 id, u32 thresh, const char *name, int *fence_fd)
+{
+#ifdef CONFIG_TEGRA_GRHOST_SYNC
+       struct platform_device *pdev;
+       struct nvhost_syncpt *sp;
+       struct nvhost_ctrl_sync_fence_info pts = {id, thresh};
+
+       if (!nvhost_get_parent(dev)) {
+               dev_err(&dev->dev, "Create Fence called with wrong dev\n");
+               return -EINVAL;
+       }
+
+       if (id == NVSYNCPT_INVALID) {
+               dev_err(&dev->dev, "Create Fence called with invalid id\n");
+               return -EINVAL;
+       }
+
+       /* get the parent */
+       pdev = to_platform_device(dev->dev.parent);
+       sp = &(nvhost_get_host(pdev)->syncpt);
+
+       return nvhost_sync_create_fence(sp, &pts, 1, name, fence_fd);
+#else
+       return -EINVAL;
+#endif
+}
+EXPORT_SYMBOL(nvhost_syncpt_create_fence_single_ext);
+
 void nvhost_syncpt_set_min_eq_max(struct nvhost_syncpt *sp, u32 id)
 {
        atomic_set(&sp->min_val[id], atomic_read(&sp->max_val[id]));
index 5b38771..06c2610 100644 (file)
@@ -338,6 +338,8 @@ void nvhost_syncpt_cpu_incr_ext(struct platform_device *dev, u32 id);
 u32 nvhost_syncpt_read_ext(struct platform_device *dev, u32 id);
 int nvhost_syncpt_wait_timeout_ext(struct platform_device *dev, u32 id, u32 thresh,
        u32 timeout, u32 *value, struct timespec *ts);
+int nvhost_syncpt_create_fence_single_ext(struct platform_device *dev,
+       u32 id, u32 thresh, const char *name, int *fence_fd);
 
 /* Hacky way to get access to struct nvhost_device_data for VI device. */
 extern struct nvhost_device_data t20_vi_info;