]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: host: Publish sync API
authorArto Merilainen <amerilainen@nvidia.com>
Thu, 6 Mar 2014 11:19:23 +0000 (13:19 +0200)
committerArto Merilainen <amerilainen@nvidia.com>
Tue, 25 Mar 2014 12:39:51 +0000 (05:39 -0700)
Currently, nvhost sync objects are considered private and they are
defined inside nvhost private headers. However, we may need to access
the internal data of the nvhost sync objects (hw syncpoint id and
threshold) as the hardware allows using this data directly from also
other devices.

Change-Id: I18dafd9d805ee85e9aa67cad91feb8a7f20950da
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/378344
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
drivers/video/tegra/dc/dc.c
drivers/video/tegra/host/bus_client.c
drivers/video/tegra/host/gk20a/channel_sync_gk20a.c
drivers/video/tegra/host/host1x/host1x.c
drivers/video/tegra/host/nvhost_sync.c
drivers/video/tegra/host/nvhost_sync.h
drivers/video/tegra/host/nvhost_syncpt.c
include/linux/nvhost.h

index f34ad5c4c95eb12ce007f4781b9838948194a99d..9e51d79db78264ce1f91ffcac8fcff0537a2210f 100644 (file)
@@ -1256,13 +1256,13 @@ void tegra_dc_incr_syncpt_min(struct tegra_dc *dc, int i, u32 val)
 struct sync_fence *tegra_dc_create_fence(struct tegra_dc *dc, int i, u32 val)
 {
        struct nvhost_ctrl_sync_fence_info syncpt;
-       struct nvhost_master *host = nvhost_get_host(dc->ndev);
        u32 id = tegra_dc_get_syncpt_id(dc, i);
 
        syncpt.id = id;
        syncpt.thresh = val;
-       return nvhost_sync_create_fence(&host->syncpt, &syncpt, 1,
-                       dev_name(&dc->ndev->dev));
+       return nvhost_sync_create_fence(
+                       to_platform_device(dc->ndev->dev.parent),
+                       &syncpt, 1, dev_name(&dc->ndev->dev));
 }
 
 void
index 7bb09897c7f953a30e462a35b20abf4ab614e795..41d2fe9f9617c3ec2a2509c504337bd3a62ef87d 100644 (file)
@@ -479,8 +479,7 @@ static int nvhost_ioctl_channel_submit(struct nvhost_channel_userctx *ctx,
                        pts[i].thresh = job->sp[i].fence;
                }
 
-               err = nvhost_sync_create_fence_fd(
-                               &nvhost_get_host(ctx->ch->dev)->syncpt,
+               err = nvhost_sync_create_fence_fd(ctx->ch->dev,
                                pts, num_syncpt_incrs, "fence", &args->fence);
                if (err)
                        goto fail;
index 0474bc3a04edcf58fdb00aebeed927d9bee8de29..4a31f0d38eed24cd6170937d5ce891acdcb00a9b 100644 (file)
@@ -301,7 +301,7 @@ int gk20a_channel_syncpt_incr_user_fd(struct gk20a_channel_sync *s,
                                                    &pt.id, &pt.thresh);
        if (err)
                return err;
-       return nvhost_sync_create_fence_fd(sp->sp, &pt, 1, "fence", fd);
+       return nvhost_sync_create_fence_fd(sp->c->g->dev, &pt, 1, "fence", fd);
 #else
        return -ENODEV;
 #endif
index d0cbef065c66ab2cb77ab9e35ae6a4918df039b9..b1e26c10cf90c440ddc4267cc2610d2ff5d40133 100644 (file)
@@ -227,8 +227,8 @@ static int nvhost_ioctl_ctrl_sync_fence_create(struct nvhost_ctrl_userctx *ctx,
                }
        }
 
-       err = nvhost_sync_create_fence_fd(&ctx->dev->syncpt, pts, args->num_pts,
-                                      name, &args->fence_fd);
+       err = nvhost_sync_create_fence_fd(ctx->dev->dev, pts, args->num_pts,
+                                         name, &args->fence_fd);
 out:
        kfree(pts);
        return err;
index 70df16be9d61c778361bb058cc2142cfcc49ed80..aa0139229dd71c6a0d721f49362694ad3e5d111a 100644 (file)
@@ -276,6 +276,7 @@ struct sync_fence *nvhost_sync_fdget(int fd)
 
        return fence;
 }
+EXPORT_SYMBOL(nvhost_sync_fdget);
 
 int nvhost_sync_num_pts(struct sync_fence *fence)
 {
@@ -288,18 +289,21 @@ int nvhost_sync_num_pts(struct sync_fence *fence)
 
        return num;
 }
+EXPORT_SYMBOL(nvhost_sync_num_pts);
 
 u32 nvhost_sync_pt_id(struct sync_pt *__pt)
 {
        struct nvhost_sync_pt *pt = to_nvhost_sync_pt(__pt);
        return pt->obj->id;
 }
+EXPORT_SYMBOL(nvhost_sync_pt_id);
 
 u32 nvhost_sync_pt_thresh(struct sync_pt *__pt)
 {
        struct nvhost_sync_pt *pt = to_nvhost_sync_pt(__pt);
        return pt->thresh;
 }
+EXPORT_SYMBOL(nvhost_sync_pt_thresh);
 
 /* Public API */
 
@@ -345,7 +349,7 @@ void nvhost_sync_pt_signal(struct nvhost_sync_pt *pt)
        sync_timeline_signal(&obj->obj);
 }
 
-int nvhost_sync_create_fence_fd(struct nvhost_syncpt *sp,
+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)
 {
@@ -353,7 +357,7 @@ int nvhost_sync_create_fence_fd(struct nvhost_syncpt *sp,
        int err;
        struct sync_fence *fence = NULL;
 
-       fence = nvhost_sync_create_fence(sp, pts, num_pts, name);
+       fence = nvhost_sync_create_fence(pdev, pts, num_pts, name);
 
        if (fence == NULL) {
                err = -EINVAL;
@@ -376,11 +380,14 @@ err:
 
        return err;
 }
+EXPORT_SYMBOL(nvhost_sync_create_fence_fd);
 
-struct sync_fence *nvhost_sync_create_fence(struct nvhost_syncpt *sp,
+struct sync_fence *nvhost_sync_create_fence(struct platform_device *pdev,
                struct nvhost_ctrl_sync_fence_info *pts,
                u32 num_pts, const char *name)
 {
+       struct nvhost_master *master = nvhost_get_host(pdev);
+       struct nvhost_syncpt *sp = &master->syncpt;
        int err;
        u32 i;
        struct sync_fence *fence = NULL;
@@ -435,3 +442,5 @@ err:
 
        return ERR_PTR(err);
 }
+EXPORT_SYMBOL(nvhost_sync_create_fence);
+
index 055f6e07ba05ab5f5bbea4c551bf1c6f6872336b..8d3fd2004152fc8e7eafc8d0c46a025aa0679f8e 100644 (file)
@@ -37,22 +37,6 @@ struct nvhost_sync_timeline *nvhost_sync_timeline_create(
 
 void nvhost_sync_pt_signal(struct nvhost_sync_pt *pt);
 
-int nvhost_sync_create_fence_fd(
-               struct nvhost_syncpt *sp,
-               struct nvhost_ctrl_sync_fence_info *pts,
-               u32 num_pts,
-               const char *name,
-               s32 *fence_fd);
-struct sync_fence *nvhost_sync_create_fence(
-               struct nvhost_syncpt *sp,
-               struct nvhost_ctrl_sync_fence_info *pts,
-               u32 num_pts,
-               const char *name);
-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);
-
 #else
 static inline struct nvhost_sync_timeline *nvhost_sync_timeline_create(
                struct nvhost_syncpt *sp,
@@ -66,45 +50,6 @@ static inline void nvhost_sync_pt_signal(struct nvhost_sync_pt *pt)
        return;
 }
 
-static inline int nvhost_sync_create_fence_fd(
-               struct nvhost_syncpt *sp,
-               struct nvhost_ctrl_sync_fence_info *pts,
-               u32 num_pts,
-               const char *name,
-               s32 *fence_fd)
-{
-       return -EINVAL;
-}
-
-static inline struct sync_fence *nvhost_sync_create_fence(
-               struct nvhost_syncpt *sp,
-               struct nvhost_ctrl_sync_fence_info *pts,
-               u32 num_pts,
-               const char *name)
-{
-       return ERR_PTR(-EINVAL);
-}
-
-static inline struct sync_fence *nvhost_sync_fdget(int fd)
-{
-       return NULL;
-}
-
-static inline int nvhost_sync_num_pts(struct sync_fence *fence)
-{
-       return 0;
-}
-
-static inline u32 nvhost_sync_pt_id(struct sync_pt *pt)
-{
-       return NVSYNCPT_INVALID;
-}
-
-static inline u32 nvhost_sync_pt_thresh(struct sync_pt *pt)
-{
-       return 0;
-}
-
 #endif
 
 #endif /* __KERNEL __ */
index 5c86670e18befaf02c9c4da43c53384be90927cb..f0b73bf6ed35fc3dc8a410aac3e7b1871144e394 100644 (file)
@@ -1122,15 +1122,13 @@ int nvhost_syncpt_create_fence_single_ext(struct platform_device *dev,
 {
 #ifdef CONFIG_TEGRA_GRHOST_SYNC
        struct nvhost_ctrl_sync_fence_info pts = {id, thresh};
-       struct nvhost_master *master = nvhost_get_host(dev);
-       struct nvhost_syncpt *sp = &master->syncpt;
 
        if (id == NVSYNCPT_INVALID) {
                dev_err(&dev->dev, "Create Fence called with invalid id\n");
                return -EINVAL;
        }
 
-       return nvhost_sync_create_fence_fd(sp, &pts, 1, name, fence_fd);
+       return nvhost_sync_create_fence_fd(dev, &pts, 1, name, fence_fd);
 #else
        return -EINVAL;
 #endif
index ef44b5b2971a0336ce04b96a400d2a247c0effb4..ed1343c9e32daecd197a8421af01327d868f4e5c 100644 (file)
@@ -38,6 +38,10 @@ struct nvhost_device_power_attr;
 struct nvhost_device_profile;
 struct mem_mgr;
 struct nvhost_as_moduleops;
+struct nvhost_ctrl_sync_fence_info;
+struct nvhost_sync_timeline;
+struct nvhost_sync_pt;
+struct sync_pt;
 
 #define NVHOST_MODULE_MAX_CLOCKS               7
 #define NVHOST_MODULE_MAX_POWERGATE_IDS        2
@@ -307,6 +311,65 @@ void nvhost_debug_dump_device(struct platform_device *pdev);
 static inline void nvhost_debug_dump_device(struct platform_device *pdev) {}
 #endif
 
+#ifdef CONFIG_TEGRA_GRHOST_SYNC
+struct sync_fence *nvhost_sync_create_fence(
+               struct platform_device *pdev,
+               struct nvhost_ctrl_sync_fence_info *pts,
+               u32 num_pts,
+               const char *name);
+int nvhost_sync_create_fence_fd(
+               struct platform_device *pdev,
+               struct nvhost_ctrl_sync_fence_info *pts,
+               u32 num_pts,
+               const char *name,
+               s32 *fence_fd);
+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);
+
+#else
+static inline struct sync_fence *nvhost_sync_create_fence(
+               struct platform_device *pdev,
+               struct nvhost_ctrl_sync_fence_info *pts,
+               u32 num_pts,
+               const char *name)
+{
+       return ERR_PTR(-EINVAL);
+}
+
+static inline int nvhost_sync_create_fence_fd(
+               struct platform_device *pdev,
+               struct nvhost_ctrl_sync_fence_info *pts,
+               u32 num_pts,
+               const char *name,
+               s32 *fence_fd)
+{
+       return -EINVAL;
+}
+
+static inline struct sync_fence *nvhost_sync_fdget(int fd)
+{
+       return NULL;
+}
+
+static inline int nvhost_sync_num_pts(struct sync_fence *fence)
+{
+       return 0;
+}
+
+static inline u32 nvhost_sync_pt_id(struct sync_pt *pt)
+{
+       return NVSYNCPT_INVALID;
+}
+
+static inline u32 nvhost_sync_pt_thresh(struct sync_pt *pt)
+{
+       return 0;
+}
+
+#endif
+
 /* Hacky way to get access to struct nvhost_device_data for VI device. */
 extern struct nvhost_device_data t20_vi_info;
 extern struct nvhost_device_data t30_vi_info;