diff options
Diffstat (limited to 'drivers/video/tegra/host/nvhost_cdma.c')
-rw-r--r-- | drivers/video/tegra/host/nvhost_cdma.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/drivers/video/tegra/host/nvhost_cdma.c b/drivers/video/tegra/host/nvhost_cdma.c index f1f4405d0745..57dc781d7af6 100644 --- a/drivers/video/tegra/host/nvhost_cdma.c +++ b/drivers/video/tegra/host/nvhost_cdma.c @@ -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, |