aboutsummaryrefslogtreecommitdiff
path: root/kernel/ethosu_driver.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_driver.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_driver.c')
-rw-r--r--kernel/ethosu_driver.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/kernel/ethosu_driver.c b/kernel/ethosu_driver.c
index 6e5bfb9..342f501 100644
--- a/kernel/ethosu_driver.c
+++ b/kernel/ethosu_driver.c
@@ -38,8 +38,6 @@
#define MINOR_BASE 0 /* Minor version starts at 0 */
#define MINOR_COUNT 64 /* Allocate minor versions */
-#define DMA_ADDR_BITS 32 /* Number of address bits */
-
/****************************************************************************
* Variables
****************************************************************************/
@@ -48,8 +46,6 @@ static struct class *ethosu_class;
static dev_t devt;
-static DECLARE_BITMAP(minors, MINOR_COUNT);
-
/****************************************************************************
* Rpmsg driver
****************************************************************************/
@@ -57,35 +53,24 @@ static DECLARE_BITMAP(minors, MINOR_COUNT);
static int ethosu_rpmsg_probe(struct rpmsg_device *rpdev)
{
struct device *dev = &rpdev->dev;
- int minor;
int ret;
- /* Reserve minor number for device node */
- minor = find_first_zero_bit(minors, MINOR_COUNT);
- if (minor >= MINOR_COUNT) {
- dev_err(dev, "No more minor numbers.");
-
- return -ENOMEM;
- }
+ dev_info(dev, "%s", __FUNCTION__);
/* Initialize device */
- ret = ethosu_dev_init(rpdev, ethosu_class, MKDEV(MAJOR(devt), minor));
+ ret = ethosu_dev_init(rpdev, ethosu_class, devt);
if (ret)
return ret;
- set_bit(minor, minors);
-
return 0;
}
static void ethosu_rpmsg_remove(struct rpmsg_device *rpdev)
{
struct device *dev = &rpdev->dev;
- struct ethosu_device *edev = dev_get_drvdata(dev);
dev_info(dev, "%s", __FUNCTION__);
- clear_bit(MINOR(edev->devt), minors);
ethosu_dev_deinit(rpdev);
}