video: tegra: host: Syncpoints deliver waitbases
Arto Merilainen [Thu, 24 Jan 2013 07:52:32 +0000 (09:52 +0200)]
This patch adds support for delivering waitbase information as a part
of nvhost_job_syncpt structure. This removes hacks in timeout code.

Change-Id: I8b8543bf63836b2501ddd2575c895e26dc26036b
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/193785
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>

drivers/video/tegra/host/bus_client.c
drivers/video/tegra/host/gr3d/gr3d_t20.c
drivers/video/tegra/host/gr3d/gr3d_t30.c
drivers/video/tegra/host/host1x/host1x_channel.c
drivers/video/tegra/host/mpe/mpe.c
drivers/video/tegra/host/nvhost_cdma.c
drivers/video/tegra/host/nvhost_job.h
drivers/video/tegra/host/nvhost_syncpt.c
drivers/video/tegra/host/nvhost_syncpt.h

index 2177aed..bbb732f 100644 (file)
@@ -48,6 +48,7 @@
 #include "chip_support.h"
 #include "nvhost_acm.h"
 
+#include "nvhost_syncpt.h"
 #include "nvhost_channel.h"
 #include "nvhost_job.h"
 #include "nvhost_hwctx.h"
@@ -484,6 +485,7 @@ static int nvhost_ioctl_channel_submit(struct nvhost_channel_userctx *ctx,
        }
        job->sp->incrs = syncpt_incr.syncpt_incrs;
        job->hwctx_syncpt_idx = 0;
+       job->sp->waitbase = nvhost_syncpt_get_waitbase(job->ch, job->sp->id);
 
        trace_nvhost_channel_submit(ctx->ch->dev->name,
                job->num_gathers, job->num_relocs, job->num_waitchk,
index e2fc34f..06c8395 100644 (file)
@@ -487,6 +487,7 @@ int nvhost_gr3d_t20_read_reg(struct platform_device *dev,
 
        job->hwctx_syncpt_idx = 0;
        job->sp->id = h->h.syncpt;
+       job->sp->waitbase = h->h.waitbase;
        job->sp->incrs = syncpt_incrs;
        job->num_syncpts = 1;
        job->serialize = 1;
index ded6ae7..229bfbf 100644 (file)
@@ -532,6 +532,7 @@ int nvhost_gr3d_t30_read_reg(
 
        job->hwctx_syncpt_idx = 0;
        job->sp->id = h->h.syncpt;
+       job->sp->waitbase = h->h.waitbase;
        job->sp->incrs = syncpt_incrs;
        job->num_syncpts = 1;
        job->serialize = 1;
index ed5ffdb..2e80454 100644 (file)
@@ -436,7 +436,7 @@ static int host1x_save_context(struct nvhost_channel *ch)
        void *ref;
        void *ctx_waiter = NULL, *wakeup_waiter = NULL;
        struct nvhost_job *job;
-       u32 syncpt_id;
+       u32 syncpt_id, waitbase;
 
        ctx_waiter = nvhost_intr_alloc_waiter();
        wakeup_waiter = nvhost_intr_alloc_waiter();
@@ -463,6 +463,7 @@ static int host1x_save_context(struct nvhost_channel *ch)
        hwctx_to_save->valid = true;
        ch->cur_ctx = NULL;
        syncpt_id = hwctx_to_save->h->syncpt;
+       waitbase = hwctx_to_save->h->waitbase;
 
        syncpt_incrs = hwctx_to_save->save_incrs;
        syncpt_val = nvhost_syncpt_incr_max(&nvhost_get_host(ch->dev)->syncpt,
@@ -470,6 +471,7 @@ static int host1x_save_context(struct nvhost_channel *ch)
 
        job->hwctx_syncpt_idx = 0;
        job->sp->id = syncpt_id;
+       job->sp->waitbase = waitbase;
        job->sp->incrs = syncpt_incrs;
        job->sp->fence = syncpt_val;
        job->num_syncpts = 1;
index 75b697c..afd7166 100644 (file)
@@ -813,6 +813,7 @@ int nvhost_mpe_read_reg(struct platform_device *dev,
 
        job->hwctx_syncpt_idx = 0;
        job->sp->id = h->h.syncpt;
+       job->sp->waitbase = h->h.waitbase;
        job->sp->incrs = syncpt_incrs;
        job->num_syncpts = 1;
        job->serialize = 1;
index 9dd508c..171ed08 100644 (file)
@@ -266,7 +266,6 @@ void nvhost_cdma_update_sync_queue(struct nvhost_cdma *cdma,
 {
        u32 get_restart;
        struct nvhost_job *job = NULL;
-       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
        int nb_pts = nvhost_syncpt_nb_pts(syncpt);
        DECLARE_BITMAP(syncpt_used, nb_pts);
 
@@ -337,17 +336,13 @@ out:
                /* won't need a timeout when replayed */
                job->timeout = 0;
 
-               for (i = 0; i < job->num_syncpts; ++i)
+               for (i = 0; i < job->num_syncpts; ++i) {
                        nvhost_cdma_finalize_job_incrs(syncpt, job->sp + i);
 
-               /* synchronize wait base. only the channel syncpoint wait base
-                * is maintained */
-               if (job->sp[job->hwctx_syncpt_idx].id != NVSYNCPT_2D_0 &&
-                       pdata->waitbases[0]) {
-
-                       nvhost_syncpt_cpu_set_wait_base(dev,
-                               pdata->waitbases[0],
-                               job->sp[job->hwctx_syncpt_idx].fence);
+                       if (job->sp[i].waitbase != NVSYNCPT_INVALID)
+                               nvhost_syncpt_cpu_set_wait_base(dev,
+                                       job->sp[i].waitbase,
+                                       job->sp[i].fence);
                }
 
                /* cleanup push buffer */
index b222d86..a84181f 100644 (file)
@@ -43,6 +43,7 @@ struct nvhost_job_syncpt {
        u32 id;
        u32 incrs;
        u32 fence;
+       u32 waitbase;
 };
 
 /*
index 4a5501a..b3eaca3 100644 (file)
@@ -27,6 +27,7 @@
 #include "nvhost_acm.h"
 #include "dev.h"
 #include "chip_support.h"
+#include "nvhost_channel.h"
 
 #define MAX_SYNCPT_LENGTH      5
 
@@ -52,6 +53,20 @@ void nvhost_syncpt_reset(struct nvhost_syncpt *sp)
        wmb();
 }
 
+int nvhost_syncpt_get_waitbase(struct nvhost_channel *ch, int id)
+{
+       struct nvhost_device_data *pdata = platform_get_drvdata(ch->dev);
+       int i;
+       bool ret = false;
+       for (i = 0; i < NVHOST_MODULE_MAX_SYNCPTS && pdata->syncpts[i]; ++i)
+               ret |= (pdata->syncpts[i] == id);
+
+       if (!ret || (id == NVSYNCPT_2D_0))
+               return NVSYNCPT_INVALID;
+
+       return pdata->waitbases[0];
+}
+
 /**
  * Resets syncpoint and waitbase values of a
  * single client to sw shadows
index d9cd48d..10c8786 100644 (file)
@@ -121,6 +121,8 @@ static inline bool nvhost_syncpt_min_eq_max(struct nvhost_syncpt *sp, u32 id)
        return (min == max);
 }
 
+int nvhost_syncpt_get_waitbase(struct nvhost_channel *ch, int id);
+
 void nvhost_syncpt_cpu_incr(struct nvhost_syncpt *sp, u32 id);
 
 u32 nvhost_syncpt_update_min(struct nvhost_syncpt *sp, u32 id);