video: tegra: host: Add context switch to trace dump
Terje Bergstrom [Wed, 9 May 2012 11:55:28 +0000 (14:55 +0300)]
Add context switch to the ftrace dump.

Change-Id: I5df032273982b919fb94263cff38d8b8b6b6be45
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/101523
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Mayuresh Kulkarni <mkulkarni@nvidia.com>
Reviewed-by: Juha Tukkinen <jtukkinen@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/host1x/host1x_debug.c
drivers/video/tegra/host/mpe/mpe.c
drivers/video/tegra/host/nvhost_cdma.c
drivers/video/tegra/host/nvhost_cdma.h
include/trace/events/nvhost.h

index e70506d..3f70a4b 100644 (file)
@@ -91,45 +91,6 @@ struct nvhost_channel_userctx {
        int clientid;
 };
 
-/*
- * Write cmdbuf to ftrace output. Checks if cmdbuf contents should be output
- * and mmaps the cmdbuf contents if required.
- */
-static void trace_write_cmdbufs(struct nvhost_job *job)
-{
-       struct nvmap_handle_ref handle;
-       void *mem = NULL;
-       int i = 0;
-
-       for (i = 0; i < job->num_gathers; i++) {
-               struct nvhost_channel_gather *gather = &job->gathers[i];
-               if (nvhost_debug_trace_cmdbuf) {
-                       handle.handle = nvmap_id_to_handle(gather->mem_id);
-                       mem = nvmap_mmap(&handle);
-                       if (IS_ERR_OR_NULL(mem))
-                               mem = NULL;
-               };
-
-               if (mem) {
-                       u32 i;
-                       /*
-                        * Write in batches of 128 as there seems to be a limit
-                        * of how much you can output to ftrace at once.
-                        */
-                       for (i = 0; i < gather->words; i += TRACE_MAX_LENGTH) {
-                               trace_nvhost_channel_write_cmdbuf_data(
-                                       job->ch->dev->name,
-                                       gather->mem_id,
-                                       min(gather->words - i,
-                                           TRACE_MAX_LENGTH),
-                                       gather->offset + i * sizeof(u32),
-                                       mem);
-                       }
-                       nvmap_munmap(&handle, mem);
-               }
-       }
-}
-
 static int nvhost_channelrelease(struct inode *inode, struct file *filp)
 {
        struct nvhost_channel_userctx *priv = filp->private_data;
@@ -370,8 +331,6 @@ static int nvhost_ioctl_channel_flush(
                ctx->timeout = nvhost_debug_force_timeout_val;
        }
 
-       trace_write_cmdbufs(ctx->job);
-
        /* context switch if needed, and submit user's gathers to the channel */
        err = nvhost_channel_submit(ctx->job);
        args->value = ctx->job->syncpt_end;
index e3a887d..c0efac0 100644 (file)
@@ -137,8 +137,9 @@ static void save_push_v0(struct nvhost_hwctx *nctx, struct nvhost_cdma *cdma)
        struct host1x_hwctx_handler *p = host1x_hwctx_handler(ctx);
 
        nvhost_cdma_push_gather(cdma,
-                       (void *)NVHOST_CDMA_PUSH_GATHER_CTXSAVE,
-                       (void *)NVHOST_CDMA_PUSH_GATHER_CTXSAVE,
+                       nvhost_get_host(nctx->channel->dev)->nvmap,
+                       p->save_buf->handle,
+                       0,
                        nvhost_opcode_gather(p->save_size),
                        p->save_phys);
 }
index 01eac53..93d98df 100644 (file)
@@ -144,8 +144,9 @@ static void save_push_v1(struct nvhost_hwctx *nctx, struct nvhost_cdma *cdma)
                ctx->restore_phys);
        /* gather the save buffer */
        nvhost_cdma_push_gather(cdma,
-                       (void *)NVHOST_CDMA_PUSH_GATHER_CTXSAVE,
-                       (void *)NVHOST_CDMA_PUSH_GATHER_CTXSAVE,
+                       nvhost_get_host(nctx->channel->dev)->nvmap,
+                       p->save_buf->handle,
+                       0,
                        nvhost_opcode_gather(p->save_size),
                        p->save_phys);
 }
index 04c5d06..3ebf956 100644 (file)
@@ -144,6 +144,7 @@ static void submit_ctxrestore(struct nvhost_job *job)
        nvhost_cdma_push_gather(&ch->cdma,
                host->nvmap,
                nvmap_ref_to_handle(ctx->restore),
+               0,
                nvhost_opcode_gather(ctx->restore_size),
                ctx->restore_phys);
 
@@ -181,12 +182,14 @@ void submit_nullkickoff(struct nvhost_job *job, int user_syncpt_incrs)
 void submit_gathers(struct nvhost_job *job)
 {
        /* push user gathers */
-       int i = 0;
-       for ( ; i < job->num_gathers; i++) {
+       int i;
+       for (i = 0 ; i < job->num_gathers; i++) {
                u32 op1 = nvhost_opcode_gather(job->gathers[i].words);
                u32 op2 = job->gathers[i].mem;
                nvhost_cdma_push_gather(&job->ch->cdma,
-                               job->nvmap, job->unpins[i/2],
+                               job->nvmap,
+                               nvmap_id_to_handle(job->gathers[i].mem_id),
+                               job->gathers[i].offset,
                                op1, op2);
        }
 }
index 46ae9c1..39565bc 100644 (file)
@@ -174,11 +174,6 @@ static void show_channel_gather(struct output *o, u32 addr,
        phys_addr_t pin_addr;
        int state, count, i;
 
-       if ((u32)nvmap->handle == NVHOST_CDMA_PUSH_GATHER_CTXSAVE) {
-               nvhost_debug_output(o, "[context save]\n");
-               return;
-       }
-
        if (!nvmap->handle || !nvmap->client
                        || atomic_read(&nvmap->handle->ref) < 1) {
                nvhost_debug_output(o, "[already deallocated]\n");
index a7c2281..6111379 100644 (file)
@@ -499,7 +499,10 @@ static void ctxmpe_save_push(struct nvhost_hwctx *nctx,
 {
        struct host1x_hwctx *ctx = to_host1x_hwctx(nctx);
        struct host1x_hwctx_handler *h = host1x_hwctx_handler(ctx);
-       nvhost_cdma_push(cdma,
+       nvhost_cdma_push_gather(cdma,
+                       nvhost_get_host(nctx->channel->dev)->nvmap,
+                       h->save_buf->handle,
+                       0,
                        nvhost_opcode_gather(h->save_size),
                        h->save_phys);
 }
index f1f4405..57dc781 100644 (file)
@@ -23,6 +23,7 @@
 #include "nvhost_job.h"
 #include "nvhost_hwctx.h"
 #include "dev.h"
+#include "debug.h"
 #include <asm/cacheflush.h>
 
 #include <linux/slab.h>
@@ -399,13 +400,49 @@ int nvhost_cdma_begin(struct nvhost_cdma *cdma, struct nvhost_job *job)
        return 0;
 }
 
+static void trace_write_gather(struct nvhost_cdma *cdma,
+               struct nvmap_handle *handle,
+               u32 offset, u32 words)
+{
+       struct nvmap_handle_ref ref;
+       void *mem = NULL;
+
+       if (nvhost_debug_trace_cmdbuf) {
+               ref.handle = handle;
+               mem = nvmap_mmap(&ref);
+               if (IS_ERR_OR_NULL(mem))
+                       mem = NULL;
+       };
+
+       if (mem) {
+               u32 i;
+               /*
+                * Write in batches of 128 as there seems to be a limit
+                * of how much you can output to ftrace at once.
+                */
+               for (i = 0; i < words; i += TRACE_MAX_LENGTH) {
+                       trace_nvhost_cdma_push_gather(
+                               cdma_to_channel(cdma)->dev->name,
+                               (u32)handle,
+                               min(words - i, TRACE_MAX_LENGTH),
+                               offset + i * sizeof(u32),
+                               mem);
+               }
+               nvmap_munmap(&ref, mem);
+       }
+}
+
 /**
  * Push two words into a push buffer slot
  * Blocks as necessary if the push buffer is full.
  */
 void nvhost_cdma_push(struct nvhost_cdma *cdma, u32 op1, u32 op2)
 {
-       nvhost_cdma_push_gather(cdma, NULL, NULL, op1, op2);
+       if (nvhost_debug_trace_cmdbuf)
+               trace_nvhost_cdma_push(cdma_to_channel(cdma)->dev->name,
+                               op1, op2);
+
+       nvhost_cdma_push_gather(cdma, NULL, NULL, 0, op1, op2);
 }
 
 /**
@@ -414,12 +451,17 @@ void nvhost_cdma_push(struct nvhost_cdma *cdma, u32 op1, u32 op2)
  */
 void nvhost_cdma_push_gather(struct nvhost_cdma *cdma,
                struct nvmap_client *client,
-               struct nvmap_handle *handle, u32 op1, u32 op2)
+               struct nvmap_handle *handle,
+               u32 offset, u32 op1, u32 op2)
 {
        u32 slots_free = cdma->slots_free;
        struct push_buffer *pb = &cdma->push_buffer;
        BUG_ON(!cdma_pb_op(cdma).push_to);
        BUG_ON(!cdma_op(cdma).kick);
+
+       if (handle)
+               trace_write_gather(cdma, handle, offset, op1 & 0xffff);
+
        if (slots_free == 0) {
                cdma_op(cdma).kick(cdma);
                slots_free = nvhost_cdma_wait_locked(cdma,
index 9583fbb..d9dd25a 100644 (file)
@@ -114,10 +114,9 @@ void       nvhost_cdma_deinit(struct nvhost_cdma *cdma);
 void   nvhost_cdma_stop(struct nvhost_cdma *cdma);
 int    nvhost_cdma_begin(struct nvhost_cdma *cdma, struct nvhost_job *job);
 void   nvhost_cdma_push(struct nvhost_cdma *cdma, u32 op1, u32 op2);
-#define NVHOST_CDMA_PUSH_GATHER_CTXSAVE 0xffffffff
 void   nvhost_cdma_push_gather(struct nvhost_cdma *cdma,
                struct nvmap_client *client,
-               struct nvmap_handle *handle, u32 op1, u32 op2);
+               struct nvmap_handle *handle, u32 offset, u32 op1, u32 op2);
 void   nvhost_cdma_end(struct nvhost_cdma *cdma,
                struct nvhost_job *job);
 void   nvhost_cdma_update(struct nvhost_cdma *cdma);
index 4c44cdc..ad18853 100644 (file)
@@ -138,7 +138,28 @@ TRACE_EVENT(nvhost_channel_write_cmdbuf,
          __entry->words, __entry->offset)
 );
 
-TRACE_EVENT(nvhost_channel_write_cmdbuf_data,
+TRACE_EVENT(nvhost_cdma_push,
+       TP_PROTO(const char *name, u32 op1, u32 op2),
+
+       TP_ARGS(name, op1, op2),
+
+       TP_STRUCT__entry(
+               __field(const char *, name)
+               __field(u32, op1)
+               __field(u32, op2)
+       ),
+
+       TP_fast_assign(
+               __entry->name = name;
+               __entry->op1 = op1;
+               __entry->op2 = op2;
+       ),
+
+       TP_printk("name=%s, op1=%08x, op2=%08x",
+               __entry->name, __entry->op1, __entry->op2)
+);
+
+TRACE_EVENT(nvhost_cdma_push_gather,
        TP_PROTO(const char *name, u32 mem_id,
                        u32 words, u32 offset, void *cmdbuf),