summaryrefslogtreecommitdiff
path: root/drivers/nvdla
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/nvdla')
-rw-r--r--drivers/nvdla/bdma.c9
-rw-r--r--drivers/nvdla/cache.c3
-rw-r--r--drivers/nvdla/include/opendla.h10
-rw-r--r--drivers/nvdla/nvdla_core_callbacks.c14
-rw-r--r--drivers/nvdla/nvdla_gem.c22
-rw-r--r--drivers/nvdla/pdp.c2
-rw-r--r--drivers/nvdla/scheduler.c1
7 files changed, 56 insertions, 5 deletions
diff --git a/drivers/nvdla/bdma.c b/drivers/nvdla/bdma.c
index bbf73c585679..8a517410a024 100644
--- a/drivers/nvdla/bdma.c
+++ b/drivers/nvdla/bdma.c
@@ -133,6 +133,7 @@ processor_bdma_program_slot(struct dla_bdma_surface_desc *bdma_surface,
uint64_t destination_addr = 0;
uint32_t high, low, reg;
uint8_t bdma_free_slots = 0;
+ uint64_t bdma_len = 0;
struct dla_engine *engine = dla_get_engine();
dla_debug("Enter: %s\n", __func__);
@@ -196,6 +197,14 @@ processor_bdma_program_slot(struct dla_bdma_surface_desc *bdma_surface,
bdma_reg_write(CFG_DST_SURF, transfer->destination_surface);
bdma_reg_write(CFG_OP, FIELD_ENUM(BDMA_CFG_OP_0, EN, ENABLE));
+#ifdef CONFIG_NVDLA_NEED_FLUSH
+ bdma_len = (transfer->surface_repeat) * (transfer->source_surface); //???
+ nvdla_flush_dcache((unsigned long)source_addr,bdma_len);
+ nvdla_flush_dcache((unsigned long)destination_addr,bdma_len);
+ dla_info("%s():surface_repeat:%#x,source_surface:%#x bdmalen:%#llx\n",__func__,transfer->surface_repeat,transfer->source_surface,bdma_len);
+ dla_info("%s():dma_src_addr:%#llx,dma_dst_addr:%#llx \n",__func__,source_addr,destination_addr);
+#endif
+
dla_debug("Exit: %s\n", __func__);
exit:
diff --git a/drivers/nvdla/cache.c b/drivers/nvdla/cache.c
index c9ba1431dde4..eb1b454ef8ec 100644
--- a/drivers/nvdla/cache.c
+++ b/drivers/nvdla/cache.c
@@ -146,6 +146,9 @@ dla_get_op_desc(struct dla_task *task, int16_t index,
}
exit:
+ if (desc) {
+ nvdla_flush_dcache(dw_virt_to_phys((void *)desc), sizeof(*desc));
+ }
return desc;
}
diff --git a/drivers/nvdla/include/opendla.h b/drivers/nvdla/include/opendla.h
index 9985259713a3..41d7e30fb10d 100644
--- a/drivers/nvdla/include/opendla.h
+++ b/drivers/nvdla/include/opendla.h
@@ -29,10 +29,20 @@
#ifndef __OPENDLA_H_
#define __OPENDLA_H_
+#define DLA_2_CONFIG
+#define CONFIG_NVDLA_NEED_FLUSH
+
#ifdef DLA_2_CONFIG
#include <opendla_small.h>
#else
#include <opendla_initial.h>
#endif
+#ifdef CONFIG_NVDLA_NEED_FLUSH
+#include <soc/starfive/vic7100.h>
+#define nvdla_flush_dcache starfive_flush_dcache
+#else
+#define nvdla_flush_dcache
+#endif
+
#endif
diff --git a/drivers/nvdla/nvdla_core_callbacks.c b/drivers/nvdla/nvdla_core_callbacks.c
index 316d8b5b3f57..193496c5eb70 100644
--- a/drivers/nvdla/nvdla_core_callbacks.c
+++ b/drivers/nvdla/nvdla_core_callbacks.c
@@ -55,6 +55,7 @@
#include <nvdla_interface.h>
#include <nvdla_linux.h>
#include <nvdla_ioctl.h>
+#include <opendla.h>
static struct nvdla_config nvdla_config_os_initial = {
.atom_size = 32,
@@ -77,7 +78,6 @@ static struct nvdla_config nvdla_config_large = {
.weight_compress_support = false,
};
-
void dla_debug(const char *str, ...)
{
va_list args;
@@ -112,7 +112,9 @@ void dla_error(const char *str, ...)
void *dla_memset(void *src, int ch, uint64_t len)
{
- return memset(src, ch, len);
+ memset(src, ch, len);
+ nvdla_flush_dcache(dw_virt_to_phys(src),len);
+ return src;
}
void *dla_memcpy(void *dest, const void *src, uint64_t len)
@@ -228,7 +230,9 @@ int32_t dla_data_write(void *driver_context, void *task_data,
struct dma_buf *buf;
struct nvdla_mem_handle *handles;
struct nvdla_task *task = (struct nvdla_task *)task_data;
+ uint64_t dma_addr = 0;
+ dla_get_dma_address(driver_context, task_data,dst, (void *)&dma_addr, DESTINATION_DMA);
handles = task->address_list;
buf = dma_buf_get(handles[dst].handle);
if (IS_ERR(buf)) {
@@ -250,7 +254,9 @@ int32_t dla_data_write(void *driver_context, void *task_data,
}
+ nvdla_flush_dcache(dw_virt_to_phys(src),size);
memcpy((void *)((uint8_t *)ptr + offset), src, size);
+ nvdla_flush_dcache(dma_addr+offset,size);
dma_buf_vunmap(buf, ptr);
@@ -272,7 +278,9 @@ int32_t dla_data_read(void *driver_context, void *task_data,
struct dma_buf *buf;
struct nvdla_mem_handle *handles;
struct nvdla_task *task = (struct nvdla_task *)task_data;
+ uint64_t dma_addr = 0;
+ dla_get_dma_address(driver_context, task_data, src, (void *)&dma_addr, DESTINATION_DMA);
handles = task->address_list;
buf = dma_buf_get(handles[src].handle);
@@ -294,7 +302,9 @@ int32_t dla_data_read(void *driver_context, void *task_data,
goto end_cpu_access;
}
+ nvdla_flush_dcache(dma_addr+offset,size);
memcpy(dst, (void *)(((uint8_t *)ptr) + offset), size);
+ nvdla_flush_dcache(dw_virt_to_phys(dst),size);
dma_buf_vunmap(buf, ptr);
diff --git a/drivers/nvdla/nvdla_gem.c b/drivers/nvdla/nvdla_gem.c
index dd53ddea33f4..066e7626449d 100644
--- a/drivers/nvdla/nvdla_gem.c
+++ b/drivers/nvdla/nvdla_gem.c
@@ -39,10 +39,12 @@
#include <linux/dma-mapping.h>
#include <linux/dma-map-ops.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
#include <nvdla_linux.h>
#include <nvdla_ioctl.h>
-
+#include <opendla.h>
#define to_nvdla_obj(x) container_of(x, struct nvdla_gem_object, object)
struct nvdla_gem_object {
@@ -78,6 +80,7 @@ static int32_t nvdla_fill_task_desc(struct nvdla_ioctl_submit_task *local_task,
task->address_list = handles;
+ nvdla_flush_dcache(dw_virt_to_phys((void *)(task)),sizeof(*task));
return 0;
}
@@ -425,6 +428,8 @@ int32_t nvdla_drm_probe(struct nvdla_device *nvdla_dev)
int32_t err;
struct drm_device *drm;
struct drm_driver *driver = &nvdla_drm_driver;
+ struct resource res_cma;
+ struct device_node *node;
drm = drm_dev_alloc(driver, &nvdla_dev->pdev->dev);
if (IS_ERR(drm))
@@ -440,8 +445,19 @@ int32_t nvdla_drm_probe(struct nvdla_device *nvdla_dev)
* TODO Register separate driver for memory and use DT node to
* read memory range
*/
- err = dma_declare_coherent_memory(drm->dev, 0xD0000000, 0xD0000000,
- 0x28000000);
+ node = of_parse_phandle(drm->dev->of_node, "memory-region", 0);
+ if(node ){
+ dev_info(drm->dev, "Get mem from memory-region\n");
+ of_address_to_resource(node, 0, &res_cma);
+ err = dma_declare_coherent_memory(drm->dev, res_cma.start, res_cma.start,resource_size(&res_cma));
+ } else {
+ dev_info(drm->dev, "NVDLA using the default mem.\n");
+ err = dma_declare_coherent_memory(drm->dev, 0xC0000000, 0xC0000000, 0x40000000);
+ }
+
+ if (err < 0) {
+ goto unref;
+ }
return 0;
diff --git a/drivers/nvdla/pdp.c b/drivers/nvdla/pdp.c
index a23efbc94913..fc98fd7ad386 100644
--- a/drivers/nvdla/pdp.c
+++ b/drivers/nvdla/pdp.c
@@ -36,7 +36,9 @@
#include "engine_debug.h"
#define MAX_SPLIT_NUM 64
+#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a[0])))
+#endif
static const uint8_t map_ram[] = {
FIELD_ENUM(PDP_RDMA_D_SRC_RAM_CFG_0, SRC_RAM_TYPE, MC),
diff --git a/drivers/nvdla/scheduler.c b/drivers/nvdla/scheduler.c
index f36a5c789c4b..22de69c97fc5 100644
--- a/drivers/nvdla/scheduler.c
+++ b/drivers/nvdla/scheduler.c
@@ -1100,6 +1100,7 @@ dla_execute_task(void *engine_context, void *task_data, void *config_data)
if (ret)
goto complete;
+ nvdla_flush_dcache(dw_virt_to_phys((void *)engine), sizeof(*engine));
dla_debug_address_info(engine->task);
/**