From fc6b594563d1ae04d2476d542bff08754252064c Mon Sep 17 00:00:00 2001 From: "Amit Sharma (SW-Tegra)" Date: Sat, 16 Sep 2017 11:44:54 +0530 Subject: [PATCH] tegra: host: nvdla: Add dump and trace buffer to nvdla_device Add dump and trace buffers to nvda_device as nvdla_device is correct place to keep them. Jira DLA-330 Change-Id: Id282e49e3586e67a3f57f2151c9f7c3590fa0e5b Signed-off-by: Amit Sharma (SW-Tegra) Reviewed-on: https://git-master.nvidia.com/r/1561392 Reviewed-by: svc-mobile-coverity GVS: Gerrit_Virtual_Submit Reviewed-by: svccoveritychecker Reviewed-by: Prashant Gaikwad Reviewed-by: Shridhar Rasal --- drivers/video/tegra/host/nvdla/nvdla.c | 91 ++++++++------------ drivers/video/tegra/host/nvdla/nvdla.h | 8 ++ drivers/video/tegra/host/nvdla/nvdla_debug.c | 18 +--- 3 files changed, 48 insertions(+), 69 deletions(-) diff --git a/drivers/video/tegra/host/nvdla/nvdla.c b/drivers/video/tegra/host/nvdla/nvdla.c index f405f5b9..514a5e32 100644 --- a/drivers/video/tegra/host/nvdla/nvdla.c +++ b/drivers/video/tegra/host/nvdla/nvdla.c @@ -51,7 +51,6 @@ int nvhost_nvdla_flcn_isr(struct platform_device *pdev) { uint32_t message; uint32_t mailbox0; - struct flcn *m = get_flcn(pdev); struct nvhost_device_data *pdata = platform_get_drvdata(pdev); struct nvdla_device *nvdla_dev = pdata->private_data; @@ -61,7 +60,8 @@ int nvhost_nvdla_flcn_isr(struct platform_device *pdev) message = mailbox0 & DLA_RESPONSE_MSG_MASK; if (message == DLA_MSG_DEBUG_PRINT) - dev_err(&pdev->dev, "falcon: %s", (char *)m->debug_dump_va); + dev_err(&pdev->dev, "falcon: %s", + (char *)nvdla_dev->debug_dump_va); if ((message == DLA_MSG_CMD_COMPLETE || message == DLA_MSG_CMD_ERROR) && @@ -227,32 +227,23 @@ int nvdla_send_cmd(struct platform_device *pdev, static int nvdla_alloc_trace_region(struct platform_device *pdev) { int err = 0; - struct flcn *m; struct nvdla_cmd_mem_info trace_cmd_mem_info; struct nvdla_cmd_data cmd_data; struct dla_region_printf *trace_region = NULL; struct nvhost_device_data *pdata = platform_get_drvdata(pdev); + struct nvdla_device *nvdla_dev = pdata->private_data; if (!pdata->flcn_isr) return 0; - nvdla_dbg_fn(pdev, ""); - - m = get_flcn(pdev); - if (!m) { - nvdla_dbg_err(pdev, "falcon is not booted!"); - err = -ENXIO; - goto falcon_not_booted; - } - /* Trace buffer allocation must be done at once only. */ - if (!m->trace_dump_va) { + if (!nvdla_dev->trace_dump_va) { /* allocate trace region */ - m->trace_dump_va = dma_alloc_attrs(&pdev->dev, - TRACE_BUFFER_SIZE, &m->trace_dump_pa, + nvdla_dev->trace_dump_va = dma_alloc_attrs(&pdev->dev, + TRACE_BUFFER_SIZE, &nvdla_dev->trace_dump_pa, GFP_KERNEL, __DMA_ATTR(attrs)); - if (!m->trace_dump_va) { + if (!nvdla_dev->trace_dump_va) { nvdla_dbg_err(pdev, "dma trace memory allocation failed"); err = -ENOMEM; @@ -271,7 +262,7 @@ static int nvdla_alloc_trace_region(struct platform_device *pdev) trace_region = (struct dla_region_printf *)(trace_cmd_mem_info.va); trace_region->region = DLA_REGION_TRACE; - trace_region->address = m->trace_dump_pa; + trace_region->address = nvdla_dev->trace_dump_pa; trace_region->size = TRACE_BUFFER_SIZE; cmd_data.method_id = DLA_CMD_SET_REGIONS; @@ -292,14 +283,15 @@ static int nvdla_alloc_trace_region(struct platform_device *pdev) trace_send_cmd_failed: alloc_trace_cmd_failed: - if (m->trace_dump_pa) { + if (nvdla_dev->trace_dump_pa) { dma_free_attrs(&pdev->dev, TRACE_BUFFER_SIZE, - m->trace_dump_va, m->trace_dump_pa, __DMA_ATTR(attrs)); - m->trace_dump_va = NULL; - m->trace_dump_pa = 0; + nvdla_dev->trace_dump_va, nvdla_dev->trace_dump_pa, + __DMA_ATTR(attrs)); + nvdla_dev->trace_dump_va = NULL; + + nvdla_dev->trace_dump_pa = 0; } fail_alloc_trace_dma: -falcon_not_booted: return err; } @@ -307,30 +299,23 @@ falcon_not_booted: static int nvdla_alloc_dump_region(struct platform_device *pdev) { int err = 0; - struct flcn *m; struct dla_region_printf *region; struct nvdla_cmd_mem_info debug_cmd_mem_info; struct nvdla_cmd_data cmd_data; struct nvhost_device_data *pdata = platform_get_drvdata(pdev); + struct nvdla_device *nvdla_dev = pdata->private_data; if (!pdata->flcn_isr) return 0; nvdla_dbg_fn(pdev, ""); - m = get_flcn(pdev); - if (!m) { - nvdla_dbg_err(pdev, "falcon is not booted!"); - err = -ENXIO; - goto fal_not_booted; - } - /* allocate dump region only once */ - if (!m->debug_dump_va) { - m->debug_dump_va = dma_alloc_attrs(&pdev->dev, - DEBUG_BUFFER_SIZE, &m->debug_dump_pa, + if (!nvdla_dev->debug_dump_va) { + nvdla_dev->debug_dump_va = dma_alloc_attrs(&pdev->dev, + DEBUG_BUFFER_SIZE, &nvdla_dev->debug_dump_pa, GFP_KERNEL, __DMA_ATTR(attrs)); - if (!m->debug_dump_va) { + if (!nvdla_dev->debug_dump_va) { nvdla_dbg_err(pdev, "debug dump dma alloc failed"); err = -ENOMEM; goto fail_to_alloc_debug_dump; @@ -348,9 +333,9 @@ static int nvdla_alloc_dump_region(struct platform_device *pdev) region->region = DLA_REGION_PRINTF; region->size = DEBUG_BUFFER_SIZE; #if CURRENT_FW_VERSION > FW_VERSION(0, 6, 0) - region->address = m->debug_dump_pa; + region->address = nvdla_dev->debug_dump_pa; #else - region->address = ALIGNED_DMA(m->debug_dump_pa); + region->address = ALIGNED_DMA(nvdla_dev->debug_dump_pa); #endif /* prepare command data */ @@ -373,15 +358,14 @@ static int nvdla_alloc_dump_region(struct platform_device *pdev) region_send_cmd_failed: set_region_failed: - if (m->debug_dump_pa) { + if (nvdla_dev->debug_dump_pa) { dma_free_attrs(&pdev->dev, DEBUG_BUFFER_SIZE, - m->debug_dump_va, m->debug_dump_pa, __DMA_ATTR(attrs)); - m->debug_dump_va = NULL; - m->debug_dump_pa = 0; + nvdla_dev->debug_dump_va, nvdla_dev->debug_dump_pa, + __DMA_ATTR(attrs)); + nvdla_dev->debug_dump_va = NULL; + nvdla_dev->debug_dump_pa = 0; } fail_to_alloc_debug_dump: -fal_not_booted: - return err; } @@ -658,29 +642,26 @@ static int __exit nvdla_remove(struct platform_device *pdev) { struct nvhost_device_data *pdata = platform_get_drvdata(pdev); struct nvdla_device *nvdla_dev = pdata->private_data; - struct flcn *m; nvhost_queue_deinit(nvdla_dev->pool); nvhost_client_device_release(pdev); - m = get_flcn(pdev); - if (!m) - return -ENXIO; - - if (m->trace_dump_pa) { + if (nvdla_dev->trace_dump_pa) { dma_free_attrs(&pdev->dev, TRACE_BUFFER_SIZE, - m->trace_dump_va, m->trace_dump_pa, + nvdla_dev->trace_dump_va, + nvdla_dev->trace_dump_pa, __DMA_ATTR(attrs)); - m->trace_dump_va = NULL; - m->trace_dump_pa = 0; + nvdla_dev->trace_dump_va = NULL; + nvdla_dev->trace_dump_pa = 0; } - if (m->debug_dump_pa) { + if (nvdla_dev->debug_dump_pa) { dma_free_attrs(&pdev->dev, DEBUG_BUFFER_SIZE, - m->debug_dump_va, m->debug_dump_pa, + nvdla_dev->debug_dump_va, + nvdla_dev->debug_dump_pa, __DMA_ATTR(attrs)); - m->debug_dump_va = NULL; - m->debug_dump_pa = 0; + nvdla_dev->debug_dump_va = NULL; + nvdla_dev->debug_dump_pa = 0; } /* free command mem in last */ diff --git a/drivers/video/tegra/host/nvdla/nvdla.h b/drivers/video/tegra/host/nvdla/nvdla.h index a55f3c2b..83b26c62 100644 --- a/drivers/video/tegra/host/nvdla/nvdla.h +++ b/drivers/video/tegra/host/nvdla/nvdla.h @@ -163,6 +163,10 @@ struct nvdla_cmd_data { * @trace_enable to enable/disable the DLA firmware trace * @events_mask mask to set/reset the different DLA firmware trace event * @is_gos_enabled flag to check if GoS enabled + * @debug_dump_pa physical address of print buffer + * @debug_dump_va virtual address of print buffer + * @trace_dump_pa physical address of trace buffer + * @trace_dump_va virtual address of trace buffer */ struct nvdla_device { struct platform_device *pdev; @@ -178,6 +182,10 @@ struct nvdla_device { u32 trace_enable; u32 events_mask; bool is_gos_enabled; + dma_addr_t debug_dump_pa; + u32 *debug_dump_va; + dma_addr_t trace_dump_pa; + u32 *trace_dump_va; }; /** diff --git a/drivers/video/tegra/host/nvdla/nvdla_debug.c b/drivers/video/tegra/host/nvdla/nvdla_debug.c index c1b73bb6..13da6703 100644 --- a/drivers/video/tegra/host/nvdla/nvdla_debug.c +++ b/drivers/video/tegra/host/nvdla/nvdla_debug.c @@ -81,7 +81,6 @@ static const struct file_operations nvdla_fw_ver_fops = { static int debug_dla_tracedump_show(struct seq_file *s, void *data) { char *bufptr; - struct flcn *m; struct nvdla_device *nvdla_dev; struct platform_device *pdev; uint32_t i = 0, cindex = 0; @@ -90,13 +89,9 @@ static int debug_dla_tracedump_show(struct seq_file *s, void *data) nvdla_dev = (struct nvdla_device *)s->private; pdev = nvdla_dev->pdev; - m = get_flcn(pdev); - if (!m) - return 0; - - if (m->trace_dump_va && nvdla_dev->trace_enable) { - bufptr = (char *)m->trace_dump_va; + if (nvdla_dev->trace_dump_va && nvdla_dev->trace_enable) { + bufptr = (char *)nvdla_dev->trace_dump_va; if (!strcmp(bufptr, "")) return 0; @@ -174,7 +169,6 @@ static int debug_dla_eventmask_help_show(struct seq_file *s, void *data) static int debug_dla_bintracedump_show(struct seq_file *s, void *data) { char *bufptr; - struct flcn *m; struct nvdla_device *nvdla_dev; struct platform_device *pdev; uint32_t i = 0; @@ -183,13 +177,9 @@ static int debug_dla_bintracedump_show(struct seq_file *s, void *data) nvdla_dev = (struct nvdla_device *)s->private; pdev = nvdla_dev->pdev; - m = get_flcn(pdev); - if (!m) - return 0; - - if (m->trace_dump_va && nvdla_dev->trace_enable) { - bufptr = (char *)m->trace_dump_va; + if (nvdla_dev->trace_dump_va && nvdla_dev->trace_enable) { + bufptr = (char *)nvdla_dev->trace_dump_va; if (!strcmp(bufptr, "")) return 0;