]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
feat(ethos-n): add check for NPU in SiP setup
authorMikael Olsson <mikael.olsson@arm.com>
Wed, 18 Jan 2023 17:05:15 +0000 (18:05 +0100)
committerJoanna Farley <joanna.farley@arm.com>
Tue, 4 Apr 2023 09:37:06 +0000 (11:37 +0200)
The SiP service in the Arm(R) Ethos(TM)-N NPU driver requires that there
is at least one NPU available. If there is no NPU available, the driver
is either used incorrectly or the HW config is incorrect.

To ensure that the SiP service is not incorrectly used, a setup handler
has been added to the service that will validate that there is at least
one NPU available.

Signed-off-by: Mikael Olsson <mikael.olsson@arm.com>
Change-Id: I8139a652f265cfc0db4a37464f39f1fb92868e10

drivers/arm/ethosn/ethosn_smc.c
include/drivers/arm/ethosn.h
plat/arm/common/arm_sip_svc.c

index cf3491055e271d841faad06fe02eae18e1de6613..6b1ab85dcfcfee9afc618700d68092a783b622de 100644 (file)
@@ -286,3 +286,13 @@ uintptr_t ethosn_smc_handler(uint32_t smc_fid,
                SMC_RET1(handle, SMC_UNK);
        }
 }
+
+int ethosn_smc_setup(void)
+{
+       if (ETHOSN_NUM_DEVICES == 0U) {
+               ERROR("ETHOSN: No NPU found\n");
+               return ETHOSN_FAILURE;
+       }
+
+       return 0;
+}
index 9f1b499d0c1ddeeb9c99f8321ce0a57c3a493e75..01868e37e6b5a05d18484d29cd83f02238fc12f4 100644 (file)
@@ -58,6 +58,8 @@
 #define ETHOSN_RESET_TYPE_FULL         U(0)
 #define ETHOSN_RESET_TYPE_HALT         U(1)
 
+int ethosn_smc_setup(void);
+
 uintptr_t ethosn_smc_handler(uint32_t smc_fid,
                             u_register_t core_addr,
                             u_register_t asset_alloc_idx,
index 6456c78411b2dba34a15b76b17aaf4e2892d4730..af8a02fb0f23e9e0e894b006f537bc10682b5e1f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2019,2021, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2023, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -34,6 +34,14 @@ static int arm_sip_setup(void)
 
 #endif /* USE_DEBUGFS */
 
+#if ARM_ETHOSN_NPU_DRIVER
+
+       if (ethosn_smc_setup() != 0) {
+               return 1;
+       }
+
+#endif /* ARM_ETHOSN_NPU_DRIVER */
+
        return 0;
 }