aboutsummaryrefslogtreecommitdiff
path: root/kernel/ethosu_cancel_inference.c
diff options
context:
space:
mode:
authorMikael Olsson <mikael.olsson@arm.com>2024-01-16 11:19:09 +0100
committerMikael Olsson <mikael.olsson@arm.com>2024-01-16 16:20:39 +0100
commit6d5e2d28d1cf60e1f7a1fe5fb591f3cd9b854b5a (patch)
tree4154098a48e8a0e739e67ec8a780870a1ecf99ff /kernel/ethosu_cancel_inference.c
parent3918eeabcda9aaf74b457e0bee98b77059625436 (diff)
downloadethos-u-linux-driver-stack-6d5e2d28d1cf60e1f7a1fe5fb591f3cd9b854b5a.tar.gz
Fix inference cancellation behavior
There is currently a possible race when canceling an inference, where the inference may be the one currently running and a response will be sent later or the inference response is already in the mailbox queue. To handle these cases, the kernel will no longer process the inference response for an inference that has been marked as aborted or is in the process of being aborted. Change-Id: Ifcd86591b09075f994ed2e903cb11ba7c0ee0418 Signed-off-by: Mikael Olsson <mikael.olsson@arm.com>
Diffstat (limited to 'kernel/ethosu_cancel_inference.c')
-rw-r--r--kernel/ethosu_cancel_inference.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/kernel/ethosu_cancel_inference.c b/kernel/ethosu_cancel_inference.c
index d89f719..47687b8 100644
--- a/kernel/ethosu_cancel_inference.c
+++ b/kernel/ethosu_cancel_inference.c
@@ -1,5 +1,5 @@
/*
- * SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
+ * SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
* SPDX-License-Identifier: GPL-2.0-only
*
* This program is free software and is provided to you under the terms of the
@@ -88,7 +88,7 @@ int ethosu_cancel_inference_request(struct device *dev,
/* increase ref count on the inference we are refering to */
ethosu_inference_get(inf);
/* mark inference ABORTING to avoid resending the inference message */
- inf->status = ETHOSU_CORE_STATUS_ABORTING;
+ inf->status = ETHOSU_UAPI_STATUS_ABORTING;
cancellation->dev = dev;
cancellation->inf = inf;
@@ -136,6 +136,9 @@ int ethosu_cancel_inference_request(struct device *dev,
goto deregister;
}
+ if (inf->status != ETHOSU_UAPI_STATUS_ABORTED)
+ inf->status = ETHOSU_UAPI_STATUS_ABORTED;
+
deregister:
ethosu_mailbox_deregister(mailbox,
&cancellation->msg);