video: tegra: host: Return a sync fd as fence
Terje Bergstrom [Tue, 10 Sep 2013 07:35:00 +0000 (10:35 +0300)]
Add a flag to submit interface to get the fence as sync fd instead of
a pair of sync point id and value.

Bug 1356557

Change-Id: Id0ac9d6fe40fcc8768edcaedee0832a45cacc50d
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/288797
Reviewed-by: Automatic_Commit_Validation_User

drivers/video/tegra/host/bus_client.c
include/linux/nvhost_ioctl.h

index e2a1ecd..5e8b3ff 100644 (file)
@@ -54,6 +54,7 @@
 #include "nvhost_job.h"
 #include "nvhost_hwctx.h"
 #include "user_hwctx.h"
+#include "nvhost_sync.h"
 
 static int validate_reg(struct platform_device *ndev, u32 offset, int count)
 {
@@ -568,7 +569,20 @@ static int nvhost_ioctl_channel_submit(struct nvhost_channel_userctx *ctx,
        /* Deliver the fence using the old mechanism _only_ if a single
         * syncpoint is used. */
 
-       if (num_syncpt_incrs == 1)
+       if (args->flags & BIT(NVHOST_SUBMIT_FLAG_SYNC_FENCE_FD)) {
+               struct nvhost_ctrl_sync_fence_info pts[num_syncpt_incrs];
+
+               for (i = 0; i < num_syncpt_incrs; i++) {
+                       pts[i].id = job->sp[i].id;
+                       pts[i].thresh = job->sp[i].fence;
+               }
+
+               err = nvhost_sync_create_fence(
+                               &nvhost_get_host(ctx->ch->dev)->syncpt,
+                               pts, num_syncpt_incrs, "fence", &args->fence);
+               if (err)
+                       goto fail;
+       } else if (num_syncpt_incrs == 1)
                args->fence = job->sp[job->hwctx_syncpt_idx].fence;
        else
                args->fence = 0;
index dd903ca..e008826 100644 (file)
@@ -277,6 +277,8 @@ struct nvhost32_submit_args {
        __u32 fence;            /* Return value */
 } __packed;
 
+#define NVHOST_SUBMIT_FLAG_SYNC_FENCE_FD       0
+
 struct nvhost_submit_args {
        __u32 submit_version;
        __u32 num_syncpt_incrs;
@@ -287,8 +289,10 @@ struct nvhost_submit_args {
        __u32 syncpt_incrs;
        __u32 fence;            /* Return value */
        __u64 cmdbuf_exts;
+       __u32 flags;
 
-       __u64 pad[3];           /* future expansion */
+       __u32 reserved;
+       __u64 pad[2];           /* future expansion */
 
        __u64 cmdbufs;
        __u64 relocs;