aboutsummaryrefslogtreecommitdiff
path: root/kernel/ethosu_buffer.c
diff options
context:
space:
mode:
authorKristofer Jonsson <kristofer.jonsson@arm.com>2023-01-23 13:05:36 +0100
committerKristofer Jonsson <kristofer.jonsson@arm.com>2023-02-02 16:30:40 +0100
commit074ef905e834cff238e708f2e673e100884218ba (patch)
treea99762832b461441b0319e984b3ecdb908efe433 /kernel/ethosu_buffer.c
parentec47704ab3fd50a9ef8339f33139ddae4caa00b6 (diff)
downloadethos-u-linux-driver-stack-074ef905e834cff238e708f2e673e100884218ba.tar.gz
Create device for Ethos-U kernel driver
When the Ethos-U kernel driver is probed it creates a /dev/ethosu<nr> device node, which user space use ioctl to communicate with. When the driver is removed the Ethos-U resources must live on until all open file handles have been closed. The rpmsg device can be removed for a number of reasons, for example if the firmware is stopped or the remoteproc driver is removed. To allow the remove to complete without waiting for all file handles to close, a new 'struct device' is created by the kernel driver. This device will be used to memory allocations and will live on until the last file handle has been closed. Change-Id: I790d8219960f25fe64f58c11a865eb65c7b08974
Diffstat (limited to 'kernel/ethosu_buffer.c')
-rw-r--r--kernel/ethosu_buffer.c28
1 files changed, 4 insertions, 24 deletions
diff --git a/kernel/ethosu_buffer.c b/kernel/ethosu_buffer.c
index 0fcbf3b..fb4a8b4 100644
--- a/kernel/ethosu_buffer.c
+++ b/kernel/ethosu_buffer.c
@@ -62,24 +62,6 @@ static const struct file_operations ethosu_buffer_fops = {
* Functions
****************************************************************************/
-__attribute__((used))
-static dma_addr_t ethosu_pa_to_da(struct device *dev,
- phys_addr_t pa,
- size_t len)
-{
- struct rproc *rproc = rproc_get_by_child(dev);
- struct rproc_mem_entry *mem;
-
- list_for_each_entry(mem, &rproc->carveouts, node) {
- ssize_t offset = pa - mem->dma;
-
- if (offset >= 0 && offset + len <= mem->len)
- return mem->da + offset;
- }
-
- return (dma_addr_t)-1;
-}
-
static bool ethosu_buffer_verify(struct file *file)
{
return file->f_op == &ethosu_buffer_fops;
@@ -90,11 +72,10 @@ static void ethosu_buffer_destroy(struct kref *kref)
struct ethosu_buffer *buf =
container_of(kref, struct ethosu_buffer, kref);
struct device *dev = buf->dev;
- struct rproc *rproc = rproc_get_by_child(dev);
- dev_info(dev, "Buffer destroy. buf=0x%pK\n", buf);
+ dev_info(dev, "Buffer destroy. buf=0x%pK", buf);
- dma_free_coherent(rproc->dev.parent, buf->capacity, buf->cpu_addr,
+ dma_free_coherent(dev, buf->capacity, buf->cpu_addr,
buf->dma_addr);
devm_kfree(dev, buf);
@@ -192,7 +173,6 @@ static long ethosu_buffer_ioctl(struct file *file,
int ethosu_buffer_create(struct device *dev,
size_t capacity)
{
- struct rproc *rproc = rproc_get_by_child(dev);
struct ethosu_buffer *buf;
int ret = -ENOMEM;
@@ -209,7 +189,7 @@ int ethosu_buffer_create(struct device *dev,
buf->size = 0;
kref_init(&buf->kref);
- buf->cpu_addr = dma_alloc_coherent(rproc->dev.parent, capacity,
+ buf->cpu_addr = dma_alloc_coherent(dev, capacity,
&buf->dma_addr, GFP_KERNEL);
if (!buf->cpu_addr)
goto free_buf;
@@ -230,7 +210,7 @@ int ethosu_buffer_create(struct device *dev,
return ret;
free_dma:
- dma_free_coherent(rproc->dev.parent, buf->capacity, buf->cpu_addr,
+ dma_free_coherent(dev, buf->capacity, buf->cpu_addr,
buf->dma_addr);
free_buf: