From: Alison Wang <alison.wang@nxp.com>
To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Cc: leoyang.li@nxp.com, xuelin.shi@nxp.com, xiaofeng.ren@nxp.com,
feng.guo@nxp.com, Alison Wang <alison.wang@nxp.com>
Subject: [PATCH 3/8] ethosu: Add inference type option for model and op
Date: Fri, 16 Jun 2023 13:59:08 +0800 [thread overview]
Message-ID: <20230616055913.2360-4-alison.wang@nxp.com> (raw)
In-Reply-To: <20230616055913.2360-1-alison.wang@nxp.com>
This patch adds inference type option for model and op.
Signed-off-by: Feng Guo <feng.guo@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
---
drivers/firmware/ethosu/ethosu_core_interface.h | 6 +++++-
drivers/firmware/ethosu/ethosu_inference.c | 14 +++++++++++++-
drivers/firmware/ethosu/ethosu_inference.h | 1 +
drivers/firmware/ethosu/ethosu_rpmsg.c | 4 +++-
drivers/firmware/ethosu/ethosu_rpmsg.h | 3 ++-
drivers/firmware/ethosu/uapi/ethosu.h | 11 ++++++++++-
6 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/drivers/firmware/ethosu/ethosu_core_interface.h b/drivers/firmware/ethosu/ethosu_core_interface.h
index ef63c3b55352..b60508e4792f 100644
--- a/drivers/firmware/ethosu/ethosu_core_interface.h
+++ b/drivers/firmware/ethosu/ethosu_core_interface.h
@@ -35,13 +35,16 @@ namespace EthosU {
#define ETHOSU_CORE_BUFFER_MAX 16
/** Maximum number of PMU counters to be returned for inference */
-#define ETHOSU_CORE_PMU_MAX 8
+#define ETHOSU_CORE_PMU_MAX 4
#define ETHOSU_CORE_MSG_MAGIC 0x41457631
#define ETHOSU_CORE_MSG_VERSION_MAJOR 0
#define ETHOSU_CORE_MSG_VERSION_MINOR 2
#define ETHOSU_CORE_MSG_VERSION_PATCH 0
+#define ETHOSU_CORE_INFERENCE_MODEL 0
+#define ETHOSU_CORE_INFERENCE_OP 1
+
/**
* enum ethosu_core_msg_type - Message types
*
@@ -107,6 +110,7 @@ struct ethosu_core_inference_req {
struct ethosu_core_buffer network;
uint8_t pmu_event_config[ETHOSU_CORE_PMU_MAX];
uint32_t pmu_cycle_counter_enable;
+ uint32_t inference_type;
};
struct ethosu_core_inference_rsp {
diff --git a/drivers/firmware/ethosu/ethosu_inference.c b/drivers/firmware/ethosu/ethosu_inference.c
index 853947a2334e..b5e94e19bce0 100644
--- a/drivers/firmware/ethosu/ethosu_inference.c
+++ b/drivers/firmware/ethosu/ethosu_inference.c
@@ -92,7 +92,8 @@ static int ethosu_inference_send(struct ethosu_inference *inf)
inf->net->buf,
inf->pmu_event_config,
ETHOSU_PMU_EVENT_MAX,
- inf->pmu_cycle_counter_enable);
+ inf->pmu_cycle_counter_enable,
+ inf->inference_type);
if (ret)
return ret;
@@ -233,6 +234,17 @@ int ethosu_inference_create(struct ethosu_device *edev,
inf = devm_kzalloc(edev->dev, sizeof(*inf), GFP_KERNEL);
if (!inf)
return -ENOMEM;
+ switch (uapi->inference_type) {
+ case ETHOSU_UAPI_INFERENCE_MODEL:
+ inf->inference_type = ETHOSU_CORE_INFERENCE_MODEL;
+ break;
+ case ETHOSU_UAPI_INFERENCE_OP:
+ inf->inference_type = ETHOSU_CORE_INFERENCE_OP;
+ break;
+ default:
+ inf->inference_type = ETHOSU_CORE_INFERENCE_MODEL;
+ break;
+ }
inf->edev = edev;
inf->net = net;
diff --git a/drivers/firmware/ethosu/ethosu_inference.h b/drivers/firmware/ethosu/ethosu_inference.h
index 07370ca01f22..8414eadbda92 100644
--- a/drivers/firmware/ethosu/ethosu_inference.h
+++ b/drivers/firmware/ethosu/ethosu_inference.h
@@ -74,6 +74,7 @@ struct ethosu_inference {
uint32_t pmu_event_count[ETHOSU_PMU_EVENT_MAX];
uint32_t pmu_cycle_counter_enable;
uint64_t pmu_cycle_counter_count;
+ uint32_t inference_type;
struct list_head list;
};
diff --git a/drivers/firmware/ethosu/ethosu_rpmsg.c b/drivers/firmware/ethosu/ethosu_rpmsg.c
index cb7e4556f635..e4cf398468e4 100644
--- a/drivers/firmware/ethosu/ethosu_rpmsg.c
+++ b/drivers/firmware/ethosu/ethosu_rpmsg.c
@@ -107,7 +107,8 @@ int ethosu_rpmsg_inference(struct ethosu_rpmsg *erp,
struct ethosu_buffer *network,
uint8_t *pmu_event_config,
uint8_t pmu_event_config_count,
- uint8_t pmu_cycle_counter_enable)
+ uint8_t pmu_cycle_counter_enable,
+ uint32_t inference_type)
{
struct ethosu_core_msg msg = {
.magic = ETHOSU_CORE_MSG_MAGIC,
@@ -132,6 +133,7 @@ int ethosu_rpmsg_inference(struct ethosu_rpmsg *erp,
req.ifm_count = ifm_count;
req.ofm_count = ofm_count;
req.pmu_cycle_counter_enable = pmu_cycle_counter_enable;
+ req.inference_type = inference_type;
for (i = 0; i < ifm_count; i++)
ethosu_core_set_size(ifm[i], &req.ifm[i]);
diff --git a/drivers/firmware/ethosu/ethosu_rpmsg.h b/drivers/firmware/ethosu/ethosu_rpmsg.h
index dd08e0d7945b..a4a639997a26 100644
--- a/drivers/firmware/ethosu/ethosu_rpmsg.h
+++ b/drivers/firmware/ethosu/ethosu_rpmsg.h
@@ -63,7 +63,8 @@ int ethosu_rpmsg_inference(struct ethosu_rpmsg *erp,
struct ethosu_buffer *network,
uint8_t *pmu_event_config,
uint8_t pmu_event_config_count,
- uint8_t pmu_cycle_counter_enable
+ uint8_t pmu_cycle_counter_enable,
+ uint32_t inference_type
);
int ethosu_rpmsg_init(struct ethosu_rpmsg *erp,
diff --git a/drivers/firmware/ethosu/uapi/ethosu.h b/drivers/firmware/ethosu/uapi/ethosu.h
index 903316dff7b3..c4a0df67336c 100644
--- a/drivers/firmware/ethosu/uapi/ethosu.h
+++ b/drivers/firmware/ethosu/uapi/ethosu.h
@@ -62,7 +62,7 @@ namespace EthosU {
#define ETHOSU_FD_MAX 16
/* Maximum number of PMUs available */
-#define ETHOSU_PMU_EVENT_MAX 8
+#define ETHOSU_PMU_EVENT_MAX 4
/****************************************************************************
* Types
@@ -173,6 +173,14 @@ struct ethosu_uapi_device_capabilities {
__u32 driver_major_rev;
};
+/**
+ * enum ethosu_uapi_inference_type - Inference type
+ */
+enum ethosu_uapi_inference_type {
+ ETHOSU_UAPI_INFERENCE_MODEL = 0,
+ ETHOSU_UAPI_INFERENCE_OP
+};
+
/**
* struct ethosu_uapi_inference_create - Create network request
* @ifm_count: Number of IFM file descriptors
@@ -185,6 +193,7 @@ struct ethosu_uapi_inference_create {
__u32 ifm_fd[ETHOSU_FD_MAX];
__u32 ofm_count;
__u32 ofm_fd[ETHOSU_FD_MAX];
+ enum ethosu_uapi_inference_type inference_type;
struct ethosu_uapi_pmu_config pmu_config;
};
--
2.17.1
next prev parent reply other threads:[~2023-06-16 5:53 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-16 5:59 [PATCH 0/8] ethosu: Add Arm Ethos-U driver Alison Wang
2023-06-16 5:59 ` [PATCH 1/8] " Alison Wang
2023-06-16 6:25 ` Greg KH
2023-06-16 8:28 ` [EXT] " Alison Wang
2023-06-16 15:08 ` Andrew Lunn
2023-07-06 6:01 ` Alison Wang
2023-06-16 6:26 ` Greg KH
2023-06-16 8:28 ` [EXT] " Alison Wang
2023-06-16 10:42 ` kernel test robot
2023-06-16 15:49 ` Robin Murphy
2023-06-16 17:16 ` kernel test robot
2023-06-24 18:30 ` kernel test robot
2023-06-16 5:59 ` [PATCH 2/8] ethosu: Use RPMsg messaging protocol based on i.MX Rpmsg implementation Alison Wang
2023-06-16 5:59 ` Alison Wang [this message]
2023-06-16 5:59 ` [PATCH 4/8] ethosu: Add suspend/resume power management Alison Wang
2023-06-16 5:59 ` [PATCH 5/8] ethosu: Use ids for identifying messages sent to Ethos-U firmware Alison Wang
2023-06-16 5:59 ` [PATCH 6/8] ethosu: Add core message about network info Alison Wang
2023-06-16 5:59 ` [PATCH 7/8] ethosu: Add core message about inference cancellation Alison Wang
2023-06-16 16:13 ` kernel test robot
2023-06-16 5:59 ` [PATCH 8/8] ethosu: Add rwlock when alloc and remove msg id Alison Wang
2023-06-16 6:22 ` [PATCH 0/8] ethosu: Add Arm Ethos-U driver Greg KH
2023-06-16 8:26 ` [EXT] " Alison Wang
2023-06-16 9:04 ` Greg KH
2023-06-16 10:47 ` Alison Wang
2023-06-16 11:11 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230616055913.2360-4-alison.wang@nxp.com \
--to=alison.wang@nxp.com \
--cc=feng.guo@nxp.com \
--cc=gregkh@linuxfoundation.org \
--cc=leoyang.li@nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiaofeng.ren@nxp.com \
--cc=xuelin.shi@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome