From a2732ecd9cb5f5ad76b34a01b4c9b03297c845b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonny=20Sv=C3=A4rd?= Date: Mon, 18 Dec 2023 17:19:15 +0100 Subject: Support timeout for interrupt semaphore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce ETHOSU_INFERENCE_TIMEOUT CMake variable to set an arbitrary timeout value that will be sent as argument to ethosu_semaphore_take() for the interrupt semaphore. Adding the ability to have a timeout for an inference. (Defaults to no timeout/wait forever.) Implement a placeholder mutex for the baremetal example and add error checks for mutex_create() call. Change-Id: Ia74391620340a27c23dc3d15f9ba742c674c8bfa Signed-off-by: Jonny Svärd --- include/ethosu_driver.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/ethosu_driver.h b/include/ethosu_driver.h index 9c9f173..7d55500 100644 --- a/include/ethosu_driver.h +++ b/include/ethosu_driver.h @@ -41,6 +41,12 @@ extern "C" { #define ETHOSU_DRIVER_VERSION_MINOR 16 ///< Driver minor version #define ETHOSU_DRIVER_VERSION_PATCH 0 ///< Driver patch version +#define ETHOSU_SEMAPHORE_WAIT_FOREVER (UINT64_MAX) + +#ifndef ETHOSU_SEMAPHORE_WAIT_INFERENCE +#define ETHOSU_SEMAPHORE_WAIT_INFERENCE ETHOSU_SEMAPHORE_WAIT_FOREVER +#endif + /****************************************************************************** * Types ******************************************************************************/ @@ -55,9 +61,17 @@ enum ethosu_job_state ETHOSU_JOB_DONE }; +enum ethosu_job_result +{ + ETHOSU_JOB_RESULT_OK = 0, + ETHOSU_JOB_RESULT_TIMEOUT, + ETHOSU_JOB_RESULT_ERROR +}; + struct ethosu_job { volatile enum ethosu_job_state state; + volatile enum ethosu_job_result result; const void *custom_data_ptr; int custom_data_size; const uint64_t *base_addr; @@ -75,7 +89,6 @@ struct ethosu_driver uint64_t fast_memory; size_t fast_memory_size; uint32_t power_request_counter; - bool status_error; bool reserved; }; @@ -161,9 +174,10 @@ int ethosu_mutex_unlock(void *mutex); * Take semaphore. * * @param sem Pointer to semaphore handle - * @returns 0 on success, else negative error code + * @param timeout Timeout value (unit impl. defined) + * @returns 0 on success else negative error code */ -int ethosu_semaphore_take(void *sem); +int ethosu_semaphore_take(void *sem, uint64_t timeout); /** * Give semaphore. -- cgit v1.2.1