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
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 @@
* 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 == ðosu_buffer_fops;
@@ -90,11 +72,10 @@
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 @@
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 @@
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 @@
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: