aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Olsson <mikael.olsson@arm.com>2023-06-12 15:00:41 +0200
committerMikael Olsson <mikael.olsson@arm.com>2023-08-09 15:11:10 +0200
commitf1cfe19a5fd6ccc07e6e86cbe5ab863f4b372418 (patch)
treec1528ff663b9a4f3ccd16ed7aa17a021e67ca173
parent7c843dc763a175269e810510af57b658ae81c529 (diff)
downloadethos-u-linux-driver-stack-f1cfe19a5fd6ccc07e6e86cbe5ab863f4b372418.tar.gz
Add kernel driver version to UAPI
The kernel driver's version is now exposed in the UAPI so the UAPI user can validate that they are compatible with the kernel driver in use. Change-Id: I52d096dfaedb8c3c1889d27a907626be96779ee7 Signed-off-by: Mikael Olsson <mikael.olsson@arm.com>
-rw-r--r--kernel/ethosu_device.c11
-rw-r--r--kernel/ethosu_driver.c12
-rw-r--r--kernel/uapi/ethosu.h19
3 files changed, 41 insertions, 1 deletions
diff --git a/kernel/ethosu_device.c b/kernel/ethosu_device.c
index 0df6c07..7ad2a28 100644
--- a/kernel/ethosu_device.c
+++ b/kernel/ethosu_device.c
@@ -252,6 +252,17 @@ static long ethosu_ioctl(struct file *file,
file, cmd, arg);
switch (cmd) {
+ case ETHOSU_IOCTL_DRIVER_VERSION_GET: {
+ const struct ethosu_uapi_kernel_driver_version version = {
+ .major = ETHOSU_KERNEL_DRIVER_VERSION_MAJOR,
+ .minor = ETHOSU_KERNEL_DRIVER_VERSION_MINOR,
+ .patch = ETHOSU_KERNEL_DRIVER_VERSION_PATCH,
+ };
+
+ ret = copy_to_user(udata, &version,
+ sizeof(version)) ? -EFAULT : 0;
+ break;
+ }
case ETHOSU_IOCTL_CAPABILITIES_REQ: {
dev_info(dev, "Device ioctl: Capabilities request");
diff --git a/kernel/ethosu_driver.c b/kernel/ethosu_driver.c
index f35c5e5..085b2c0 100644
--- a/kernel/ethosu_driver.c
+++ b/kernel/ethosu_driver.c
@@ -27,12 +27,22 @@
#include <linux/rpmsg.h>
#include "ethosu_device.h"
+#include "uapi/ethosu.h"
/****************************************************************************
* Defines
****************************************************************************/
-#define ETHOSU_DRIVER_VERSION "1.0"
+#define ETHOSU_DRIVER_STR(s) #s
+#define ETHOSU_DRIVER_VERSION_STR(major, minor, patch) \
+ ETHOSU_DRIVER_STR(major) "." \
+ ETHOSU_DRIVER_STR(minor) "." \
+ ETHOSU_DRIVER_STR(patch)
+#define ETHOSU_DRIVER_VERSION ETHOSU_DRIVER_VERSION_STR( \
+ ETHOSU_KERNEL_DRIVER_VERSION_MAJOR, \
+ ETHOSU_KERNEL_DRIVER_VERSION_MINOR, \
+ ETHOSU_KERNEL_DRIVER_VERSION_PATCH)
+
#define ETHOSU_DRIVER_NAME "ethosu"
#define MINOR_BASE 0 /* Minor version starts at 0 */
diff --git a/kernel/uapi/ethosu.h b/kernel/uapi/ethosu.h
index 2451623..d82c901 100644
--- a/kernel/uapi/ethosu.h
+++ b/kernel/uapi/ethosu.h
@@ -45,6 +45,8 @@ namespace EthosU {
#define ETHOSU_IOCTL_PING ETHOSU_IO(0x00)
#define ETHOSU_IOCTL_CAPABILITIES_REQ ETHOSU_IOR(0x02, \
struct ethosu_uapi_device_capabilities)
+#define ETHOSU_IOCTL_DRIVER_VERSION_GET ETHOSU_IOR(0x03, \
+ struct ethosu_uapi_kernel_driver_version)
#define ETHOSU_IOCTL_BUFFER_CREATE ETHOSU_IOR(0x10, \
struct ethosu_uapi_buffer_create)
#define ETHOSU_IOCTL_BUFFER_SET ETHOSU_IOR(0x11, \
@@ -68,6 +70,11 @@ namespace EthosU {
/* Maximum number of PMUs available */
#define ETHOSU_PMU_EVENT_MAX 8
+/* Kernel driver version */
+#define ETHOSU_KERNEL_DRIVER_VERSION_MAJOR 1
+#define ETHOSU_KERNEL_DRIVER_VERSION_MINOR 0
+#define ETHOSU_KERNEL_DRIVER_VERSION_PATCH 0
+
/****************************************************************************
* Types
****************************************************************************/
@@ -85,6 +92,18 @@ enum ethosu_uapi_status {
};
/**
+ * struct ethosu_uapi_kernel_driver_version - Kernel driver version
+ * @major: Major version
+ * @minor: Minor version
+ * @patch: Patch version
+ */
+struct ethosu_uapi_kernel_driver_version {
+ __u32 major;
+ __u32 minor;
+ __u32 patch;
+};
+
+/**
* struct ethosu_uapi_buffer_create - Create buffer request
* @capacity: Maximum capacity of the buffer
*/