On a mapping failure of the SRAM, the SRAM size is left as non-zero. The
probe will succeed as the error return is not checked since having SRAM is
not a hard requirement. The non-zero size allows jobs to access SRAM which
is left pointing to physical base address 0x0.

Fixes: 5a5e9c0228e6 ("accel: Add Arm Ethos-U NPU driver")
Cc: [email protected]
Signed-off-by: Rob Herring (Arm) <[email protected]>
---
 drivers/accel/ethosu/ethosu_drv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/accel/ethosu/ethosu_drv.c 
b/drivers/accel/ethosu/ethosu_drv.c
index d121fb0d7732..f1af7b3ea038 100644
--- a/drivers/accel/ethosu/ethosu_drv.c
+++ b/drivers/accel/ethosu/ethosu_drv.c
@@ -281,8 +281,6 @@ static int ethosu_device_suspend(struct device *dev)
 
 static int ethosu_sram_init(struct ethosu_device *ethosudev)
 {
-       ethosudev->npu_info.sram_size = 0;
-
        ethosudev->srampool = of_gen_pool_get(ethosudev->base.dev->of_node, 
"sram", 0);
        if (!ethosudev->srampool)
                return 0;
@@ -293,6 +291,7 @@ static int ethosu_sram_init(struct ethosu_device *ethosudev)
                                                             
ethosudev->npu_info.sram_size,
                                                             
&ethosudev->sramphys);
        if (!ethosudev->sram) {
+               ethosudev->npu_info.sram_size = 0;
                dev_err(ethosudev->base.dev, "failed to allocate from SRAM 
pool\n");
                return -ENOMEM;
        }

-- 
2.53.0

Reply via email to