Commit Graph

22 Commits

Author SHA1 Message Date
Feng Guo
3f71223af4 Fix checkpatch issues for commit 7ca0f0f180
Signed-off-by: Feng Guo <feng.guo@nxp.com>
2024-07-25 17:18:04 +08:00
Feng Guo
7ca0f0f180 AIR-11693 driver: ethosu: Enable NPU memory cache to increase the performance
1.Flush input buffer cache when start inference
2.Invalidate output buffer cache when inference finish

Signed-off-by: Feng Guo <feng.guo@nxp.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
2024-07-25 16:26:09 +08:00
Feng Guo
e96169c2dd AIR-8353 ethosu: add rwlock when alloc and remove msg id
The msg id will be removed unpredictable when one thread call
ethosu_rpmsg_register and another thread call ethosu_rpmsg_deregister
at the same time. So add write_lock in ethosu_rpmsg_register and
ethosu_rpmsg_deregister, add read_lock in ethosu_rpmsg_find.

Signed-off-by: Feng Guo <feng.guo@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 16:02:38 +08:00
Alison Wang
dc0a7fdbac LF-8029 ethosu: Update the interface for printing hex dump
This patch updates the interface for printing hex dump to avoid too much
journalctl logs.

Signed-off-by: Alison Wang <alison.wang@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 16:02:37 +08:00
Feng Guo
6757468520 LF-7941 ethosu: fix potential out-of-bounds issue
Fix coverity Issue CID 24233199-24233208,24233210,22841322
1. The index will out-of-bounds when rsp->ifm_count or rsp->ofm_count
is larger than ETHOSU_CORE_BUFFER_MAX, so add checking for these two
counters.
2. Add return value checking for wait_for_completion_interruptible.

Signed-off-by: Feng Guo <feng.guo@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 16:02:37 +08:00
Alison Wang
c8433c2619 ethosu: Fix implicit conversion warning
Fix implicit conversion from enumeration type 'enum ethosu_core_status'
to different enumeration type 'enum ethosu_uapi_status'.

Signed-off-by: Alison Wang <alison.wang@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 16:02:37 +08:00
Alison Wang
5c7943803f ethosu: Fix memcpy overflow issue
The wrong structure name causes memory overflow issue, this patch fixes
it.

Signed-off-by: Alison Wang <alison.wang@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 16:02:37 +08:00
Feng Guo
38687a9611 ethosu: Add input and output types/shapes/offset in network info
This patch adds input and output types, shapes and offset in network
info.

Signed-off-by: Feng Guo <feng.guo@nxp.com>
2023-10-30 16:02:37 +08:00
Alison Wang
2e95559155 ethosu: Add support for inference cancellation
Send cancel inference messages to the ethosu subsystem to abort
inference execution there.

Signed-off-by: Davide Grohmann <davide.grohmann@arm.com>
Signed-off-by: Alison Wang <alison.wang@nxp.com>
2023-10-30 16:02:37 +08:00
Alison Wang
ea3bf30a91 ethosu: Add core message about network info
Add core message that allows user space to fetch information about
network models built into the firmware.

Support referencing a network model by index that has been built into
the firmwae binary.

Signed-off-by: Kristofer Jonsson <kristofer.jonsson@arm.com>
Signed-off-by: Alison Wang <alison.wang@nxp.com>
2023-10-30 16:02:37 +08:00
Alison Wang
7524393068 ethosu: Update uapi definition for capability request
ETHOSU_IOCTL_CAPABILITIES_REQ is a read ioctl with a parameter.

Signed-off-by: Per Åstrand <per.astrand@arm.com>
Signed-off-by: Alison Wang <alison.wang@nxp.com>
2023-10-30 16:02:37 +08:00
Alison Wang
923df67357 ethosu: Use ids for identifying messages sent to EthosU firmware
Avoid to use pointers to kernel memory as identify messages, prior this
change, if memory is reused that can lead to unexpected conflicts.

Remove ref counting from capabilities since memory is freed in only one
place.

Finally, extract the capabilities code in its own files.

Signed-off-by: Davide Grohmann <davide.grohmann@arm.com>
Signed-off-by: Kristofer Jonsson <kristofer.jonsson@arm.com>
Signed-off-by: Alison Wang <alison.wang@nxp.com>
2023-10-30 16:02:37 +08:00
Alison Wang
2703f6f27a ethosu: Check size of buffer before allocating
Avoid undefined behaviour from calling dma_alloc_coherent with
requested size=0 as reported by UBSAN.

Signed-off-by: Per Åstrand <per.astrand@arm.com>
Signed-off-by: Alison Wang <alison.wang@nxp.com>
2023-10-30 16:02:37 +08:00
Alison Wang
df8bba43b1 ethosu: Add message type ETHOSU_CORE_MSG_POWER_RSP
Add message type ETHOSU_CORE_MSG_POWER_RSP for Ethos-U driver.

Signed-off-by: Alison Wang <alison.wang@nxp.com>
2023-10-30 16:02:37 +08:00
Guo Feng
bfa9c36224 ethosu: Fix kernel call trace before rpmsg dev probe
M33 firmware will be loaded when ethosu device opens, and driver
shouldn't send msg to M33 before M33 boot up.

Signed-off-by: Feng Guo <feng.guo@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 16:02:37 +08:00
Alison Wang
28e198420b ethosu: Add switch for NPU power management
As power management depends on NPU device is opened, this patch adds the
switch for it.

Signed-off-by: Alison Wang <alison.wang@nxp.com>
2023-10-30 16:02:37 +08:00
Alison Wang
00cda37d15 ethosu: Add suspend/resume power management
Signed-off-by: Alison Wang <alison.wang@nxp.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 16:02:36 +08:00
Alison Wang
64a0654dfa ethosu: Add remoteproc support in the NPU driver
Signed-off-by: Alison Wang <alison.wang@nxp.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 16:02:36 +08:00
Feng Guo
14e7e98827 ethosu: Npu only supports 4 pmu events
Signed-off-by: Feng Guo <feng.guo@nxp.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 16:02:36 +08:00
Alison Wang
8f2670c59b ethosu: add inference type to support A-core tflite
Signed-off-by: Feng Guo <feng.guo@nxp.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 16:02:36 +08:00
Alison Wang
407a4f9f70 npu: ethosu: Add Rpmsg support based on i.MX Rpmsg implementation
Rpmsg is used for the communication mechanism between Cortex-A and
Cortex-M for ethos-u driver.

Signed-off-by: Lei Xu <lei.xu@nxp.com>
Signed-off-by: Alison Wang <alison.wang@nxp.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 16:02:36 +08:00
Alison Wang
9585864339 npu: ethosu: Add Arm ethos-u driver
This Linux drvier is to provide an example of how a rich operating
system like Linux can dispatch inferences to an Arm Cortex-M subsystem,
consisting of an Arm Cortex-M and an Arm Ethos-U NPU.

The code is from link: https://git.mlplatform.org/ml/ethos-u/ethos-u-linux-driver-stack.git. Tag: 22.02.

Signed-off-by: Kristofer Jonsson <kristofer.jonsson@arm.com>
Signed-off-by: Per Astrand <per.astrand@arm.com>
Signed-off-by: Jonny Svärd <jonny.svaerd@arm.com>
Signed-off-by: Lior Dekel <Lior.dekel@arm.com>
Signed-off-by: Henrik Hoglind <henrik.hoglind@arm.com>
Signed-off-by: Davide Grohmann <davide.grohmann@arm.com>
Signed-off-by: Alison Wang <alison.wang@nxp.com>
2023-10-30 16:02:36 +08:00