]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: host: Extend syncpoint API
authorArto Merilainen <amerilainen@nvidia.com>
Wed, 5 Mar 2014 14:21:10 +0000 (16:21 +0200)
committerArto Merilainen <amerilainen@nvidia.com>
Tue, 25 Mar 2014 12:39:40 +0000 (05:39 -0700)
This patch extends syncpoint API to support some commonly used functions.
In addition, this patch modifies the current API so that it does not
require giving the host1x client device but it allows giving also host1x
device pointer directly.

Change-Id: Ie3ea53b0faaaa8209639a41f7c375b025b3a277e
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/378343
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
drivers/video/tegra/host/gk20a/debug_gk20a.c
drivers/video/tegra/host/nvhost_syncpt.c
drivers/video/tegra/host/nvhost_syncpt.h
include/linux/nvhost.h

index 82a59b8aae406efd3d969844865c5d72433b978e..c5b6953cfd02ba07a7f3bb32a6d26df52ad6da8f 100644 (file)
@@ -14,6 +14,7 @@
  *
  */
 
+#include <linux/nvhost.h>
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
 
@@ -21,7 +22,6 @@
 
 #include "gk20a.h"
 #include "debug_gk20a.h"
-#include "nvhost_syncpt.h"
 
 #include "hw_ram_gk20a.h"
 #include "hw_fifo_gk20a.h"
@@ -105,7 +105,6 @@ static void gk20a_debug_show_channel(struct gk20a *g,
        u32 status = ccsr_channel_status_v(channel);
        u32 syncpointa, syncpointb;
        void *inst_ptr;
-       struct nvhost_master *host = nvhost_get_host(g->dev);
 
        inst_ptr = ch->inst_block.cpuva;
        if (!inst_ptr)
@@ -147,7 +146,8 @@ static void gk20a_debug_show_channel(struct gk20a *g,
                        pbdma_syncpointb_wait_switch_en_v()))
                gk20a_debug_output(o, "Waiting on syncpt %u (%s) val %u\n",
                        pbdma_syncpointb_syncpt_index_v(syncpointb),
-                       get_syncpt_name(&host->syncpt,
+                       nvhost_syncpt_get_name(
+                               to_platform_device(g->dev->dev.parent),
                                pbdma_syncpointb_syncpt_index_v(syncpointb)),
                        pbdma_syncpointa_payload_v(syncpointa));
 
index bfdabae9b5dc780c28008626d95701b4c0ce821a..5c86670e18befaf02c9c4da43c53384be90927cb 100644 (file)
@@ -576,12 +576,17 @@ struct nvhost_sync_timeline *nvhost_syncpt_timeline(struct nvhost_syncpt *sp,
 }
 #endif
 
-const char *get_syncpt_name(struct nvhost_syncpt *sp, int id)
+const char *nvhost_syncpt_get_name(struct platform_device *pdev, int id)
 {
+       struct nvhost_master *host = nvhost_get_host(pdev);
+       struct nvhost_syncpt *sp = &host->syncpt;
        const char *name = NULL;
+
        name = sp->syncpt_names[id];
+
        return name ? name : "";
 }
+EXPORT_SYMBOL_GPL(nvhost_syncpt_get_name);
 
 static ssize_t syncpt_type_show(struct kobject *kobj,
                struct kobj_attribute *attr, char *buf)
@@ -604,7 +609,8 @@ static ssize_t syncpt_name_show(struct kobject *kobj,
                container_of(attr, struct nvhost_syncpt_attr, attr);
 
        return snprintf(buf, PAGE_SIZE, "%s\n",
-               get_syncpt_name(&syncpt_attr->host->syncpt, syncpt_attr->id));
+               nvhost_syncpt_get_name(syncpt_attr->host->dev,
+                                      syncpt_attr->id));
 }
 
 static ssize_t syncpt_min_show(struct kobject *kobj,
@@ -767,6 +773,7 @@ u32 nvhost_get_syncpt_host_managed(struct platform_device *pdev,
 
        return id;
 }
+EXPORT_SYMBOL_GPL(nvhost_get_syncpt_host_managed);
 
 /**
  * Interface to get a new free (client managed) syncpt dynamically
@@ -809,6 +816,7 @@ void nvhost_free_syncpt(u32 id)
 
        mutex_unlock(&sp->syncpt_mutex);
 }
+EXPORT_SYMBOL_GPL(nvhost_free_syncpt);
 
 static void nvhost_reserve_vblank_syncpts(struct nvhost_syncpt *sp)
 {
@@ -1058,36 +1066,16 @@ void nvhost_syncpt_set_manager(struct nvhost_syncpt *sp, int id, bool client)
 /* public sync point API */
 u32 nvhost_syncpt_incr_max_ext(struct platform_device *dev, u32 id, u32 incrs)
 {
-       struct platform_device *pdev;
-       struct nvhost_syncpt *sp;
-
-       if (!nvhost_get_parent(dev)) {
-               dev_err(&dev->dev, "Incr max called with wrong dev\n");
-               return 0;
-       }
-
-       /* get the parent */
-       pdev = to_platform_device(dev->dev.parent);
-       sp = &(nvhost_get_host(pdev)->syncpt);
-
+       struct nvhost_master *master = nvhost_get_host(dev);
+       struct nvhost_syncpt *sp = &master->syncpt;
        return nvhost_syncpt_incr_max(sp, id, incrs);
 }
 EXPORT_SYMBOL(nvhost_syncpt_incr_max_ext);
 
 void nvhost_syncpt_cpu_incr_ext(struct platform_device *dev, u32 id)
 {
-       struct platform_device *pdev;
-       struct nvhost_syncpt *sp;
-
-       if (!nvhost_get_parent(dev)) {
-               dev_err(&dev->dev, "Incr called with wrong dev\n");
-               return;
-       }
-
-       /* get the parent */
-       pdev = to_platform_device(dev->dev.parent);
-       sp = &(nvhost_get_host(pdev)->syncpt);
-
+       struct nvhost_master *master = nvhost_get_host(dev);
+       struct nvhost_syncpt *sp = &master->syncpt;
        nvhost_syncpt_cpu_incr(sp, id);
 }
 EXPORT_SYMBOL(nvhost_syncpt_cpu_incr_ext);
@@ -1104,37 +1092,26 @@ void nvhost_syncpt_cpu_set_wait_base(struct platform_device *pdev, u32 id,
 
 int nvhost_syncpt_read_ext_check(struct platform_device *dev, u32 id, u32 *val)
 {
-       struct platform_device *pdev;
-       struct nvhost_syncpt *sp;
-
-       if (!nvhost_get_parent(dev)) {
-               dev_err(&dev->dev, "Read called with wrong dev\n");
-               return -EINVAL;
-       }
-
-       /* get the parent */
-       pdev = to_platform_device(dev->dev.parent);
-       sp = &(nvhost_get_host(pdev)->syncpt);
-
+       struct nvhost_master *master = nvhost_get_host(dev);
+       struct nvhost_syncpt *sp = &master->syncpt;
        return nvhost_syncpt_read_check(sp, id, val);
 }
 EXPORT_SYMBOL(nvhost_syncpt_read_ext_check);
 
+int nvhost_syncpt_is_expired_ext(struct platform_device *dev,
+                                u32 id, u32 thresh)
+{
+       struct nvhost_master *master = nvhost_get_host(dev);
+       struct nvhost_syncpt *sp = &master->syncpt;
+       return nvhost_syncpt_is_expired(sp, id, thresh);
+}
+EXPORT_SYMBOL(nvhost_syncpt_is_expired_ext);
+
 int nvhost_syncpt_wait_timeout_ext(struct platform_device *dev, u32 id,
        u32 thresh, u32 timeout, u32 *value, struct timespec *ts)
 {
-       struct platform_device *pdev;
-       struct nvhost_syncpt *sp;
-
-       if (!nvhost_get_parent(dev)) {
-               dev_err(&dev->dev, "Wait called with wrong dev\n");
-               return -EINVAL;
-       }
-
-       /* get the parent */
-       pdev = to_platform_device(dev->dev.parent);
-       sp = &(nvhost_get_host(pdev)->syncpt);
-
+       struct nvhost_master *master = nvhost_get_host(dev);
+       struct nvhost_syncpt *sp = &master->syncpt;
        return nvhost_syncpt_wait_timeout(sp, id, thresh, timeout, value, ts,
                        false);
 }
@@ -1144,24 +1121,15 @@ 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;
-       }
+       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;
        }
 
-       /* get the parent */
-       pdev = to_platform_device(dev->dev.parent);
-       sp = &(nvhost_get_host(pdev)->syncpt);
-
        return nvhost_sync_create_fence_fd(sp, &pts, 1, name, fence_fd);
 #else
        return -EINVAL;
@@ -1169,6 +1137,24 @@ int nvhost_syncpt_create_fence_single_ext(struct platform_device *dev,
 }
 EXPORT_SYMBOL(nvhost_syncpt_create_fence_single_ext);
 
+void nvhost_syncpt_set_min_eq_max_ext(struct platform_device *dev, u32 id)
+{
+       struct nvhost_master *master = nvhost_get_host(dev);
+       struct nvhost_syncpt *sp = &master->syncpt;
+       atomic_set(&sp->min_val[id], atomic_read(&sp->max_val[id]));
+       syncpt_op().reset(sp, id);
+}
+EXPORT_SYMBOL(nvhost_syncpt_set_min_eq_max_ext);
+
+int nvhost_syncpt_nb_pts_ext(struct platform_device *dev)
+{
+       struct nvhost_master *master = nvhost_get_host(dev);
+       struct nvhost_syncpt *sp = &master->syncpt;
+
+       return syncpt_to_dev(sp)->info.nb_pts;
+}
+EXPORT_SYMBOL(nvhost_syncpt_nb_pts_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 4829c48931297479e0d8c7dd10fe97535f814724..4fae2c982b95f3451026f48174d9b964338f92de 100644 (file)
@@ -62,10 +62,6 @@ struct nvhost_syncpt {
 int nvhost_syncpt_init(struct platform_device *, struct nvhost_syncpt *);
 void nvhost_syncpt_deinit(struct nvhost_syncpt *);
 
-u32 nvhost_get_syncpt_host_managed(struct platform_device *pdata,
-                                  u32 param);
-void nvhost_free_syncpt(u32 id);
-
 #define syncpt_to_dev(sp) container_of(sp, struct nvhost_master, syncpt)
 #define SYNCPT_CHECK_PERIOD (2 * HZ)
 #define MAX_STUCK_CHECK_COUNT 15
@@ -109,7 +105,6 @@ int nvhost_syncpt_nb_pts(struct nvhost_syncpt *sp);
 int nvhost_syncpt_nb_bases(struct nvhost_syncpt *sp);
 int nvhost_syncpt_nb_mlocks(struct nvhost_syncpt *sp);
 void nvhost_syncpt_set_manager(struct nvhost_syncpt *sp, int id, bool client);
-const char *get_syncpt_name(struct nvhost_syncpt *sp, int id);
 
 /**
  * Returns true if syncpoint min == max
index ab6eb9d7ae7feca5c67080dc0d1735565b293083..ef44b5b2971a0336ce04b96a400d2a247c0effb4 100644 (file)
@@ -270,6 +270,10 @@ void nvhost_module_idle_ext(struct platform_device *dev);
 
 /* public host1x sync-point management APIs */
 u32 nvhost_get_syncpt_client_managed(const char *syncpt_name);
+u32 nvhost_get_syncpt_host_managed(struct platform_device *pdev,
+                                  u32 param);
+void nvhost_free_syncpt(u32 id);
+const char *nvhost_syncpt_get_name(struct platform_device *dev, int id);
 u32 nvhost_syncpt_incr_max_ext(struct platform_device *dev, u32 id, u32 incrs);
 void nvhost_syncpt_cpu_incr_ext(struct platform_device *dev, u32 id);
 int nvhost_syncpt_read_ext_check(struct platform_device *dev, u32 id, u32 *val);
@@ -277,6 +281,10 @@ int nvhost_syncpt_wait_timeout_ext(struct platform_device *dev, u32 id, u32 thre
        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);
+int nvhost_syncpt_is_expired_ext(struct platform_device *dev,
+       u32 id, u32 thresh);
+void nvhost_syncpt_set_min_eq_max_ext(struct platform_device *dev, u32 id);
+int nvhost_syncpt_nb_pts_ext(struct platform_device *dev);
 
 /* public host1x interrupt management APIs */
 int nvhost_intr_register_notifier(struct platform_device *pdev,