Skip to contentSkip to conversation

ARM: meson: fixup error on efuse commands return

PATCH In review Jerome Brunet 2 participants 3 messages Aug 4, 2022 – Aug 8, 2022

Subsystems (3)
lore
Share & tools
lore

Jerome Brunet

author reviewer
#0 lore raw

PATCH 1/1 ARM: meson: fixup error on efuse commands return

All sm efuseread/efusewrite commands exit with an error, even if the fuse have actually been dealt with correctly.

This is because the smc call return the size it actually processed but this result is checked against 0.

Return failure in do_efuse_read/write if the return value of meson_sm_read/write_efuse() is not the requested size.

Fixes 52195ba5f579 ("ARM: amlogic: add sm efuse write support and cmd for read/write efuse")
---
 arch/arm/mach-meson/sm.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
arch/arm/mach-meson/sm.c +3 -6
index 6c28c0f5e445..d6eb910689f4 100644
@@ -82,10 +82,7 @@ ssize_t meson_sm_write_efuse(uintptr_t offset, void *buffer, size_t size)
 
 	smc_call(&regs);
 
-	if (regs.regs[0] == 0)
-		return -1;
-
-	return 0;
+	return regs.regs[0];
 }
 
 #define SM_CHIP_ID_LENGTH	119
@@ -222,7 +219,7 @@ static int do_efuse_read(struct cmd_tbl *cmdtp, int flag, int argc,
         address = simple_strtoul(argv[3], NULL, 0);
 
 	ret = meson_sm_read_efuse(offset, (void *)address, size);
-	if (ret)
+	if (ret != size)
 		return CMD_RET_FAILURE;
 
 	return CMD_RET_SUCCESS;
@@ -243,7 +240,7 @@ static int do_efuse_write(struct cmd_tbl *cmdtp, int flag, int argc,
         address = simple_strtoul(argv[3], NULL, 0);
 
 	ret = meson_sm_write_efuse(offset, (void *)address, size);
-	if (ret)
+	if (ret != size)
 		return CMD_RET_FAILURE;
 
 	return CMD_RET_SUCCESS;
Signature · 1 line
2.36.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 41 lines · Jerome Brunet

All sm efuseread/efusewrite commands exit with an error, even if the fuse have actually been dealt with correctly.

This is because the smc call return the size it actually processed but this result is checked against 0.

Return failure in do_efuse_read/write if the return value of meson_sm_read/write_efuse() is not the requested size.

Fixes 52195ba5f579 ("ARM: amlogic: add sm efuse write support and cmd for read/write efuse")
---
  arch/arm/mach-meson/sm.c | 9 +++------
  1 file changed, 3 insertions(+), 6 deletions(-)
arch/arm/mach-meson/sm.c +2 -5
index 6c28c0f5e445..d6eb910689f4 100644
@@ -82,10 +82,7 @@ ssize_t meson_sm_write_efuse(uintptr_t offset, void *buffer, size_t size)
 
  	smc_call(&regs);
 
-	if (regs.regs[0] == 0)
-		return -1;
-
-	return 0;
+	return regs.regs[0];
  }
 
  #define SM_CHIP_ID_LENGTH	119
@@ -222,7 +219,7 @@ static int do_efuse_read(struct cmd_tbl *cmdtp, int flag, int argc,
          address = simple_strtoul(argv[3], NULL, 0);
 
  	ret = meson_sm_read_efuse(offset, (void *)address, size);
-	if (ret)
+	if (ret != size)
  		return CMD_RET_FAILURE;
 
  	return CMD_RET_SUCCESS;

arch/arm/mach-meson/sm.c static int do_efuse_write(struct cmd_tbl *cmdtp, int flag, int argc, · line 246

Quoted 8 lines
arch/arm/mach-meson/sm.c +1 -1
@@ -243,7 +240,7 @@ static int do_efuse_write(struct cmd_tbl *cmdtp, int flag, int argc,
          address = simple_strtoul(argv[3], NULL, 0);
 
  	ret = meson_sm_write_efuse(offset, (void *)address, size);
-	if (ret)
+	if (ret != size)
  		return CMD_RET_FAILURE;
 
  	return CMD_RET_SUCCESS;
#2 lore raw
In reply to Jerome Brunet

Hi,

Quoted 10 lines · Jerome Brunet

All sm efuseread/efusewrite commands exit with an error, even if the fuse have actually been dealt with correctly.

This is because the smc call return the size it actually processed but this result is checked against 0.

Return failure in do_efuse_read/write if the return value of meson_sm_read/write_efuse() is not the requested size.

[...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic (u-boot-amlogic-test)

[1/1] ARM: meson: fixup error on efuse commands return

      https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/3145e0d0ff0837647351f2ca261b4cde779f83e0
Signature · 1 line
Neil